Skip to content

Commit

Permalink
resource: Move vector of queues into io_queue_topology
Browse files Browse the repository at this point in the history
The io_queue_topology describes "numerical" topology -- the
numbers of queues and groups and their mappings to each other.
Later this info is materialized into device_io_topology by
creating vectors of queues and groups.

There's no real need in this split. The io_queue_topology can
just create the needed vectors with no objects in them, so
that later queues and groups are put into _it_ instead of on
the device_io_topology.

This is step scylladb#1 -- move vector of queues into io_queue_topology.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
  • Loading branch information
xemul committed Jun 11, 2021
1 parent 9d97dcc commit c8d3d39
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
5 changes: 2 additions & 3 deletions include/seastar/core/resource.hh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct memory {
// This will allow us to easily find who is the IO coordinator for a given
// node without a trip to a remote CPU.
struct io_queue_topology {
unsigned nr_queues;
std::vector<io_queue*> queues;
std::vector<unsigned> shard_to_group;
unsigned nr_groups;

Expand All @@ -85,7 +85,6 @@ struct resources {
};

struct device_io_topology {
std::vector<io_queue*> queues;
struct group {
std::shared_ptr<io_group> g;
unsigned attached = 0;
Expand All @@ -94,7 +93,7 @@ struct device_io_topology {
std::vector<group> groups;

device_io_topology() noexcept = default;
device_io_topology(const io_queue_topology& iot) noexcept : queues(iot.nr_queues), groups(iot.nr_groups) {}
device_io_topology(const io_queue_topology& iot) noexcept : groups(iot.nr_groups) {}
};

resources allocate(configuration c);
Expand Down
6 changes: 3 additions & 3 deletions src/core/reactor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3917,12 +3917,12 @@ void smp::configure(boost::program_options::variables_map configuration, reactor
group = iog.g;
}

topology.queues[shard] = new io_queue(std::move(group), engine()._io_sink);
io_info.queues[shard] = new io_queue(std::move(group), engine()._io_sink);
seastar_logger.debug("attached {} queue to {} IO group", shard, group_idx);
};

auto assign_io_queue = [&devices_topology] (shard_id shard_id, dev_t dev_id) {
io_queue* queue = devices_topology[dev_id].queues[shard_id];
auto assign_io_queue = [&ioq_topology] (shard_id shard_id, dev_t dev_id) {
io_queue* queue = ioq_topology[dev_id].queues[shard_id];
engine()._io_queues.emplace(dev_id, queue);
};

Expand Down
7 changes: 4 additions & 3 deletions src/core/resource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <limits>
#include "cgroup.hh"
#include <seastar/util/log.hh>
#include <seastar/core/io_queue.hh>

#include <boost/range/adaptor/map.hpp>
#include <boost/range/algorithm/copy.hpp>
Expand Down Expand Up @@ -249,7 +250,7 @@ io_queue_topology::~io_queue_topology() {
}

io_queue_topology::io_queue_topology(io_queue_topology&& o)
: nr_queues(std::exchange(o.nr_queues, 0))
: queues(std::move(o.queues))
, shard_to_group(std::move(o.shard_to_group))
, nr_groups(std::exchange(o.nr_groups, 0))
{ }
Expand Down Expand Up @@ -412,7 +413,7 @@ allocate_io_queues(hwloc_topology_t& topology, std::vector<cpu> cpus, std::unord
};

auto cpu_sets = distribute_objects(topology, num_io_groups);
ret.nr_queues = cpus.size();
ret.queues.resize(cpus.size());
ret.nr_groups = 0;

// First step: distribute the IO queues given the information returned in cpu_sets.
Expand Down Expand Up @@ -639,7 +640,7 @@ allocate_io_queues(configuration c, std::vector<cpu> cpus) {
io_queue_topology ret;

unsigned nr_cpus = unsigned(cpus.size());
ret.nr_queues = nr_cpus;
ret.queues.resize(nr_cpus);
ret.shard_to_group.resize(nr_cpus);
ret.nr_groups = 1;

Expand Down

0 comments on commit c8d3d39

Please sign in to comment.