* [PATCH] workqueue: add cmdline parameter `unbound_workqueue_cpus` to further constrain wq_unbound_cpumask at boot time
@ 2023-06-22 3:34 tiozhang
2023-06-22 3:47 ` Randy Dunlap
0 siblings, 1 reply; 9+ messages in thread
From: tiozhang @ 2023-06-22 3:34 UTC (permalink / raw)
To: tj; +Cc: jiangshanlai, linux-kernel, zyhtheonly, zwp10758, zyhtheonly, tiozhang
Motivation of doing this is to better improve boot times for devices when
we want to prevent our workqueue works from running on some specific CPUs,
e,g, some CPUs are busy with interrupts.
Signed-off-by: tiozhang <tiozhang@didiglobal.com>
---
kernel/workqueue.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 7cd5f5e7e0a1..47e7b29df5fe 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -329,6 +329,9 @@ static bool workqueue_freezing; /* PL: have wqs started freezing? */
/* PL: allowable cpus for unbound wqs and work items */
static cpumask_var_t wq_unbound_cpumask;
+/* for further constrain wq_unbound_cpumask by cmdline parameter*/
+static cpumask_var_t wq_cmdline_cpumask;
+
/* CPU where unbound work was last round robin scheduled from this CPU */
static DEFINE_PER_CPU(int, wq_rr_cpu_last);
@@ -6006,6 +6009,10 @@ void __init workqueue_init_early(void)
cpumask_copy(wq_unbound_cpumask, housekeeping_cpumask(HK_TYPE_WQ));
cpumask_and(wq_unbound_cpumask, wq_unbound_cpumask, housekeeping_cpumask(HK_TYPE_DOMAIN));
+ if (!cpumask_empty(wq_cmdline_cpumask))
+ cpumask_and(wq_unbound_cpumask, wq_unbound_cpumask, wq_cmdline_cpumask);
+ free_bootmem_cpumask_var(wq_cmdline_cpumask);
+
pwq_cache = KMEM_CACHE(pool_workqueue, SLAB_PANIC);
/* initialize CPU pools */
@@ -6129,3 +6136,21 @@ void __init workqueue_init(void)
*/
void __warn_flushing_systemwide_wq(void) { }
EXPORT_SYMBOL(__warn_flushing_systemwide_wq);
+
+
+static int __init unbound_workqueue_cpus_setup(char *str)
+{
+ cpumask_var_t cpumask;
+
+ alloc_bootmem_cpumask_var(&wq_cmdline_cpumask);
+ alloc_bootmem_cpumask_var(&cpumask);
+ if (cpulist_parse(str, cpumask) < 0)
+ pr_warn("unbound_workqueue_cpus: incorrect CPU range\n");
+ else
+ cpumask_copy(wq_cmdline_cpumask, cpumask);
+
+ free_bootmem_cpumask_var(cpumask);
+
+ return 0;
+}
+__setup("unbound_workqueue_cpus=", unbound_workqueue_cpus_setup);
--
2.17.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] workqueue: add cmdline parameter `unbound_workqueue_cpus` to further constrain wq_unbound_cpumask at boot time
2023-06-22 3:34 [PATCH] workqueue: add cmdline parameter `unbound_workqueue_cpus` to further constrain wq_unbound_cpumask at boot time tiozhang
@ 2023-06-22 3:47 ` Randy Dunlap
2023-06-23 7:30 ` [PATCH v2] workqueue: add cmdline parameter `workqueue_unbound_cpus` " tiozhang
0 siblings, 1 reply; 9+ messages in thread
From: Randy Dunlap @ 2023-06-22 3:47 UTC (permalink / raw)
To: tj, jiangshanlai, linux-kernel, zyhtheonly, zwp10758, zyhtheonly
On 6/21/23 20:34, tiozhang wrote:
> Motivation of doing this is to better improve boot times for devices when
> we want to prevent our workqueue works from running on some specific CPUs,
> e,g, some CPUs are busy with interrupts.
>
> Signed-off-by: tiozhang <tiozhang@didiglobal.com>
> ---
> kernel/workqueue.c | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
Documentation for this new command line parameter should be added to
Documentation/admin-guide/kernel-parameters.rst (in alphabetical order).
Thanks.
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index 7cd5f5e7e0a1..47e7b29df5fe 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -329,6 +329,9 @@ static bool workqueue_freezing; /* PL: have wqs started freezing? */
> /* PL: allowable cpus for unbound wqs and work items */
> static cpumask_var_t wq_unbound_cpumask;
>
> +/* for further constrain wq_unbound_cpumask by cmdline parameter*/
> +static cpumask_var_t wq_cmdline_cpumask;
> +
> /* CPU where unbound work was last round robin scheduled from this CPU */
> static DEFINE_PER_CPU(int, wq_rr_cpu_last);
>
> @@ -6006,6 +6009,10 @@ void __init workqueue_init_early(void)
> cpumask_copy(wq_unbound_cpumask, housekeeping_cpumask(HK_TYPE_WQ));
> cpumask_and(wq_unbound_cpumask, wq_unbound_cpumask, housekeeping_cpumask(HK_TYPE_DOMAIN));
>
> + if (!cpumask_empty(wq_cmdline_cpumask))
> + cpumask_and(wq_unbound_cpumask, wq_unbound_cpumask, wq_cmdline_cpumask);
> + free_bootmem_cpumask_var(wq_cmdline_cpumask);
> +
> pwq_cache = KMEM_CACHE(pool_workqueue, SLAB_PANIC);
>
> /* initialize CPU pools */
> @@ -6129,3 +6136,21 @@ void __init workqueue_init(void)
> */
> void __warn_flushing_systemwide_wq(void) { }
> EXPORT_SYMBOL(__warn_flushing_systemwide_wq);
> +
> +
> +static int __init unbound_workqueue_cpus_setup(char *str)
> +{
> + cpumask_var_t cpumask;
> +
> + alloc_bootmem_cpumask_var(&wq_cmdline_cpumask);
> + alloc_bootmem_cpumask_var(&cpumask);
> + if (cpulist_parse(str, cpumask) < 0)
> + pr_warn("unbound_workqueue_cpus: incorrect CPU range\n");
> + else
> + cpumask_copy(wq_cmdline_cpumask, cpumask);
> +
> + free_bootmem_cpumask_var(cpumask);
> +
> + return 0;
> +}
> +__setup("unbound_workqueue_cpus=", unbound_workqueue_cpus_setup);
--
~Randy
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2] workqueue: add cmdline parameter `workqueue_unbound_cpus` to further constrain wq_unbound_cpumask at boot time
2023-06-22 3:47 ` Randy Dunlap
@ 2023-06-23 7:30 ` tiozhang
2023-06-25 3:15 ` [PATCH v3] " tiozhang
0 siblings, 1 reply; 9+ messages in thread
From: tiozhang @ 2023-06-23 7:30 UTC (permalink / raw)
To: rdunlap, tj
Cc: jiangshanlai, linux-kernel, zyhtheonly, zwp10758, zyhtheonly, tiozhang
Motivation of doing this is to better improve boot times for devices when
we want to prevent our workqueue works from running on some specific CPUs,
e,g, some CPUs are busy with interrupts.
Signed-off-by: tiozhang <tiozhang@didiglobal.com>
---
.../admin-guide/kernel-parameters.txt | 8 ++++++
kernel/workqueue.c | 25 +++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index a465d5242774..7f2fe8c60d5c 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -6780,6 +6780,14 @@
disables both lockup detectors. Default is 10
seconds.
+ workqueue_unbound_cpus=
+ [KNL,SMP]
+ Format: <cpu-list>
+ Specify to constrain one or some CPUs to use in
+ unbound workqueues.
+ By default, all online CPUs are available for
+ unbound workqueues.
+
workqueue.watchdog_thresh=
If CONFIG_WQ_WATCHDOG is configured, workqueue can
warn stall conditions and dump internal state to
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 7cd5f5e7e0a1..1475f8f560cc 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -329,6 +329,9 @@ static bool workqueue_freezing; /* PL: have wqs started freezing? */
/* PL: allowable cpus for unbound wqs and work items */
static cpumask_var_t wq_unbound_cpumask;
+/* for further constrain wq_unbound_cpumask by cmdline parameter*/
+static cpumask_var_t wq_cmdline_cpumask;
+
/* CPU where unbound work was last round robin scheduled from this CPU */
static DEFINE_PER_CPU(int, wq_rr_cpu_last);
@@ -6006,6 +6009,10 @@ void __init workqueue_init_early(void)
cpumask_copy(wq_unbound_cpumask, housekeeping_cpumask(HK_TYPE_WQ));
cpumask_and(wq_unbound_cpumask, wq_unbound_cpumask, housekeeping_cpumask(HK_TYPE_DOMAIN));
+ if (!cpumask_empty(wq_cmdline_cpumask))
+ cpumask_and(wq_unbound_cpumask, wq_unbound_cpumask, wq_cmdline_cpumask);
+ free_bootmem_cpumask_var(wq_cmdline_cpumask);
+
pwq_cache = KMEM_CACHE(pool_workqueue, SLAB_PANIC);
/* initialize CPU pools */
@@ -6129,3 +6136,21 @@ void __init workqueue_init(void)
*/
void __warn_flushing_systemwide_wq(void) { }
EXPORT_SYMBOL(__warn_flushing_systemwide_wq);
+
+
+static int __init workqueue_unbound_cpus_setup(char *str)
+{
+ cpumask_var_t cpumask;
+
+ alloc_bootmem_cpumask_var(&wq_cmdline_cpumask);
+ alloc_bootmem_cpumask_var(&cpumask);
+ if (cpulist_parse(str, cpumask) < 0)
+ pr_warn("workqueue_unbound_cpus: incorrect CPU range\n");
+ else
+ cpumask_copy(wq_cmdline_cpumask, cpumask);
+
+ free_bootmem_cpumask_var(cpumask);
+
+ return 0;
+}
+__setup("workqueue_unbound_cpus=", workqueue_unbound_cpus_setup);
--
2.17.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3] workqueue: add cmdline parameter `workqueue_unbound_cpus` to further constrain wq_unbound_cpumask at boot time
2023-06-23 7:30 ` [PATCH v2] workqueue: add cmdline parameter `workqueue_unbound_cpus` " tiozhang
@ 2023-06-25 3:15 ` tiozhang
2023-06-26 21:00 ` Tejun Heo
0 siblings, 1 reply; 9+ messages in thread
From: tiozhang @ 2023-06-25 3:15 UTC (permalink / raw)
To: tj, rdunlap
Cc: linux-kernel, jiangshanlai, zyhtheonly, zyhtheonly, zwp10758, tiozhang
Motivation of doing this is to better improve boot times for devices when
we want to prevent our workqueue works from running on some specific CPUs,
e,g, some CPUs are busy with interrupts.
Signed-off-by: tiozhang <tiozhang@didiglobal.com>
---
.../admin-guide/kernel-parameters.txt | 8 +++++++
kernel/workqueue.c | 24 +++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index a465d5242774..7f2fe8c60d5c 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -6780,6 +6780,14 @@
disables both lockup detectors. Default is 10
seconds.
+ workqueue_unbound_cpus=
+ [KNL,SMP]
+ Format: <cpu-list>
+ Specify to constrain one or some CPUs to use in
+ unbound workqueues.
+ By default, all online CPUs are available for
+ unbound workqueues.
+
workqueue.watchdog_thresh=
If CONFIG_WQ_WATCHDOG is configured, workqueue can
warn stall conditions and dump internal state to
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 7cd5f5e7e0a1..c247725b0873 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -329,6 +329,9 @@ static bool workqueue_freezing; /* PL: have wqs started freezing? */
/* PL: allowable cpus for unbound wqs and work items */
static cpumask_var_t wq_unbound_cpumask;
+/* for further constrain wq_unbound_cpumask by cmdline parameter*/
+static cpumask_var_t wq_cmdline_cpumask;
+
/* CPU where unbound work was last round robin scheduled from this CPU */
static DEFINE_PER_CPU(int, wq_rr_cpu_last);
@@ -6006,6 +6009,10 @@ void __init workqueue_init_early(void)
cpumask_copy(wq_unbound_cpumask, housekeeping_cpumask(HK_TYPE_WQ));
cpumask_and(wq_unbound_cpumask, wq_unbound_cpumask, housekeeping_cpumask(HK_TYPE_DOMAIN));
+ if (!cpumask_empty(wq_cmdline_cpumask))
+ cpumask_and(wq_unbound_cpumask, wq_unbound_cpumask, wq_cmdline_cpumask);
+ free_bootmem_cpumask_var(wq_cmdline_cpumask);
+
pwq_cache = KMEM_CACHE(pool_workqueue, SLAB_PANIC);
/* initialize CPU pools */
@@ -6129,3 +6136,20 @@ void __init workqueue_init(void)
*/
void __warn_flushing_systemwide_wq(void) { }
EXPORT_SYMBOL(__warn_flushing_systemwide_wq);
+
+static int __init workqueue_unbound_cpus_setup(char *str)
+{
+ cpumask_var_t cpumask;
+
+ alloc_bootmem_cpumask_var(&wq_cmdline_cpumask);
+ alloc_bootmem_cpumask_var(&cpumask);
+ if (cpulist_parse(str, cpumask) < 0)
+ pr_warn("workqueue_unbound_cpus: incorrect CPU range\n");
+ else
+ cpumask_copy(wq_cmdline_cpumask, cpumask);
+
+ free_bootmem_cpumask_var(cpumask);
+
+ return 0;
+}
+__setup("workqueue_unbound_cpus=", workqueue_unbound_cpus_setup);
--
2.17.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3] workqueue: add cmdline parameter `workqueue_unbound_cpus` to further constrain wq_unbound_cpumask at boot time
2023-06-25 3:15 ` [PATCH v3] " tiozhang
@ 2023-06-26 21:00 ` Tejun Heo
2023-06-28 11:18 ` [PATCH v4] workqueue: add cmdline parameter `workqueue.unbound_cpus` " tiozhang
0 siblings, 1 reply; 9+ messages in thread
From: Tejun Heo @ 2023-06-26 21:00 UTC (permalink / raw)
To: rdunlap, linux-kernel, jiangshanlai, zyhtheonly, zyhtheonly, zwp10758
Hello,
On Sun, Jun 25, 2023 at 11:15:02AM +0800, tiozhang wrote:
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index a465d5242774..7f2fe8c60d5c 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -6780,6 +6780,14 @@
> disables both lockup detectors. Default is 10
> seconds.
>
> + workqueue_unbound_cpus=
Please use workqueue.unbound_cpus for consistency.
> + [KNL,SMP]
> + Format: <cpu-list>
> + Specify to constrain one or some CPUs to use in
> + unbound workqueues.
> + By default, all online CPUs are available for
> + unbound workqueues.
and flow the paragraph.
> workqueue.watchdog_thresh=
> If CONFIG_WQ_WATCHDOG is configured, workqueue can
> warn stall conditions and dump internal state to
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index 7cd5f5e7e0a1..c247725b0873 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -329,6 +329,9 @@ static bool workqueue_freezing; /* PL: have wqs started freezing? */
> /* PL: allowable cpus for unbound wqs and work items */
> static cpumask_var_t wq_unbound_cpumask;
>
> +/* for further constrain wq_unbound_cpumask by cmdline parameter*/
> +static cpumask_var_t wq_cmdline_cpumask;
> +
> /* CPU where unbound work was last round robin scheduled from this CPU */
> static DEFINE_PER_CPU(int, wq_rr_cpu_last);
>
> @@ -6006,6 +6009,10 @@ void __init workqueue_init_early(void)
> cpumask_copy(wq_unbound_cpumask, housekeeping_cpumask(HK_TYPE_WQ));
> cpumask_and(wq_unbound_cpumask, wq_unbound_cpumask, housekeeping_cpumask(HK_TYPE_DOMAIN));
>
> + if (!cpumask_empty(wq_cmdline_cpumask))
> + cpumask_and(wq_unbound_cpumask, wq_unbound_cpumask, wq_cmdline_cpumask);
> + free_bootmem_cpumask_var(wq_cmdline_cpumask);
If workqueue_unbound_cpus_setup() wasn't called during boot because the
parameter wasn't set, the above would end up trying to access and fre
wq_cmdline_cpumask which hasn't been allocated. Let's just use statically
allocated __initdata struct cpumask so that we don't have to worry about
allocation and freeing during early boot.
> +static int __init workqueue_unbound_cpus_setup(char *str)
> +{
> + cpumask_var_t cpumask;
> +
> + alloc_bootmem_cpumask_var(&wq_cmdline_cpumask);
> + alloc_bootmem_cpumask_var(&cpumask);
> + if (cpulist_parse(str, cpumask) < 0)
> + pr_warn("workqueue_unbound_cpus: incorrect CPU range\n");
> + else
> + cpumask_copy(wq_cmdline_cpumask, cpumask);
You can just parse direclty into wq_cmdline_cpumask and then clear it on
error.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v4] workqueue: add cmdline parameter `workqueue.unbound_cpus` to further constrain wq_unbound_cpumask at boot time
2023-06-26 21:00 ` Tejun Heo
@ 2023-06-28 11:18 ` tiozhang
2023-06-28 18:51 ` Randy Dunlap
0 siblings, 1 reply; 9+ messages in thread
From: tiozhang @ 2023-06-28 11:18 UTC (permalink / raw)
To: tj
Cc: rdunlap, frederic, jiangshanlai, linux-kernel, zyhtheonly,
zyhtheonly, zwp10758, tiozhang, fuyuanli
Motivation of doing this is to better improve boot times for devices when
we want to prevent our workqueue works from running on some specific CPUs,
e,g, some CPUs are busy with interrupts.
Signed-off-by: tiozhang <tiozhang@didiglobal.com>
---
.../admin-guide/kernel-parameters.txt | 7 +++++++
kernel/workqueue.c | 20 +++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index a465d5242774..a88b133ab09b 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -6780,6 +6780,13 @@
disables both lockup detectors. Default is 10
seconds.
+ workqueue.unbound_cpus=
+ [KNL,SMP] Specify to constrain one or some CPUs
+ to use in unbound workqueues.
+ Format: <cpu-list>
+ By default, all online CPUs are available for
+ unbound workqueues.
+
workqueue.watchdog_thresh=
If CONFIG_WQ_WATCHDOG is configured, workqueue can
warn stall conditions and dump internal state to
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 7cd5f5e7e0a1..29e8254edd63 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -329,6 +329,9 @@ static bool workqueue_freezing; /* PL: have wqs started freezing? */
/* PL: allowable cpus for unbound wqs and work items */
static cpumask_var_t wq_unbound_cpumask;
+/* for further constrain wq_unbound_cpumask by cmdline parameter*/
+static struct cpumask wq_cmdline_cpumask __initdata;
+
/* CPU where unbound work was last round robin scheduled from this CPU */
static DEFINE_PER_CPU(int, wq_rr_cpu_last);
@@ -6006,6 +6009,9 @@ void __init workqueue_init_early(void)
cpumask_copy(wq_unbound_cpumask, housekeeping_cpumask(HK_TYPE_WQ));
cpumask_and(wq_unbound_cpumask, wq_unbound_cpumask, housekeeping_cpumask(HK_TYPE_DOMAIN));
+ if (!cpumask_empty(&wq_cmdline_cpumask))
+ cpumask_and(wq_unbound_cpumask, wq_unbound_cpumask, &wq_cmdline_cpumask);
+
pwq_cache = KMEM_CACHE(pool_workqueue, SLAB_PANIC);
/* initialize CPU pools */
@@ -6129,3 +6135,17 @@ void __init workqueue_init(void)
*/
void __warn_flushing_systemwide_wq(void) { }
EXPORT_SYMBOL(__warn_flushing_systemwide_wq);
+
+static int __init workqueue_unbound_cpus_setup(char *str)
+{
+ int ret;
+
+ ret = cpulist_parse(str, &wq_cmdline_cpumask);
+ if (ret < 0) {
+ cpumask_clear(&wq_cmdline_cpumask);
+ pr_warn("workqueue.unbound_cpus: incorrect CPU range\n");
+ }
+
+ return ret;
+}
+__setup("workqueue.unbound_cpus=", workqueue_unbound_cpus_setup);
--
2.17.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v4] workqueue: add cmdline parameter `workqueue.unbound_cpus` to further constrain wq_unbound_cpumask at boot time
2023-06-28 11:18 ` [PATCH v4] workqueue: add cmdline parameter `workqueue.unbound_cpus` " tiozhang
@ 2023-06-28 18:51 ` Randy Dunlap
2023-06-29 3:50 ` [PATCH v5] " tiozhang
0 siblings, 1 reply; 9+ messages in thread
From: Randy Dunlap @ 2023-06-28 18:51 UTC (permalink / raw)
To: tj, frederic, jiangshanlai, linux-kernel, zyhtheonly, zyhtheonly,
zwp10758, fuyuanli
Hi--
On 6/28/23 04:18, tiozhang wrote:
> Motivation of doing this is to better improve boot times for devices when
> we want to prevent our workqueue works from running on some specific CPUs,
> e,g, some CPUs are busy with interrupts.
>
> Signed-off-by: tiozhang <tiozhang@didiglobal.com>
> ---
> .../admin-guide/kernel-parameters.txt | 7 +++++++
> kernel/workqueue.c | 20 +++++++++++++++++++
> 2 files changed, 27 insertions(+)
>
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index 7cd5f5e7e0a1..29e8254edd63 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -6129,3 +6135,17 @@ void __init workqueue_init(void)
> */
> void __warn_flushing_systemwide_wq(void) { }
> EXPORT_SYMBOL(__warn_flushing_systemwide_wq);
> +
> +static int __init workqueue_unbound_cpus_setup(char *str)
> +{
> + int ret;
> +
> + ret = cpulist_parse(str, &wq_cmdline_cpumask);
> + if (ret < 0) {
> + cpumask_clear(&wq_cmdline_cpumask);
> + pr_warn("workqueue.unbound_cpus: incorrect CPU range\n");
> + }
> +
> + return ret;
> +}
> +__setup("workqueue.unbound_cpus=", workqueue_unbound_cpus_setup);
__setup() functions don't return 0 for success or errno/other values
for error. They return 1 if the parameter is handled and 0 if it is
not handled, as documented in include/linux/init.h.
And "handled" basically means "recognized" as a kernel parameter,
not that the value(s) passed to it are correct.
I.e., they should usually return 0.
--
~Randy
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v5] workqueue: add cmdline parameter `workqueue.unbound_cpus` to further constrain wq_unbound_cpumask at boot time
2023-06-28 18:51 ` Randy Dunlap
@ 2023-06-29 3:50 ` tiozhang
2023-07-10 20:43 ` Tejun Heo
0 siblings, 1 reply; 9+ messages in thread
From: tiozhang @ 2023-06-29 3:50 UTC (permalink / raw)
To: tj, rdunlap
Cc: frederic, jiangshanlai, linux-kernel, zyhtheonly, zyhtheonly,
zwp10758, tiozhang, fuyuanli
Motivation of doing this is to better improve boot times for devices when
we want to prevent our workqueue works from running on some specific CPUs,
e,g, some CPUs are busy with interrupts.
Signed-off-by: tiozhang <tiozhang@didiglobal.com>
---
Documentation/admin-guide/kernel-parameters.txt | 7 +++++++
kernel/workqueue.c | 17 +++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index a465d5242774..a88b133ab09b 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -6780,6 +6780,13 @@
disables both lockup detectors. Default is 10
seconds.
+ workqueue.unbound_cpus=
+ [KNL,SMP] Specify to constrain one or some CPUs
+ to use in unbound workqueues.
+ Format: <cpu-list>
+ By default, all online CPUs are available for
+ unbound workqueues.
+
workqueue.watchdog_thresh=
If CONFIG_WQ_WATCHDOG is configured, workqueue can
warn stall conditions and dump internal state to
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 7cd5f5e7e0a1..70145031acdb 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -329,6 +329,9 @@ static bool workqueue_freezing; /* PL: have wqs started freezing? */
/* PL: allowable cpus for unbound wqs and work items */
static cpumask_var_t wq_unbound_cpumask;
+/* for further constrain wq_unbound_cpumask by cmdline parameter*/
+static struct cpumask wq_cmdline_cpumask __initdata;
+
/* CPU where unbound work was last round robin scheduled from this CPU */
static DEFINE_PER_CPU(int, wq_rr_cpu_last);
@@ -6006,6 +6009,9 @@ void __init workqueue_init_early(void)
cpumask_copy(wq_unbound_cpumask, housekeeping_cpumask(HK_TYPE_WQ));
cpumask_and(wq_unbound_cpumask, wq_unbound_cpumask, housekeeping_cpumask(HK_TYPE_DOMAIN));
+ if (!cpumask_empty(&wq_cmdline_cpumask))
+ cpumask_and(wq_unbound_cpumask, wq_unbound_cpumask, &wq_cmdline_cpumask);
+
pwq_cache = KMEM_CACHE(pool_workqueue, SLAB_PANIC);
/* initialize CPU pools */
@@ -6129,3 +6135,14 @@ void __init workqueue_init(void)
*/
void __warn_flushing_systemwide_wq(void) { }
EXPORT_SYMBOL(__warn_flushing_systemwide_wq);
+
+static int __init workqueue_unbound_cpus_setup(char *str)
+{
+ if (cpulist_parse(str, &wq_cmdline_cpumask) < 0) {
+ cpumask_clear(&wq_cmdline_cpumask);
+ pr_warn("workqueue.unbound_cpus: incorrect CPU range, using default\n");
+ }
+
+ return 1;
+}
+__setup("workqueue.unbound_cpus=", workqueue_unbound_cpus_setup);
--
2.17.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v5] workqueue: add cmdline parameter `workqueue.unbound_cpus` to further constrain wq_unbound_cpumask at boot time
2023-06-29 3:50 ` [PATCH v5] " tiozhang
@ 2023-07-10 20:43 ` Tejun Heo
0 siblings, 0 replies; 9+ messages in thread
From: Tejun Heo @ 2023-07-10 20:43 UTC (permalink / raw)
To: rdunlap, frederic, jiangshanlai, linux-kernel, zyhtheonly,
zyhtheonly, zwp10758, fuyuanli
On Thu, Jun 29, 2023 at 11:50:50AM +0800, tiozhang wrote:
> Motivation of doing this is to better improve boot times for devices when
> we want to prevent our workqueue works from running on some specific CPUs,
> e,g, some CPUs are busy with interrupts.
>
> Signed-off-by: tiozhang <tiozhang@didiglobal.com>
Applied to wq/for-6.6.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-07-10 20:43 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-22 3:34 [PATCH] workqueue: add cmdline parameter `unbound_workqueue_cpus` to further constrain wq_unbound_cpumask at boot time tiozhang
2023-06-22 3:47 ` Randy Dunlap
2023-06-23 7:30 ` [PATCH v2] workqueue: add cmdline parameter `workqueue_unbound_cpus` " tiozhang
2023-06-25 3:15 ` [PATCH v3] " tiozhang
2023-06-26 21:00 ` Tejun Heo
2023-06-28 11:18 ` [PATCH v4] workqueue: add cmdline parameter `workqueue.unbound_cpus` " tiozhang
2023-06-28 18:51 ` Randy Dunlap
2023-06-29 3:50 ` [PATCH v5] " tiozhang
2023-07-10 20:43 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome