Commit Graph

123 Commits

Author SHA1 Message Date
Avi Kivity
c95e452a3a Merge branch 'directory'
Directory listing support, using subscription<sstring> to represent the
stream of file names produced by the directory lister running in parallel
with the directory consumer.
2015-01-08 11:14:52 +02:00
Avi Kivity
3be04e7009 reactor: implement open_directory(), list_directory()
open_directory() is similar to open_file_dma() with just the O_ flags adjusted.

list_directory() returns a subscription(), so that both the producer and
the consumer can be asynchronous.
2015-01-08 11:09:25 +02:00
Takuya ASADA
b9a2541c7e Add reactor::connect(), client_socket definition and network stack stub code
Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
2015-01-08 01:26:36 +09:00
Takuya ASADA
24820543ff Add reactor::posix_connect()
Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
2015-01-08 01:26:30 +09:00
Shlomi Livne
3362851e55 reactor: add a SIGTERM handler
Signed-off-by: Shlomi Livne <shlomi@cloudius-systems.com>
2015-01-04 17:17:33 +02:00
Gleb Natapov
6ad9114c0b reactor: add at_destroy() function to the reactor and use it
Unfortunately at_exit() cannot be used to delete objects since when
it runs the reactor is still active and deleted object may still been used.
We need another API that runs its task after reactor is already stopped.
at_destroy() will be such api.
2014-12-30 15:21:10 +02:00
Gleb Natapov
efd6c33af0 reactor: remove no longer needed thread_pool function 2014-12-28 18:19:20 +02:00
Gleb Natapov
3eefc1ada2 reactor: replace thread_pool poller with signal notification
Drops one poller since now signal poller is used to process thread_pool
completions.
2014-12-28 18:19:18 +02:00
Gleb Natapov
367bbd75f3 reactor: move epoll to its own poller
Enable it only if there is fd to poll.
2014-12-28 14:54:43 +02:00
Gleb Natapov
889cc69a28 reactor: remove non polling mode 2014-12-28 14:54:43 +02:00
Gleb Natapov
7d3fb282c5 reactor: poll thread pool for completion instead of using eventfd 2014-12-28 14:54:43 +02:00
Gleb Natapov
a57e75ab9f reactor: move timers to use signals instead of timerfd to signal a completion 2014-12-28 14:54:43 +02:00
Gleb Natapov
51b56d90f2 reactor: poll for signals completion instead of using signalfd 2014-12-28 14:54:43 +02:00
Gleb Natapov
3d374110c6 reactor: poll for aio completion instead of using eventfd
io_getevents() avoids system call if timeout is zero and there is no
completed event.
2014-12-28 13:39:59 +02:00
Gleb Natapov
6d7916a9f8 reactor: disable batching during engine termination
SMP messages that are send while engine is been stopped should be
sent immediately because after the engine is stopped they will not be.
2014-12-28 13:37:25 +02:00
Vlad Zolotarov
ddf239a943 dpdk: Move the scattered DPDK EAL initialization into the dpdk::eal.
- Move the smp::dpdk_eal_init() code into the dpdk::eal::init() where it belongs.
 - Removed the unused "opts" parameter of dpdk::dpdk_device constructor - all its usage
   has been moved to dpdk::eal::init().
 - Cleanup in reactor.cc: #if HAVE_DPDK -> #ifdef HAVE_DPDK; since we give a -DHAVE_DPDK
   option to a compiler.

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2014-12-22 17:36:49 +02:00
Vlad Zolotarov
7ec062e222 dpdk: Move dpdk_eal class into a separate file
- Make it's methods static.
 - Rename dpdk::dpdk_eal -> dpdk::eal

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2014-12-22 17:36:42 +02:00
Gleb Natapov
b958a44304 smp: create seastar threads using DPDK when compiled with DPDK support
DPDK initialization creates its own threads and assumes that application
uses them, otherwise things do not work correctly (rte_lcore_id()
returns incorrect value for instance). This patch uses DPDK threads to
run seastar main loop making DPDK APIs work as expected.
2014-12-18 14:43:37 +02:00
Avi Kivity
c09694d76c reactor: fix corruption in _pollers
register_poller() (and unregister_poller()) adjusts _pollers, but it may be
called while iterating it, and since std::vector<> mutations invalidate
iterators, corruption occurs.

Fix by deferring manipulation of _pollers into a task, which is executed at
a time where _pollers is not touched.
2014-12-17 16:56:20 +02:00
Avi Kivity
481080feb8 reactor: refactor reactor::poller
Currently, reactor::_pollers holds reactor::poller pointers; since these
are movable types, it's hard to maintain _pollers, as the pointers can keep
changing.

Refactor poller so that _pollers points at an internal type, which does not
move when a reactor::poller moves.  This requires getting rid of
std::function, since it lacks a comparison operator.
2014-12-17 16:20:52 +02:00
Avi Kivity
3e4c53300d Merge branch 'mq' of ssh://github.com/cloudius-systems/seastar-dev
Multiqueue support for #cpu != #q, from Gleb.
2014-12-16 11:11:22 +02:00
Gleb Natapov
ad29ccd3df net: start dhcp after the stack is created on all cpus 2014-12-15 17:30:13 +02:00
Asias He
42c4085f29 timer: Introduce lowres_clock 2014-12-15 19:39:33 +08:00
Asias He
db0124ef05 timer: Add now() for timer_set 2014-12-15 19:39:33 +08:00
Asias He
62fff15e54 timer: Make timer a template 2014-12-15 19:39:33 +08:00
Avi Kivity
c56dcaf17a smp: fix cross-cpu access in poll mode
We look at _poll mode in another cpu's cache accidentally, as pard of
the peer->idle() call.

Fix by looking at our own _poll variable first; they should all be the same.
2014-12-15 11:30:06 +02:00
Avi Kivity
4ab36be8c9 reactor: fix pointless allocation in wait_and_process()
wait_and_process() expects an std::function<>, but we pass it a lambda,
forcing it to allocate.

Prepare the sdt::function<> in advance, so it can pass by reference.
2014-12-14 15:58:56 +02:00
Avi Kivity
209e0958d2 Merge branch 'nettx'
More virtio and smp batching.
2014-12-13 18:45:25 +02:00
Avi Kivity
d11803d1b9 smp: batch request processing
We're currently using boost::lockfree::consume_all() to consume
smp requests, but this has two problems:

 1. consume_all() calls consume_one() internally, which means it accesses
    the ring index once per message
 2  we interleave calling the request function with accessing the ring, which
    allows the other side to access the ring again, bouncing ring cache lines.

Fix by copying all available items in one show, using pop(array), and then
processing them afterwards.
2014-12-11 19:20:50 +02:00
Avi Kivity
5855f0c82a smp: batch completion processing
We're currently using boost::lockfree::consume_all() to consume
smp completions, but this has two problems:

 1. consume_all() calls consume_one() internally, which means it accesses
    the ring index once per message
 2  we interleave calling the request function with accessing the ring, which
    allows the other side to access the ring again, bouncing ring cache lines.

Fix by copying all available items in one show, using pop(array), and then
processing them afterwards.
2014-12-11 19:20:50 +02:00
Avi Kivity
04488eebea smp: batch messages across smp request/response queues
Instead of incurring the overhead of pushing a message down the queue (two
cache line misses), amortize of over 16 messages (3/4 cache line misses per
batch).

Batch size is limited by poll frequency, so we should adjust that
dynamically.
2014-12-11 19:20:50 +02:00
Avi Kivity
2717ac3c37 smp: improve _pending_fifo flushing
Instead of flushing pending items one by one, flush them all at once,
amortizing the write to the index.
2014-12-11 19:20:50 +02:00
Avi Kivity
b6485bcb7c smp: initialize _pending_fifo on sending cpu
If it needs to be resized, it will cause a deallocation on the wrong cpu,
so initialize it on the sending cpu.

Does not break with circular_buffer<>, but it's not going to be a
circular_buffer<> for long.
2014-12-11 19:20:50 +02:00
Avi Kivity
db88632456 reactor: wire up hugetlbfs support 2014-12-11 12:25:31 +02:00
Gleb Natapov
73f6d943e1 net: separate device initialization from queues initialization
This patch adds new class distributed_device which is responsible for
initializing HW device and it is shared between all cpus. Old device
class responsibility becomes managing rx/tx queue pair and it is local
per cpu. Each cpu have to call distributed_device::init_local_queue() to
create its own device. The logic to distribute cpus between available
queues (in case there is no enough queues for each cpu) is in the
distributed_device currently and not really implemented yet, so only one
queue or queues == cpus scenarios are supported currently, but this can
be fixed later.

The plan is to rename "distributed_device" to "device" and "device"
to "queue_pair" in later patches.
2014-12-09 18:55:14 +02:00
Gleb Natapov
34a8744fd3 smp: wait for all cpus before signaling start promise
If start promise on initial cpu is signaled before other cpus have
networking stack constructed collected initialization crashes since it
tries to create a UDP socket on all available cpus when initial one is
ready.
2014-12-09 18:54:56 +02:00
Avi Kivity
30143fe18d reactor: destroy network_stack after timer infrastructure
The network stack contains a timer, so it must be constructed after the
timer infrastructure and destroyed before it.

Fixes a segfault on shutdown.
2014-12-07 17:37:13 +02:00
Avi Kivity
f4d7bd7e00 reactor: register pollers using a RAII class
Avoids leaking a poller.
2014-12-07 17:36:44 +02:00
Gleb Natapov
4fd3313e3e reactor: add "--poll" command line switch
If the switch is used reactor never goes idle.
2014-12-03 14:37:49 +02:00
Gleb Natapov
d151763967 reactor: move memory barrier to idle() accessors 2014-12-03 14:37:41 +02:00
Gleb Natapov
4d3b6497ea reactor: rework poll infrastructure
Move idle state management out from smp poller back to generic code. Each
poller returns if it did any useful work and generic code decided if it
should go idle based on that. If a poller requires constant polling it
should always return true.
2014-12-03 14:37:33 +02:00
Gleb Natapov
bf46f9c948 net: Change how networking devices are created
Currently each cpu creates network device as part of native networking
stack creation and all cpus create native networking stack independently,
which makes it impossible to use data initialized by one cpu in another
cpu's networking device initialization. For multiqueue devices often some
parts of an initialization have to be handled by one cpu and all other
cpus should wait for the first one before creating their network devices.
Even without multiqueue proxy devices should be created after master
device is created so that proxy device may get a pointer to the master
at creation time (existing code uses global per cpu device pointer and
assume that master device is created on cpu 0 to compensate for the lack
of ordering).

This patch makes it possible to delay native networking stack creation
until network device is created. It allows one cpu to be responsible
for creation of network devices on multiple cpus. Single queue device
initialize master device on one cpu and call other cpus with a pointer
to master device and its cpu id which are used in proxy device creation.
This removes the need for per cpu device pointer and "master on cpu 0"
assumption from the code since now master device and slave devices know
about each other and can communicate directly.
2014-11-30 18:10:08 +02:00
Avi Kivity
e9432e9254 reactor: move collectd initialization out of reactor::run()
It's complicated enough without it.
2014-11-30 14:24:19 +02:00
Vlad Zolotarov
47b3721ccf reactor: added a "pollers" abstraction
Each "poller" registers a non-blocking callback which is then called in
every iteration of a reactor's main loop.

Each "poller"'s callback returns a boolean: if TRUE then a main loop is allowed to block
(e.g. in epoll()).

If any of registered "pollers" returns FALSE then reactor's main loop is forbidded to block
in the current iteration.

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2014-11-30 12:12:39 +02:00
Gleb Natapov
4f4731c37b net: delay network stack creation
Network device has to be available when network stack is created, but
sometimes network device creation should wait for device initialization
by another cpu. This patch makes it possible to delay network stack
creation until network device is available.
2014-11-26 16:46:04 +02:00
Avi Kivity
87fdf52205 Merge branch 'clang' 2014-11-26 15:01:14 +02:00
Avi Kivity
c30b3e93c2 reactor: massage collectd registrations to satisfy clang
Warns of an unused variable, even though the destructor has side effects.
2014-11-26 14:57:02 +02:00
Gleb Natapov
01e9410adc smp: move thread creation sync point after start_all_queues()
Configure all smp queues before calling engine.configure() so that
engine.configure() may use submit_to() api. Note that messages will
still be processed only after engine.run() is executed.
2014-11-26 12:20:04 +02:00
Avi Kivity
347b135b78 memory: rename statistics member functions to be more readable
Requested by Gleb.
2014-11-24 11:53:13 +02:00
Avi Kivity
a7f14fa13e core: export memory statistics via collectd 2014-11-23 19:28:26 +02:00