Skip to contentSkip to conversation

workqueue: Free useless memory when disabling NUMA in wq_numa_init()

PATCH In review Xunlei Pang 2 participants 2 messages Sep 17, 2015 Workqueue

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 workqueue: Free useless memory when disabling NUMA in wq_numa_init()

From: Xunlei Pang <[email protected]>

wq_update_unbound_numa_attrs_buf and tbl will never be used in case of invalid NUMA node mapping, so just free them.

---
 kernel/workqueue.c | 7 +++++++
 1 file changed, 7 insertions(+)
kernel/workqueue.c +7 -0
index ca71582..22d7747 100644
@@ -5197,6 +5197,13 @@ static void __init wq_numa_init(void)
 		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);
+
+			for_each_node(node)
+				free_cpumask_var(tbl[node]);
+			kfree(tbl);
+
+			free_workqueue_attrs(wq_update_unbound_numa_attrs_buf);
+			wq_update_unbound_numa_attrs_buf = NULL;
 			/* happens iff arch is bonkers, let's just proceed */
 			return;
 		}
Signature · 1 line
1.9.1
maintainer
#1 lore raw

Hello,

Quoted 15 lines · Xunlei Pang

From: Xunlei Pang <[email protected]>

wq_update_unbound_numa_attrs_buf and tbl will never be used in case of invalid NUMA node mapping, so just free them.

---
 kernel/workqueue.c | 7 +++++++
 1 file changed, 7 insertions(+)
kernel/workqueue.c +0 -0
index ca71582..22d7747 100644

kernel/workqueue.c static void __init wq_numa_init(void) · line 5203

Quoted 7 lines
kernel/workqueue.c +4 -0
@@ -5197,6 +5197,13 @@ static void __init wq_numa_init(void)
 		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);
+
+			for_each_node(node)
+				free_cpumask_var(tbl[node]);
+			kfree(tbl);

So, this is "either bios or arch code buggy but let's keep limping on rather than crashing" path. It doesn't matter whether there's something lingering behind. We wanna keep it as simple as possible.

Thanks.

Signature · 1 line
tejun