[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <D2B8146D-0A41-4722-9E25-9D3F818C86C9@linux.dev>
Date: Tue, 5 Dec 2023 10:46:52 +0800
From: Muchun Song <muchun.song@...ux.dev>
To: Mike Kravetz <mike.kravetz@...cle.com>
Cc: Muchun Song <songmuchun@...edance.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Linux-MM <linux-mm@...ck.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/4] mm: hugetlb_vmemmap: move PageVmemmapSelfHosted()
check to split_vmemmap_huge_pmd()
> On Dec 5, 2023, at 07:27, Mike Kravetz <mike.kravetz@...cle.com> wrote:
>
> On 11/27/23 16:46, Muchun Song wrote:
>> To check a page whether it is self-hosted needs to traverse the page table (e.g.
>> pmd_off_k()), however, we already have done this in the next calling of
>> vmemmap_remap_range(). Moving PageVmemmapSelfHosted() check to vmemmap_pmd_entry()
>> could simplify the code a bit.
>>
>> Signed-off-by: Muchun Song <songmuchun@...edance.com>
>> ---
>> mm/hugetlb_vmemmap.c | 70 +++++++++++++++-----------------------------
>> 1 file changed, 24 insertions(+), 46 deletions(-)
>>
>> diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
>> index ef14356855d13..ce920ca6c90ee 100644
>> --- a/mm/hugetlb_vmemmap.c
>> +++ b/mm/hugetlb_vmemmap.c
>> @@ -95,6 +95,7 @@ static int vmemmap_split_pmd(pmd_t *pmd, struct page *head, unsigned long start,
>> static int vmemmap_pmd_entry(pmd_t *pmd, unsigned long addr,
>> unsigned long next, struct mm_walk *walk)
>> {
>> + int ret = 0;
>> struct page *head;
>> struct vmemmap_remap_walk *vmemmap_walk = walk->private;
>>
>> @@ -104,9 +105,30 @@ static int vmemmap_pmd_entry(pmd_t *pmd, unsigned long addr,
>>
>> spin_lock(&init_mm.page_table_lock);
>> head = pmd_leaf(*pmd) ? pmd_page(*pmd) : NULL;
>
> I was going to ask why you dropped the:
> if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG))
> However, without the extra page table reads it really is not necessary.
I thought the compiler is smart enough to find out this code
is unnecessary so that it will be dropped. But I am wrong,
I did a test showing the compiler does optimize the code
when CONFIG_MEMORY_HOTPLUG is disabled, but it is not
enough compared with adding the check of "IS_ENABLED(CONFIG_MEMORY_HOTPLUG)".
I will add the check back in a separate patch (I suspect it is easy
for Andrew to merge).
>
> Reviewed-by: Mike Kravetz <mike.kravetz@...cle.com>
Thanks.
> --
> Mike Kravetz
Powered by blists - more mailing lists