Re: [PATCH] list: Remove unnecessary WRITE_ONCE()

From: Alan Huang
Date: Mon Jun 19 2023 - 07:39:23 EST



> 2023年6月19日 19:02,Eric Dumazet <edumazet@xxxxxxxxxx> 写道:
>
> On Mon, Jun 19, 2023 at 11:03 AM Alan Huang <mmpgouride@xxxxxxxxx> wrote:
>>
>> Commit c54a2744497d("list: Add hlist_unhashed_lockless()") added
>> various WRITE_ONCE() to pair with the READ_ONCE() in
>> hlist_unhashed_lockless(), but there is no need to protect
>> ->next with WRITE_ONCE(). Therefore, this commit removes those
>> unnecessary WRITE_ONCE().
>
> Why are they unnecessary ?

There is no reader locklessly read ->next.

These functions are protected by something like spin_lock, only the thread running
the function can access ->next.

> They seem just fine to me.
> Please elaborate.