linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Oscar Salvador <osalvador@suse.de>
Cc: Muchun Song <songmuchun@bytedance.com>,
	corbet@lwn.net, mike.kravetz@oracle.com, tglx@linutronix.de,
	mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com,
	dave.hansen@linux.intel.com, luto@kernel.org,
	peterz@infradead.org, viro@zeniv.linux.org.uk,
	akpm@linux-foundation.org, paulmck@kernel.org,
	mchehab+huawei@kernel.org, pawan.kumar.gupta@linux.intel.com,
	rdunlap@infradead.org, oneukum@suse.com,
	anshuman.khandual@arm.com, jroedel@suse.de,
	almasrymina@google.com, rientjes@google.com, willy@infradead.org,
	mhocko@suse.com, song.bao.hua@hisilicon.com, david@redhat.com,
	duanxiongchun@bytedance.com, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v8 06/12] mm/hugetlb: Allocate the vmemmap pages associated with each HugeTLB page
Date: Fri, 11 Dec 2020 11:52:52 +0100	[thread overview]
Message-ID: <58B0C89E-DD34-4D59-83A4-5DAAF0D617AE@redhat.com> (raw)
In-Reply-To: <20201211093517.GA22210@linux>


> Am 11.12.2020 um 10:35 schrieb Oscar Salvador <osalvador@suse.de>:
> 
> On Thu, Dec 10, 2020 at 11:55:20AM +0800, Muchun Song wrote:
>> When we free a HugeTLB page to the buddy allocator, we should allocate the
>> vmemmap pages associated with it. We can do that in the __free_hugepage()
> "vmemmap pages that describe the range" would look better to me, but it is ok.
> 
>> +#define GFP_VMEMMAP_PAGE        \
>> +    (GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_HIGH | __GFP_NOWARN)
>> 
>> #ifndef VMEMMAP_HPAGE_SHIFT
>> #define VMEMMAP_HPAGE_SHIFT        HPAGE_SHIFT
>> @@ -197,6 +200,11 @@
>>    (__boundary - 1 < (end) - 1) ? __boundary : (end);         \
>> })
>> 
>> +typedef void (*vmemmap_remap_pte_func_t)(struct page *reuse, pte_t *pte,
>> +                     unsigned long start, unsigned long end,
>> +                     void *priv);
> 
> Any reason to not have defined GFP_VMEMMAP_PAGE and the new typedef into
> hugetlb_vmemmap.h?
> 
> 
>> +static void vmemmap_restore_pte_range(struct page *reuse, pte_t *pte,
>> +                      unsigned long start, unsigned long end,
>> +                      void *priv)
>> +{
>> +    pgprot_t pgprot = PAGE_KERNEL;
>> +    void *from = page_to_virt(reuse);
>> +    unsigned long addr;
>> +    struct list_head *pages = priv;
> [...]
>> +
>> +        /*
>> +         * Make sure that any data that writes to the @to is made
>> +         * visible to the physical page.
>> +         */
>> +        flush_kernel_vmap_range(to, PAGE_SIZE);
> 
> Correct me if I am wrong, but flush_kernel_vmap_range is a NOOP under arches which
> do not have ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE.
> Since we only enable support for x86_64, and x86_64 is one of those arches,
> could we remove this, and introduced later on in case we enable this feature
> on an arch that needs it?
> 
> I am not sure if you need to flush the range somehow, as you did in
> vmemmap_remap_range.
> 
>> +retry:
>> +        page = alloc_page(GFP_VMEMMAP_PAGE);
>> +        if (unlikely(!page)) {
>> +            msleep(100);
>> +            /*
>> +             * We should retry infinitely, because we cannot
>> +             * handle allocation failures. Once we allocate
>> +             * vmemmap pages successfully, then we can free
>> +             * a HugeTLB page.
>> +             */
>> +            goto retry;
> 
> I think this is the trickiest part.
> With 2MB HugeTLB pages we only need 6 pages, but with 1GB, the number of pages
> we need to allocate increases significantly (4088 pages IIRC).
> And you are using __GFP_HIGH, which will allow us to use more memory (by
> cutting down the watermark), but it might lead to putting the system
> on its knees wrt. memory.
> And yes, I know that once we allocate the 4088 pages, 1GB gets freed, but
> still.

Similar to memory hotplug, no? I don‘t think this is really an issue that cannot be mitigated. Yeah, we might want to tweak allocation flags.

> 
> I would like to hear Michal's thoughts on this one, but I wonder if it makes
> sense to not let 1GB-HugeTLB pages be freed.
> 
> -- 
> Oscar Salvador
> SUSE L3
> 


  reply	other threads:[~2020-12-11 10:55 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-10  3:55 [PATCH v8 00/12] Free some vmemmap pages of HugeTLB page Muchun Song
2020-12-10  3:55 ` [PATCH v8 01/12] mm/memory_hotplug: Factor out bootmem core functions to bootmem_info.c Muchun Song
2020-12-10  3:55 ` [PATCH v8 02/12] mm/hugetlb: Introduce a new config HUGETLB_PAGE_FREE_VMEMMAP Muchun Song
2020-12-10  3:55 ` [PATCH v8 03/12] mm/bootmem_info: Introduce free_bootmem_page helper Muchun Song
2020-12-10 14:15   ` Oscar Salvador
2020-12-10 15:22     ` [External] " Muchun Song
2020-12-10 15:26       ` Muchun Song
2020-12-10  3:55 ` [PATCH v8 04/12] mm/hugetlb: Free the vmemmap pages associated with each HugeTLB page Muchun Song
2020-12-10 14:42   ` Oscar Salvador
2020-12-10 14:44     ` Oscar Salvador
2020-12-10 15:58       ` [External] " Muchun Song
2020-12-10 15:57     ` Muchun Song
2020-12-10  3:55 ` [PATCH v8 05/12] mm/hugetlb: Defer freeing of HugeTLB pages Muchun Song
2020-12-10  3:55 ` [PATCH v8 06/12] mm/hugetlb: Allocate the vmemmap pages associated with each HugeTLB page Muchun Song
2020-12-11  9:35   ` Oscar Salvador
2020-12-11 10:52     ` David Hildenbrand [this message]
2020-12-11 13:01     ` [External] " Muchun Song
2020-12-10  3:55 ` [PATCH v8 07/12] mm/hugetlb: Set the PageHWPoison to the raw error page Muchun Song
2020-12-10 11:11   ` Muchun Song
2020-12-11 13:36   ` Oscar Salvador
2020-12-11 14:08     ` [External] " Muchun Song
2020-12-10  3:55 ` [PATCH v8 08/12] mm/hugetlb: Flush work when dissolving hugetlb page Muchun Song
2020-12-10  3:55 ` [PATCH v8 09/12] mm/hugetlb: Add a kernel parameter hugetlb_free_vmemmap Muchun Song
2020-12-10 10:04   ` Oscar Salvador
2020-12-10 12:26     ` [External] " Muchun Song
2020-12-10  3:55 ` [PATCH v8 10/12] mm/hugetlb: Introduce nr_free_vmemmap_pages in the struct hstate Muchun Song
2020-12-10 10:15   ` Oscar Salvador
2020-12-10 12:32     ` [External] " Muchun Song
2020-12-10  3:55 ` [PATCH v8 11/12] mm/hugetlb: Gather discrete indexes of tail page Muchun Song
2020-12-10  3:55 ` [PATCH v8 12/12] mm/hugetlb: Optimize the code with the help of the compiler Muchun Song
2020-12-10 10:25   ` Oscar Salvador
2020-12-10 12:14     ` [External] " Muchun Song
2020-12-10 13:16       ` Oscar Salvador
2020-12-10 13:29         ` Muchun Song
2020-12-10 16:19           ` Muchun Song
2020-12-10  9:18 ` [PATCH v8 00/12] Free some vmemmap pages of HugeTLB page Oscar Salvador

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=58B0C89E-DD34-4D59-83A4-5DAAF0D617AE@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=almasrymina@google.com \
    --cc=anshuman.khandual@arm.com \
    --cc=bp@alien8.de \
    --cc=corbet@lwn.net \
    --cc=dave.hansen@linux.intel.com \
    --cc=duanxiongchun@bytedance.com \
    --cc=hpa@zytor.com \
    --cc=jroedel@suse.de \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@kernel.org \
    --cc=mchehab+huawei@kernel.org \
    --cc=mhocko@suse.com \
    --cc=mike.kravetz@oracle.com \
    --cc=mingo@redhat.com \
    --cc=oneukum@suse.com \
    --cc=osalvador@suse.de \
    --cc=paulmck@kernel.org \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=peterz@infradead.org \
    --cc=rdunlap@infradead.org \
    --cc=rientjes@google.com \
    --cc=song.bao.hua@hisilicon.com \
    --cc=songmuchun@bytedance.com \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).