From nobody Thu Apr 9 14:59:31 2026 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 097942C9D for ; Tue, 3 Mar 2026 06:05:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772517931; cv=none; b=BPpXqp69bVfytgmuRGkBAJkUyN7RQWmKTlxnvNTk3ok+qbynZTInn6oS1a7ZFLOZT4qidFZe4LtmBgx3Ra5jmCf4wi9zbUQd06SjVKV/V1LeC/cO2T4rOYgksmJthmJQYpftnlOyHcPEdn0v2hbgnBn/+WiP5v4YrO6vkNdXM+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772517931; c=relaxed/simple; bh=bv2Jz4U2DpMjAUfifYxKw27bsTlEORVTMJigqU5sadg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Hh1so+BZumeZ6TaNAHRRkX3FoX5ZSd6TbJbHEppffOeJZwRUo3KbxQcRmjSXsiKrv8a/2nejGPY4BtlFQT6wo4chwwwaa7mm6NSzoglIRXzaXOI61NjCW67fxb6yyfo+yZYK6wHiSsMk/4xTzZAljnUePwF8uc/eXzCzQhOrMBY= 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=QcIlmxMI; arc=none smtp.client-ip=209.85.210.178 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="QcIlmxMI" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-82735a41920so2018936b3a.2 for ; Mon, 02 Mar 2026 22:05:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772517929; x=1773122729; 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=P6esbafM8AfMQhSMQFEvnisdVNGuHu/hvV9/NaeusRQ=; b=QcIlmxMIQduSND30AQqDcAGfxZlP4IoEGsRsFv1vH4cthxPq71fb3tgUw/XGGbLHpo nBuAcG7Ce9dWLoNVRQDs5rZObeasQwLnMeQ2CSDQZrxLw4Gkk12pzr/cNKYP65KT9KG1 fMyDxH4HRc/tHArd2oMV85CHbD3kYsLVUO5YiF0O4qAx3gy09zbbLAD9EJxb55RVPrRF 3v22f/xEnI8+wuPtubgbLePHPO3Dt19sN0YLT9fJBQAb/xoe+xD9xKc5N97L3my3FqLY nLwstNW6Z5UsYe/D4MQ04GxkVqkOJDS6+quPSA9V547vLGO7OkwbDF9aJFWEjErIDoti PCSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772517929; x=1773122729; 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=P6esbafM8AfMQhSMQFEvnisdVNGuHu/hvV9/NaeusRQ=; b=L0JUW368r4BEptOoYJiNzqd5YrW10JcqmbSxNpYUJEoYaFyzf2IlJB7+hRD6gdPKnu 7W9wqUqDySHZkk0yQ+XBbY5fjzE2wgkmilwRI96kbxtJYP9M1vcMTlVZYM/tn7DdtrID 6YwmEZD7uNpDadEPF978RgeI5bL2P6d54p8bz7VWig/aYGKlHAzJq8ttJPoZfXEJts5G IorqQOT/RmTArUqhJME0GRUQjzo/3bsRuXCoP3nfddsM7CSkJdoDFuUVvCBi69dNiZgR gzyyu2BRFxdRAGLekSS/nNYAdFvuP4nXHsV8BhWGcCVTmrrV7tFL2ChJWp5Z3ay/dnzC 8X4A== X-Gm-Message-State: AOJu0Yx4ioWxLQVG07hHx+66scjPK5OiZmVih53Jx4cTv+LCKpICxnaf GUUYISgY+FSkPARMaRD6jYxTa2TtmacFIxaEkCja/MTC/rUaH/pj8qldJbvpThW8 X-Gm-Gg: ATEYQzyEe0cXsAMDbYkDtdG6ux3S1taMwWH/t+tLCaW8vtlR2zlvxhbn7kpSjGDgSpC +Cic5l0/TAn0X7AEHD37EjIXie0+a9MBpQ7zhw7tTZDvPgUwEWVY0NfgARyqWgpY7ktAmP0zmAV Mk3WqCZHhPzVq/FZif52JZQRBJ2j6HRAkSS+xbU0iFuf7i0HZCCkPdQwvIlPkur0gJ7CTxf4+ob pQ/W/HaLfnkTsiF94fYQLLCxG757+bC0Xna00Izb6lPmQEF4oleyauyJrLeRM/eaZ9nhNGpxIbw Ft3zoE+cc0+wVO5DHQ3ICPBWeMUcCYEIr6Ub7U759P8YDMZusrT0iOkTVX8VuMwt6nk1wQp7Kml Ak/2dOVKfGjy9vJxx5Jg+GfCn6CCY8huIiD6ad828Z1A+rgLNDQLH/CYwH1YgYUjgriUCa9f8Tw WqEco5sz+Noqk6Stzf7Fxx17duiHBqEgBc/Ugyc1+L5yv7LUi5WCiyFxPUSwP5tuPJl+AK7h3Y0 34= X-Received: by 2002:a05:6a21:2983:b0:371:8e6d:27e1 with SMTP id adf61e73a8af0-395c3aefedbmr12567570637.36.1772517928989; Mon, 02 Mar 2026 22:05:28 -0800 (PST) Received: from mi-HP-ProDesk-680-G6-PCI-Microtower-PC.mioffice.cn ([43.224.245.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82739ff34fesm14036074b3a.42.2026.03.02.22.05.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2026 22:05:28 -0800 (PST) From: zhidao su X-Google-Original-From: zhidao su To: linux-kernel@vger.kernel.org Cc: tejun@kernel.org, htejun@fb.com, zhidao su Subject: [PATCH] sched_ext: Use READ_ONCE() for plain reads of scx_watchdog_timeout Date: Tue, 3 Mar 2026 14:05:23 +0800 Message-ID: <20260303060523.119220-1-suzhidao@xiaomi.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" scx_watchdog_timeout is written with WRITE_ONCE() in scx_enable(): WRITE_ONCE(scx_watchdog_timeout, timeout); However, three read-side accesses use plain reads without the matching READ_ONCE(): /* check_rq_for_timeouts() - L2824 */ last_runnable + scx_watchdog_timeout /* scx_watchdog_workfn() - L2852 */ scx_watchdog_timeout / 2 /* scx_enable() - L5179 */ scx_watchdog_timeout / 2 The KCSAN documentation requires that if one accessor uses WRITE_ONCE() to annotate lock-free access, all other accesses must also use the appropriate accessor. Plain reads alongside WRITE_ONCE() leave the pair incomplete and can trigger KCSAN warnings. Note that scx_tick() already uses the correct READ_ONCE() annotation: last_check + READ_ONCE(scx_watchdog_timeout) Fix the three remaining plain reads to match, making all accesses to scx_watchdog_timeout consistently annotated and KCSAN-clean. Signed-off-by: zhidao su --- kernel/sched/ext.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c index 147b31a7b3cf..b9247c9f0430 100644 --- a/kernel/sched/ext.c +++ b/kernel/sched/ext.c @@ -2821,7 +2821,7 @@ static bool check_rq_for_timeouts(struct rq *rq) unsigned long last_runnable =3D p->scx.runnable_at; =20 if (unlikely(time_after(jiffies, - last_runnable + scx_watchdog_timeout))) { + last_runnable + READ_ONCE(scx_watchdog_timeout)))) { u32 dur_ms =3D jiffies_to_msecs(jiffies - last_runnable); =20 scx_exit(sch, SCX_EXIT_ERROR_STALL, 0, @@ -2849,7 +2849,7 @@ static void scx_watchdog_workfn(struct work_struct *w= ork) cond_resched(); } queue_delayed_work(system_unbound_wq, to_delayed_work(work), - scx_watchdog_timeout / 2); + READ_ONCE(scx_watchdog_timeout) / 2); } =20 void scx_tick(struct rq *rq) @@ -5176,7 +5176,7 @@ static int scx_enable(struct sched_ext_ops *ops, stru= ct bpf_link *link) WRITE_ONCE(scx_watchdog_timeout, timeout); WRITE_ONCE(scx_watchdog_timestamp, jiffies); queue_delayed_work(system_unbound_wq, &scx_watchdog_work, - scx_watchdog_timeout / 2); + READ_ONCE(scx_watchdog_timeout) / 2); =20 /* * Once __scx_enabled is set, %current can be switched to SCX anytime. --=20 2.43.0