Skip to content

Commit 6496049

Browse files
soleenakpm00
authored andcommitted
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/[email protected] Signed-off-by: Pasha Tatashin <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]> Cc: Mateusz Guzik <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 816a880 commit 6496049

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

kernel/fork.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,7 @@ static inline void free_task_struct(struct task_struct *tsk)
188188
kmem_cache_free(task_struct_cachep, tsk);
189189
}
190190

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
198192
/*
199193
* vmalloc() is a bit slow, and calling vfree() enough times will force a TLB
200194
* flush. Try to minimize the number of calls by caching stacks.
@@ -344,7 +338,13 @@ static void free_thread_stack(struct task_struct *tsk)
344338
tsk->stack_vm_area = NULL;
345339
}
346340

347-
# else /* !CONFIG_VMAP_STACK */
341+
#else /* !CONFIG_VMAP_STACK */
342+
343+
/*
344+
* Allocate pages if THREAD_SIZE is >= PAGE_SIZE, otherwise use a
345+
* kmemcache based allocator.
346+
*/
347+
#if THREAD_SIZE >= PAGE_SIZE
348348

349349
static void thread_stack_free_rcu(struct rcu_head *rh)
350350
{
@@ -376,8 +376,7 @@ static void free_thread_stack(struct task_struct *tsk)
376376
tsk->stack = NULL;
377377
}
378378

379-
# endif /* CONFIG_VMAP_STACK */
380-
# else /* !(THREAD_SIZE >= PAGE_SIZE || defined(CONFIG_VMAP_STACK)) */
379+
#else /* !(THREAD_SIZE >= PAGE_SIZE) */
381380

382381
static struct kmem_cache *thread_stack_cache;
383382

@@ -416,7 +415,8 @@ void thread_stack_cache_init(void)
416415
BUG_ON(thread_stack_cache == NULL);
417416
}
418417

419-
# endif /* THREAD_SIZE >= PAGE_SIZE || defined(CONFIG_VMAP_STACK) */
418+
#endif /* THREAD_SIZE >= PAGE_SIZE */
419+
#endif /* CONFIG_VMAP_STACK */
420420

421421
/* SLAB cache for signal_struct structures (tsk->signal) */
422422
static struct kmem_cache *signal_cachep;

0 commit comments

Comments
 (0)