On 12/12/24 10:15, Vlastimil Babka wrote: > On 12/12/24 03:49, Alexei Starovoitov wrote: >> I like your >> +struct local_tryirq_lock >> approach, but let's put it in local_lock.h ? > > Sure, that was a proof of concept so kept it local. > >> and it probably needs local_inc_return() instead of READ/WRITE_ONCE. >> With irq and nmis it's racy. > > Hm guess you are right, thanks! > Ah I remember now, the idea was that if an irq or nmi interrupts someone else between checking that active is 0 and setting it to 1, it will finish the critical section and unlock before the interrupted context can continue, so the race is harmless.