From e2c334d6e4df76e4db7d901d49c56b2d2c7506e4 Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Mon, 13 Feb 2023 10:13:18 +0100 Subject: [PATCH] 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 --- .../patches/workqueue_deadlock.patch | 20 +++++++++++++++++++ repos/dde_linux/ports/linux.hash | 2 +- repos/dde_linux/ports/linux.port | 4 +++- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 repos/dde_linux/patches/workqueue_deadlock.patch diff --git a/repos/dde_linux/patches/workqueue_deadlock.patch b/repos/dde_linux/patches/workqueue_deadlock.patch new file mode 100644 index 0000000000..bffdd0fb5e --- /dev/null +++ b/repos/dde_linux/patches/workqueue_deadlock.patch @@ -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; + } + + /* diff --git a/repos/dde_linux/ports/linux.hash b/repos/dde_linux/ports/linux.hash index b9daa17cd4..03391f4c34 100644 --- a/repos/dde_linux/ports/linux.hash +++ b/repos/dde_linux/ports/linux.hash @@ -1 +1 @@ -e6468ebf5e274f248bf6c8362fe6b59107ff7122 +04e5e6e790ae0a41343fec197667cc94a1bc3f25 diff --git a/repos/dde_linux/ports/linux.port b/repos/dde_linux/ports/linux.port index cfa8253995..e60c8a6874 100644 --- a/repos/dde_linux/ports/linux.port +++ b/repos/dde_linux/ports/linux.port @@ -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)}