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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0083C6FA82 for ; Wed, 21 Sep 2022 17:26:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=P2RLfETD2AFKv5/IyUEujOTsQbuquG3j/ve1Kof1DRg=; b=nj3ftYPfgHaYpB f52Pc6boHQQvfVQDpq3wUElnGodjQOajputUGoqBSzDoyYZTwcOg0EnRQP21lr72stJvqZjllIST0 cwO9m0atMXI/ZmxiW//9ApzreuY9LMEw/8NisRsb86s2dBO4I5MWM/BKevNK27AcL7Jt1CDq1QFnQ 6sNV+BybNUXa3vlCT1rGlsjLqsRJXnOymq5ncajRJWlgml5II84SFKRjXaFi+uGrG6FoH6HobPY57 lnrWP2f9efV+WEY6y/yfKELAKtUq6EO1HldCdWhdf8ltF5qF8//juJN/m3zgW4ddBBNeAaqQpOod/ pc1AuWuJFlH0lXPPBDoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ob3TJ-00CBRO-NN; Wed, 21 Sep 2022 17:25:17 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ob3TF-00CBQ8-Sc for linux-arm-kernel@lists.infradead.org; Wed, 21 Sep 2022 17:25:15 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DC1F4B822EB; Wed, 21 Sep 2022 17:25:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F949C433C1; Wed, 21 Sep 2022 17:25:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663781108; bh=wKJthoQT0tsR8fGFfaCS09xqQkAr5tvsQxNAnhR8RFU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=eH3mhQXPUz2GfmoUsDDY2HRV2RPhz0t+JgXI6vYPdsU9TTLIWbFuqncPkhLoA+Kjg UrVB5KXqAN4/rHMGT4PyHMXxiTx5S+o9lr8rHONUK+7rTsNYnNh0dxKcl5uIdaiP5v uswXymCWTM0j/n1DbJ0kkEZ4wWL7w17MdEjQlN3+eqgaajgeizVxAbK2MbI0xcSdgi UBDnIx2J0Cv1C30fIPP8b7Ci3HSIgp1/E/VMz/OBlRoauyWXlEW9kXh6HTLw6nZw06 V+z03qa6u+f4PXIhE7JnF2cDKDksQdgPuqlD36zPfnm57CyGFjC+T7AF54YyHIEl/l +0zKigVQGTkvA== Received: from 185-176-101-241.host.sccbroadband.ie ([185.176.101.241] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1ob3T8-00BjHQ-7T; Wed, 21 Sep 2022 18:25:06 +0100 Date: Wed, 21 Sep 2022 18:25:04 +0100 Message-ID: <87o7v8k5cf.wl-maz@kernel.org> From: Marc Zyngier To: Denis Nikitin Cc: Catalin Marinas , Will Deacon , James Morse , Alexandru Elisei , Nick Desaulniers , Manoj Gupta , David Brazdil , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: arm64: nvhe: Disable profile optimization In-Reply-To: References: <20220920082005.2459826-1-denik@chromium.org> <877d1yl797.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.176.101.241 X-SA-Exim-Rcpt-To: denik@chromium.org, catalin.marinas@arm.com, will@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, ndesaulniers@google.com, manojgupta@google.com, dbrazdil@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220921_102514_261875_21DD3DF8 X-CRM114-Status: GOOD ( 49.64 ) 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 Wed, 21 Sep 2022 07:02:50 +0100, Denis Nikitin wrote: > > Adding a few more comments... > > On Tue, Sep 20, 2022 at 5:08 PM Denis Nikitin wrote: > > > > Hi Mark, > > > > Thank you for a quick response. > > > > On Tue, Sep 20, 2022 at 2:34 AM Marc Zyngier wrote: > > > > > > Hi Denis, > > > > > > On Tue, 20 Sep 2022 09:20:05 +0100, > > > Denis Nikitin wrote: > > > > > > > > Kernel build with -fprofile-sample-use raises the following failure: > > > > > > > > error: arch/arm64/kvm/hyp/nvhe/kvm_nvhe.tmp.o: Unexpected SHT_REL > > > > section ".rel.llvm.call-graph-profile" > > > > > > How is this flag provided? I don't see any occurrence of it in the > > > kernel so far. > > > > On ChromeOS we build the kernel with sample profiles by adding > > -fprofile-sample-use=/path/to/gcov.profile to KCFLAGS. > > > > > > > > > > > > > SHT_REL is generated by the latest lld, see > > > > https://reviews.llvm.org/rGca3bdb57fa1ac98b711a735de048c12b5fdd8086. > > > > > > Is this part of a released toolchain? If so, can you spell out the > > > first version where this occurs? > > > > Yes, it was added in llvm-13. I will update the patch. > > > > > > > > > Disable profile optimization in kvm/nvhe to fix the build with > > > > AutoFDO. > > > > > > It'd be good to at least mention how AutoFDO and -fprofile-sample-use > > > relate to each other. > > > > Good point. AutoFDO is an example of sample profiles. > > It's not actually relevant for the bug. I will better remove it. > > > > > > > > > > > > > Signed-off-by: Denis Nikitin > > > > --- > > > > arch/arm64/kvm/hyp/nvhe/Makefile | 3 +++ > > > > 1 file changed, 3 insertions(+) > > > > > > > > diff --git a/arch/arm64/kvm/hyp/nvhe/Makefile b/arch/arm64/kvm/hyp/nvhe/Makefile > > > > index b5c5119c7396..6a6188374a52 100644 > > > > --- a/arch/arm64/kvm/hyp/nvhe/Makefile > > > > +++ b/arch/arm64/kvm/hyp/nvhe/Makefile > > > > @@ -89,6 +89,9 @@ quiet_cmd_hypcopy = HYPCOPY $@ > > > > # Remove ftrace, Shadow Call Stack, and CFI CFLAGS. > > > > # This is equivalent to the 'notrace', '__noscs', and '__nocfi' annotations. > > > > KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI), $(KBUILD_CFLAGS)) > > > > +# Profile optimization creates SHT_REL section '.llvm.call-graph-profile' for > > > > +# the hot code. SHT_REL is currently not supported by the KVM tools. > > > > > > 'KVM tools' seems vague. Maybe call out the actual helper that > > > processes the relocations? > > > > Agreed. > > > > > > > > > +KBUILD_CFLAGS += $(call cc-option,-fno-profile-sample-use,-fno-profile-use) > > > > > > Why adding these options instead of filtering out the offending option > > > as it is done just above? > > > > That was actually the alternative solution and it worked as well. > > Let me double check if profile optimization doesn't mess up with other > > sections and if it doesn't I will remove the '.llvm.call-graph-profile' > > section instead. > > When I remove the '.llvm.call-graph-profile' section the layout of other > sections slightly changes (offsets and sizes) compared to > `-fno-profile-sample-use`. But the list of sections remains the same. If this method works well enough, I'd rather we stick to it, instead of having two ways to disable this sort of things. > > > Also, is this the only place the kernel fails to compile? The EFI stub > > > does similar things AFAIR, and could potentially fail the same way. > > > > This was the only place in 5.15 where we tested it. > > Let me see if EFI has this section. > > EFI code is not marked as hot in the profile. > > Regarding "could potentially fail", I don't see any explicit manipulations > with code sections in EFI. > The hardcoded EFI stub entries should not be affected. I was more worried by the runtime relocation that the EFI stub performs for the kernel, but if you've checked that already, that works for me. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel