Re: [PATCH 0/1] sched: Restore PREEMPT_NONE as default
From: David Laight
Date: Tue Apr 07 2026 - 06:19:08 EST
On Sun, 5 Apr 2026 10:09:35 -0400
Andres Freund <andres@xxxxxxxxxxx> wrote:
...
> FWIW, from what I can tell, the whole "WHAA, it's a userspace spinlock" part
> has just about nothing to do with the problem. My understanding is that
> default futexes don't transfer the lock waiter's scheduler slice to the lock
> holder (there's no information about who the lock holder is unless it's a PI
> futex), Postgres' spinlock have randomized exponential backoff and the amount
> of spinning is adjusted over time, so you don't actually end up with spinlock
> waiters preventing the lock owner from getting scheduled to a significant
> degree.
Another problem (which also affects futex) is that the lock holder can
get preempted (or just stolen by network interrupts and softint code).
So even if the lock is only held for a few instructions sometimes that can
take several milliseconds.
Pretty much the only way to avoid that is changing the code to be lockless.
(eg changing linked lists to arrays and using atmomic_increment() on a index.)
A much more subtle effect can also affect performance - especially of a
single-threaded cpu-intensive program.
The clock speed of the busy cpu will be boosted (perhaps to 5GHz).
Then a lot of other higher priority processes are all scheduled at the
same time, the cpu-intensive program is preempted.
When the the high priority processes sleep (perhaps almost immediately)
the cpu-intensive program is scheduled on a 'random' cpu that has
been idle so runs at initially (say) 800MHz, before being boosted again.
That effect increased the compile time for an fpga image from ~10 minutes
to ~20 minutes when the renaming of a kernel config option caused one of
the mitigations that significantly slow down system call entry/exit to
slow down an idle daemon than woke threads every 10ms (to process RTP
audio) so that all the threads were active at the same time.
David
>
> Greetings,
>
> Andres Freund
>