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 3E3B7412276 for ; Fri, 31 Jul 2026 12:51:38 +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=1785502301; cv=none; b=c9LQXmddISBlt3povMwUOjk9BCQRHwK6Dy9q4+TqC+Gxe81h93RpP5QuZQ0kvfUGtktQCOAUN65LWWgAfjPBXOcLg+RGar4R04f5KlBw479tQdDm+Q5k8VMnxs+0VQ4cYU1fq892q1WNJnG5WE11bO0G1i2IyLWun+Nw60/f3PY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785502301; c=relaxed/simple; bh=pzoMoHN8Xbk+tBHJK4RtpsuB9qr2xAHSbWUTa2L+TEs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gvA4UoYanNro4JKj962ZLYXzFNybwzM76QV45Oo/wEPs/MG/FLcgSkelMmKVlaH88pqQlaHWxRWpVcR08U/gXgHkn9ktoUwyHVEuIuWh7TYQOuryWrHMLMcoyeJhXudt8o/bzAQHIp/sn9NO92ggNN2F4MDw3ztAXPgX5tzpTIc= 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=YboKNLhB; 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="YboKNLhB" 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 22EB8204C; Fri, 31 Jul 2026 05:51:33 -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 CF75F3F86F; Fri, 31 Jul 2026 05:51:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1785502297; bh=pzoMoHN8Xbk+tBHJK4RtpsuB9qr2xAHSbWUTa2L+TEs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YboKNLhB9rvsoGAVCqlSNlUZKCuGpyDBGkA+QSqQzQr5L5JPB/PMQBTYx4FNFZBay ikgCYLubmzgs/kqx8lHlVpFKzTKLrhUJMWmnJCMGjun3SyjQaBQQxhtTmqhhg+ZqK6 +deT62mhcmPbSnbZ5TuWP2DFDmqVykEM+Rc3dtpQ= Date: Fri, 31 Jul 2026 13:51:26 +0100 From: Mark Rutland To: "Paul E. McKenney" Cc: Catalin Marinas , Will Deacon , Jinjie Ruan , Ada Couprie Diaz , linux-arm-kernel@lists.infradead.org, "Peter Zijlstra (Intel)" , linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC] arm64: Mark set_preempt_need_resched() access to .need_resched Message-ID: References: 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: Hi Paul, On Thu, Jul 30, 2026 at 04:59:57PM -0700, Paul E. McKenney wrote: > The .need_resched field can be accessed from both task level and > from interrrupt handlers, so apply WRITE_ONCE() to the update in > set_preempt_need_resched(). This also brings arm64 in line with s390 > (which uses atomic operations) and x86 (which uses inline assembly). > Other architectures avoid this issue via the empty definition in > include/asm-generic/preempt.h. > > KCSAN located this issue. Do you have the KCSAN splat to hand? Seeing the exact race (and the relevant reader(s)) would be handy. > Signed-off-by: Paul E. McKenney > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Jinjie Ruan > Cc: Ada Couprie Diaz > Cc: > > --- > preempt.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/include/asm/preempt.h b/arch/arm64/include/asm/preempt.h > index 932ea4b6204289..610853da140a78 100644 > --- a/arch/arm64/include/asm/preempt.h > +++ b/arch/arm64/include/asm/preempt.h > @@ -28,7 +28,7 @@ static inline void preempt_count_set(u64 pc) > > static inline void set_preempt_need_resched(void) > { > - current_thread_info()->preempt.need_resched = 0; > + WRITE_ONCE(current_thread_info()->preempt.need_resched, 0); > } I was under the impression that we only used this in a context where we couldn't have a nested writer (e.g. within a scheduler IRQ hook, with IRQs disabled). If we have concurrent writers, this is probably broken regardless of whether it is single-copy-atomic, and I worry WRITE_ONCE() will mask a bug. If you can share the KCSAN splat, that'd really help. I think we need READ_ONCE() in test_preempt_need_resched(), but today that's only used by tracing to determine what to log. Mark.