From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796307227; b=Q+8l6RDBqI5IV+5/Nr4zwRkOX3Pe9m7VF7aQdQies/ZM4XL/2Yb9QWByc/khgVGh58K+ ojn9zbISWWMONBnuttMtrmjLWtFa16eneC6wph+plEEyUts+DYOsRRWyktp3pwOa4BgBC w7FBVH0TvmvIh+ywPJHXJA+7kE2+vjDqJ+AnqgaOig2Yf0d//D3t8ldKGFTx6daYxqqJP PfmiKj9z8fHmxBrS4YDc8YEjEV1zHQFoUzflPU+5sJKooD7R/0N3npVUvRqgobXx+//5+ nbsQ4ulXkmNtAtW3xMq4xPhFX2FVdEwwCJSXsc0D/pwhFdEQGlBFKONFYVHmSMCfWVg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796307227; h=DMARC-Filter:Received:Received:DKIM-Signature:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=SwJstxdzHTSRwLmS6lWVVFJsfyBp+dOlFX2L6Z78KWc=; b=Pv2xtAj9n/LV6iWaMRHO6CeQQeP549D1B3oDV84fAHZySnKyYL4qWXcqngc56uA1wN6M YjTgr2cWyS282y3+UQJrFwTOPqI/eXZbEZsb3J/n1ceCxzjiv7PkyNR5f1XvuBPypWOr8 3lJ9kXl0k3wQwREcmXVKmsYZbv1z3zs2WNHgLEIeu9JNpSYU1EvKgyVcoyHoILW3ZQKY6 IiphklvvC6PyBJNgD4uEyNncKU7FW09bIfPM9RrCYhvl3rQ01W8oUuoaurE7gmrD2CRwf vyqDyS4y6dYWplPJ9n3gyGHHd7TPBuzrITZh2ZMphn0il7lPJefHVEmT8FVSe7ARuhw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b="K/3iN9vI"; arc=none smtp.remote-ip=217.140.110.172 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B7B0A606A322; Thu, 3 Dec 2026 14:13:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B7B0A606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=K/3iN9vI 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-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261201230247.73877-2-andrii@kernel.org> 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