From nobody Fri Jul 24 22:52:03 2026 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (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 B34203382DE for ; Wed, 22 Jul 2026 14:33:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.69 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784730808; cv=none; b=Dqbfdj08ibksg9jYPTcYwn9dNS3dDzRCwPM6QzHYFndPPfBCmtJIlWApcG/wgds71C0dcpdgjaSaQTn7K61OapuGH5qWob+tOF8ndVrnWCnkQQfsX7AUl+mcb1aHehkBP+mjj81v38sTkEjViaWL7CkjhC+beISME0fwnQ99Ewc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784730808; c=relaxed/simple; bh=KWWYZWq3f3S202lOKPos9BEBMJMQ+52hdTniyYecPlk=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=ImO4ccnHiWrgenVIbZzxD0SLgw5AOGjLQVbJEelU8HquD2LMckbAWm7DrxxM9aZ0sEleKOSfbv38aKGurXNmlxepXigAz6vijmIK5rrPbAeHEMH39GIxujY3KUSGqBYKJezn55D55EZUP67MPubNIId6xvrJ0Squ6oFMsZwQ33k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jpiecuch.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=taKQrEAL; arc=none smtp.client-ip=209.85.128.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jpiecuch.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="taKQrEAL" Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-493fa6e28a7so119345615e9.1 for ; Wed, 22 Jul 2026 07:33:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784730805; x=1785335605; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=mjcGCiS9WuUKTpAPW5dETsTCw/akiYA9lgsLsiqyTqI=; b=taKQrEALcnJh4KJBUHICe8AaLJ/Otp7XJv8MkmrWthZvEiOR9WxtBGubsF7d0Oo/Yz FXr3WR7qRcVx1LyVRgMD0C30J84BPcPkmZlAOeGrrFGN6GDynsZe3Y7NZFAnkZCZWJ5B 28zVr9rDD3zaTVHBtZs0dnvOa1sUnQimP2/4PzahCLDG7uCNchQ08/sh5h+p2FZzn9+7 YKlR1gh37cEpN/gohqiYbwOZ/AXNrbuyPQOUYobK5vsKRLLiSUbOwZiN6W8URhZtzNs9 jZHp/20VVtjIQk4bPBJDDliramCEeQICM9YgHpyxMltjQ2foEaojvfcHBfMzWWKfsZu8 EXNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784730805; x=1785335605; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=mjcGCiS9WuUKTpAPW5dETsTCw/akiYA9lgsLsiqyTqI=; b=Z6E8Ny2JR9CjGsCwow72ZlRGRvlmEh+5YLdeXc1OCi4jEKVtf0GCnddX/FHQOkqXq0 5ow9TyG601+DjM22d7yZyBbo1YqcVvMQwpQpI8gj/Y1Lb4EVXWGzyNIU5wjvC7epOLuX FQtAl4oJLeSia12xTVqO1pFWt7gcx+WABY+Sa84zDQGa+nujuaTTpvZm/ntm+pxZzHsK gKUlGsn5poyoGeYu97x9ODFnPAeRGpUDMhoZ7qMWNS9tjDA3w4+hZ5TJUzXLNu8TgHfc A5jLklftAogJK6NI1ugVV34QpN0vdL0Fs8qsVJFcY7hpOi0YrVj6x9qbAi6R59BHOsCA 9Hdg== X-Gm-Message-State: AOJu0Yw3a87YEiMIOEtjrhYRJIxwygu5p737JYHZ0gymvJgPOzM5qz/b VyitSBIT5QMqW1RMip+CvhC/k+X8k0Y2x6ok8nOvQiUMEtugIdT6CKLJO3wuhnMuvhg06cZ6zUQ tu4yVhvna7Vyt7g== X-Received: from wmgg13.prod.google.com ([2002:a05:600d:d:b0:493:bba5:775a]) (user=jpiecuch job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:4ed1:b0:495:4cb8:42b9 with SMTP id 5b1f17b1804b1-4954cb842f7mr224569105e9.4.1784730804594; Wed, 22 Jul 2026 07:33:24 -0700 (PDT) Date: Wed, 22 Jul 2026 14:33:07 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.55.0.229.g6434b31f56-goog Message-ID: <20260722143307.2772632-1-jpiecuch@google.com> Subject: [PATCH sched_ext/for-7.2-fixes] sched_ext: mark waker CPU busy when selected in WAKE_SYNC case From: Kuba Piecuch To: Tejun Heo , Andrea Righi , Changwoo Min , David Vernet Cc: linux-kernel@vger.kernel.org, sched-ext@lists.linux.dev, Kuba Piecuch Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" SCX's built-in idle CPU tracking is imperfect and can be out-of-sync with the actual idle state of CPUs, especially immediately after enabling SCX due to scx_idle_enable() marking all online CPUs idle. scx_select_cpu_dfl() skips marking the selected CPU as busy if the selected CPU is the waker CPU in the SCX_WAKE_SYNC case. If the waker CPU was marked idle by SCX, it will still be marked idle after CPU selection and potentially even after switching to the wakee. In the allowed_cpus selftest, this can manifest as the test failing with the following message in dmesg: allowed_cpus.bpf.c:21: CPU 0 should be marked as busy This patch explicitly marks the waker CPU as busy. With this patch, the test failure no longer reproduces. There are still some pretty unlikely races that could make the test fail (e.g. pick_task_idle() marking the selected CPU idle between selection and validation), but these can't be fixed easily. Signed-off-by: Kuba Piecuch --- kernel/sched/ext/idle.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/sched/ext/idle.c b/kernel/sched/ext/idle.c index 8e8c6201b7df..6f93cc32b650 100644 --- a/kernel/sched/ext/idle.c +++ b/kernel/sched/ext/idle.c @@ -554,8 +554,10 @@ s32 scx_select_cpu_dfl(struct task_struct *p, s32 prev= _cpu, u64 wake_flags, cpu_rq(cpu)->scx.local_dsq.nr =3D=3D 0 && (!(flags & SCX_PICK_IDLE_IN_NODE) || (waker_node =3D=3D node)) && !cpumask_empty(idle_cpumask(waker_node)->cpu)) { - if (cpumask_test_cpu(cpu, allowed)) + if (cpumask_test_cpu(cpu, allowed)) { + scx_idle_test_and_clear_cpu(cpu); goto out_unlock; + } } } =20 --=20 2.55.0.229.g6434b31f56-goog