Skip to contentSkip to conversation

mm/page_alloc.c: Clean code by removing unnecessary initialization

PATCH Applied [email protected] 2 participants 2 messages Sep 4, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/page_alloc.c: Clean code by removing unnecessary initialization

From: Mateusz Nosek <[email protected]>

Previously variable 'tmp' was initialized, but was not read later before reassigning. So the initialization can be removed.

---
 mm/page_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c +1 -1
index 3ae4f3651aec..77c3d2084004 100644
@@ -5637,7 +5637,7 @@ static int find_next_best_node(int node, nodemask_t *used_node_mask)
 	int n, val;
 	int min_val = INT_MAX;
 	int best_node = NUMA_NO_NODE;
-	const struct cpumask *tmp = cpumask_of_node(0);
+	const struct cpumask *tmp;
 
 	/* Use the local node if we haven't already */
 	if (!node_isset(node, *used_node_mask)) {
Signature · 1 line
2.20.1
maintainer
#1 lore raw
Quoted 10 lines · On Fri, 4 Sep 2020 15:24:22 +0200 [email protected] wrote:

From: Mateusz Nosek <[email protected]>

Previously variable 'tmp' was initialized, but was not read later before reassigning. So the initialization can be removed.

...

mm/page_alloc.c static int find_next_best_node(int node, nodemask_t *used_node_mask) · line 5643

Quoted 8 lines
mm/page_alloc.c +1 -1
@@ -5637,7 +5637,7 @@ static int find_next_best_node(int node, nodemask_t *used_node_mask)
 	int n, val;
 	int min_val = INT_MAX;
 	int best_node = NUMA_NO_NODE;
-	const struct cpumask *tmp = cpumask_of_node(0);
+	const struct cpumask *tmp;
 
 	/* Use the local node if we haven't already */
 	if (!node_isset(node, *used_node_mask)) {

OK. But we may as well kill tmp altogether?

mm/page_alloc.c renamed from mm/page_alloc.c~mm-page_allocc-clean-code-by-removing-unnecessary-initialization-fix +1 -3
@@ -5637,7 +5637,6 @@ static int find_next_best_node(int node,
 	int n, val;
 	int min_val = INT_MAX;
 	int best_node = NUMA_NO_NODE;
-	const struct cpumask *tmp;
 
 	/* Use the local node if we haven't already */
 	if (!node_isset(node, *used_node_mask)) {
@@ -5658,8 +5657,7 @@ static int find_next_best_node(int node,
 		val += (n < node);
 
 		/* Give preference to headless and unused nodes */
-		tmp = cpumask_of_node(n);
-		if (!cpumask_empty(tmp))
+		if (!cpumask_empty(cpumask_of_node(n)))
 			val += PENALTY_FOR_NODE_WITH_CPUS;
 
 		/* Slight preference for less loaded node */

_