fork: Redo ifdefs around task stack handling
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Thu, 17 Feb 2022 10:23:59 +0000 (11:23 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 22 Feb 2022 21:25:01 +0000 (22:25 +0100)
commitbe9a2277cafd318976d59c41a7f45a934ec43b26
tree66165b83a6a06c0ef82f201486fc0db20b82742b
parentcfb92440ee71adcc2105b0890bb01ac3cddb8507
fork: Redo ifdefs around task stack handling

The use of ifdef CONFIG_VMAP_STACK is confusing in terms what is
actually happenning and what can happen.

For instance from reading free_thread_stack() it appears that in the
CONFIG_VMAP_STACK case it may receive a non-NULL vm pointer but it may also
be NULL in which case __free_pages() is used to free the stack.  This is
however not the case because in the VMAP case a non-NULL pointer is always
returned here.  Since it looks like this might happen, the compiler creates
the correct dead code with the invocation to __free_pages() and everything
around it. Twice.

Add spaces between the ifdef and the identifer to recognize the ifdef
level which is currently in scope.

Add the current identifer as a comment behind #else and #endif.
Move the code within free_thread_stack() and alloc_thread_stack_node()
into the relevant ifdef blocks.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Andy Lutomirski <luto@kernel.org>
Link: https://lore.kernel.org/r/20220217102406.3697941-2-bigeasy@linutronix.de
kernel/fork.c