mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kuba Piecuch <jpiecuch@google.com>
To: Tejun Heo <tj@kernel.org>, David Vernet <void@manifault.com>,
	Andrea Righi <arighi@nvidia.com>,
	 Changwoo Min <changwoo@igalia.com>,
	Peter Zijlstra <peterz@infradead.org>
Cc: Kuba Piecuch <jpiecuch@google.com>,
	Ingo Molnar <mingo@redhat.com>,
	sched-ext@lists.linux.dev,  linux-kernel@vger.kernel.org
Subject: [PATCHSET v3 sched_ext/for-7.4-fixes] sched: Fix SCX_ENQ_CPU_SELECTED for queued wakeups
Date: Mon, 30 Nov 2026 13:05:56 +0000	[thread overview]
Message-ID: <20261130130447.2225810-1-jpiecuch@google.com> (raw)

SCX_ENQ_CPU_SELECTED is meant to tell ops.enqueue() whether
ops.select_cpu() ran for a wakeup. However, wakeups delivered through
the ttwu wakelist never have the flag set, because sched_ttwu_pending()
drops WF_RQ_SELECTED. Schedulers that set SCX_OPS_ALLOW_QUEUED_WAKEUP
therefore cannot tell whether ops.select_cpu() was skipped, and
SCX_EV_SELECT_CPU_FALLBACK is undercounted.

Patch 1 carries WF_RQ_SELECTED across the wakelist the same way
WF_MIGRATED already is.

Patch 2 adds the enq_cpu_selected selftest. enq_cpu_selected fails
without patch 1 because every queued wakeup reaches ops.enqueue() with
SCX_ENQ_CPU_SELECTED clear despite ops.select_cpu() having run.

Patch 1 changes kernel/sched/core.c and include/linux/sched.h, but only
sched_ext consumes ENQUEUE_RQ_SELECTED. A similar change in
kernel/sched/core.c, commit 2f7928516314 ("sched/core: Pass
ENQUEUE_RQ_SELECTED on initial enqueue"), was taken through the
sched_ext tree, so this version is rebased onto sched_ext/for-7.4-fixes.

The patches were written with the help of an AI coding assistant. I have
reviewed the patches and verified the tests run by the tool.

Changes in v3:
- Rebase onto sched_ext/for-7.4-fixes (d43078a23723) (Tejun).
- Patch 1: Add Cc: stable@vger.kernel.org # v6.15+.
- Patch 2: Destroy the BPF skeleton on load failure in setup(), and
  close open pipe fds on error paths in spawn_pair() as well as unused
  pipe ends in the forked workers (Sashiko).

Resend of v2:
- Rebase onto tip/sched/urgent (f4eb2ace3efd); no code or commit-message
  changes.

Changes in v2:
- Patch 1: Reword the description to distinguish the wakelist path
  before ->select_task_rq() from the one after it, and fix the
  ttwu_do_activate() name (Andrea). Add Acked-by from Tejun and
  Reviewed-by from Andrea.
- Patch 2: Give each ping-pong task its own two CPUs and dispatch to
  SCX_DSQ_LOCAL. The waker and the wakee then always run on different
  CPUs, so the test no longer depends on tasks spreading out on their
  own (Sashiko). Skip on systems with fewer than four CPUs.

v2 resend: https://lore.kernel.org/all/20261123171637.3859594-1-jpiecuch@google.com/
v2: https://lore.kernel.org/all/20261026114429.209588-1-jpiecuch@google.com/
v1: https://lore.kernel.org/all/20261023144811.2230393-1-jpiecuch@google.com/

Kuba Piecuch (2):
  sched/core: Preserve WF_RQ_SELECTED across queued wakeups
  selftests/sched_ext: Test SCX_ENQ_CPU_SELECTED with queued wakeups

 include/linux/sched.h                         |   6 +-
 kernel/sched/core.c                           |  10 +-
 tools/testing/selftests/sched_ext/Makefile    |   1 +
 .../sched_ext/enq_cpu_selected.bpf.c          | 111 +++++++++
 .../selftests/sched_ext/enq_cpu_selected.c    | 215 ++++++++++++++++++
 5 files changed, 340 insertions(+), 3 deletions(-)
 create mode 100644 tools/testing/selftests/sched_ext/enq_cpu_selected.bpf.c
 create mode 100644 tools/testing/selftests/sched_ext/enq_cpu_selected.c


base-commit: d43078a237230fd8fb6bf082ff285c93d0ccd763
-- 
2.56.1.839.g22a8290db9-goog


             reply	other threads:[~2026-11-30 13:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 13:05 Kuba Piecuch [this message]
2026-11-30 13:05 ` [PATCH v3 1/2] sched/core: Preserve WF_RQ_SELECTED across " Kuba Piecuch
2026-11-30 13:05 ` [PATCH v3 2/2] selftests/sched_ext: Test SCX_ENQ_CPU_SELECTED with " Kuba Piecuch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130130447.2225810-1-jpiecuch@google.com \
    --to=jpiecuch@google.com \
    --cc=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    --cc=void@manifault.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®