[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5f363b58-f70a-4a6a-9761-aae93cb49138@oracle.com>
Date: Thu, 29 Apr 2021 16:19:40 -0700
From: Mike Kravetz <mike.kravetz@...cle.com>
To: Muchun Song <songmuchun@...edance.com>
Cc: Jonathan Corbet <corbet@....net>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, bp@...en8.de,
X86 ML <x86@...nel.org>, hpa@...or.com,
dave.hansen@...ux.intel.com, luto@...nel.org,
Peter Zijlstra <peterz@...radead.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
Andrew Morton <akpm@...ux-foundation.org>, paulmck@...nel.org,
pawan.kumar.gupta@...ux.intel.com,
Randy Dunlap <rdunlap@...radead.org>, oneukum@...e.com,
anshuman.khandual@....com, jroedel@...e.de,
Mina Almasry <almasrymina@...gle.com>,
David Rientjes <rientjes@...gle.com>,
Matthew Wilcox <willy@...radead.org>,
Oscar Salvador <osalvador@...e.de>,
Michal Hocko <mhocko@...e.com>,
"Song Bao Hua (Barry Song)" <song.bao.hua@...ilicon.com>,
David Hildenbrand <david@...hat.com>,
HORIGUCHI NAOYA(堀口 直也)
<naoya.horiguchi@....com>,
Joao Martins <joao.m.martins@...cle.com>,
Xiongchun duan <duanxiongchun@...edance.com>,
fam.zheng@...edance.com, zhengqi.arch@...edance.com,
linux-doc@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
Linux Memory Management List <linux-mm@...ck.org>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>
Subject: Re: [External] Re: [PATCH v21 0/9] Free some vmemmap pages of HugeTLB
page
On 4/29/21 3:23 PM, Mike Kravetz wrote:
> On 4/28/21 9:02 PM, Muchun Song wrote:
>> On Thu, Apr 29, 2021 at 10:32 AM Mike Kravetz <mike.kravetz@...cle.com> wrote:
>>>
>>> On 4/28/21 5:26 AM, Muchun Song wrote:
>>>> On Wed, Apr 28, 2021 at 7:47 AM Mike Kravetz <mike.kravetz@...cle.com> wrote:
>>>>>
>>>>> Thanks! I will take a look at the modifications soon.
>>>>>
>>>>> I applied the patches to Andrew's mmotm-2021-04-21-23-03, ran some tests and
>>>>> got the following warning. We may need to special case that call to
>>>>> __prep_new_huge_page/free_huge_page_vmemmap from alloc_and_dissolve_huge_page
>>>>> as it is holding hugetlb lock with IRQs disabled.
>>>>
>>>> Good catch. Thanks Mike. I will fix it in the next version. How about this:
>>>>
>>>> @@ -1618,7 +1617,8 @@ static void __prep_new_huge_page(struct hstate
>>>> *h, struct page *page)
>>>>
>>>> static void prep_new_huge_page(struct hstate *h, struct page *page, int nid)
>>>> {
>>>> + free_huge_page_vmemmap(h, page);
>>>> __prep_new_huge_page(page);
>>>> spin_lock_irq(&hugetlb_lock);
>>>> __prep_account_new_huge_page(h, nid);
>>>> spin_unlock_irq(&hugetlb_lock);
>>>> @@ -2429,6 +2429,7 @@ static int alloc_and_dissolve_huge_page(struct
>>>> hstate *h, struct page *old_page,
>>>> if (!new_page)
>>>> return -ENOMEM;
>>>>
>>>> + free_huge_page_vmemmap(h, new_page);
>>>> retry:
>>>> spin_lock_irq(&hugetlb_lock);
>>>> if (!PageHuge(old_page)) {
>>>> @@ -2489,7 +2490,7 @@ static int alloc_and_dissolve_huge_page(struct
>>>> hstate *h, struct page *old_page,
>>>>
>>>> free_new:
>>>> spin_unlock_irq(&hugetlb_lock);
>>>> - __free_pages(new_page, huge_page_order(h));
>>>> + update_and_free_page(h, new_page, false);
>>>>
>>>> return ret;
>>>> }
>>>>
>>>>
>>>
>>> Another option would be to leave the prep* routines as is and only
>>> modify alloc_and_dissolve_huge_page as follows:
>>
>> OK. LGTM. I will use this. Thanks Mike.
>
> There are issues with my suggested patch below. I am occasionally
> hitting the BUG that checks for page ref count being zero at put_page
> time. Still do not fully understand, but I do not hit the same BUG
> with your patch above. Please do not use my patch below.
>
Ah! The issue is pretty obvious.
> @@ -2489,7 +2489,7 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page,
>
> free_new:
> spin_unlock_irq(&hugetlb_lock);
> - __free_pages(new_page, huge_page_order(h));
> + update_and_free_page(h, old_page, false);
That should of course be:
update_and_free_page(h, new_page, false);
>
> return ret;
> }
>
--
Mike Kravetz
Powered by blists - more mailing lists