Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fork: clean up ifdef logic around stack allocation

There is an unneeded OR in the ifdef functions that are used to allocate
and free kernel stacks based on direct map or vmap. Adding dynamic stack
support would complicate this logic even further.

Therefore, clean up by changing the order so OR is no longer needed.

Link: https://lkml.kernel.org/r/20250618-fork-fixes-v4-1-2e05a2e1f5fc@linaro.org
Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Link: https://lore.kernel.org/20240311164638.2015063-3-pasha.tatashin@soleen.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Cc: Mateusz Guzik <mjguzik@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Pasha Tatashin and committed by
Andrew Morton
64960497 816a8800

+11 -11
+11 -11
kernel/fork.c
··· 188 188 kmem_cache_free(task_struct_cachep, tsk); 189 189 } 190 190 191 - /* 192 - * Allocate pages if THREAD_SIZE is >= PAGE_SIZE, otherwise use a 193 - * kmemcache based allocator. 194 - */ 195 - # if THREAD_SIZE >= PAGE_SIZE || defined(CONFIG_VMAP_STACK) 196 - 197 - # ifdef CONFIG_VMAP_STACK 191 + #ifdef CONFIG_VMAP_STACK 198 192 /* 199 193 * vmalloc() is a bit slow, and calling vfree() enough times will force a TLB 200 194 * flush. Try to minimize the number of calls by caching stacks. ··· 338 344 tsk->stack_vm_area = NULL; 339 345 } 340 346 341 - # else /* !CONFIG_VMAP_STACK */ 347 + #else /* !CONFIG_VMAP_STACK */ 348 + 349 + /* 350 + * Allocate pages if THREAD_SIZE is >= PAGE_SIZE, otherwise use a 351 + * kmemcache based allocator. 352 + */ 353 + #if THREAD_SIZE >= PAGE_SIZE 342 354 343 355 static void thread_stack_free_rcu(struct rcu_head *rh) 344 356 { ··· 376 376 tsk->stack = NULL; 377 377 } 378 378 379 - # endif /* CONFIG_VMAP_STACK */ 380 - # else /* !(THREAD_SIZE >= PAGE_SIZE || defined(CONFIG_VMAP_STACK)) */ 379 + #else /* !(THREAD_SIZE >= PAGE_SIZE) */ 381 380 382 381 static struct kmem_cache *thread_stack_cache; 383 382 ··· 415 416 BUG_ON(thread_stack_cache == NULL); 416 417 } 417 418 418 - # endif /* THREAD_SIZE >= PAGE_SIZE || defined(CONFIG_VMAP_STACK) */ 419 + #endif /* THREAD_SIZE >= PAGE_SIZE */ 420 + #endif /* CONFIG_VMAP_STACK */ 419 421 420 422 /* SLAB cache for signal_struct structures (tsk->signal) */ 421 423 static struct kmem_cache *signal_cachep;