Re: [PATCH net-next v4] net: skb: prevent the split of kfree_skb_reason() by gcc
From: Menglong Dong <hidden>
Date: 2022-08-19 14:55:59
Also in:
linux-toolchains, lkml
Hello, On Fri, Aug 19, 2022 at 1:00 AM Segher Boessenkool [off-list ref] wrote:
Hi! On Fri, Aug 19, 2022 at 12:31:44AM +0800, Menglong Dong wrote:quoted
On Wed, Aug 17, 2022 at 11:54 PM Nick Desaulniers [off-list ref] wrote:quoted
Perhaps noipa might also work here?In my testing, both 'noclone' and 'noipa' both work! As for the '-fdisable-ipa-fnsplit', it seems it's not supported by gcc, and I failed to find any documentation of it.noipa is noinline+noclone+no_icf plus assorted not separately enablable things. There is no reason you would want to disable all inter-procedural optimisations here, so you don't need noipa. You need both noinline and no_icf if you want all calls to this to be actual function calls, and using this specific function name. If you don't have noinline some calls may go missing (which may be fine for how you use it). If you don't have no_icf the compiler may replace the call with a call to another function, if that does the same thing semantically. You may want to prevent that as well, depending on exactly what you have this for.
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. Meanwhile, I think that the functions which use '__builtin_return_address' should consider the optimization you mentioned above, and I'll have a check on them by the way. Thanks! Menglong Dong
Segher