Commit Graph

53948 Commits

Author SHA1 Message Date
Tomasz Grabiec
57bc48ddbb core: add queue::pop_eventually()
It's an asynchronous version of blocking pop().
2014-10-06 18:34:28 +02:00
Tomasz Grabiec
b27b200e94 virtio: simplify rxq buffer preparation 2014-10-06 19:28:59 +03:00
Avi Kivity
b255039284 build: re-add -g flag
Dropped accidentally in 00fc8fb38a.
2014-10-06 18:17:11 +03:00
Nadav Har'El
5db2c1b506 build: Compile-time option to use default memory allocator
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>
2014-10-06 14:59:36 +03:00
Nadav Har'El
90d99c4009 build: add option to compile as PIE or SO.
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>
2014-10-06 09:50:18 +03:00
Avi Kivity
255c3ec7a7 reactor.hh: get rid of errant #include 2014-10-05 21:08:12 +03:00
Avi Kivity
20c27ceebd build: properly quote configure parameters 2014-10-05 20:49:37 +03:00
Avi Kivity
00fc8fb38a build: split --cflags into --cflags and --ldflags
clang dislikes some cflags if given to its linker.  Unfortunately this
means some options will need to be repeated.
2014-10-05 20:46:18 +03:00
Avi Kivity
2b12c13055 memory: support sized deallocation
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.
2014-10-05 20:24:00 +03:00
Avi Kivity
0019c858a6 README: remove gperftools, unneeded 2014-10-05 20:05:41 +03:00
Avi Kivity
fa6b731a68 Merge branch 'memory'
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.
2014-10-05 19:58:55 +03:00
Avi Kivity
9cd0e4f405 memory: improve allocation density
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)
2014-10-05 19:58:12 +03:00
Avi Kivity
3db75b272e bitops: mark functions as constexpr
Luckily, the gcc builtins are also constexpr.
2014-10-05 19:58:12 +03:00
Avi Kivity
e42158aea6 memory: small allocation support
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.
2014-10-05 19:58:10 +03:00
Avi Kivity
c407f5e091 memory: hook standard library allocation functions 2014-10-05 19:57:46 +03:00
Avi Kivity
b849b6b4cd memory: add support for aligned large allocations 2014-10-05 19:57:46 +03:00
Avi Kivity
86c0b7b7c9 memory: add per-cpu memory allocator
Largely inspired by tcmalloc, but simpler.  No support for small allocations
at the moment.
2014-10-05 19:57:40 +03:00
Avi Kivity
8806fbd4d4 smp: use posix_thread instead of std::thread
Friendlier towards our allocator, which doesn't support malloc/free on
different cpus.
2014-10-05 19:00:09 +03:00
Avi Kivity
4e9f7804c9 core: switch thread_pool to posix_thread
std::thread allocates, which interferes with the seastar memory allocator,
which doesn't support allocation in worker threads.
2014-10-05 19:00:09 +03:00
Avi Kivity
50c4dcbd5f posix: posix_thread: allocate stack manually
Otherwise, the stack is allocated on the creating thread and destroyed
on the created thread, which we don't support.
2014-10-05 19:00:04 +03:00
Avi Kivity
08706fcc6d posix: wrap mmap() for anonymous maps
Automatically munmap() when the result is destroyed.
2014-10-05 18:49:38 +03:00
Avi Kivity
1cd888c4a9 posix: move posix_thread implementation to new source file 2014-10-05 18:49:36 +03:00
Avi Kivity
10ea65cc0b posix: support std::move()ing a posix_thread
Useful for storing in containers.
2014-10-05 18:45:51 +03:00
Avi Kivity
96c83e1bdd posix: add pthread wrapper
std::thread allocates memory, while we want a non allocating version
for the worker threads.
2014-10-05 18:09:09 +03:00
Avi Kivity
1dbab3504c posix: add missing includes 2014-10-05 18:09:09 +03:00
Avi Kivity
5bc6f8911b build: define DEBUG for the debug build 2014-10-05 18:09:09 +03:00
Avi Kivity
7a16599f70 core: add bit operations library 2014-10-05 18:09:09 +03:00
Avi Kivity
a597379db8 core: add align_down() 2014-10-05 18:09:09 +03:00
Avi Kivity
0bbd42bc63 core: extract align_up() into an include file 2014-10-05 18:09:09 +03:00
Avi Kivity
ef96af29f2 future: avoid generalized lambda in forward_to()
Crashes gdb with -O0.
2014-10-05 15:44:49 +03:00
Avi Kivity
4cc5ce93de Merge branch 'tgrabiec/virtio-back-pressure' of github.com:cloudius-systems/seastar-dev
Back pressure from virtio into the rest of the stack, plus removal os the
virtio tx queue, from Tomek.

Conflicts:
	net/virtio.cc
2014-10-05 09:59:43 +03:00
Nadav Har'El
d08b1dcacd README: say you need to run ./configure.py once
Add to the README the instruction to run "./configure.py" once.
If you don't, ninja-build will not work because the build.ninja
file will be missing.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2014-10-05 09:48:56 +03:00
Tomasz Grabiec
05aece51dc virtio: remove intermediate queue
Currently the send path buffers packets in (unbounded) _tx_queue and
in virtio ring. On queue would suffice though.

This change also prpagates the back pressure resulting from queue-full
condition up the send path. This is needed, becasue otherwise if
senders are faster than the network we will eventually run out of
memory. This would also cause a "buffer bloat" effect, which hurts
latency-sensitive workloads.
2014-10-04 11:27:23 +02:00
Tomasz Grabiec
076d3b2682 ip: connect send() action with L3's send() action
So that back-pressure or failure from the lower layers are tranferred.
2014-10-04 11:27:23 +02:00
Tomasz Grabiec
6fa9cd7ac9 core: introduce do_until() and keep_doing() 2014-10-04 11:27:23 +02:00
Avi Kivity
24aafbf8f9 virtio: reduce allocations in transmit path
Reserve enough entries in the buffer chain to store all fragments.
2014-10-04 10:16:44 +03:00
Gleb Natapov
0a3df514cb smp: fix completion handling in inter_thread_work_queue
Currently completion processing start during object creation, but since
all object are created by main thread they all run on the same cpu which
is incorrect. This patch starts completion processing on correct cpu.
2014-10-02 15:49:53 +03:00
Raphael S. Carvalho
89147b2532 fileiotest: verify read size
add assert to dma_read return

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2014-10-02 15:45:06 +03:00
Gleb Natapov
534ce9b0db packet: use delegating constructor instead of duplicating code 2014-10-02 15:43:09 +03:00
Avi Kivity
1f44e71cb2 virtio: switch to circular_buffer 2014-10-02 14:32:34 +03:00
Avi Kivity
98665bf944 reactor: switch _pending_tasks to circular_buffer
This lets us get rid of the double buffering, since we can pop tasks off
one end while inserting them on the other.
2014-10-02 14:32:34 +03:00
Avi Kivity
2d012e1df8 queue: switch to circular_buffer 2014-10-02 14:32:34 +03:00
Avi Kivity
c8b602e713 httpd: switch to circular_buffer 2014-10-02 14:32:34 +03:00
Avi Kivity
df32573bf2 tcp: mark connection as noexcept move constructible 2014-10-02 14:32:34 +03:00
Avi Kivity
bc8a940dfa packet: mark as noexcept move constructible 2014-10-02 14:32:34 +03:00
Avi Kivity
dacf81745e core: add circular_buffer
Since we have lots of queues, we need an efficient queue structure,
esp. for moveable types.  libstdc++'s std::deque is quite hairy,
and boost's circular_buffer_space_optimized uses assignments instead of
constructors, which are both slower and less available than constructors.

This patch implements a growable circular buffer for these needs.
2014-10-02 14:32:32 +03:00
Avi Kivity
42db87a8c2 core: add helper functions for "transferring" objects
Here, transferring is defined as moving an object to a new location
(either via a move or copy constructor) and destroying the source.  This
is useful when implementing containers.
2014-10-02 14:28:14 +03:00
Avi Kivity
26f78f97f4 Merge branch 'tgrabiec/arp' of github.com:cloudius-systems/seastar-dev
ARP related fixes, including many core updates.
2014-10-01 16:34:21 +03:00
Tomasz Grabiec
73413748a7 arp: limit the number of waiting requests
Currently the waiters queue can grow to infinity pretty quickly.
2014-10-01 13:45:29 +02:00
Tomasz Grabiec
a435a0561d arp: fail requests on timeout 2014-10-01 13:45:29 +02:00