Skip to contentSkip to conversation

mm: mempool: Optimize the mempool_create_node function

PATCH In review Li zeming 2 participants 2 messages Mar 14, 2023 – Mar 15, 2023

Subsystems (2)
lore
Share & tools
lore

Li zeming

author
#0 lore raw

PATCH 1/1 mm: mempool: Optimize the mempool_create_node function

The pool pointer variable gets the kzalloc_node function return value directly at definition time, which should be more concise.

---
 mm/mempool.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
mm/mempool.c +1 -3
index 734bcf5afbb7..9a4db6efc9ab 100644
@@ -267,9 +267,7 @@ mempool_t *mempool_create_node(int min_nr, mempool_alloc_t *alloc_fn,
 			       mempool_free_t *free_fn, void *pool_data,
 			       gfp_t gfp_mask, int node_id)
 {
-	mempool_t *pool;
-
-	pool = kzalloc_node(sizeof(*pool), gfp_mask, node_id);
+	mempool_t *pool = kzalloc_node(sizeof(*pool), gfp_mask, node_id);
 	if (!pool)
 		return NULL;
 
Signature · 1 line
2.18.2
#1 lore raw
Quoted 4 lines · Li zeming

The pool pointer variable gets the kzalloc_node function return value directly at definition time, which should be more concise.

This looks pretty useless as a change, the generated code is going to be the same before/after, it is also not more readable, and it is definitively not an optimization in the sense that optimization should be used as meaning: the code is more efficient after that change.

Signature · 1 line
Florian