From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F003247884D for ; Thu, 13 Aug 2026 15:58:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786636684; cv=none; b=S/2yCeNFM3oYA+vEvqnzAG6sGxF4XBbAiXe8MZG4KbosH+wl2D204K40MMfWymXXJAZ/PmfYzsM54F3w1B0jrxqMcCbM1P8shCeqNUQ3wSbLpgOuM6nI+j4CRTPTmKEN1duynhuNmJy3U5+v3dnh7Gez/pYi9Tmzft/ZkbSCUyU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786636684; c=relaxed/simple; bh=rvhiuPQdW9L0CdLy0fuVwbiOMGKrdl6HUy5X+6ARmgU=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=c880o8g1FHmFSNAzaiihbt6NvBGLir55z+iyQ3/pSzPz3P7gSw8Jx4a4EUVp3DfbYTEv8yhxHLaM1WLQlJLEfH2hA4+lqEOaKSAegptps1lNflBPxSNrzNqWSzyItPS1zkMBhF2vMvIvJFUhuKOx89pZUcaN3LbLX1t0Y4iIwI8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Hp9DucV7; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Hp9DucV7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD4221F000E9; Thu, 13 Aug 2026 15:58:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786636682; bh=X+sf+p3WhWnqM+wowbpZwkUZExGfKoZLqOMvtUH8jQk=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=Hp9DucV7OGLG9m/FudPQWPZAS8FQEfKoOcVhBywLxXt2TMkJ8qskyGU0U2f8bvJo5 8vcoabbgKXod/KTWP4b7H4Uh3W5COSWeAZAeOapWrAuHt+vCoeSGvyOeSk/2hhxk68 Dcb7j/eDAnqPvku+ZYZ5J8Gvlcyq2AJ3WRbq7tEBzxs6A6y9f2WtC2muZVhgE7o84p QU12XP4scz6PGeizQzxMiTy4MjJRZ1cfzWw7zdcPhWpcnwsxpLtuVGfPtQBD/3Nmv1 yRsPbJlObOy2CcU3gUlXPljOfebCE5EuZ9ZiJzik/MNnNbKZL8OkVXvde/AUfIrCBU Z3f+INhJswJIA== Date: Fri, 14 Aug 2026 00:57:58 +0900 From: Masami Hiramatsu (Google) To: Hongyan Xia Cc: Mark Rutland , Will Deacon , Catalin Marinas , Jiazi Li , Pu Hu , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [RFC PATCH v2 1/4] arm64/entry: Make debug_exception_enter/exit() noinstr Message-Id: <20260814005758.c8cc04d276a0f82689ccddca@kernel.org> In-Reply-To: References: X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 13 Aug 2026 06:49:27 +0000 Hongyan Xia wrote: > From: Hongyan Xia > > Commit 879a6754d3d11e30af24b7dc486f561510d62641 ran into a crash because > debug_exception_enter/exit() triggered page faults caused by perf dwarf > call graph tracing. That patch was a band-aid on top. > > Instead of trying to band-aid all possible paths that can happen during > instrumentation or perf tracing, simply force-inline these functions and > use the notrace variant of preempt handling to avoid all the complexity. > > Drop the RCU_LOCKDEP_WARN(): arm64_enter_el1_dbg() runs first and > enters NMI context via ct_nmi_enter(), so RCU is always watching by the > time debug_exception_enter() runs. > > Also mark __preempt_count_add/sub() __always_inline so the preempt > count updates fold into the noinstr callers instead of becoming > outlined calls to instrumentable text. Looks good to me as a kprobe maintainer. Reviewed-by: Masami Hiramatsu (Google) Thanks, > > Signed-off-by: Hongyan Xia > --- > arch/arm64/include/asm/preempt.h | 4 ++-- > arch/arm64/kernel/entry-common.c | 13 ++++--------- > 2 files changed, 6 insertions(+), 11 deletions(-) > > diff --git a/arch/arm64/include/asm/preempt.h b/arch/arm64/include/asm/preempt.h > index 932ea4b62042..326f221c3f56 100644 > --- a/arch/arm64/include/asm/preempt.h > +++ b/arch/arm64/include/asm/preempt.h > @@ -41,14 +41,14 @@ static inline bool test_preempt_need_resched(void) > return !current_thread_info()->preempt.need_resched; > } > > -static inline void __preempt_count_add(int val) > +static __always_inline void __preempt_count_add(int val) > { > u32 pc = READ_ONCE(current_thread_info()->preempt.count); > pc += val; > WRITE_ONCE(current_thread_info()->preempt.count, pc); > } > > -static inline void __preempt_count_sub(int val) > +static __always_inline void __preempt_count_sub(int val) > { > u32 pc = READ_ONCE(current_thread_info()->preempt.count); > pc -= val; > diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c > index ceb4eb11232a..d5c1d6defe29 100644 > --- a/arch/arm64/kernel/entry-common.c > +++ b/arch/arm64/kernel/entry-common.c > @@ -292,20 +292,15 @@ static __always_inline void fpsimd_syscall_exit(void) > * accidentally schedule in exception context and it will force a warning > * if we somehow manage to schedule by accident. > */ > -static void debug_exception_enter(struct pt_regs *regs) > +static __always_inline void debug_exception_enter(struct pt_regs *regs) > { > - preempt_disable(); > - > - /* This code is a bit fragile. Test it. */ > - RCU_LOCKDEP_WARN(!rcu_is_watching(), "exception_enter didn't work"); > + preempt_disable_notrace(); > } > -NOKPROBE_SYMBOL(debug_exception_enter); > > -static void debug_exception_exit(struct pt_regs *regs) > +static __always_inline void debug_exception_exit(struct pt_regs *regs) > { > - preempt_enable_no_resched(); > + preempt_enable_no_resched_notrace(); > } > -NOKPROBE_SYMBOL(debug_exception_exit); > > UNHANDLED(el1t, 64, sync) > UNHANDLED(el1t, 64, irq) > -- > 2.47.3 > -- Masami Hiramatsu (Google)