LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v2 0/1] workqueue: Fix possible memory leaks in wq_numa_init()
@ 2021-07-22 3:03 Zhen Lei
2021-07-22 3:03 ` [PATCH v2 1/1] " Zhen Lei
0 siblings, 1 reply; 4+ messages in thread
From: Zhen Lei @ 2021-07-22 3:03 UTC (permalink / raw)
To: Tejun Heo, Lai Jiangshan, linux-kernel; +Cc: Zhen Lei
v1 --> v2:
1. Keep the original "for_each_possible_cpu(cpu)" loop and "cpumask_set_cpu(cpu, tbl[node]);"
2. Remove the comment: /* happens iff arch is bonkers, let's just proceed */
Zhen Lei (1):
workqueue: Fix possible memory leaks in wq_numa_init()
kernel/workqueue.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/1] workqueue: Fix possible memory leaks in wq_numa_init()
2021-07-22 3:03 [PATCH v2 0/1] workqueue: Fix possible memory leaks in wq_numa_init() Zhen Lei
@ 2021-07-22 3:03 ` Zhen Lei
2021-07-28 2:50 ` Lai Jiangshan
2021-07-29 17:24 ` Tejun Heo
0 siblings, 2 replies; 4+ messages in thread
From: Zhen Lei @ 2021-07-22 3:03 UTC (permalink / raw)
To: Tejun Heo, Lai Jiangshan, linux-kernel; +Cc: Zhen Lei
In error handling branch "if (WARN_ON(node == NUMA_NO_NODE))", the
previously allocated memories are not released. Doing this before
allocating memory eliminates memory leaks.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
kernel/workqueue.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 50142fc08902..79cc470bd9ce 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5896,6 +5896,13 @@ static void __init wq_numa_init(void)
return;
}
+ for_each_possible_cpu(cpu) {
+ if (WARN_ON(cpu_to_node(cpu) == NUMA_NO_NODE)) {
+ pr_warn("workqueue: NUMA node mapping not available for cpu%d, disabling NUMA support\n", cpu);
+ return;
+ }
+ }
+
wq_update_unbound_numa_attrs_buf = alloc_workqueue_attrs();
BUG_ON(!wq_update_unbound_numa_attrs_buf);
@@ -5913,11 +5920,6 @@ static void __init wq_numa_init(void)
for_each_possible_cpu(cpu) {
node = cpu_to_node(cpu);
- if (WARN_ON(node == NUMA_NO_NODE)) {
- pr_warn("workqueue: NUMA node mapping not available for cpu%d, disabling NUMA support\n", cpu);
- /* happens iff arch is bonkers, let's just proceed */
- return;
- }
cpumask_set_cpu(cpu, tbl[node]);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/1] workqueue: Fix possible memory leaks in wq_numa_init()
2021-07-22 3:03 ` [PATCH v2 1/1] " Zhen Lei
@ 2021-07-28 2:50 ` Lai Jiangshan
2021-07-29 17:24 ` Tejun Heo
1 sibling, 0 replies; 4+ messages in thread
From: Lai Jiangshan @ 2021-07-28 2:50 UTC (permalink / raw)
To: Zhen Lei; +Cc: Tejun Heo, linux-kernel
Reviewed-by: Lai Jiangshan <jiangshanlai@gmail.com>
On Thu, Jul 22, 2021 at 11:04 AM Zhen Lei <thunder.leizhen@huawei.com> wrote:
>
> In error handling branch "if (WARN_ON(node == NUMA_NO_NODE))", the
> previously allocated memories are not released. Doing this before
> allocating memory eliminates memory leaks.
>
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> ---
> kernel/workqueue.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index 50142fc08902..79cc470bd9ce 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -5896,6 +5896,13 @@ static void __init wq_numa_init(void)
> return;
> }
>
> + for_each_possible_cpu(cpu) {
> + if (WARN_ON(cpu_to_node(cpu) == NUMA_NO_NODE)) {
> + pr_warn("workqueue: NUMA node mapping not available for cpu%d, disabling NUMA support\n", cpu);
> + return;
> + }
> + }
> +
> wq_update_unbound_numa_attrs_buf = alloc_workqueue_attrs();
> BUG_ON(!wq_update_unbound_numa_attrs_buf);
>
> @@ -5913,11 +5920,6 @@ static void __init wq_numa_init(void)
>
> for_each_possible_cpu(cpu) {
> node = cpu_to_node(cpu);
> - if (WARN_ON(node == NUMA_NO_NODE)) {
> - pr_warn("workqueue: NUMA node mapping not available for cpu%d, disabling NUMA support\n", cpu);
> - /* happens iff arch is bonkers, let's just proceed */
> - return;
> - }
> cpumask_set_cpu(cpu, tbl[node]);
> }
>
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/1] workqueue: Fix possible memory leaks in wq_numa_init()
2021-07-22 3:03 ` [PATCH v2 1/1] " Zhen Lei
2021-07-28 2:50 ` Lai Jiangshan
@ 2021-07-29 17:24 ` Tejun Heo
1 sibling, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2021-07-29 17:24 UTC (permalink / raw)
To: Zhen Lei; +Cc: Lai Jiangshan, linux-kernel
On Thu, Jul 22, 2021 at 11:03:52AM +0800, Zhen Lei wrote:
> In error handling branch "if (WARN_ON(node == NUMA_NO_NODE))", the
> previously allocated memories are not released. Doing this before
> allocating memory eliminates memory leaks.
>
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Applied to wq/for-5.15.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-07-29 17:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-22 3:03 [PATCH v2 0/1] workqueue: Fix possible memory leaks in wq_numa_init() Zhen Lei
2021-07-22 3:03 ` [PATCH v2 1/1] " Zhen Lei
2021-07-28 2:50 ` Lai Jiangshan
2021-07-29 17:24 ` Tejun Heo
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 NNTP newsgroup(s).