From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 668E74399E6 for ; Fri, 31 Jul 2026 14:43:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785509038; cv=none; b=Kmb22v0LncZgnolJ6qCzy2NQAtCcmpWQEoJTiQRoEuQ7PnMTM0ZHXHdNLLv2dhFnXVlXKDSTnhOykUY5LUtK7Yjr35AXjStpmU/+UJEUVLtUZnf16DU2kAXlxL/PORBslRJL2/saMqeM2+sLyl12crfWjrFVMTsswtaeY/iXv3E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785509038; c=relaxed/simple; bh=PzWteN1QWhe4JHT13mQYIO/VwTEzMzEqxavV1NFDI60=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=c3yjU3/65gIYmxng6MdZSrUIToxxxDR7yjMuLRWhcsQHcvwIjHuuiE3WwZ8LFa9o3aTVFRfxLCx7Kcs8yEHDzi2UXQL4AH9Z8ObPgc5Ul0JijWHxh2MlV0lyMqtCdI9PIcKnvyfoQxYTXd16IJ1CAFkqIzRzc79MQMHYNsVQjBY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=Pcxasyko; arc=none smtp.client-ip=217.140.110.172 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) header.d=arm.com header.i=@arm.com header.b="Pcxasyko" 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 4E1A715A1; Fri, 31 Jul 2026 07:43:51 -0700 (PDT) Received: from J2N7QTR9R3 (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F28F73F86F; Fri, 31 Jul 2026 07:43:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1785509035; bh=PzWteN1QWhe4JHT13mQYIO/VwTEzMzEqxavV1NFDI60=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Pcxasyko5i49uIS+oUGkntoGeHocun8pEEhjyPS6VSLjVHtsstHkyXWkre7/nLS3u 6p/BfW98EegXis5Bmo7TW8gLY7DNOdmJ0s+6xPjxQSce28G5OJlL+eIUnpGGxafH+6 EsjrsYxJbcF2dSLF2CzOycTzN7EMm1rM5HaKl7L4= Date: Fri, 31 Jul 2026 15:43:51 +0100 From: Mark Rutland To: Hongyan Xia Cc: Will Deacon , Masami Hiramatsu , Catalin Marinas , Jiazi Li , Pu Hu , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [RFC PATCH 2/9] arm64/entry: Make debug_exception_enter/exit() noinstr Message-ID: References: <774d423f462ff2c245e5f796dad98dd1740fa5f7.1785153469.git.hongyan.xia@transsion.com> 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-Disposition: inline In-Reply-To: <774d423f462ff2c245e5f796dad98dd1740fa5f7.1785153469.git.hongyan.xia@transsion.com> On Mon, Jul 27, 2026 at 12:25:36PM +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 make both functions noinstr. > > 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. > > Signed-off-by: Hongyan Xia > --- > arch/arm64/kernel/entry-common.c | 24 +++++++++++++++--------- > 1 file changed, 15 insertions(+), 9 deletions(-) > > diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c > index 466529cce1c3..f06b5e2437cd 100644 > --- a/arch/arm64/kernel/entry-common.c > +++ b/arch/arm64/kernel/entry-common.c > @@ -293,20 +293,26 @@ 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 void noinstr 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"); > + /* > + * debug_exception_enter/exit() can be quite delicate. The normal > + * preempt_disable/enable() can be instrumented or traced by perf, > + * which leads to a can of worms including triggering page faults. > + * > + * Instead of trying to make all of them work properly here, just > + * open-code the simpler version of preempt_disable/enable() and make > + * enter/exit() both noinstr to avoid the entire complexity. > + */ > + __preempt_count_inc(); > + barrier(); > } > -NOKPROBE_SYMBOL(debug_exception_enter); This is an open-coded version of preempt_disable_notrace(), and there's no reason the existing code needs to be out-of-line in the first place. Please make this: static __always_inline void debug_exception_enter(struct pt_regs *regs) { preempt_disable_notrace(); } > -static void debug_exception_exit(struct pt_regs *regs) > +static void noinstr debug_exception_exit(struct pt_regs *regs) > { > - preempt_enable_no_resched(); > + barrier(); > + __preempt_count_dec(); > } > -NOKPROBE_SYMBOL(debug_exception_exit); Similarly, this is an open-coded copy of preempt_enable_no_resched_notrace(). Please make this: static __always_inline void debug_exception_exit(struct pt_regs *regs) { preempt_enable_no_resched_notrace(); } In both cases I'm happy with keeping the regs argument for now. Mark.