Skip to contentSkip to conversation

workqueue: Increase worker desc's length to 32

PATCH Applied Wenchao Hao 2 participants 4 messages Jun 6, 2024 – Jun 7, 2024 Workqueue

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 workqueue: Increase worker desc's length to 32

Commit 31c89007285d ("workqueue.c: Increase workqueue name length") increased WQ_NAME_LEN from 24 to 32, but forget to increase WORKER_DESC_LEN, which would cause truncation when setting kworker's desc from workqueue_struct's name, process_one_work() for example.

Fixes 31c89007285d ("workqueue.c: Increase workqueue name length")
CC Audra Mitchell <[email protected]>
---
 include/linux/workqueue.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/workqueue.h +1 -1
index fb3993894536..d9968bfc8eac 100644
@@ -95,7 +95,7 @@ enum wq_misc_consts {
 	WORK_BUSY_RUNNING	= 1 << 1,
 
 	/* maximum string length for set_worker_desc() */
-	WORKER_DESC_LEN		= 24,
+	WORKER_DESC_LEN		= 32,
 };
 
 /* Convenience constants - of type 'unsigned long', not 'enum'! */
Signature · 1 line
2.38.1
#1 lore raw

PATCH 2/2 workqueue: cleancode in alloc_and_link_pwqs()

wq->flags would not change, so it's not necessary to check if WQ_BH is set in loop for_each_possible_cpu(), move define and set of pools out of loop to simpliy the code.

---
 kernel/workqueue.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
kernel/workqueue.c +7 -6
index 3fbaecfc88c2..078d56ddbe3a 100644
@@ -5477,16 +5477,17 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq)
 		goto enomem;
 
 	if (!(wq->flags & WQ_UNBOUND)) {
+		struct worker_pool __percpu *pools;
+
+		if (wq->flags & WQ_BH)
+			pools = bh_worker_pools;
+		else
+			pools = cpu_worker_pools;
+
 		for_each_possible_cpu(cpu) {
 			struct pool_workqueue **pwq_p;
-			struct worker_pool __percpu *pools;
 			struct worker_pool *pool;
 
-			if (wq->flags & WQ_BH)
-				pools = bh_worker_pools;
-			else
-				pools = cpu_worker_pools;
-
 			pool = &(per_cpu_ptr(pools, cpu)[highpri]);
 			pwq_p = per_cpu_ptr(wq->cpu_pwq, cpu);
 
Signature · 1 line
2.38.1
maintainer Applied
#2 lore raw

Re: [PATCH 2/2] workqueue: cleancode in alloc_and_link_pwqs()

Quoted 5 lines · Wenchao Hao

wq->flags would not change, so it's not necessary to check if WQ_BH is set in loop for_each_possible_cpu(), move define and set of pools out of loop to simpliy the code.

Applied to wq/for-6.11.

Thanks.

Signature · 1 line
tejun
maintainer Applied
#3 lore raw
In reply to Wenchao Hao
Quoted 9 lines · Wenchao Hao

Commit 31c89007285d ("workqueue.c: Increase workqueue name length") increased WQ_NAME_LEN from 24 to 32, but forget to increase WORKER_DESC_LEN, which would cause truncation when setting kworker's desc from workqueue_struct's name, process_one_work() for example.

Fixes 31c89007285d ("workqueue.c: Increase workqueue name length")
CC Audra Mitchell <[email protected]>

Applied to wq/for-6.10-fixes.

Thanks.

Signature · 1 line
tejun