Skip to content

Commit 85e1f75

Browse files
soleenakpm00
authored andcommitted
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/[email protected]/ 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. [[email protected]: rebased] Link: https://lkml.kernel.org/r/[email protected] 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]> Acked-by: Mike Rapoport (Microsoft) <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 2536c5c commit 85e1f75

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
@@ -185,13 +185,7 @@ static inline void free_task_struct(struct task_struct *tsk)
185185
kmem_cache_free(task_struct_cachep, tsk);
186186
}
187187

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
195189
/*
196190
* vmalloc() is a bit slow, and calling vfree() enough times will force a TLB
197191
* flush. Try to minimize the number of calls by caching stacks.
@@ -342,7 +336,13 @@ static void free_thread_stack(struct task_struct *tsk)
342336
tsk->stack_vm_area = NULL;
343337
}
344338

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

347347
static void thread_stack_free_rcu(struct rcu_head *rh)
348348
{
@@ -374,8 +374,7 @@ static void free_thread_stack(struct task_struct *tsk)
374374
tsk->stack = NULL;
375375
}
376376

377-
# endif /* CONFIG_VMAP_STACK */
378-
# else /* !(THREAD_SIZE >= PAGE_SIZE || defined(CONFIG_VMAP_STACK)) */
377+
#else /* !(THREAD_SIZE >= PAGE_SIZE) */
379378

380379
static struct kmem_cache *thread_stack_cache;
381380

@@ -414,7 +413,8 @@ void thread_stack_cache_init(void)
414413
BUG_ON(thread_stack_cache == NULL);
415414
}
416415

417-
# endif /* THREAD_SIZE >= PAGE_SIZE || defined(CONFIG_VMAP_STACK) */
416+
#endif /* THREAD_SIZE >= PAGE_SIZE */
417+
#endif /* CONFIG_VMAP_STACK */
418418

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

0 commit comments

Comments
 (0)