Commit Graph

43077 Commits

Author SHA1 Message Date
Avi Kivity
692ee47456 deleter: introduce make_object_deleter
When we have an object acting as resource guard for memory, we can convert
it into a deleter using

  make_deleter([obj = std::move(obj)] {})

introduce a simpler interface

  make_object_deleter(std::move(obj))

for doing the same thing.
2014-12-16 14:55:02 +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
c8189157ed net: use RSS hash key calculated by HW if available
Some (all?) RSS capable HW provides us with a hash that was used to
select rx queue the packet was delivered to. If such hash is available
it is better to use it to forward packet instead of calculating hash
ourself and suffering cache missed.
2014-12-16 10:53:41 +02:00
Gleb Natapov
d796487976 net: use our RSS key instead of letting DPDK select one 2014-12-16 10:53:41 +02:00
Gleb Natapov
d8ddaeb104 net: forward reassembled ip packet to correct queue
To figure out a cpu that should handle reassembled TCP packet RSS
redirection table have to be consulted.
2014-12-16 10:53:41 +02:00
Gleb Natapov
64adef7def net: copy RSS redirection table from a device
We will need it in later patch.
2014-12-16 10:53:41 +02:00
Gleb Natapov
fbef83beb0 net: support for num of cpus > num of queues
This patch introduce a logic to divide cpus between available hw queue
pairs. Each cpu with hw qp gets a set of cpus to distribute traffic
to. The algorithm doesn't take any topology considerations into account yet.
2014-12-16 10:53:41 +02:00
Gleb Natapov
7ac3ba901c net: rework packet forwarding logic
Instead of forward() deciding packet destination make it collect input
for RSS hash function depending on packet type. After data is collected
use toeplitz hash function to calculate packet's destination.
2014-12-16 10:53:41 +02:00
Gleb Natapov
dd2f73401f net: add toeplitz hash function for rss 2014-12-16 10:53:41 +02:00
Gleb Natapov
bd9b0b8962 net: remove broadcast logic from forwarding path
No longer used.
2014-12-15 17:38:20 +02:00
Gleb Natapov
055fbb9430 net: broadcast arp reply on arp protocol level
Instead of returning special value from forward() to broadcast arm reply
call arp.learn() on all cpus at arp protocol lever. The ability of
forward() to return special value will be removed by later patches.
2014-12-15 17:36:14 +02:00
Gleb Natapov
c13adb9c12 net: rework how dhcp handles dhcp packet.
Currently dhcp assumes that cpu 0 gets all the packets and redistributes
them by itself. With multiqueue this is not necessary the case, so the
current trick to disable forwarding by installing special dhcp forward()
function will not work. Rework it by installing packet filter on all
cpus before running dhcp and forward all dhcp packets to cpu 0.
2014-12-15 17:31:25 +02:00
Gleb Natapov
ad29ccd3df net: start dhcp after the stack is created on all cpus 2014-12-15 17:30:13 +02:00
Avi Kivity
e83361010b Merge branch 'asias/lowres_clock' of github.com:cloudius-systems/seastar-dev
From Asias:

"Add a low resolution clock source in addition to what std::chrono provides.
With it we can reduce the expensive std::chrono::high_resolution_clock::now()
calls."
2014-12-15 13:45:05 +02:00
Asias He
c9553b7825 tcp: Switch to user lowres_clock 2014-12-15 19:39:33 +08:00
Asias He
0790266be0 ip: Switch to use lowres_clock 2014-12-15 19:39:33 +08:00
Asias He
42c4085f29 timer: Introduce lowres_clock 2014-12-15 19:39:33 +08:00
Asias He
1d48610f1b tests: Improve timertest
Test both high-res and low-res clock timer.
2014-12-15 19:39:33 +08:00
Asias He
f1e46791f5 timer: Drop unused ulong_bits 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
0242d402b7 timer: Drop Clock template parameter in time_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
a3f08c32de virtio: rename misleading _deleters field
It's just a set of buffers (albeit maintained as unique_ptrs for their
destructors).  Not the 'deleter' type.
2014-12-15 11:42:33 +02:00
Avi Kivity
38b1398750 virtio: remove outdated TODO re single-fragment packet
We already special case single fragment packets on the receive path.
2014-12-15 11:39:00 +02: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
52be2f2bf4 Merge branch 'virtio'
Futures are great for complicated asynchronous operations, but for a
synchronous operation like destroying a packet after transmit, or
converting a buffer to a packet during receive, they're overkill.

This patchset fixes those two cases in virtio, in which futures
are used as an abstraction layer between vring and the transmit/receive
queues, by converting vring into a template, so that the completion function
can be adjusted for the transmit or receive case during compile time instead
of at run time.

10% improvement on httpd with --smp 1, >20% with --smp 3.
2014-12-15 11:29:35 +02:00
Avi Kivity
508322c7da virtio: de-futurize receive
Move completion handling (destroy packet, adjust descriptors count) to
a completion function rather than a future.  Reduces allocations and task
executed.
2014-12-14 18:49:01 +02:00
Avi Kivity
1ee959d3e2 virtio: de-futurize transmit
Move completion handling (destroy packet, adjust descriptors count) to
a completion function rather than a future.  Reduces allocations and task
executed.
2014-12-14 18:49:01 +02:00
Avi Kivity
c7c0aebf07 virtio: abstract vring request completions
Currently vring request completions are handled by fulfilling a promise
contained in the request.  While promises are very flexible, this comes
at a cost (allocating and executing a task), and this flexibility is unneeded
when request handling is very regular (such as in virtio-net rx and tx
completion handling).

Make vring more flexible by allowing the completion function to be specified
as a template parameter.  No changes to the actual users - they now specify
the completion function as fulfilling the same promise as vring previously
did.
2014-12-14 18:49:01 +02:00
Avi Kivity
a86faf0209 virtio: de-virtualize virt_to_phys
It is not a device property, but a system property.
2014-12-14 18:49:01 +02:00
Avi Kivity
f3d2908757 virtio: move buffer and config out of vring class
Prior to templating it, best to get the common elements out.
2014-12-14 18:49:01 +02:00
Avi Kivity
fcbcc19231 virtio: remove buffer_chain class
It's a concept that is instantiated by its users, not a true class.
2014-12-14 18:49:01 +02:00
Avi Kivity
5c4ae7a726 virtio: minor code movement 2014-12-14 18:49:01 +02:00
Avi Kivity
d14da53171 virtio: move into 'namespace virtio' 2014-12-14 18:49:01 +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
ea2cfbbcd8 virtio: fix indentation 2014-12-14 10:28:48 +02:00
Avi Kivity
535b447343 circular_buffer: get rid of {pre|post}_push_{front|back}
As Nadav suggests, with the simplified circular_buffer implementation they
no longer provide any value and only obfuscate the code.
2014-12-14 10:00:43 +02:00
Avi Kivity
94a1cdd6e4 Merge branch 'circular_buffer'
circular_buffer simplifications and enhancements.
2014-12-13 18:45:47 +02:00
Avi Kivity
209e0958d2 Merge branch 'nettx'
More virtio and smp batching.
2014-12-13 18:45:25 +02:00
Avi Kivity
9de1b10724 circular_buffer: add unsafe array access method
By allowing access-past-the-end, we can prefetch ahead of the queue without
checking the current queue size.
2014-12-11 22:20:50 +02:00
Avi Kivity
ec0fb398fb circular_buffer: optimize by using masking instead of tests
Since we control the capacity, we can force it to be a power of two,
and use masking instead of tests to handle wraparound.

A side benefit is that we don't have to allocate an extra element.
2014-12-11 22:14:02 +02:00
Avi Kivity
aaf9884064 circular_buffer: fix pop_front(), pop_back()
These methods should destroy the objects they are popping.

We probably haven't seen any leaks since we usually move() the item
before popping it.
2014-12-11 21:55:09 +02:00
Avi Kivity
746dfae355 circular_buffer: add array dereference operator
Useful for prefetching.
2014-12-11 21:32:56 +02:00
Avi Kivity
8a5a8192e4 Merge branch 'hugepages' of ../seastar
Allow backing seastar memory with hugetlbfs files.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
2014-12-11 19:25:06 +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
503f1bf4d0 virtio: batch transmitted packets
Instead of placing packets directly into the virtio ring, add them to
a temporary queue, and flush it when we are polled.  This reduces
cross-cpu writes and kicks.
2014-12-11 19:20:50 +02:00