Re: [RFC PATCH] fanotify: wake-up all waiters on release
From: Sergey Senozhatsky
Date: Mon Jun 23 2025 - 11:22:46 EST
On (25/06/23 12:52), Jan Kara wrote:
> > My another silly idea was, fsnotify_put_mark_wake() is called in a loop
> > and it tests group->shutdown locklessly, as far as I can tell, so maybe
> > there is a speculative load and we use stale/"cached" group->shutdown
> > value w/o ever waking up ->notification_waitq. Am running out of ideas.
>
> Well, but atomic_dec_and_test() in fsnotify_put_mark_wake() should be a
> full memory barrier so such reordering should not be possible?
You are right, as always. Generated code looks fine:
...
61f: f0 41 ff 4e 6c lock decl 0x6c(%r14)
624: 75 1f jne 645 <fsnotify_finish_user_wait+0x55>
626: 41 80 7e 44 01 cmpb $0x1,0x44(%r14)
62b: 75 18 jne 645 <fsnotify_finish_user_wait+0x55>
...
->shutdown fetch is always done after atomic-dec.