linux: allow more workers when scheduling works

Workers are only summoned by the manager or when there are no workers on
a work queue. In case a work in front of a work queue depends on a work
behind it, a deadlock may occur. To solve this Linux spawns a rescue
worker using timers. Timing of Linux based drivers is currently reworked
and not reliable. Therefore, we increase the number of workers that are
spawned from 1 to 3 per work queue in order to resolve possible
deadlocks.

Fixes #4762
This commit is contained in:
Sebastian Sumpf 2023-02-13 10:13:18 +01:00 committed by Christian Helmuth
parent df27cc87b5
commit e2c334d6e4
3 changed files with 24 additions and 2 deletions

View File

@ -0,0 +1,20 @@
This patch increases the amount of worker that will be spawned upon a work queue
when a work is submitted. The patch implies that three workers will be used for
three works (before it was one). The fourth work will be queued.
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index ccad28b..ed16e05 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -763,7 +763,10 @@ static bool work_is_canceling(struct work_struct *work)
static bool __need_more_worker(struct worker_pool *pool)
{
- return !atomic_read(&pool->nr_running);
+ /*
+ * Assume two works can deadlock and make a third available
+ */
+ return atomic_read(&pool->nr_running) < 3;
}
/*

View File

@ -1 +1 @@
e6468ebf5e274f248bf6c8362fe6b59107ff7122
04e5e6e790ae0a41343fec197667cc94a1bc3f25

View File

@ -11,10 +11,12 @@ DIR(linux) := src/linux
#
PATCH_FILES := i915_irq.patch i915_alderlake.patch xhci_fix_event_37.patch \
xhci_abort_ring.patch iwlwifi_enable_irq_before_pnvm.patch \
realloc-fix-gcc-12.patch
realloc-fix-gcc-12.patch \
workqueue_deadlock.patch
PATCHES += $(addprefix patches/,$(PATCH_FILES))
# i915
PATCH_OPT(patches/i915_irq.patch) := -p1 -d${DIR(linux)}
PATCH_OPT(patches/xhci_abort_ring.patch) := -p1 -d${DIR(linux)}
PATCH_OPT(patches/xhci_fix_event_37.patch) := -p1 -d${DIR(linux)}
PATCH_OPT(patches/workqueue_deadlock.patch) := -p1 -d${DIR(linux)}