Linux kernel -stable discussions
 help / color / mirror / Atom feed
* Please backport 101f3498b4bd to 6.18.y
@ 2026-07-23  7:14 Janne Huttunen (Nokia)
  2026-07-24 11:22 ` Sasha Levin
  0 siblings, 1 reply; 4+ messages in thread
From: Janne Huttunen (Nokia) @ 2026-07-23  7:14 UTC (permalink / raw)
  To: stable@vger.kernel.org; +Cc: Peter Zijlstra

Please consider backporting this patch to 6.18.y:

101f3498b4bd sched/fair: Revert 6d71a9c61604 ("sched/fair: Fix EEVDF entity placement bug causing scheduling lag")


Rationale:

After updating a bunch of servers to 6.18.y, we started experiencing
some scheduler related starvations. The servers each have a group of
very dedicated and isolated CPU cores, meaning that they normally
only run a single user space thread (in "system.slice"), they don't
process any interrupts and nohz_full is in effect. The thread is
SCHED_OTHER (nice -10) and it is almost always runnable consuming
all the available CPU time.

In some rare situations, for e.g. debugging or metrics collecting,
there might be also some other thread for a brief period of time on
such a core. This other thread is also SCHED_OTHER, but it is in
"user.slice". The affinity mask allows that thread to only run on
that specific core. Now whether this CPU sharing is intentional or
not is debatable, but I don't think it should cause the kind of
problem we have observed. What sometimes happens is that the thread
in "user.slice" gets starved for seconds, minutes, hours (seen),
maybe even days (I don't think we have seen that). During that
starvation even SIGKILL won't release the thread because it gets
no runtime and cannot complete processing the signal.

After staring at this way too long, I came up with these observations
and (not 100% proven) theory:

1. The vruntime of "user.slice" advances forward quite a bit and
   the corresponding thread gets pre-empted. The slice is now ready
   to run but ineligible due to its large vruntime compared to the
   "system.slice".

2. The vruntime of "system.slice" starts behaving in a strange
   "sawtooth" pattern where apparently update_curr() nudges it
   forward a few times (causing the upward slope of the sawtooth)
   until a reweight comes. The reweight then calls place_entity()
   with 'cfs_rq->curr == se == "system.slice"', which seems to mess
   up the vruntime. I don't claim to understand the math in there,
   but to me it looks like when 'cfs_rq->curr == se', the math
   includes the weight of it twice when calculating the lag
   preservation. Apparently this may negate most/all of the upward
   slope causing the downward drop of the sawtooth.

The overall trend of the vruntime over long period of time seems to
still be slightly upward, which means that eventually it does reach
a point where "user.slice" becomes eligible again, but due to the
vruntime constantly snapping back down, this can take extremely long
time. During all that time the "user.slice" is never picked by the
scheduler causing the starvation. Introducing even more threads to
"user.slice" of the affected core seems to somehow fix the math and
release the blockage, but it varies how many such treads are needed
(they hang too if they don't manage to fix it).

After coming up with this theory, I noticed that the scheduler in
7.1 was changed to not call the place_entity() the same way anymore.
With a trivial backport (I think there was some difference in the
division operation) of the patch mentioned at the beginning of this
mail on top of 6.18.y, we could not reproduce the starvation anymore.

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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-23  7:14 Please backport 101f3498b4bd to 6.18.y Janne Huttunen (Nokia)
2026-07-24 11:22 ` Sasha Levin
2026-07-24 12:58   ` Janne Huttunen (Nokia)
2026-07-26 12:04     ` Sasha Levin

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