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 378B6C433E0 for ; Fri, 5 Mar 2021 12:07:38 +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 AD4DA64FE2 for ; Fri, 5 Mar 2021 12:07:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD4DA64FE2 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=RPJHWoHjctXwnfUIsUaoeMsGWr+nQVlDroOCtQrapRI=; b=dm/p+iXAS4qgLhyF+NjAdnmtp mXQPM3d1qe2bk6SitaKM/3YQAU0gKScrQmBDayETFI0IqTxGCYjmDADpRezjGpJ1PsOIt6gLRzmJy vQgR3kVpSZz98aYbjDKTwyH979hiPFsOa/uVQaA6bPPckBLULaTgqOsaaXUUMoW/ZDBc+Cr68Tj/p yeh5o3VfuSKOQBENZIrR3UORSboLFi3BTsEm6IgFc80WbtDWLLiEhc4hUAPDdVU6FRcNAzM85TfSS B/M5xbhizHHTBaXRnTn4qCP8qmoiFAyn7ldfsOqAaY35ldc4PqLbXfnW3WMP8BmHSYEzcvGad6G4P +o0Y5/WtQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lI9Dc-00Et8z-69; Fri, 05 Mar 2021 12:06:08 +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 1lI9DZ-00Et8C-3Z for linux-arm-kernel@desiato.infradead.org; Fri, 05 Mar 2021 12:06:05 +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=SLCCn59yF2lHkFGeGMH+08+03NCTJUCMcNIxKKCI3fs=; b=l5aeZoadsC9bGKj+KJ9Z8v/Abv u1zZcnnyci2AilsqMh1cq92FeU4rpgoJEu29D2vYv13/Xb3rpB9aBK/z+4hNGZe5zugi1clSD6QCc RK7JrfGz5NUhNH1n07Vm/OBoBAdNwbnmt66N+Sb2c+olXg/cTwqDM1ElVPy5RtTg5pX2W0qhZWHQ/ ibDETMc27whHSVVROVUjJiUlrH8aUlYeO5b4i6+Z2v+Pvmt95qou2HiDHY32iCAKv+g0P83gMLstB zqIO7h3cOZS1ylK/sH/OY47o/XlTIjKDUtIXZS1Ftu2V+I9hq8waQiBgyxFQVkxGQu9oDlSuo7/J5 MnLIe5BA==; Received: from foss.arm.com ([217.140.110.172]) by casper.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lI9D9-00BWqk-4N for linux-arm-kernel@lists.infradead.org; Fri, 05 Mar 2021 12:05:53 +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 6F22531B; Fri, 5 Mar 2021 04:05:27 -0800 (PST) Received: from C02TD0UTHF1T.local (unknown [10.57.47.91]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B046D3F766; Fri, 5 Mar 2021 04:05:24 -0800 (PST) Date: Fri, 5 Mar 2021 12:04:53 +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, linux-toolchains@vger.kernel.org Subject: Re: [PATCH v1] powerpc: Include running function as first entry in save_stack_trace() and friends Message-ID: <20210305120453.GA74705@C02TD0UTHF1T.local> References: <1802be3e-dc1a-52e0-1754-a40f0ea39658@csgroup.eu> <20210304145730.GC54534@C02TD0UTHF1T.local> <20210304165923.GA60457@C02TD0UTHF1T.local> <20210304180154.GD60457@C02TD0UTHF1T.local> <20210304185148.GE60457@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-20210305_120545_469228_B29D749E X-CRM114-Status: GOOD ( 23.14 ) 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 08:01:29PM +0100, Marco Elver wrote: > On Thu, 4 Mar 2021 at 19:51, Mark Rutland wrote: > > On Thu, Mar 04, 2021 at 07:22:53PM +0100, Marco Elver wrote: > > > I was having this problem with KCSAN, where the compiler would > > > tail-call-optimize __tsan_X instrumentation. > > > > Those are compiler-generated calls, right? When those are generated the > > compilation unit (and whatever it has included) might not have provided > > a prototype anyway, and the compiler has special knowledge of the > > functions, so it feels like the compiler would need to inhibit TCO here > > for this to be robust. For their intended usage subjecting them to TCO > > doesn't seem to make sense AFAICT. > > > > I suspect that compilers have some way of handling that; otherwise I'd > > expect to have heard stories of mcount/fentry calls getting TCO'd and > > causing problems. So maybe there's an easy fix there? > > I agree, the compiler builtins should be handled by the compiler > directly, perhaps that was a bad example. But we also have "explicit > instrumentation", e.g. everything that's in . True -- I agree for those we want similar, and can see a case for a no-tco-calls-to-me attribute on functions as with noreturn. Maybe for now it's worth adding prevent_tail_call_optimization() to the instrument_*() call wrappers in ? As those are __always_inline, that should keep the function they get inlined in around. Though we probably want to see if we can replace the mb() in prevent_tail_call_optimization() with something that doesn't require a real CPU barrier. [...] > > I reckon for basically any instrumentation we don't want calls to be > > TCO'd, though I'm not immediately sure of cases beyond sanitizers and > > mcount/fentry. > > Thinking about this more, I think it's all debugging tools. E.g. > lockdep, if you lock/unlock at the end of a function, you might tail > call into lockdep. If the compiler applies TCO, and lockdep determines > there's a bug and then shows a trace, you'll have no idea where the > actual bug is. The kernel has lots of debugging facilities that add > instrumentation in this way. So perhaps it's a general debugging-tool > problem (rather than just sanitizers). This makes sense to me. Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel