From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04683C54EE9 for ; Wed, 7 Sep 2022 19:58:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229585AbiIGT6o (ORCPT ); Wed, 7 Sep 2022 15:58:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbiIGT6n (ORCPT ); Wed, 7 Sep 2022 15:58:43 -0400 Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3642AA5992; Wed, 7 Sep 2022 12:58:41 -0700 (PDT) Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 287JlHCp027774; Wed, 7 Sep 2022 14:47:17 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 287JlFIx027773; Wed, 7 Sep 2022 14:47:15 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Wed, 7 Sep 2022 14:47:15 -0500 From: Segher Boessenkool To: Florian Weimer Cc: Menglong Dong , Nick Desaulniers , kuba@kernel.org, miguel.ojeda.sandonis@gmail.com, ojeda@kernel.org, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, asml.silence@gmail.com, imagedong@tencent.com, luiz.von.dentz@intel.com, vasily.averin@linux.dev, jk@codeconstruct.com.au, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, kernel test robot , linux-toolchains Subject: Re: [PATCH net-next v4] net: skb: prevent the split of kfree_skb_reason() by gcc Message-ID: <20220907194715.GK25951@gate.crashing.org> References: <20220818165838.GM25951@gate.crashing.org> <20220819152157.GO25951@gate.crashing.org> <871qt86711.fsf@oldenburg.str.redhat.com> <87edwo65lw.fsf@oldenburg.str.redhat.com> <20220906153046.GD25951@gate.crashing.org> <87zgfbnh81.fsf@oldenburg.str.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87zgfbnh81.fsf@oldenburg.str.redhat.com> User-Agent: Mutt/1.4.2.3i Precedence: bulk List-ID: X-Mailing-List: linux-toolchains@vger.kernel.org On Wed, Sep 07, 2022 at 08:59:26PM +0200, Florian Weimer wrote: > * Segher Boessenkool: > > > On Tue, Sep 06, 2022 at 02:37:47PM +0200, Florian Weimer wrote: > >> > On Mon, Aug 22, 2022 at 4:01 PM Florian Weimer wrote: > >> > I did some research on the 'sibcalls' you mentioned above. Feel like > >> > It's a little similar to 'inline', and makes the callee use the same stack > >> > frame with the caller, which obviously will influence the result of > >> > '__builtin_return_address'. > > > > Sibling calls are essentially calls that can be replaced by jumps (aka > > "tail call"), without needing a separate entry point to the callee. > > > > Different targets can have a slightly different implementation and > > definition of what exactly is a sibling call, but that's the gist. > > > >> > Hmm......but I'm not able to find any attribute to disable this optimization. > >> > Do you have any ideas? > >> > >> Unless something changed quite recently, GCC does not allow disabling > >> the optimization with a simple attribute (which would have to apply to > >> function pointers as well, not functions). > > > > It isn't specified what a sibling call exactly *is*, certainly not on C > > level (only in the generated machine code), and the details differs per > > target. > > Sure, but GCC already disables this optimization in a generic fashion > for noreturn calls. It should be possible to do the same based another > function attribute. My point is that disabling sibling calls does not necessarily do what you really want, certainly not on all targets. Many targets have their own frame optimisations and prologue/epilogue optimisations as well. But you can just do void f(void) __attribute__((optimize("no-optimize-sibling-calls"))); (in my previous example), and that works: it disables the (generic) sibling call optimisation. This may or may not do what you actually want though. Segher