From: Lai Jiangshan <jiangshanlai@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Tejun Heo <tj@kernel.org>,
Lai Jiangshan <jiangshan.ljs@antgroup.com>,
Lai Jiangshan <jiangshanlai@gmail.com>
Subject: [PATCH 1/2] workqueue: Use pwq->work_color for wq_barrier
Date: Tue, 25 Nov 2025 18:31:24 +0800 [thread overview]
Message-ID: <20251125103126.684929-2-jiangshanlai@gmail.com> (raw)
In-Reply-To: <20251125103126.684929-1-jiangshanlai@gmail.com>
From: Lai Jiangshan <jiangshan.ljs@antgroup.com>
wq_barrier work items are internal and do not count as user work items.
They do not participate in flush_workqueue() except for a sanity check,
since wq_barrier owns the PWQ reference. Therefore, any work color is
acceptable; just use the latest pwq->work_color.
See the commit d812796eb390 ("workqueue: Assign a color to barrier work
items").
Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com>
---
kernel/workqueue.c | 9 ++-------
kernel/workqueue_internal.h | 1 -
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 253311af47c6..4d817c7144cf 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3187,7 +3187,6 @@ __acquires(&pool->lock)
if (worker->task)
worker->current_at = worker->task->se.sum_exec_runtime;
work_data = *work_data_bits(work);
- worker->current_color = get_work_color(work_data);
/*
* Record wq name for cmdline and debug reporting, may get
@@ -3308,7 +3307,6 @@ __acquires(&pool->lock)
worker->current_work = NULL;
worker->current_func = NULL;
worker->current_pwq = NULL;
- worker->current_color = INT_MAX;
/* must be the last step, see the function comment */
pwq_dec_nr_in_flight(pwq, work_data);
@@ -3796,7 +3794,6 @@ static void insert_wq_barrier(struct pool_workqueue *pwq,
{
static __maybe_unused struct lock_class_key bh_key, thr_key;
unsigned int work_flags = 0;
- unsigned int work_color;
struct list_head *head;
/*
@@ -3826,19 +3823,17 @@ static void insert_wq_barrier(struct pool_workqueue *pwq,
*/
if (worker) {
head = worker->scheduled.next;
- work_color = worker->current_color;
} else {
unsigned long *bits = work_data_bits(target);
head = target->entry.next;
/* there can already be other linked works, inherit and set */
work_flags |= *bits & WORK_STRUCT_LINKED;
- work_color = get_work_color(*bits);
__set_bit(WORK_STRUCT_LINKED_BIT, bits);
}
- pwq->nr_in_flight[work_color]++;
- work_flags |= work_color_to_flags(work_color);
+ pwq->nr_in_flight[pwq->work_color]++;
+ work_flags |= work_color_to_flags(pwq->work_color);
insert_work(pwq, &barr->work, head, work_flags);
}
diff --git a/kernel/workqueue_internal.h b/kernel/workqueue_internal.h
index f6275944ada7..76d2d99b26ab 100644
--- a/kernel/workqueue_internal.h
+++ b/kernel/workqueue_internal.h
@@ -32,7 +32,6 @@ struct worker {
work_func_t current_func; /* K: function */
struct pool_workqueue *current_pwq; /* K: pwq */
u64 current_at; /* K: runtime at start or last wakeup */
- unsigned int current_color; /* K: color */
int sleeping; /* S: is worker sleeping? */
--
2.19.1.6.gb485710b
next prev parent reply other threads:[~2025-11-25 10:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-25 10:31 [PATCH 0/2] workqueue: Simplify color management Lai Jiangshan
2025-11-25 10:31 ` Lai Jiangshan [this message]
2025-12-02 17:37 ` [PATCH 1/2] workqueue: Use pwq->work_color for wq_barrier Tejun Heo
2025-12-03 3:48 ` Lai Jiangshan
2025-11-25 10:31 ` [PATCH 2/2] workqueue: Move flush color assignment code into insert_work() Lai Jiangshan
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=20251125103126.684929-2-jiangshanlai@gmail.com \
--to=jiangshanlai@gmail.com \
--cc=jiangshan.ljs@antgroup.com \
--cc=linux-kernel@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®