|
|
Subscribe / Log in / New account

Revisiting the kernel's preemption models (part 1)

Revisiting the kernel's preemption models (part 1)

Posted Sep 21, 2023 20:49 UTC (Thu) by geofft (subscriber, #59789)
In reply to: Revisiting the kernel's preemption models (part 1) by mtodorov
Parent article: Revisiting the kernel's preemption models (part 1)

It sounds like the reason it isn't possible is that code is compiled differently, e.g. "even most spinlocks become preemptible" - in fact they are no longer spinlocks at all, but relatively normal locks where waiting code sleeps (yields to another process) instead of spinning: https://wiki.linuxfoundation.org/realtime/documentation/t...

So you can't really convert this in a running system, because locks can be held at any time. You'd have to acquire the spinlock (which can block), then turn it into a sleeping lock, then figure out who's been spinning on the spinlock while you held it and somehow convert them. For a use case like going into battle, even if this were technically possible, having the mode switch require acquiring every lock in the system isn't acceptable because it could take indefinitely long. (And even if it weren't for this, there would be an ongoing performance cost in both modes in order to support checking what mode you're in and so forth, meaning that performance will never be as good as a pure real-time or pure non-real-time kernel.)


to post comments

Revisiting the kernel's preemption models (part 1)

Posted Sep 21, 2023 21:26 UTC (Thu) by mtodorov (guest, #158788) [Link]

I see your point. It could be reduced to checking a single variable telling which mode the system is currently in.

The locks which are currently held in a non-preemptible mode are obviously going to be held, but the idea behind locking is that it is short-held for performance reasons anyway.

I recall the kernel NMI timeouts on i.e. RCU locks being held for 20 seconds, but IMHO that is a sign of something deeply wrong in the kernel code ...

However, I have given up the idea that I will ever understand fully how +32M lines of code work and inter-operate.

Spinlocks are the idea of waiting from 6502 and Z80 and I think they're evil.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds