All of lore.kernel.org
 help / color / mirror / Atom feed
From: Edward Adam Davis <eadavis@sina.com>
To: syzbot+97fde463a8ffb9e839d2@syzkaller.appspotmail.com
Cc: tj@kernel.org, jiangshanlai@gmail.com,
	linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: [PATCH] workqueue: Avoid noise generated by real-time tasks
Date: Thu, 26 Nov 2026 18:25:30 +0800	[thread overview]
Message-ID: <20261126102530.37205-1-eadavis@sina.com> (raw)
In-Reply-To: <6b0576ba.a481e175.27cf24.0027.GAE@google.com>

A user creates a SCHED_FIFO real-time thread and pins it to CPU0, and arm
watchdog timer on CPU1 with 3s threshold. The real-time thread runs for an
extended period without voluntarily yielding the CPU, preventing standard
kworker threads on CPU0 from gaining access to the processor.

As a result, certain kernel works cannot be executed in a timely manner,
which may even trigger a watchdog report:

BUG: workqueue lockup - pool cpus=0 node=0 flags=0x0 nice=0 stuck for 5s!
Showing busy workqueues and worker pools:
workqueue mm_percpu_wq: flags=0x108
  pwq 2: cpus=0 node=0 flags=0x0 nice=0 active=1 refcnt=2
    pending: vmstat_update

To address this, a check for CPU-bound tasks has been added to the work
pool; this helps prevent false-positive reports caused by prolonged CPU
occupancy by real-time tasks.

Fixes: 82607adcf9cd ("workqueue: implement lockup detector")
Reported-by: syzbot+97fde463a8ffb9e839d2@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=97fde463a8ffb9e839d2
Signed-off-by: Edward Adam Davis <eadavis@sina.com>
---
 kernel/workqueue.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index af845214e78b..daf7aad79062 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -52,6 +52,7 @@
 #include <linux/uaccess.h>
 #include <linux/sched/isolation.h>
 #include <linux/sched/debug.h>
+#include <sched/sched.h>
 #include <linux/nmi.h>
 #include <linux/kvm_para.h>
 #include <linux/delay.h>
@@ -8202,6 +8203,8 @@ static void wq_watchdog_timer_fn(struct timer_list *unused)
 		 * is a hotter path.
 		 */
 		if (time_after(now, ts + thresh)) {
+			struct task_struct *p;
+
 			scoped_guard(raw_spinlock_irqsave, &pool->lock) {
 				pool_ts = pool->last_progress_ts;
 				if (time_after(pool_ts, touched))
@@ -8212,6 +8215,11 @@ static void wq_watchdog_timer_fn(struct timer_list *unused)
 			if (!time_after(now, ts + thresh))
 				continue;
 
+			p = pool->cpu >= 0 ? cpu_curr(pool->cpu) : NULL;
+			if (p && (p->policy == SCHED_FIFO ||
+				  p->policy == SCHED_RR))
+				continue;
+
 			lockup_detected = true;
 			stall_time = jiffies_to_msecs(now - pool_ts) / 1000;
 			max_stall_time = max(max_stall_time, stall_time);
-- 
2.43.0


  parent reply	other threads:[~2026-11-26 10:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 11:36 [syzbot] [ext4?] BUG: workqueue lockup in update_super_work syzbot
2026-11-25  0:53 ` Hillf Danton
2026-11-26 10:25 ` Edward Adam Davis [this message]
2026-11-26 10:57   ` [PATCH] workqueue: Avoid noise generated by real-time tasks Tejun Heo
2026-11-27  5:07     ` Edward Adam Davis
2026-11-27  5:40   ` [PATCH next v2] workqueue: Avoid noise generated by userspace realtime tasks Edward Adam Davis
2026-11-29 22:46   ` [PATCH] workqueue: Avoid noise generated by real-time tasks kernel test robot
2026-11-30  1:01   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261126102530.37205-1-eadavis@sina.com \
    --to=eadavis@sina.com \
    --cc=jiangshanlai@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+97fde463a8ffb9e839d2@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.