Process packets in batches at the VFS server

Process I/O packets in batches. If a batch is processed and there are
still packets pending, send a signal locally to the packet handler and
return to the entrypoint signal dispatcher. This prevents clients from
starving each other, which happens when a client continuously submits
packets at a faster rate than the server can process.

Fix #2900
This commit is contained in:
Emery Hemingway 2018-07-03 13:56:38 +02:00 committed by Christian Helmuth
parent f3abee631a
commit b1b83f4d6d
2 changed files with 26 additions and 1 deletions

View File

@ -1,3 +1,14 @@
#
# \brief Test of packet handling and signal scheduling
# \author Emery Hemingway
# \date 2018-07-03
#
if {[get_cmd_switch --autopilot] && [have_include "power_on/qemu"]} {
puts "Running fs_packet test in autopilot on Qemu is not recommended.\n"
exit
}
#
# Build
#
@ -53,7 +64,7 @@ append config {
</start>
<start name="short-test">
<binary name="sequence"/>
<resource name="RAM" quantum="2M"/>
<resource name="RAM" quantum="4M"/>
<config>
<start name="a">
<binary name="test-fs_packet"/>

View File

@ -301,6 +301,8 @@ class Vfs_server::Session_component : public File_system::Session_rpc_object,
*/
void _process_packets()
{
using namespace Genode;
/*
* XXX Process client backlog before looking at new requests. This
* limits the number of simultaneously addressed handles (which
@ -311,7 +313,19 @@ class Vfs_server::Session_component : public File_system::Session_rpc_object,
/* backlog not cleared - block for next condition change */
return;
/**
* Process packets in batches, otherwise a client that
* submits packets as fast as they are processed will
* starve the signal handler.
*/
int quantum = TX_QUEUE_SIZE;
while (tx_sink()->packet_avail()) {
if (--quantum == 0) {
/* come back to this later */
Signal_transmitter(_process_packet_handler).submit();
break;
}
/*
* Make sure that the '_process_packet' function does not