Thread (10 messages) flat view 10 messages, 5 authors, 2021-03-05

Re: [PATCH v1] powerpc: Include running function as first entry in save_stack_trace() and friends

From: Segher Boessenkool <hidden>
Date: 2021-03-04 19:33:39
Also in: linux-arm-kernel, linuxppc-dev, lkml

On Thu, Mar 04, 2021 at 09:54:44AM -0800, Nick Desaulniers wrote:
On Thu, Mar 4, 2021 at 9:42 AM Marco Elver [off-list ref] wrote:
include/linux/compiler.h:246:
prevent_tail_call_optimization

commit a9a3ed1eff36 ("x86: Fix early boot crash on gcc-10, third try")
That is much heavier than needed (an mb()).  You can just put an empty
inline asm after a call before a return, and that call cannot be
optimised to a sibling call: (the end of a function is an implicit
return:)

Instead of:

void g(void);
void f(int x)
	if (x)
		g();
}

Do:

void g(void);
void f(int x)
	if (x)
		g();
	asm("");
}

This costs no extra instructions, and certainly not something as heavy
as an mb()!  It works without the "if" as well, of course, but with it
it is a more interesting example of a tail call.


Segher
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help