From 7039fd62a5863741adb757665696a67a8228db40 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Thu, 28 Mar 2019 14:26:36 +0100 Subject: ipcpd: Give max priority to flow allocator The flow allocator thread was running on a low priority, causing some delay when handling packets. Usually this isn't a problem, but for congestion control updates, the delay may become problematic. The priority is now set to the maximum allowed by the scheduler policy to improve responsiveness. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/ipcpd/normal/fa.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'src/ipcpd') diff --git a/src/ipcpd/normal/fa.c b/src/ipcpd/normal/fa.c index e03467c2..76942143 100644 --- a/src/ipcpd/normal/fa.c +++ b/src/ipcpd/normal/fa.c @@ -306,15 +306,44 @@ void fa_fini(void) int fa_start(void) { + struct sched_param par; + int pol; + int max; + fa.psched = psched_create(packet_handler); - if (fa.psched == NULL) + if (fa.psched == NULL) { + log_err("Failed to start packet scheduler."); goto fail_psched; + } - if (pthread_create(&fa.worker, NULL, fa_handle_packet, NULL)) + if (pthread_create(&fa.worker, NULL, fa_handle_packet, NULL)) { + log_err("Failed to create worker thread."); goto fail_thread; + } + + if (pthread_getschedparam(fa.worker, &pol, &par)) { + log_err("Failed to get worker thread scheduling parameters."); + goto fail_sched; + } + + max = sched_get_priority_max(pol); + if (max < 0) { + log_err("Failed to get max priority for scheduler."); + goto fail_sched; + } + + par.sched_priority = max; + + if (pthread_setschedparam(fa.worker, pol, &par)) { + log_err("Failed to set scheduler priority to maximum."); + goto fail_sched; + } return 0; + fail_sched: + pthread_cancel(fa.worker); + pthread_join(fa.worker, NULL); fail_thread: psched_destroy(fa.psched); fail_psched: -- cgit v1.2.3