Skip to contentSkip to conversation

fork: Use __vmalloc_node() for stack allocation

PATCH Applied Uladzislau Rezki (Sony) 2 participants 2 messages Mar 17, 2025 – Mar 18, 2025

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

PATCH 1/1 fork: Use __vmalloc_node() for stack allocation

Replace __vmalloc_node_range() by the __vmalloc_node() function. The last variant requires less parameters and it uses exactly the same arguments which are partly now hidden inside __vmalloc_node() function.

This change does not change any functionality. It makes the code a bit simpler.

---
 kernel/fork.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
kernel/fork.c +2 -4
index 2fa2a3582925..72d9e7c7639e 100644
@@ -311,11 +311,9 @@ static int alloc_thread_stack_node(struct task_struct *tsk, int node)
 	 * so memcg accounting is performed manually on assigning/releasing
 	 * stacks to tasks. Drop __GFP_ACCOUNT.
 	 */
-	stack = __vmalloc_node_range(THREAD_SIZE, THREAD_ALIGN,
-				     VMALLOC_START, VMALLOC_END,
+	stack = __vmalloc_node(THREAD_SIZE, THREAD_ALIGN,
 				     THREADINFO_GFP & ~__GFP_ACCOUNT,
-				     PAGE_KERNEL,
-				     0, node, __builtin_return_address(0));
+				     node, __builtin_return_address(0));
 	if (!stack)
 		return -ENOMEM;
 
Signature · 1 line
2.39.5
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Uladzislau Rezki

Replace __vmalloc_node_range() by the __vmalloc_node() function. The last variant requires less parameters and it uses exactly the same arguments which are partly now hidden inside __vmalloc_node() function.

This change does not change any functionality. It makes the code a bit simpler.

Quoted 25 lines
---
 kernel/fork.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
kernel/fork.c +2 -4
index 2fa2a3582925..72d9e7c7639e 100644
@@ -311,11 +311,9 @@ static int alloc_thread_stack_node(struct task_struct *tsk, int node)
 	 * so memcg accounting is performed manually on assigning/releasing
 	 * stacks to tasks. Drop __GFP_ACCOUNT.
 	 */
-	stack = __vmalloc_node_range(THREAD_SIZE, THREAD_ALIGN,
-				     VMALLOC_START, VMALLOC_END,
+	stack = __vmalloc_node(THREAD_SIZE, THREAD_ALIGN,
 				     THREADINFO_GFP & ~__GFP_ACCOUNT,
-				     PAGE_KERNEL,
-				     0, node, __builtin_return_address(0));
+				     node, __builtin_return_address(0));
 	if (!stack)
 		return -ENOMEM;
 
Signature · 1 line
2.39.5
Signature · 2 lines
Michal Hocko
SUSE Labs