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 X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6553DC433E0 for ; Thu, 4 Mar 2021 19:33:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 39F9864F60 for ; Thu, 4 Mar 2021 19:33:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230458AbhCDTdH (ORCPT ); Thu, 4 Mar 2021 14:33:07 -0500 Received: from gate.crashing.org ([63.228.1.57]:47593 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235782AbhCDTcz (ORCPT ); Thu, 4 Mar 2021 14:32:55 -0500 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 124JOm06007417; Thu, 4 Mar 2021 13:24:48 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 124JOlBd007416; Thu, 4 Mar 2021 13:24:47 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Thu, 4 Mar 2021 13:24:47 -0600 From: Segher Boessenkool To: Nick Desaulniers Cc: Marco Elver , Mark Rutland , Catalin Marinas , Will Deacon , LKML , Mark Brown , Paul Mackerras , kasan-dev , linux-toolchains@vger.kernel.org, linuxppc-dev , Linux ARM Subject: Re: [PATCH v1] powerpc: Include running function as first entry in save_stack_trace() and friends Message-ID: <20210304192447.GT29191@gate.crashing.org> References: <1802be3e-dc1a-52e0-1754-a40f0ea39658@csgroup.eu> <20210304145730.GC54534@C02TD0UTHF1T.local> <20210304165923.GA60457@C02TD0UTHF1T.local> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Precedence: bulk List-ID: X-Mailing-List: linux-toolchains@vger.kernel.org On Thu, Mar 04, 2021 at 09:54:44AM -0800, Nick Desaulniers wrote: > On Thu, Mar 4, 2021 at 9:42 AM Marco Elver 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