[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <83DBE074-0B63-4CB2-9BD2-65967977B69C@linux.dev>
Date: Sat, 27 Aug 2022 10:48:34 +0800
From: Muchun Song <muchun.song@...ux.dev>
To: Miaohe Lin <linmiaohe@...wei.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>, mike.kravetz@...cle.com,
Muchun Song <songmuchun@...edance.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 03/10] hugetlb: Use LIST_HEAD() to define a list head
> On Aug 27, 2022, at 10:27, Miaohe Lin <linmiaohe@...wei.com> wrote:
>
> On 2022/8/27 9:47, Muchun Song wrote:
>>
>>
>>> On Aug 26, 2022, at 17:24, Miaohe Lin <linmiaohe@...wei.com> wrote:
>>>
>>> We can avoid unneeded WRITE_ONCE() overhead by using LIST_HEAD() to define
>>> a list head.
>>
>> IIUC, the overhead doesn’t change. Right?
>
> I think the overhead is changed. LIST_HEAD is initialized without using WRITE_ONCE():
I think there is no special difference with "WRITE_ONCE(var, 0)" vs "var = 0” in
assembly code. Both code of line will be compiled to a mov or movq instruction.
I didn’t confirm if the assembly code is different (I tend to think it is similar).
Just some analysis from me.
>
> #define LIST_HEAD_INIT(name) { &(name), &(name) }
>
> #define LIST_HEAD(name) \
> struct list_head name = LIST_HEAD_INIT(name)
>
> while INIT_LIST_HEAD has:
>
> static inline void INIT_LIST_HEAD(struct list_head *list)
> {
> WRITE_ONCE(list->next, list);
> WRITE_ONCE(list->prev, list);
> }
>
> Or am I miss something?
>
>>
>> I’m fine with your changes.
>>
>> Reviewed-by: Muchun Song <songmuchun@...edance.com>
>
> Many thanks for your review and comment. :)
>
> Thanks,
> Miaohe Lin
>
Powered by blists - more mailing lists