From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDB6624E4B4 for ; Fri, 6 Mar 2026 04:51:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772772662; cv=none; b=YdNNwOX2/pdac+as1BGNP7cn3vkmdeSdDVSRkdh3PH+AT7DwXZizgfG7Uu/YdY/fnwXSfVncGCaEZl8+YJHGgZYkpIZDG1Fpjz40wkrOnk4uEcS20kgTHtVEKAyqthVktUbtewfypHw+L3bH0gpy2wU2euKroHJc5JhJqEbHTZY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772772662; c=relaxed/simple; bh=CqkVw09clHexZLnhO3UV35Zz5eiwK3ilUNQptjChTI8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=fCKVhSDwi8eiNyZWpzFl8luYoDrKs/mblnOXfyxBuOSwWfAswIaRrveg8vlrwE3Zd3t/GDN8Go6pjB0XJiDFxzKjeRe8NIzfMk3jd+e9t5UsriMNKWRG5YNPwlJqEQy+gXF7mQzsR5rwj8cQgyUa6gozZujdo7woxiEAPyX9RQI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=l63stQc1; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l63stQc1" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4837f27cf2dso81087175e9.2 for ; Thu, 05 Mar 2026 20:51:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772772659; x=1773377459; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=iFhQoEl/dM8nL6pSwyNsPCXyep3exDOjlpIQopbHS6o=; b=l63stQc1U6dcntyQ3RcXqaliVEmTLte6WB+nFtxqz1MNQmGPEjD0y9Ijeh2wm4zGCd 7BAy9c9lxr4CtwZJPJbkd4NPTc3XT3OG10/XVYgSu/h52gtMhDFC5O/cvwqdTTvk9fTg kHMT1zdvRzZ50Fo4dN39AjoYS5daGANH/ZTaAXxUrqxTe+h8COhI1mStunbLw4fwOLtI fDfagX5iLofscvGfWqXAmOHj4sQ1uhI0rkjaV8CgMBTB2acslhsp/g915EOwObrvjOQr gIlTXOiqmGvB+UgvDvpQGcE6n3mmo6Af/wHswGWrooFN9bgQWKjQfsk5YRBwwxmdsuOr WdNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772772659; x=1773377459; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=iFhQoEl/dM8nL6pSwyNsPCXyep3exDOjlpIQopbHS6o=; b=QTCmfEDWn3jDOmTeblazXKUJ4fc54/XPyF7sVVU5uGRHLJEU+3qbR/4hxKEiOwdH0n 3/NnNOugXc3WIY8FhMlfM4PfBgq6HKPujf9wHHl3z3vfMeVIBwqnE07OELVA+7nhLMkm n7OigTu4VnZL0hB2dvogsKlXBlxINO67sLA8Ev+uC47O3RzbwR5JzvBz99c/90OgESNz whTl+bXCYgIupxsDil48FK5q84gXu3d4Vj2fgSAVvEif+4ltAj4tNhpVS+XX+ROlvMV6 BCJAfsPzuReCWVVainDL8wOeS/BWT+vlV6OtlmPaipg61hQx7j1H5MAYFyhdsR5lk+5V fLDQ== X-Gm-Message-State: AOJu0YwTECAXshkayhP9oq8tKmBZc7g2RgUB0djzQP+sGhI8XtOi+IAu PUHlb3Dkxd5APLuynpDs1wE2ugHqGIAWT9+eiu8a4SPuoMFbKAQUsQVl X-Gm-Gg: ATEYQzwmS9cXE1xBQu9Ckwn2lEKtCyfjhlf2kbhzVSqrEJnbJSPDuLwk1yuRmhKX04b Srm90NZKwowTMBSCZuWM5Kro0rzr6uP3Uhh4FpD3sKumOTegQ3c1tVucxk3bPfW6fGfyfZ5uvj1 EtPhI6nk6d9ncdFUkLScoXh29XWuSBxrXqWBGy7UPtDOiUERbD0DjqTNdtz+2iPpVsuo02XMAzY n3Gy3LB7q6y88fJgIlow0oM0bEw26H63fsFxl1+lwyUYBoYg1SPs76h85beJiU86Sw2p4/z126L gbNGqhFxaRJR5EwMZoi+wRjjDIAKH5olX+K6gVXDwBJnRg3bmQm2gs/6s/2Kkuq+t2eFeThI2V9 niG0pBpGdaC2lVv9MjTte5JIlsKKb6SMYqly4OANXe9kaX3Kxe2c9bCpWtSRxu9Y5wbp+KS7jbl FX5oT9D0TYRmTk8blX/3aw9HYlOJx90yjYIeJCUHtlfaqB1aS7whQFzamvUm4OEjkUmC5vB8QUY Voyf8BmjDdUJ5qeP6GI X-Received: by 2002:a05:600c:4752:b0:480:4a8f:2d5c with SMTP id 5b1f17b1804b1-4852697721cmr9553025e9.29.1772772658978; Thu, 05 Mar 2026 20:50:58 -0800 (PST) Received: from rozandragon.chello.ie (188-141-5-72.dynamic.upc.ie. [188.141.5.72]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-485276b0c38sm8350455e9.9.2026.03.05.20.50.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2026 20:50:58 -0800 (PST) From: David Carlier To: Tejun Heo , David Vernet , Andrea Righi Cc: linux-kernel@vger.kernel.org, David Carlier Subject: [PATCH] sched_ext: Use READ_ONCE() for scx_slice_bypass_us in scx_bypass() Date: Fri, 6 Mar 2026 04:50:55 +0000 Message-ID: <20260306045055.6493-1-devnexen@gmail.com> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Commit 0927780c90ce ("sched_ext: Use READ_ONCE() for lock-free reads of module param variables") annotated the plain reads of scx_slice_bypass_us and scx_bypass_lb_intv_us in bypass_lb_cpu(), but missed a third site in scx_bypass(): WRITE_ONCE(scx_slice_dfl, scx_slice_bypass_us * NSEC_PER_USEC); scx_slice_bypass_us is a module parameter writable via sysfs in process context through set_slice_us() -> param_set_uint_minmax(), which performs a plain store without holding bypass_lock. scx_bypass() reads the variable under bypass_lock, but since the writer does not take that lock, the two accesses are concurrent. WRITE_ONCE() only applies volatile semantics to the store of scx_slice_dfl -- the val expression containing scx_slice_bypass_us is evaluated as a plain read, providing no protection against concurrent writes. Wrap the read with READ_ONCE() to complete the annotation started by commit 0927780c90ce and make the access KCSAN-clean, consistent with the existing READ_ONCE(scx_slice_bypass_us) in bypass_lb_cpu(). Signed-off-by: David Carlier --- kernel/sched/ext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c index 10866bfb88bf..f323df7be180 100644 --- a/kernel/sched/ext.c +++ b/kernel/sched/ext.c @@ -4137,7 +4137,7 @@ static void scx_bypass(bool bypass) WARN_ON_ONCE(scx_bypass_depth <= 0); if (scx_bypass_depth != 1) goto unlock; - WRITE_ONCE(scx_slice_dfl, scx_slice_bypass_us * NSEC_PER_USEC); + WRITE_ONCE(scx_slice_dfl, READ_ONCE(scx_slice_bypass_us) * NSEC_PER_USEC); bypass_timestamp = ktime_get_ns(); if (sch) scx_add_event(sch, SCX_EV_BYPASS_ACTIVATE, 1); -- 2.51.0