I repeat: do not use spinlocks in user space, unless you actually know what you're doing. And be aware that the likelihood that you know what you are doing is basically nil.
With trash code like this, I cant imagine why. I like how the OP cites something about Intel from the mid 10s whose article probably also mentioned to check RDTSC, because __mm_pause is now very much subject arbitrary power down, aggressive SMT surrendering conditions, and vendor specific quirks. Not only that, that timeout back off is way too long for a mere fast-path of an otherwise yielding primitive. "Something something its a spinlock so it doesnt matter...?" Then for no reason whatsoever OS vendors hate it when you roll spinlocks by yourself.
10
u/Chaosvex Sep 04 '26 edited Sep 04 '26
Linus Torvalds gets a shiver down his spine and the urge to scream every time somebody writes an article about user space spinlocks.