Re: [PATCH] workqueue: Fix memory ordering race in queue_work*()

From: Linus Torvalds
Date: Tue Aug 16 2022 - 12:59:22 EST


On Tue, Aug 16, 2022 at 9:22 AM Hector Martin <marcan@xxxxxxxxx> wrote:
>
> It's worth pointing out that the workqueue code does *not* pair
> test_and_set_bit() with clear_bit(). It does an atomic_long_set()
> instead

Yes. That code is much too subtle.

And yes, I think those barriers are

(a) misleading

(b) don't work with the "serialize bits using spinlock" model at all

It's a good example of "we need to really have a better model for this".

Linus