* [PATCH] workqueue: Fix rescuer task's name truncated
@ 2024-05-13 3:06 Wenchao Hao
2024-05-13 7:35 ` kernel test robot
0 siblings, 1 reply; 3+ messages in thread
From: Wenchao Hao @ 2024-05-13 3:06 UTC (permalink / raw
To: Tejun Heo, Lai Jiangshan, Aaron Tomlin, linux-kernel
Cc: Wenchao Hao, Wenchao Hao
Task comm of task is limitted to 16, prefix "kworker/R-" is added for
rescuer worker's task, which cause most task name is truncated as
following:
root 81 0.0 0.0 0 0 ? I< 11:18 0:00 [kworker/R-xprti]
root 82 0.0 0.0 0 0 ? I< 11:18 0:00 [kworker/R-cfg80]
root 85 0.0 0.0 0 0 ? I< 11:18 0:00 [kworker/R-nfsio]
root 86 0.0 0.0 0 0 ? I< 11:18 0:00 [kworker/R-xfsal]
root 87 0.0 0.0 0 0 ? I< 11:18 0:00 [kworker/R-xfs_m]
root 88 0.0 0.0 0 0 ? I< 11:18 0:00 [kworker/R-acpi_]
root 93 0.0 0.0 0 0 ? I< 11:18 0:00 [kworker/R-iscsi]
root 95 0.0 0.0 0 0 ? I< 11:18 0:00 [kworker/R-scsi_]
root 97 0.0 0.0 0 0 ? I< 11:18 0:00 [kworker/R-scsi_]
root 99 0.0 0.0 0 0 ? I< 11:18 0:00 [kworker/R-scsi_]
Fix this issue by split rescuer name to 2 part like other kworker,
the normal part is "kworker/R" which is set to task_struct's comm,
another part is wq->name which is added to kworker's desc. These 2 parts
would be merged in wq_worker_comm().
Fixes: b6a46f7263bd ("workqueue: Rename rescuer kworker")
Signed-off-by: Wenchao Hao <haowenchao2@huawei.com>
Reviewed-by: Aaron Tomlin <atomlin@atomlin.com>
---
kernel/workqueue.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index d2dbe099286b..07c077a53f93 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5443,7 +5443,7 @@ static int init_rescuer(struct workqueue_struct *wq)
}
rescuer->rescue_wq = wq;
- rescuer->task = kthread_create(rescuer_thread, rescuer, "kworker/R-%s", wq->name);
+ rescuer->task = kthread_create(rescuer_thread, rescuer, "kworker/R");
if (IS_ERR(rescuer->task)) {
ret = PTR_ERR(rescuer->task);
pr_err("workqueue: Failed to create a rescuer kthread for wq \"%s\": %pe",
@@ -5452,6 +5452,8 @@ static int init_rescuer(struct workqueue_struct *wq)
return ret;
}
+ snprintf(rescuer->desc, sizeof(rescuer->desc), "%s", wq->name);
+
wq->rescuer = rescuer;
if (wq->flags & WQ_UNBOUND)
kthread_bind_mask(rescuer->task, wq_unbound_cpumask);
@@ -6302,6 +6304,8 @@ void wq_worker_comm(char *buf, size_t size, struct task_struct *task)
worker->desc);
}
raw_spin_unlock_irq(&pool->lock);
+ } else if (worker->desc[0] != '\0') {
+ scnprintf(buf + off, size - off, "-%s", worker->desc);
}
}
--
2.32.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] workqueue: Fix rescuer task's name truncated
2024-05-13 3:06 [PATCH] workqueue: Fix rescuer task's name truncated Wenchao Hao
@ 2024-05-13 7:35 ` kernel test robot
2024-05-13 13:28 ` Wenchao Hao
0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2024-05-13 7:35 UTC (permalink / raw
To: Wenchao Hao, Tejun Heo, Lai Jiangshan, Aaron Tomlin, linux-kernel
Cc: oe-kbuild-all, Wenchao Hao
Hi Wenchao,
kernel test robot noticed the following build warnings:
[auto build test WARNING on tj-wq/for-next]
[also build test WARNING on linus/master v6.9 next-20240510]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Wenchao-Hao/workqueue-Fix-rescuer-task-s-name-truncated/20240513-110849
base: https://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-next
patch link: https://lore.kernel.org/r/20240513030639.3772468-1-haowenchao2%40huawei.com
patch subject: [PATCH] workqueue: Fix rescuer task's name truncated
config: openrisc-allnoconfig (https://download.01.org/0day-ci/archive/20240513/202405131400.sEYZHYk2-lkp@intel.com/config)
compiler: or1k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240513/202405131400.sEYZHYk2-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405131400.sEYZHYk2-lkp@intel.com/
All warnings (new ones prefixed by >>):
kernel/workqueue.c: In function 'init_rescuer':
>> kernel/workqueue.c:5558:57: warning: '%s' directive output may be truncated writing up to 31 bytes into a region of size 24 [-Wformat-truncation=]
5558 | snprintf(rescuer->desc, sizeof(rescuer->desc), "%s", wq->name);
| ^~
kernel/workqueue.c:5558:9: note: 'snprintf' output between 1 and 32 bytes into a destination of size 24
5558 | snprintf(rescuer->desc, sizeof(rescuer->desc), "%s", wq->name);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +5558 kernel/workqueue.c
5528
5529 /*
5530 * Workqueues which may be used during memory reclaim should have a rescuer
5531 * to guarantee forward progress.
5532 */
5533 static int init_rescuer(struct workqueue_struct *wq)
5534 {
5535 struct worker *rescuer;
5536 int ret;
5537
5538 if (!(wq->flags & WQ_MEM_RECLAIM))
5539 return 0;
5540
5541 rescuer = alloc_worker(NUMA_NO_NODE);
5542 if (!rescuer) {
5543 pr_err("workqueue: Failed to allocate a rescuer for wq \"%s\"\n",
5544 wq->name);
5545 return -ENOMEM;
5546 }
5547
5548 rescuer->rescue_wq = wq;
5549 rescuer->task = kthread_create(rescuer_thread, rescuer, "kworker/R");
5550 if (IS_ERR(rescuer->task)) {
5551 ret = PTR_ERR(rescuer->task);
5552 pr_err("workqueue: Failed to create a rescuer kthread for wq \"%s\": %pe",
5553 wq->name, ERR_PTR(ret));
5554 kfree(rescuer);
5555 return ret;
5556 }
5557
> 5558 snprintf(rescuer->desc, sizeof(rescuer->desc), "%s", wq->name);
5559
5560 wq->rescuer = rescuer;
5561 if (wq->flags & WQ_UNBOUND)
5562 kthread_bind_mask(rescuer->task, wq_unbound_cpumask);
5563 else
5564 kthread_bind_mask(rescuer->task, cpu_possible_mask);
5565 wake_up_process(rescuer->task);
5566
5567 return 0;
5568 }
5569
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] workqueue: Fix rescuer task's name truncated
2024-05-13 7:35 ` kernel test robot
@ 2024-05-13 13:28 ` Wenchao Hao
0 siblings, 0 replies; 3+ messages in thread
From: Wenchao Hao @ 2024-05-13 13:28 UTC (permalink / raw
To: kernel test robot, Tejun Heo, Lai Jiangshan, Aaron Tomlin,
linux-kernel
Cc: oe-kbuild-all, Wenchao Hao
On 2024/5/13 15:35, kernel test robot wrote:
> Hi Wenchao,
>
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on tj-wq/for-next]
> [also build test WARNING on linus/master v6.9 next-20240510]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Wenchao-Hao/workqueue-Fix-rescuer-task-s-name-truncated/20240513-110849
> base: https://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-next
> patch link: https://lore.kernel.org/r/20240513030639.3772468-1-haowenchao2%40huawei.com
> patch subject: [PATCH] workqueue: Fix rescuer task's name truncated
> config: openrisc-allnoconfig (https://download.01.org/0day-ci/archive/20240513/202405131400.sEYZHYk2-lkp@intel.com/config)
> compiler: or1k-linux-gcc (GCC) 13.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240513/202405131400.sEYZHYk2-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202405131400.sEYZHYk2-lkp@intel.com/
>
> All warnings (new ones prefixed by >>):
>
> kernel/workqueue.c: In function 'init_rescuer':
>>> kernel/workqueue.c:5558:57: warning: '%s' directive output may be truncated writing up to 31 bytes into a region of size 24 [-Wformat-truncation=]
> 5558 | snprintf(rescuer->desc, sizeof(rescuer->desc), "%s", wq->name);
> | ^~
> kernel/workqueue.c:5558:9: note: 'snprintf' output between 1 and 32 bytes into a destination of size 24
> 5558 | snprintf(rescuer->desc, sizeof(rescuer->desc), "%s", wq->name);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> vim +5558 kernel/workqueue.c
>
> 5528
> 5529 /*
> 5530 * Workqueues which may be used during memory reclaim should have a rescuer
> 5531 * to guarantee forward progress.
> 5532 */
> 5533 static int init_rescuer(struct workqueue_struct *wq)
> 5534 {
> 5535 struct worker *rescuer;
> 5536 int ret;
> 5537
> 5538 if (!(wq->flags & WQ_MEM_RECLAIM))
> 5539 return 0;
> 5540
> 5541 rescuer = alloc_worker(NUMA_NO_NODE);
> 5542 if (!rescuer) {
> 5543 pr_err("workqueue: Failed to allocate a rescuer for wq \"%s\"\n",
> 5544 wq->name);
> 5545 return -ENOMEM;
> 5546 }
> 5547
> 5548 rescuer->rescue_wq = wq;
> 5549 rescuer->task = kthread_create(rescuer_thread, rescuer, "kworker/R");
> 5550 if (IS_ERR(rescuer->task)) {
> 5551 ret = PTR_ERR(rescuer->task);
> 5552 pr_err("workqueue: Failed to create a rescuer kthread for wq \"%s\": %pe",
> 5553 wq->name, ERR_PTR(ret));
> 5554 kfree(rescuer);
> 5555 return ret;
> 5556 }
> 5557
>> 5558 snprintf(rescuer->desc, sizeof(rescuer->desc), "%s", wq->name);
This is because commit 31c89007285d3 ("workqueue.c: Increase workqueue name length") increase
WQ_NAME_LEN from 24 to 32, but forget to increase WORKER_DESC_LEN (WORKER_DESC_LEN should equal
to WQ_NAME_LEN ).
Same usage can be found in process_one_work(), it called strscpy() which would not WARNING.
I would add following changes and post V2:
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index 158784dd189a..72031fa80414 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -92,7 +92,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'! */
> 5559
> 5560 wq->rescuer = rescuer;
> 5561 if (wq->flags & WQ_UNBOUND)
> 5562 kthread_bind_mask(rescuer->task, wq_unbound_cpumask);
> 5563 else
> 5564 kthread_bind_mask(rescuer->task, cpu_possible_mask);
> 5565 wake_up_process(rescuer->task);
> 5566
> 5567 return 0;
> 5568 }
> 5569
>
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-13 13:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-13 3:06 [PATCH] workqueue: Fix rescuer task's name truncated Wenchao Hao
2024-05-13 7:35 ` kernel test robot
2024-05-13 13:28 ` Wenchao Hao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).