On Fri, Oct 14, 2022 at 08:01:29AM -0400, Elad Lahav wrote: > Hello, > > I'm not sure about the statement made in this section: "In contrast, > Linux avoids these hints, in- > stead getting similar results from a mechanism called futexes". > Futexes are just wrappers around kernel mutexes, to speed up the case > of acquiring a free lock. As such they do not solve the priority > inversion problem, and are certainly not a replacement for disabling > pre-emption when using spin locks. > Kernel-level mutexes may address priority inversion by employing one > of the established protocols (priority inheritance or priority > protection). > > Am I missing something? Futexes were the response of the Linux kernel community to the request from certain large database vendors for the ability to disable preemption in userspace applications. I was there and I heard it with my own ears, but to your point I find little on the web to back this up. In fact, I am not easily finding the fact that most proprietary UNIX kernels did in fact have userspace disable-preemption hints. Futexes are more a sleep/wakeup mechanism than a wrapper around mutexes, though there was a hilarious bug early on that allowed a usermode application to force a kernel-mode deadlock. The semantics are involved, a fact being driven home to those attempting to standardize it. How about the following change? This documents futexes as the response to the request for scheduler-conscious synchronization, but does not claim anything beyond that. Thanx, Paul ------------------------------------------------------------------------ commit 63c4deb868d5eec9df96fd8810e58e1519abb392 Author: Paul E. McKenney <paulmck@xxxxxxxxxx> Date: Wed Oct 19 15:14:03 2022 -0700 locking: Avoid over-claiming for futexes It is true that futexes were the response of the Linux-kernel community to requests for user-mode disabling of preemption, but it is not clear how futexes were evaluated by those making the requests. Reported-by: Elad Lahav <e2lahav@xxxxxxxxx> Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxx> diff --git a/locking/locking.tex b/locking/locking.tex index b138cd59..6d3bb1c8 100644 --- a/locking/locking.tex +++ b/locking/locking.tex @@ -2057,8 +2057,9 @@ being placed in a machine register. These hints frequently take the form of a bit set in a particular machine register, which enables extremely low per-lock-acquisition overhead for these mechanisms. -In contrast, Linux avoids these hints, instead getting -similar results from a mechanism called +In contrast, Linux avoids these hints. +Instead, the Linux kernel community's response to requests for +scheduler-conscious synchronization was a mechanism called \emph{futexes}~\cite{HubertusFrancke2002Futex,IngoMolnar2006RobustFutexes,StevenRostedt2006piFutexes,UlrichDrepper2011Futexes}. Interestingly enough, atomic instructions are not strictly needed to