Thread (12 messages) 12 messages, 5 authors, 2022-08-20

Re: [PATCH net-next v4] net: skb: prevent the split of kfree_skb_reason() by gcc

From: Menglong Dong <hidden>
Date: 2022-08-20 11:00:59
Also in: linux-toolchains, lkml

Hello,
On Fri, Aug 19, 2022 at 11:24 PM Segher Boessenkool
[off-list ref] wrote:
Hi!

On Fri, Aug 19, 2022 at 10:55:42PM +0800, Menglong Dong wrote:
quoted
Thanks for your explanation about the usage of 'noinline' and 'no_icf'!
I think 'noclone' seems enough in this case? As the function
'kfree_skb_reason' we talk about is a global function, I think that the
compiler has no reason to make it inline, or be merged with another
function.
Whether something is inlined is decided per instance (except for
always_inline and noinline functions).  Of course the function body has
to be available for anything to be inlined, so barring LTO this can only
happen for function uses in the same source file.  Not very likely
indeed, but not entirely impossible either.
I understand it now, the global function is indeed possible to be
made inline by the compiler, and 'noinline' seems necessary
here too.

Maybe I can add a new compiler attribute like this:

/*
 * Used by functions that use '__builtin_return_address'. These function
 * don't want to be splited or made inline, which can make
 * the '__builtin_return_address' got unexpected address.
 */
#define __fix_address noinline __noclone
A function can be merged if there is another function that does exactly
the same thing.  This is unlikely with functions that do some serious
work of course, but it is likely with stub-like functions.
I understand how 'icf'(Identical Code Folding) works now. In the case
we talk about, It seems fine even if the function is merged. The only
effect of 'icf' is the change of function name, which doesn't affect
the result of '__builtin_return_address(0)'.

Thanks!
Menglong Dong
gl;hf,


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