Skip to content

Commit 0ce055f

Browse files
Sebastian Andrzej SiewiorKAGA-KOKO
authored andcommitted
fork: Use IS_ENABLED() in account_kernel_stack()
Not strickly needed but checking CONFIG_VMAP_STACK instead of task_stack_vm_area()' result allows the compiler the remove the else path in the CONFIG_VMAP_STACK case where the pointer can't be NULL. Check for CONFIG_VMAP_STACK in order to use the proper path. Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Andy Lutomirski <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e540bf3 commit 0ce055f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

kernel/fork.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,16 +485,16 @@ void vm_area_free(struct vm_area_struct *vma)
485485

486486
static void account_kernel_stack(struct task_struct *tsk, int account)
487487
{
488-
void *stack = task_stack_page(tsk);
489-
struct vm_struct *vm = task_stack_vm_area(tsk);
490-
491-
if (vm) {
488+
if (IS_ENABLED(CONFIG_VMAP_STACK)) {
489+
struct vm_struct *vm = task_stack_vm_area(tsk);
492490
int i;
493491

494492
for (i = 0; i < THREAD_SIZE / PAGE_SIZE; i++)
495493
mod_lruvec_page_state(vm->pages[i], NR_KERNEL_STACK_KB,
496494
account * (PAGE_SIZE / 1024));
497495
} else {
496+
void *stack = task_stack_page(tsk);
497+
498498
/* All stack pages are in the same node. */
499499
mod_lruvec_kmem_state(stack, NR_KERNEL_STACK_KB,
500500
account * (THREAD_SIZE / 1024));

0 commit comments

Comments
 (0)