The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCHSET sched_ext/for-7.2-fixes] sched_ext: Fix finite-slice ticks on nohz_full
@ 2026-07-06 16:18 Andrea Righi
  2026-07-06 16:18 ` [PATCH 1/2] sched_ext: Enable tick for finite slices " Andrea Righi
  2026-07-06 16:18 ` [PATCH 2/2] selftests/sched_ext: Verify nohz_full tick behavior Andrea Righi
  0 siblings, 2 replies; 6+ messages in thread
From: Andrea Righi @ 2026-07-06 16:18 UTC (permalink / raw)
  To: Tejun Heo, David Vernet, Changwoo Min
  Cc: Joel Fernandes, sched-ext, linux-kernel

When an EXT task with a finite slice is scheduled on a nohz_full CPU, the
scheduler may incorrectly keep the tick disabled because it still observes the
outgoing task (e.g., the idle task) during the context switch. As a result, the
incoming task can run past its assigned slice.

Fix this by always enabling the scheduler tick for finite-slice EXT tasks and
provide a kselftest that reproduces the scenario and verifies that scheduler
ticks are delivered correctly. Test is skipped in kernels without available
nohz_full CPUS.

Test case (using virtme-ng):

  $ vng -vb --config tools/testing/selftests/sched_ext/config \
        --configitem CONFIG_NO_HZ_FULL=y
  $ vng --append "nohz_full=all" -- \
        tools/testing/selftests/sched_ext/runner -t nohz_tick

Before:

  $ vng --append "nohz_full=all" -- tools/testing/selftests/sched_ext/runner -t nohz_tick
  ===== START =====
  TEST: nohz_tick
  DESCRIPTION: Verify finite EXT slices restart the NOHZ_FULL tick
  OUTPUT:
  ERR: nohz_tick.c:270
  Finite-slice worker received only 1 scheduler ticks
  not ok 1 nohz_tick #
  =====  END  =====


  =============================

  RESULTS:

  PASSED:  0
  SKIPPED: 0
  FAILED:  1

  Failed tests:
    - nohz_tick

After:

  $ vng --append "nohz_full=all" -- tools/testing/selftests/sched_ext/runner -t nohz_tick
  ===== START =====
  TEST: nohz_tick
  DESCRIPTION: Verify finite EXT slices restart the NOHZ_FULL tick
  OUTPUT:
  CPU 1 received 4 finite-slice ticks
  ok 1 nohz_tick #
  =====  END  =====


  =============================

  RESULTS:

  PASSED:  1
  SKIPPED: 0
  FAILED:  0

Andrea Righi (2):
  sched_ext: Enable tick for finite slices on nohz_full
  selftests/sched_ext: Verify nohz_full tick behavior

 kernel/sched/ext/ext.c                            |  14 +-
 tools/testing/selftests/sched_ext/Makefile        |   1 +
 tools/testing/selftests/sched_ext/nohz_tick.bpf.c |  65 +++++
 tools/testing/selftests/sched_ext/nohz_tick.c     | 309 ++++++++++++++++++++++
 4 files changed, 386 insertions(+), 3 deletions(-)

^ permalink raw reply	[flat|nested] 6+ messages in thread
* [PATCHSET v2 sched_ext/for-7.2-fixes] sched_ext: Fix finite-slice ticks on nohz_full
@ 2026-07-07  8:17 Andrea Righi
  2026-07-07  8:17 ` [PATCH 1/2] sched_ext: Enable tick for finite slices " Andrea Righi
  0 siblings, 1 reply; 6+ messages in thread
From: Andrea Righi @ 2026-07-07  8:17 UTC (permalink / raw)
  To: Tejun Heo, David Vernet, Changwoo Min
  Cc: Joel Fernandes, sched-ext, linux-kernel

The scheduler tick dependency for EXT tasks can become stale across context
switches on nohz_full CPUs. An incoming finite-slice task may incorrectly keep
the tick disabled because the scheduler still observes the outgoing task. The
same can happen after an idle interval when the previous EXT task also had a
finite slice. Likewise, when the last finite-slice EXT task is dequeued, its
outgoing state can incorrectly keep the tick enabled after the CPU goes idle.

Fix this by directly asserting the scheduler tick dependency whenever a
finite-slice EXT task is selected and by ignoring the outgoing EXT slice state
when no EXT tasks are accounted on the runqueue.

Moreover, provide a kselftest that exercises both infinite-to-finite and
finite-to-finite transitions across an idle interval and verifies that scheduler
ticks are delivered correctly. The test is skipped when an allowed nohz_full CPU
and a separate housekeeping CPU are not available.

Test case (using virtme-ng):

  $ vng -vb --config tools/testing/selftests/sched_ext/config \
        --configitem CONFIG_NO_HZ_FULL=y
  $ vng --append "nohz_full=all" -- \
        tools/testing/selftests/sched_ext/runner -t nohz_tick

Before:

  $ vng --append "nohz_full=all" -- tools/testing/selftests/sched_ext/runner -t nohz_tick
  ===== START =====
  TEST: nohz_tick
  DESCRIPTION: Verify finite EXT slices restart the NOHZ_FULL tick
  OUTPUT:
  ERR: nohz_tick.c:277
  Finite-slice worker received only 1 scheduler ticks
  not ok 1 nohz_tick #
  =====  END  =====


  =============================

  RESULTS:

  PASSED:  0
  SKIPPED: 0
  FAILED:  1

  Failed tests:
    - nohz_tick

After:

  $ vng --append "nohz_full=all" -- tools/testing/selftests/sched_ext/runner -t nohz_tick
  ===== START =====
  TEST: nohz_tick
  DESCRIPTION: Verify finite EXT slices restart the NOHZ_FULL tick
  OUTPUT:
  CPU 1 received 6 finite-slice ticks
  ok 1 nohz_tick #
  =====  END  =====


  =============================

  RESULTS:

  PASSED:  1
  SKIPPED: 0
  FAILED:  0

Changes in v2:
 - Reassert the tick dependency for every selected finite-slice EXT task, fixing
   the finite-to-idle-to-finite case and extend the selftest to cover it
   (Tejun, sashiko AI)
 - Ignore stale outgoing EXT slice state when no EXT tasks are accounted on the
   runqueue (sashiko AI).
 - Clarify that the infinite-slice bypass scenario is unreachable because bypass
   mode always assigns finite slices (sashiko AI).
 - Kill test workers automatically if their parent exits unexpectedly in the
   selfetst (sashiko AI)
 - Link to v1: https://lore.kernel.org/all/20260706162819.650155-1-arighi@nvidia.com/

Andrea Righi (2):
      sched_ext: Enable tick for finite slices on nohz_full
      selftests/sched_ext: Verify nohz_full tick behavior

 kernel/sched/ext/ext.c                            |  31 +-
 tools/testing/selftests/sched_ext/Makefile        |   1 +
 tools/testing/selftests/sched_ext/nohz_tick.bpf.c |  65 ++++
 tools/testing/selftests/sched_ext/nohz_tick.c     | 347 ++++++++++++++++++++++
 4 files changed, 440 insertions(+), 4 deletions(-)
 create mode 100644 tools/testing/selftests/sched_ext/nohz_tick.bpf.c
 create mode 100644 tools/testing/selftests/sched_ext/nohz_tick.c

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-07-07  8:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06 16:18 [PATCHSET sched_ext/for-7.2-fixes] sched_ext: Fix finite-slice ticks on nohz_full Andrea Righi
2026-07-06 16:18 ` [PATCH 1/2] sched_ext: Enable tick for finite slices " Andrea Righi
2026-07-06 22:09   ` Tejun Heo
2026-07-07  5:52     ` Andrea Righi
2026-07-06 16:18 ` [PATCH 2/2] selftests/sched_ext: Verify nohz_full tick behavior Andrea Righi
  -- strict thread matches above, loose matches on Subject: below --
2026-07-07  8:17 [PATCHSET v2 sched_ext/for-7.2-fixes] sched_ext: Fix finite-slice ticks on nohz_full Andrea Righi
2026-07-07  8:17 ` [PATCH 1/2] sched_ext: Enable tick for finite slices " Andrea Righi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox