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

From: Segher Boessenkool
Date: Fri Aug 19 2022 - 11:32:59 EST


Hi!

On Fri, Aug 19, 2022 at 10:55:42PM +0800, Menglong Dong wrote:
> 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.

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.

gl;hf,


Segher