Messages in this thread | | | From | Linus Torvalds <> | Date | Sun, 31 Jul 2022 13:51:21 -0700 | Subject | Re: [PATCH v3 2/2] make buffer_locked provide an acquire semantics |
| |
On Sun, Jul 31, 2022 at 1:43 PM Mikulas Patocka <mpatocka@redhat.com> wrote: > > + > +static __always_inline int buffer_locked(const struct buffer_head *bh) > +{ > + unsigned long state = smp_load_acquire(&bh->b_state); > + return test_bit(BH_Lock, &state);
This should not use 'test_bit()'. I suspect that generates horrendous code, because it's a volatile access, so now you'll load it into a register, and I suspect it will generate s pointless spill just to do a volatile load.
I didn't check.
So once you've loaded b_state, just test the bit directly with
return (state & (1u << BH_Lock)) != 0;
or whatever.
Linus
| |