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.
This commit is contained in:
Avi Kivity
2014-12-11 15:05:05 +02:00
parent 5855f0c82a
commit d11803d1b9

View File

@@ -712,11 +712,15 @@ void smp_message_queue::complete() {
}
size_t smp_message_queue::process_incoming() {
return _pending.consume_all([this] (smp_message_queue::work_item* wi) {
work_item* items[queue_length];
auto nr = _pending.pop(items);
for (unsigned i = 0; i < nr; ++i) {
auto wi = items[i];
wi->process().then([this, wi] {
respond(wi);
});
});
}
return nr;
}
void smp_message_queue::start() {