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

Patch series "fork: Page operation cleanups in the fork code", v3.

This patchset consists of outtakes from a 1 year+ old patchset from Pasha,
which all stand on their own. See:
https://lore.kernel.org/all/20240311164638.2015063-1-pasha.tatashin@soleen.com/

These are good cleanups for readability so I split these off, rebased on
v6.15-rc1, addressed review comments and send them separately.

All mentions of dynamic stack are removed from the patchset as we have no
idea whether that will go anywhere.


This patch (of 3):

There is unneeded OR in the ifdef functions that are used to allocate and
free kernel stacks based on direct map or vmap.

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

[linus.walleij@linaro.org: rebased]
Link: https://lkml.kernel.org/r/20250509-fork-fixes-v3-1-e6c69dd356f2@linaro.org
Link: https://lkml.kernel.org/r/20250509-fork-fixes-v3-0-e6c69dd356f2@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>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Pasha Tatashin and committed by
Andrew Morton
85e1f758 2536c5c7

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