From dcf3af1286cedd07caaa46719d127abedaf4d6a7 Mon Sep 17 00:00:00 2001 From: Petr Mladek Date: Apr 18 2023 08:06:19 +0000 Subject: - workqueue: Fix spurious sanity check failures in destroy_workqueue() (bsc#1210460). - blacklist.conf: Remove the commit from the blacklist. --- diff --git a/blacklist.conf b/blacklist.conf index 15f76d4..2fbab0d 100644 --- a/blacklist.conf +++ b/blacklist.conf @@ -549,7 +549,6 @@ d0a8d9378d16eb3c69bd8e6d23779fbdbee3a8c7 # Breaks build 9aee5f8a7e30330d0a8f4c626dc924ca5590aba5 # Doesn't fix a bug, breaks kABI 45b575c00d8e72d69d75dd8c112f044b7b01b069 # Doesn't fix a bug, breaks kABI 78ce241099bb363b19dbd0245442e66c8de8f567 # Not relevant -def98c84b6cdf2eeea19ec5736e90e316df5206b # workqueue: Too intrusive. Could the rescuer be needed to drain the queue? Anyway, the most likely reason for sanity check failure was hopefully fixed by commit e66b39af00f426b3356b ("workqueue: Fix pwq ref leak in rescuer_thread()") 65099ea85e885c3ea1272eca8774b771419d8ce8 # iio: revert: not applicable 12f92866f13f9ca12e158c07978246ed83d52ed0 # media: revert: not applicable 99fb0f25c448ab72481bd700b66e0e48c583ef5a # mfd: cros_ec: not applicable diff --git a/patches.suse/workqueue-Fix-spurious-sanity-check-failures-in-dest.patch b/patches.suse/workqueue-Fix-spurious-sanity-check-failures-in-dest.patch new file mode 100644 index 0000000..294a6e1 --- /dev/null +++ b/patches.suse/workqueue-Fix-spurious-sanity-check-failures-in-dest.patch @@ -0,0 +1,88 @@ +From def98c84b6cdf2eeea19ec5736e90e316df5206b Mon Sep 17 00:00:00 2001 +From: Tejun Heo +Date: Wed, 18 Sep 2019 18:43:40 -0700 +Subject: [PATCH] workqueue: Fix spurious sanity check failures in + destroy_workqueue() +Git-commit: def98c84b6cdf2eeea19ec5736e90e316df5206b +Patch-mainline: v5.5-rc1 +References: bsc#1210460 + +Before actually destrying a workqueue, destroy_workqueue() checks +whether it's actually idle. If it isn't, it prints out a bunch of +warning messages and leaves the workqueue dangling. It unfortunately +has a couple issues. + +* Mayday list queueing increments pwq's refcnts which gets detected as + busy and fails the sanity checks. However, because mayday list + queueing is asynchronous, this condition can happen without any + actual work items left in the workqueue. + +* Sanity check failure leaves the sysfs interface behind too which can + lead to init failure of newer instances of the workqueue. + +This patch fixes the above two by + +* If a workqueue has a rescuer, disable and kill the rescuer before + sanity checks. Disabling and killing is guaranteed to flush the + existing mayday list. + +* Remove sysfs interface before sanity checks. + +Signed-off-by: Tejun Heo +Reported-by: Marcin Pawlowski +Reported-by: "Williams, Gerald S" +Cc: stable@vger.kernel.org +Acked-by: Petr Mladek + +--- + kernel/workqueue.c | 24 +++++++++++++++++++----- + 1 file changed, 19 insertions(+), 5 deletions(-) + +diff --git a/kernel/workqueue.c b/kernel/workqueue.c +index bc2e09a8ea61..93e20f5330fc 100644 +--- a/kernel/workqueue.c ++++ b/kernel/workqueue.c +@@ -4325,9 +4325,28 @@ void destroy_workqueue(struct workqueue_struct *wq) + struct pool_workqueue *pwq; + int node; + ++ /* ++ * Remove it from sysfs first so that sanity check failure doesn't ++ * lead to sysfs name conflicts. ++ */ ++ workqueue_sysfs_unregister(wq); ++ + /* drain it before proceeding with destruction */ + drain_workqueue(wq); + ++ /* kill rescuer, if sanity checks fail, leave it w/o rescuer */ ++ if (wq->rescuer) { ++ struct worker *rescuer = wq->rescuer; ++ ++ /* this prevents new queueing */ ++ spin_lock_irq(&wq_mayday_lock); ++ wq->rescuer = NULL; ++ spin_unlock_irq(&wq_mayday_lock); ++ ++ /* rescuer will empty maydays list before exiting */ ++ kthread_stop(rescuer->task); ++ } ++ + /* sanity checks */ + mutex_lock(&wq->mutex); + for_each_pwq(pwq, wq) { +@@ -4359,11 +4378,6 @@ void destroy_workqueue(struct workqueue_struct *wq) + list_del_rcu(&wq->list); + mutex_unlock(&wq_pool_mutex); + +- workqueue_sysfs_unregister(wq); +- +- if (wq->rescuer) +- kthread_stop(wq->rescuer->task); +- + if (!(wq->flags & WQ_UNBOUND)) { + /* + * The base ref is never dropped on per-cpu pwqs. Directly +-- +2.35.3 + diff --git a/series.conf b/series.conf index 397fa23..044839b 100644 --- a/series.conf +++ b/series.conf @@ -53695,6 +53695,7 @@ patches.suse/edac-amd64-save-max-number-of-controllers-to-family-type.patch patches.suse/edac-ghes-fix-locking-and-memory-barrier-issues.patch patches.suse/edac-ghes-do-not-warn-when-incrementing-refcount-on-0.patch + patches.suse/workqueue-Fix-spurious-sanity-check-failures-in-dest.patch patches.suse/0001-workqueue-Fix-pwq-ref-leak-in-rescuer_thread.patch patches.suse/cgroup-pids-use-atomic64_t-for-pids-limit.patch patches.suse/livepatch-keep-replaced-patches-until-post_patch-callback-is-called.patch