Re: [PATCH 0/9 RFC] Make wake_up_{bit,var} less fragile
From: Linus Torvalds
Date: Tue Aug 20 2024 - 17:58:35 EST
On Tue, 20 Aug 2024 at 14:47, NeilBrown <neilb@xxxxxxx> wrote:
>
> I can definitely get behind the idea has having a few more helpers and
> using them more widely. But unless we get rid of wake_up_bit(), people
> will still use and some will use it wrongly.
I do not believe this is a valid argument.
"We have interfaces that somebody can use wrongly" is a fact of life,
not an argument.
The whole "wake_up_bit()" is a very special thing, and dammit, if
people don't know the rules, then they shouldn't be using it.
Anybody using that interface *ALREADY* has to have some model of
atomicity for the actual bit they are changing. And yes, they can get
that wrong too.
The only way to actually make it a simple interface is to do the bit
operation and the wakeup together. Which is why I think that
interfaces like clear_bit_and_wake() or set_bit_and_wake() are fine,
because at that point you actually have a valid rule for the whole
operation.
But wake_up_bit() on its own ALREADY depends on the user doing the
right thing for the bit itself. Putting a memory barrier in it will
only *HIDE* incompetence, it won't be fixing it.
So no. Don't add interfaces that hide the problem.
Linus