From b1b83f4d6db9143faf84a845f5f13a255bb04ac1 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Tue, 3 Jul 2018 13:56:38 +0200 Subject: [PATCH] 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 --- repos/os/run/fs_packet.run | 13 ++++++++++++- repos/os/src/server/vfs/main.cc | 14 ++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/repos/os/run/fs_packet.run b/repos/os/run/fs_packet.run index 96b9f3a496..60d907d13d 100644 --- a/repos/os/run/fs_packet.run +++ b/repos/os/run/fs_packet.run @@ -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 { - + diff --git a/repos/os/src/server/vfs/main.cc b/repos/os/src/server/vfs/main.cc index 5e0ba32678..a979e15dec 100644 --- a/repos/os/src/server/vfs/main.cc +++ b/repos/os/src/server/vfs/main.cc @@ -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