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=-3.8 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 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 AE0BDC433E0 for ; Thu, 4 Mar 2021 17:01:43 +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 3E59B64F59 for ; Thu, 4 Mar 2021 17:01:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E59B64F59 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com 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=qNXSMV9x42xokPyV+5ZiaWaSr8YZySE6EHfUyEWETJc=; b=l4XaYHjWUiDe+ozHgeRZ8M/Br q4rCT5tXy+kQ7o2edHub29OiJbThuuJH4OndARobPeZllfwsetqVsRZ5dz57rMTIJ2KtkHceTrMUO aav5rsOgyOOfPT/SfSGd7NTEGUrs2ycFGFkDtuXNRObBkerSO1oUvVcuyxrrsrJJYs2rB8gDuJLvC sgXlEGfGGp3c4HLZiM5G3k1eZBeYN7HFmNhTeodqrujzEYKVOMU6N1VCKkEUUnzDUI/djC9Su5Z+3 YPJEqWmWc5XnOExUOprivWHvxTpWYkVC20FSvun512W+rhcrrUh70vdVtiXhSoFFpOMQfIWy4fphU gE+sRMMnA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHrKC-009M3F-LH; Thu, 04 Mar 2021 16:59:44 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHrKA-009M2u-5p for linux-arm-kernel@desiato.infradead.org; Thu, 04 Mar 2021 16:59:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=TQlCYySSGKD3tn5PA5QBN83twsp7f5KnBmdM8Ag4Njo=; b=k8kEI3T50wdAIBi7TmWnh46vhr neQI868QuvAtopO6FZayxMrEitIZh9goe6kL7eVP7D8e150WY438ZMLbh/2wr5SCkodd1Ou2gUwKP HuWxosC9U4BsKDO3mWPaoP+hnIZ4mYQkrTOsXCq8bdl24urkf6zEh4AdUxh3Wrh3Eepb3CDRYHnaI MFiG+LCAqHr+KHf4TIh5ARew8J+rSGiQhxAtwsElaWCnyyW5SoCNKlhH/4x6V4gRZ3+osGBtVKMso +7ndgpRb2/r1Gx5TR+JhKJeE5OSmPkJA6ENq/1JjuaiHezn86hiih/3/tpMZBUmo3yGLXPh4MlRGM qLP4mqEg==; Received: from foss.arm.com ([217.140.110.172]) by casper.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHrK1-007tmI-Kh for linux-arm-kernel@lists.infradead.org; Thu, 04 Mar 2021 16:59:36 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E108031B; Thu, 4 Mar 2021 08:59:30 -0800 (PST) Received: from C02TD0UTHF1T.local (unknown [10.57.53.210]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DA6FF3F7D7; Thu, 4 Mar 2021 08:59:28 -0800 (PST) Date: Thu, 4 Mar 2021 16:59:23 +0000 From: Mark Rutland To: Marco Elver Cc: Christophe Leroy , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , LKML , linuxppc-dev@lists.ozlabs.org, kasan-dev , Catalin Marinas , Will Deacon , Linux ARM , broonie@kernel.org Subject: Re: [PATCH v1] powerpc: Include running function as first entry in save_stack_trace() and friends Message-ID: <20210304165923.GA60457@C02TD0UTHF1T.local> References: <1802be3e-dc1a-52e0-1754-a40f0ea39658@csgroup.eu> <20210304145730.GC54534@C02TD0UTHF1T.local> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210304_165936_032065_9E5AFEDB X-CRM114-Status: GOOD ( 25.01 ) 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 04:30:34PM +0100, Marco Elver wrote: > On Thu, 4 Mar 2021 at 15:57, Mark Rutland wrote: > > [adding Mark Brown] > > > > The bigger problem here is that skipping is dodgy to begin with, and > > this is still liable to break in some cases. One big concern is that > > (especially with LTO) we cannot guarantee the compiler will not inline > > or outline functions, causing the skipp value to be too large or too > > small. That's liable to happen to callers, and in theory (though > > unlikely in practice), portions of arch_stack_walk() or > > stack_trace_save() could get outlined too. > > > > Unless we can get some strong guarantees from compiler folk such that we > > can guarantee a specific function acts boundary for unwinding (and > > doesn't itself get split, etc), the only reliable way I can think to > > solve this requires an assembly trampoline. Whatever we do is liable to > > need some invasive rework. > > Will LTO and friends respect 'noinline'? I hope so (and suspect we'd have more problems otherwise), but I don't know whether they actually so. I suspect even with 'noinline' the compiler is permitted to outline portions of a function if it wanted to (and IIUC it could still make specialized copies in the absence of 'noclone'). > One thing I also noticed is that tail calls would also cause the stack > trace to appear somewhat incomplete (for some of my tests I've > disabled tail call optimizations). I assume you mean for a chain A->B->C where B tail-calls C, you get a trace A->C? ... or is A going missing too? > Is there a way to also mark a function non-tail-callable? I think this can be bodged using __attribute__((optimize("$OPTIONS"))) on a caller to inhibit TCO (though IIRC GCC doesn't reliably support function-local optimization options), but I don't expect there's any way to mark a callee as not being tail-callable. Accoding to the GCC documentation, GCC won't TCO noreturn functions, but obviously that's not something we can use generally. https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes > But I'm also not sure if with all that we'd be guaranteed the code we > want, even though in practice it might. True! I'd just like to be on the least dodgy ground we can be. Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel