Re: [PATCH] mm: hugetlb_vmemmap: fix a race between vmemmap pmd split

From: Muchun Song
Date: Fri Jul 07 2023 - 21:41:20 EST




> On Jul 8, 2023, at 03:41, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Fri, 7 Jul 2023 11:38:59 +0800 Muchun Song <songmuchun@xxxxxxxxxxxxx> wrote:
>
>> And inline __split_vmemmap_huge_pmd()
>> since it only has one user.
>
> "open code" would be a better term than "inline" in this situation.
>
> If we are to offer this change to -stable then it would be better to do
> the open-coding of __split_vmemmap_huge_pmd() in a separate, later
> patch.
>

I see. Bug fix is better to "open code" instead of "inline". However, it
is a simpler and cleaner way to fix this bug by using "inline". Because
we must hold init_mm.page_table_lock to get the page table page in __split_vmemmap_huge_pmd(), then it is just a couple of duplicated
code from split_vmemmap_huge_pmd(). Consequently, split_vmemmap_huge_pmd()
is redundant, just remove it. And rename __split_vmemmap_huge_pmd()
to split_vmemmap_huge_pmd(). The result is the same as the "inline" way.
So I keep "inline" to fix this.

Thanks.