linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Muchun Song <songmuchun@bytedance.com>,
	Oscar Salvador <osalvador@suse.de>
Cc: "Jonathan Corbet" <corbet@lwn.net>,
	"Mike Kravetz" <mike.kravetz@oracle.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Ingo Molnar" <mingo@redhat.com>,
	bp@alien8.de, "X86 ML" <x86@kernel.org>,
	hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	paulmck@kernel.org, mchehab+huawei@kernel.org,
	pawan.kumar.gupta@linux.intel.com,
	"Randy Dunlap" <rdunlap@infradead.org>,
	oneukum@suse.com, anshuman.khandual@arm.com, jroedel@suse.de,
	"Mina Almasry" <almasrymina@google.com>,
	"David Rientjes" <rientjes@google.com>,
	"Matthew Wilcox" <willy@infradead.org>,
	"Michal Hocko" <mhocko@suse.com>,
	"Song Bao Hua (Barry Song)" <song.bao.hua@hisilicon.com>,
	"HORIGUCHI NAOYA(堀口 直也)" <naoya.horiguchi@nec.com>,
	"Joao Martins" <joao.m.martins@oracle.com>,
	"Xiongchun duan" <duanxiongchun@bytedance.com>,
	linux-doc@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	"Linux Memory Management List" <linux-mm@kvack.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	"Miaohe Lin" <linmiaohe@huawei.com>,
	"Chen Huang" <chenhuang5@huawei.com>,
	"Bodeddula Balasubramaniam" <bodeddub@amazon.com>
Subject: Re: [External] Re: [PATCH v19 7/8] mm: hugetlb: add a kernel parameter hugetlb_free_vmemmap
Date: Fri, 19 Mar 2021 13:36:18 +0100	[thread overview]
Message-ID: <e9af16bb-2296-c9fb-976f-f99472490940@redhat.com> (raw)
In-Reply-To: <CAMZfGtXAgcJQp59AVuieqLT+1Qb3RGQmFK-SGNZH-T6K83Y=HQ@mail.gmail.com>

On 19.03.21 13:15, Muchun Song wrote:
> On Fri, Mar 19, 2021 at 4:59 PM Oscar Salvador <osalvador@suse.de> wrote:
>>
>> On Mon, Mar 15, 2021 at 05:20:14PM +0800, Muchun Song wrote:
>>> --- a/arch/x86/mm/init_64.c
>>> +++ b/arch/x86/mm/init_64.c
>>> @@ -34,6 +34,7 @@
>>>   #include <linux/gfp.h>
>>>   #include <linux/kcore.h>
>>>   #include <linux/bootmem_info.h>
>>> +#include <linux/hugetlb.h>
>>>
>>>   #include <asm/processor.h>
>>>   #include <asm/bios_ebda.h>
>>> @@ -1557,7 +1558,8 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
>>>   {
>>>        int err;
>>>
>>> -     if (end - start < PAGES_PER_SECTION * sizeof(struct page))
>>> +     if ((is_hugetlb_free_vmemmap_enabled()  && !altmap) ||
>>> +         end - start < PAGES_PER_SECTION * sizeof(struct page))
>>>                err = vmemmap_populate_basepages(start, end, node, NULL);
>>>        else if (boot_cpu_has(X86_FEATURE_PSE))
>>>                err = vmemmap_populate_hugepages(start, end, node, altmap);
>>
>> I've been thinking about this some more.
>>
>> Assume you opt-in the hugetlb-vmemmap feature, and assume you pass a valid altmap
>> to vmemmap_populate.
>> This will lead to use populating the vmemmap array with hugepages.
> 
> Right.
> 
>>
>> What if then, a HugeTLB gets allocated and falls within that memory range (backed
>> by hugetpages)?
> 
> I am not sure whether we can allocate the HugeTLB pages from there.
> Will only device memory pass a valid altmap parameter to
> vmemmap_populate()? If yes, can we allocate HugeTLB pages from
> device memory? Sorry, I am not an expert on this.

I think, right now, yes. System RAM that's applicable for HugePages 
never uses an altmap. But Oscar's patch will change that, maybe before 
your series might get included from what I've been reading. [1]

[1] https://lkml.kernel.org/r/20210319092635.6214-1-osalvador@suse.de

> 
> 
>> AFAIK, this will get us in trouble as currently the code can only operate on memory
>> backed by PAGE_SIZE pages, right?
>>
>> I cannot remember, but I do not think nothing prevents that from happening?
>> Am I missing anything?
> 
> Maybe David H is more familiar with this.
> 
> Hi David,
> 
> Do you have some suggestions on this?

There has to be some way to identify whether we can optimize specific 
vmemmap pages or should just leave them alone. altmap vs. !altmap.

Unfortunately, there is no easy way to detect that - e.g., 
PageReserved() applies also to boot memory.

We could go back to setting a special PageType for these vmemmap pages, 
indicating "this is a page allocated from an altmap, don't touch it".

-- 
Thanks,

David / dhildenb



  reply	other threads:[~2021-03-19 12:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210315092015.35396-1-songmuchun@bytedance.com>
     [not found] ` <20210315092015.35396-8-songmuchun@bytedance.com>
2021-03-19  8:59   ` [PATCH v19 7/8] mm: hugetlb: add a kernel parameter hugetlb_free_vmemmap Oscar Salvador
2021-03-19 12:15     ` [External] " Muchun Song
2021-03-19 12:36       ` David Hildenbrand [this message]
2021-03-19 12:42         ` David Hildenbrand

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=e9af16bb-2296-c9fb-976f-f99472490940@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=almasrymina@google.com \
    --cc=anshuman.khandual@arm.com \
    --cc=bodeddub@amazon.com \
    --cc=bp@alien8.de \
    --cc=chenhuang5@huawei.com \
    --cc=corbet@lwn.net \
    --cc=dave.hansen@linux.intel.com \
    --cc=duanxiongchun@bytedance.com \
    --cc=hpa@zytor.com \
    --cc=joao.m.martins@oracle.com \
    --cc=jroedel@suse.de \
    --cc=linmiaohe@huawei.com \
    --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=naoya.horiguchi@nec.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).