The result is not used for anything and I am not sure what it could be
used for, as the result carries little (write) to none (flush)
information. So I went ahead and simplified it to be future<> so that
it is easier to return it in places which expect future<>.
Only tx path is added for now. Will enable rx path when merge receive
buffer feature is supported in virtio-net.
UDP fragmentation offload is not hooked up, will do in a separate patch.
Allow the memory manager to call us back requesting a reclaim. Push
the task to the front of the queue, so we don't run out of memory waiting
for it to fire.
Allow memory users to declare methods of reclaiming memory (reclaimers),
and allow the main loop to declare a safe point for calling these reclaimers.
The memory mananger will then schedule calls to reclaimers when memory runs
low.
From Gleb:
"This patchset adds smp support for networking. Posix and native stack
implementation are completely disjoint, but present the same API to an
application. Speaking about application API it is the same as before,
but application is expected to create server socket on all cpus, otherwise
some connection will stuck or reset."
Only one cpu can talk to virtio NIC directly (at least without
multiqueue), so other cpus receive packets from the one that drives
virtio and forward packets that need to be send back. This is done
by proxy net interface.
Some packets are processed by a cpu other than the one that allocates it
and its fragments. free_on_cpu() function should be called on a cpu that
does processing and it returns a packet that is deletable by the current
cpu. It is done by copying packet/packet::impl to locally allocated one
and adding new deleter that runs old deleter on original cpu.
Classifier returns what cpu a packets should be processed on. It may
return special broadcast identifier. The patch includes classifier for
tcp, udp and arp. Arp classifier broadcasts arp reply to all cpus. Default
classifier does not forward packet.
Will need it later to handle forwarded packets. Also save net::device
pointer in thread local variable to get to device instance easily. When
we ill have more then one device per cpu we will have to change to
something more sophisticated.
The idea is that only one thread opens listen socket and runs accept().
Other threads emulate listen()/accept() by waiting for connected
socket from the main thread. Main thread distributes connected sockets
according to round robin pattern. Patch introduce new specialization
for server_socket_impl and network_stack: posix_ap_server_socket_impl
and posix_ap_network_stack respectively. _ap_ stand for auxiliary processor.
Sometimes we need to know if we are running on main thread during engine
initialization, before engine._id is available. This function will be
used for that.
Basically, wrapping stat around _thread_pool as it might block
waiting for metadata to be read from the underlying device.
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Add a compile-time option, DEFAULT_ALLOCATOR, to use the existing
memory allocator (malloc() and friends) instead of redefining it.
This option is a workaround needed to run Seastar on OSv.
Without this workaround, what seems to happen is that some code compiled
into the kernel (notably, libboost_program_options.a) uses the standard
malloc(), while inline code compiled into Seastar uses the seastar free()
to try and free that memory, resulting in a spectacular crash.
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
This is the first step in a journy of many miles, to be able to run
Seastar applications (such as httpd or memcached) on top of OSv.
This patch adds a configure.py option "-so" to build the applications as
shared-objects instead of executables. It also adds the option "-pie" to
build position-independent executables instead.
These are needed to run a Seastar application on OSv, as OSv cannot run
a normal position-dependent executable. Note that currently, PIE won't
actually work (because of OSv bug #352 - unfortunately Seastar uses
thread_local in one place) - so only "-so" is useful to build an application
to run in OSv.
The resulting shared-object doesn't yet run on OSv (many bugs ahead, as
well as missing features), but it's a start.
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
With N3778, the compiler can provide us with the size of the object,
so we can avoid looking it up in the page array. Unfortunately only
implemented in clang at the moment.
This patchset adds a memory allocator, inspired by tcmalloc,
that paritions memory into per-cpu pools and only allows allocation
from local memory. As a result it is very efficient.
Instead of rounding up to a power-of-two, have four equally spaced
regions between powers of two. For example:
1024
1280 (+256)
1536 (+256)
1792 (+256)
2048 (+256)
2560 (+512)
3072 (+512)
3584 (+512)
4096 (+512)
Allocate small objects within spans, minimizing waste.
Each object size class has its own pool, and its own freelist. On overflow
free objects are pushed into the spans; if a span is completely free, it is
returned to the main free list.