From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5EF0C606A322 for ; Thu, 3 Dec 2026 14:13:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=sOVsMKYJ; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=K/3iN9vI DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=SwJstxdzHTSRwLmS6lWVVFJsfyBp+dOlFX2L6Z78KWc=; b=sOVsMKYJ+iq4s9bCWeMSqy0lrZ pgo5ybOAFKVQrCZFQvz7m8uXZK7YNQmrXSZAsj2dAozRysZG6/JeX2gz/QTciDriagPxUIx6uRjxG pgrloeoNobK9ofW/bAW7akYIvDXt1hNWB7lLHSHGG6MWGBZGMQFIL8bmW7isY4lgXTrAlEbpm/do4 KCfVV4userztGnjueBa9R/JZZ2SsXto1jUbqPHuJL6BAz46cw5/nOMi+JyvsQt5ZBmbp9zv6SEgle zJSeZvul1WosaJKOsLO7UH2APl5O4UyyR1bHJtAIgWrdiVGU3NxxKBA+uVhGS7iPEfvsbjGqB4ce6 KF5dEsVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ7ZG-0000000EtCV-1q5b; Thu, 03 Dec 2026 14:13:50 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ7ZE-0000000EtBm-3n8l for linux-arm-kernel@lists.infradead.org; Thu, 03 Dec 2026 14:13:50 +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 6436E497; Thu, 3 Dec 2026 06:13:43 -0800 (PST) Received: from localhost (unknown [10.2.196.114]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C930A3F86F; Thu, 3 Dec 2026 06:13:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796307226; bh=HIDs5rE/ueLQSSCeE0sPnk9IykjZOcpzCSdu9hRva/8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=K/3iN9vIsdgs2lJoewGr6r/O1Mfulj/0Nwz66Qwe5tu8FWmsc+afB9LXcz4GM7+Zi g46TInM/ellnQIcbbsPKC7Rc8bAbLB6Y/Gxy8Nyyxr1KQRYfhUmbyY0rKhkV9ABOE2 lqHXYUTflEEh5JVZaKkGHHuyARYNFpRTECnwFY4U= Date: Thu, 3 Dec 2026 14:13:43 +0000 From: Leo Yan To: Andrii Nakryiko Cc: bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, linux-perf-users@vger.kernel.org, peterz@infradead.org, jolsa@kernel.org, rostedt@goodmis.org, Alexei Starovoitov Subject: Re: [PATCH bpf-next v3 1/3] arm64: perf: Don't report the caller twice in caller-regs callchains Message-ID: <20261203141343.GA3019743@e132581.arm.com> References: <20261201230247.73877-1-andrii@kernel.org> <20261201230247.73877-2-andrii@kernel.org> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261201230247.73877-2-andrii@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261203_061349_064642_25249825 X-CRM114-Status: GOOD ( 16.30 ) X-Spam-Score: -4.4 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Tue, Dec 01, 2026 at 03:02:45PM -0800, Andrii Nakryiko wrote: > perf_arch_fetch_caller_regs() sets regs->pc to the return address of > the function it is used in (CALLER_ADDR0) and points regs->regs[29] at > that function's own frame record, whose saved LR is that same return > address. > Mark these regs on arm64 by setting pstate to PSR_MODE_EL1t, which > exceptions taken from the kernel never have (the kernel runs in EL1h, > or EL2h with VHE). For regs with that mode, kunwind_stack_walk() steps > to the frame record at x29 before reporting anything, so the unwind > starts from the LR saved there and regs->pc is not reported. I tested this patch and confirmed it fixes the issue. ... > +/* PSR_MODE_EL1t marks these regs for kunwind_stack_walk() */ > #define perf_arch_fetch_caller_regs(regs, __ip) { \ > (regs)->pc = (__ip); \ > (regs)->regs[29] = (unsigned long) __builtin_frame_address(0); \ > (regs)->sp = current_stack_pointer; \ > - (regs)->pstate = PSR_MODE_EL1h; \ > + (regs)->pstate = PSR_MODE_EL1t; \ > } It seems to me that the issue comes from a mismatch between the IP and the frame pointer. Could we update the interface to pass them as a pair? perf_arch_fetch_caller_regs(regs, caller_ip, caller_fp) I've read Will's comment on v1, so I'll wait to hear which approach he prefers. If go with this version, please feel free to add my test tag: Tested-by: Leo Yan Thanks, Leo