From nobody Mon Jun 8 15:38:28 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 E051A3AFD18; Thu, 28 May 2026 09:42:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779961329; cv=none; b=MvRS071h0aQlSosirPWIxR1gcRE0QZAz/ra2b+h6hDPbwG0zj9c0+OAg5NKfCI59k9t5dAzo1PT+c0RAcDwlZHvNjmKqTn6EhOdowSjsXpC/Kow7iE/qy0h9dwYbuvqCxSRTX2Hacw7sGtpYYwdTlX223C6MYIUvXA8ilvX+fqA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779961329; c=relaxed/simple; bh=mMAmB7lSKeBIbJjvf4H5K2BDeeDdoFyApv6sbnYtR5Y=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=GZwzyPJzKWIKrE+BQJXaUOGwah7VYl620TXRbc25ahoPjjMod17CEgKzlaulHGDr5bl7gmaCIe1gqFylLG86YEzH3fsDnJP4OysUY280+/tXujZHOq+w7Q0E5LzArNvLTSGkVSErmFZbZxInf9c7XuJhJCBR6x5RtN6ZgEZkqCk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=YFXGF4AE; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=a9+NaUry; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="YFXGF4AE"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="a9+NaUry" Date: Thu, 28 May 2026 09:42:04 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779961326; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+Dj/X9NnH7iclKhq1cxfdvsE6Z3EjU72DgFXe2Q9ed8=; b=YFXGF4AETWCeO8EN4u61tMa5xGxkODRYv5jSxqMsMDXZyF50UxERuGG2nOyCWuNbaFFGqf uSzanACOGX46NTb21wUOlB0f1ce6oBQA8lcnbxCQCifLJ3ABLhbhZDbS7z/wd53/PJFAaL IuBCAjfwO3l8Lqk3ubSgR+LofFYyqY0U2pYkxrZAscMvXQdG8NDH/uw4p0LmoKQsg9tqxm 6WmmiGq8mCaR9WxTuHbRWJcKv2aLlBpaPo849tilE+LDAeyEOTCid0ucGNnYc0lxcHJrGe 5WV3lUqJtdZhZL+NA2q3fU28bq2cc5Ts5BhFEG8bOeJ9wV8y9Ox6Nxppk5FANA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779961326; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+Dj/X9NnH7iclKhq1cxfdvsE6Z3EjU72DgFXe2Q9ed8=; b=a9+NaUrysZIth+4FFpUTeA6Z2Zomzh5xc6EKazHJ0U0/0RRqppkyjOSEDDGvEYWTI139Ku XLeOVhQOj4jUnWDA== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched: Use {READ,WRITE}_ONCE() for preempt_dynamic_mode Cc: "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260511120627.176946327@infradead.org> References: <20260511120627.176946327@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177996132497.1039918.12321923360025215417.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the sched/core branch of tip: Commit-ID: 77557002234546a4fb46ebf517d6cb1d515535a9 Gitweb: https://git.kernel.org/tip/77557002234546a4fb46ebf517d6cb1d5= 15535a9 Author: Peter Zijlstra AuthorDate: Mon, 11 May 2026 13:31:06 +02:00 Committer: Peter Zijlstra CommitterDate: Tue, 26 May 2026 13:53:13 +02:00 sched: Use {READ,WRITE}_ONCE() for preempt_dynamic_mode Robots figured out you can read and write this concurrently and got 'upset'. Gemini even noted sched_dynamic_show() can generate 'confusing' output if it observed different values during the printing. Signed-off-by: Peter Zijlstra (Intel) Link: https://patch.msgid.link/20260511120627.176946327@infradead.org --- kernel/sched/core.c | 15 ++++++++------- kernel/sched/debug.c | 5 +++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index b3a416b..83202f0 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7979,7 +7979,7 @@ static void __sched_dynamic_update(int mode) break; } =20 - preempt_dynamic_mode =3D mode; + WRITE_ONCE(preempt_dynamic_mode, mode); } =20 void sched_dynamic_update(int mode) @@ -8020,12 +8020,13 @@ static void __init preempt_dynamic_init(void) } } =20 -# define PREEMPT_MODEL_ACCESSOR(mode) \ - bool preempt_model_##mode(void) \ - { \ - WARN_ON_ONCE(preempt_dynamic_mode =3D=3D preempt_dynamic_undefined); \ - return preempt_dynamic_mode =3D=3D preempt_dynamic_##mode; \ - } \ +# define PREEMPT_MODEL_ACCESSOR(mode) \ + bool preempt_model_##mode(void) \ + { \ + int mode =3D READ_ONCE(preempt_dynamic_mode); \ + WARN_ON_ONCE(mode =3D=3D preempt_dynamic_undefined); \ + return mode =3D=3D preempt_dynamic_##mode; \ + } \ EXPORT_SYMBOL_GPL(preempt_model_##mode) =20 PREEMPT_MODEL_ACCESSOR(none); diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index af13a89..4cdf2f9 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -281,6 +281,7 @@ static ssize_t sched_dynamic_write(struct file *filp, c= onst char __user *ubuf, static int sched_dynamic_show(struct seq_file *m, void *v) { int i =3D (IS_ENABLED(CONFIG_PREEMPT_RT) || IS_ENABLED(CONFIG_ARCH_HAS_PR= EEMPT_LAZY)) * 2; + int mode =3D READ_ONCE(preempt_dynamic_mode); int j; =20 /* Count entries in NULL terminated preempt_modes */ @@ -289,10 +290,10 @@ static int sched_dynamic_show(struct seq_file *m, voi= d *v) j -=3D !IS_ENABLED(CONFIG_ARCH_HAS_PREEMPT_LAZY); =20 for (; i < j; i++) { - if (preempt_dynamic_mode =3D=3D i) + if (mode =3D=3D i) seq_puts(m, "("); seq_puts(m, preempt_modes[i]); - if (preempt_dynamic_mode =3D=3D i) + if (mode =3D=3D i) seq_puts(m, ")"); =20 seq_puts(m, " ");