News: 0001573881

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

Linux Scheduler Adapted For A Latency Win & Avoiding An RT Deadlock

([Linux Kernel] 5 Hours Ago Defer Throttle)


A patch series for the Linux kernel scheduler code is queued up for expected introduction in Linux 6.18 to defer throttle when tasks exit to user-space. These changes to switch the scheduler to a task-based throttle model and task-based throttle time accounting can provide a latency win and also address a possible deadlock situation for real-time "RT" kernels.

Queued up today in tip/tip.git's "sched/core" Git branch are the patches for reworking the scheduler code around throttling. The status quo issue is described in the patch cover letter of [1]defer throttle when task exits to user :

"CFS tasks can end up throttled while holding locks that other, non-throttled tasks are blocking on.

For !PREEMPT_RT, this can be a source of latency due to the throttling causing a resource acquisition denial.

For PREEMPT_RT, this is worse and can lead to a deadlock:

o A CFS task p0 gets throttled while holding read_lock(&lock)

o A task p1 blocks on write_lock(&lock), making further readers enter the slowpath

o A ktimers or ksoftirqd task blocks on read_lock(&lock)

...

To fix this issue for PREEMPT_RT and improve latency situation for !PREEMPT_RT, change the throttle model to task based, i.e. when a cfs_rq is throttled, mark its throttled status but do not remove it from cpu's rq. Instead, for tasks that belong to this cfs_rq, when they get picked, add a task work to them so that when they return to user, they can be dequeued. In this way, tasks throttled will not hold any kernel resources. When cfs_rq gets unthrottled, enqueue back those throttled tasks."

With these patches now [2]queued into the sched/core TIP branch, this task-based throttle model work should be merged for the upcoming Linux 6.18 merge window barring no objections from Linus Torvalds or other code issues from coming to light.



[1] https://lore.kernel.org/all/20250829081120.806-1-ziqianlu@bytedance.com/

[2] https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/log/?h=sched/core



Kjell

varikonniemi

npwx

Volta

An Hacker there was, one of the finest sort
Who controlled the system; graphics was his sport.
A manly man, to be a wizard able;
Many a protected file he had sitting on his table.
His console, when he typed, a man might hear
Clicking and feeping wind as clear,
Aye, and as loud as does the machine room bell
Where my lord Hacker was Prior of the cell.
The Rule of good St Savage or St Doeppnor
As old and strict he tended to ignore;
He let go by the things of yesterday
And took the modern world's more spacious way.
He did not rate that text as a plucked hen
Which says that Hackers are not holy men.
And that a hacker underworked is a mere
Fish out of water, flapping on the pier.
That is to say, a hacker out of his cloister.
That was a text he held not worth an oyster.
And I agreed and said his views were sound;
Was he to study till his head wend round
Poring over books in the cloisters? Must he toil
As Andy bade and till the very soil?
Was he to leave the world upon the shelf?
Let Andy have his labor to himself!
-- Chaucer
[well, almost. Ed.]