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 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 D1DE7C433DB for ; Thu, 4 Mar 2021 19:29:27 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E159C64F60 for ; Thu, 4 Mar 2021 19:29:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E159C64F60 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Ds1C92pMHz3d59 for ; Fri, 5 Mar 2021 06:29:25 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=permerror (SPF Permanent Error: Unknown mechanism found: ip:192.40.192.88/32) smtp.mailfrom=kernel.crashing.org (client-ip=63.228.1.57; helo=gate.crashing.org; envelope-from=segher@kernel.crashing.org; receiver=) Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by lists.ozlabs.org (Postfix) with ESMTP id 4Ds1Bp5m24z3ck3 for ; Fri, 5 Mar 2021 06:29:05 +1100 (AEDT) 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 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 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Marco Elver , Catalin Marinas , linuxppc-dev , LKML , kasan-dev , Mark Brown , Paul Mackerras , linux-toolchains@vger.kernel.org, Will Deacon , Linux ARM Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 3D1C5C433E0 for ; Thu, 4 Mar 2021 19:30:09 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A73F664F69 for ; Thu, 4 Mar 2021 19:30:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A73F664F69 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:Mime-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=d5DhRTjabLSicHQsibTFdqF13ftranXIbmUeTLt99R0=; b=al/D43iApUwcYinw17EpM6NnW rzNcza0oYeRzoHgKmAqDuIJEbMnm9zGi7up7KfcANDNLMuJXI7VD5wejAqRG8FCvRIqi/uU9szZZs TZvFxv9QhD0gQIcUImuDsXHbKE10Ir7wbQLpSNDQn/++o4yzb+i/X+503G5aoVsitqLok8ar/DwlB j5XbS911jTaGIVf7XMbLu49C6u49LJg2Lw4DWERsEuASwQKP4SaJecVxBPZ/Q376H2aSF2lNZ6Rid Jm1USlEK3Lj68m48QTzBQBdaAdbtIAb32YfCQ78GydVDsfQK0sHmA7I2J+unii8GrZrKuUqs9uL3o IwX4PE8FA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHtdn-009lB4-Tm; Thu, 04 Mar 2021 19:28:08 +0000 Received: from gate.crashing.org ([63.228.1.57]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHtdg-009l9T-2T for linux-arm-kernel@lists.infradead.org; Thu, 04 Mar 2021 19:28:03 +0000 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-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel