[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241230064500.1404206-1-imran.f.khan@oracle.com>
Date: Mon, 30 Dec 2024 17:45:00 +1100
From: Imran Khan <imran.f.khan@...cle.com>
To: tj@...nel.org, jiangshanlai@...il.com
Cc: linux-kernel@...r.kernel.org
Subject: [RFC PATCH] workqueue: introduce WORK_STRUCT_TIMER_PENDING_BIT.
Currently WORK_STRUCT_PENDING_BIT can indicate a work_struct that is
already made it to work list of a worker_pool or a work_struct that has
not yet made it there because it comes from a delayed_work whose timer
has not expired yet.
Use WORK_STRUCT_TIMER_PENDING_BIT to distinguish between these two
states of work_struct.
Signed-off-by: Imran Khan <imran.f.khan@...cle.com>
---
I have kept the patch as RFC, because this change is not fixing a bug.
It makes WORK_STRUCT_PENDING_BIT less ambiguous and helps in debugging,
by indicating where one should look for this pending work.
include/linux/workqueue.h | 1 +
kernel/workqueue.c | 2 ++
2 files changed, 3 insertions(+)
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index b0dc957c3e560..2d327d9e9b53a 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -27,6 +27,7 @@ enum work_bits {
WORK_STRUCT_INACTIVE_BIT, /* work item is inactive */
WORK_STRUCT_PWQ_BIT, /* data points to pwq */
WORK_STRUCT_LINKED_BIT, /* next work is linked to this one */
+ WORK_STRUCT_TIMER_PENDING_BIT, /* timer pending for delayed work */
#ifdef CONFIG_DEBUG_OBJECTS_WORK
WORK_STRUCT_STATIC_BIT, /* static initializer (debugobjects) */
#endif
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index eb71e3d9d16dd..454382a9a1585 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2481,6 +2481,7 @@ void delayed_work_timer_fn(struct timer_list *t)
{
struct delayed_work *dwork = from_timer(dwork, t, timer);
+ clear_bit(WORK_STRUCT_TIMER_PENDING_BIT, work_data_bits(&dwork->work));
/* should have been called from irqsafe timer with irq already off */
__queue_work(dwork->cpu, dwork->wq, &dwork->work);
}
@@ -2511,6 +2512,7 @@ static void __queue_delayed_work(int cpu, struct workqueue_struct *wq,
dwork->wq = wq;
dwork->cpu = cpu;
timer->expires = jiffies + delay;
+ set_bit(WORK_STRUCT_TIMER_PENDING_BIT, work_data_bits(work));
if (housekeeping_enabled(HK_TYPE_TIMER)) {
/* If the current cpu is a housekeeping cpu, use it. */
base-commit: 8155b4ef3466f0e289e8fcc9e6e62f3f4dceeac2
--
2.34.1
Powered by blists - more mailing lists