Re: [PATCH v3 1/2] wait_bit: do read barrier after testing a bit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Sun, 31 Jul 2022, Linus Torvalds wrote:

> On Sun, Jul 31, 2022 at 1:41 PM Mikulas Patocka <mpatocka@xxxxxxxxxx> wrote:
> >
> > -       if (!test_bit(bit, word))
> > +       if (!test_bit(bit, word)) {
> > +               smp_rmb();
> 
> Logically, I don't think that makes sense.
> 
> Maybe you're checking the buffer being up-to-date before you *write* to it?

None of the CPUs have speculative writes - so the write can't be moved 
before the "test_bit" function. So, we are only concerned about reads.

> So smp_rmb() seems entirely wrong.
> 
> I think it should consistently aim for just doing
> 
>         unsigned long state = smp_read_acquire(word);
>         if (!(state & (1 << bit)))
>                 return 0;
> 
> or whatever.
> 
> We should strive to *not* add new uses of the legacy memory barriers.
> They are garbage from last century when people didn't know better.
> 
> Then people learnt to use acquire and release, and things improved.
> Let's live in that improved world.
> 
>                  Linus

OK - I'm sending new patches that introduce the function test_bit_acquire.

Mikulas




[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux