linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: David Hildenbrand <david@redhat.com>,
	Mike Kravetz <mike.kravetz@oracle.com>
Cc: "linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
	"linux-ia64@vger.kernel.org" <linux-ia64@vger.kernel.org>,
	"Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>,
	Muchun Song <songmuchun@bytedance.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Naoya Horiguchi <naoya.horiguchi@linux.dev>
Subject: Re: [PATCH] hugetlb: simplify hugetlb handling in follow_page_mask
Date: Mon, 5 Sep 2022 09:33:29 +0000	[thread overview]
Message-ID: <ac9ef726-c465-ccec-363e-9cfb60c170e7@csgroup.eu> (raw)
In-Reply-To: <5f6a7c6b-5073-f050-8dae-6ee279a8bb0b@redhat.com>



Le 05/09/2022 à 10:37, David Hildenbrand a écrit :
> On 03.09.22 09:07, Christophe Leroy wrote:
>> +Resending with valid powerpc list address
>>
>> Le 02/09/2022 à 20:52, David Hildenbrand a écrit :
>>>>>> Adding Christophe on Cc:
>>>>>>
>>>>>> Christophe do you know if is_hugepd is true for all hugetlb 
>>>>>> entries, not
>>>>>> just hugepd?
>>
>> is_hugepd() is true if and only if the directory entry points to a huge
>> page directory and not to the normal lower level directory.
>>
>> As far as I understand if the directory entry is not pointing to any
>> lower directory but is a huge page entry, pXd_leaf() is true.
>>
>>
>>>>>>
>>>>>> On systems without hugepd entries, I guess ptdump skips all 
>>>>>> hugetlb entries.
>>>>>> Sigh!
>>
>> As far as I can see, ptdump_pXd_entry() handles the pXd_leaf() case.
>>
>>>>>
>>>>> IIUC, the idea of ptdump_walk_pgd() is to dump page tables even 
>>>>> outside
>>>>> VMAs (for debugging purposes?).
>>>>>
>>>>> I cannot convince myself that that's a good idea when only holding the
>>>>> mmap lock in read mode, because we can just see page tables getting
>>>>> freed concurrently e.g., during concurrent munmap() ... while holding
>>>>> the mmap lock in read we may only walk inside VMA boundaries.
>>>>>
>>>>> That then raises the questions if we're only calling this on 
>>>>> special MMs
>>>>> (e.g., init_mm) whereby we cannot really see concurrent munmap() and
>>>>> where we shouldn't have hugetlb mappings or hugepd entries.
>>
>> At least on powerpc, PTDUMP handles only init_mm.
>>
>> Hugepage are used at least on powerpc 8xx for linear memory mapping, see
>>
>> commit 34536d780683 ("powerpc/8xx: Add a function to early map kernel
>> via huge pages")
>> commit cf209951fa7f ("powerpc/8xx: Map linear memory with huge pages")
>>
>> hugepds may also be used in the future to use huge pages for vmap and
>> vmalloc, see commit a6a8f7c4aa7e ("powerpc/8xx: add support for huge
>> pages on VMAP and VMALLOC")
>>
>> As far as I know, ppc64 also use huge pages for VMAP and VMALLOC, see
>>
>> commit d909f9109c30 ("powerpc/64s/radix: Enable HAVE_ARCH_HUGE_VMAP")
>> commit 8abddd968a30 ("powerpc/64s/radix: Enable huge vmalloc mappings")
> 
> There is a difference between an ordinary huge mapping (e.g., as used 
> for THP) and a a hugetlb mapping.
> 
> Our current understanding is that hugepd only applies to hugetlb. 
> Wouldn't vmap/vmalloc user ordinary huge pmd entries instead of hugepd?
> 

'hugepd' stands for huge page directory. It is independant of whether a 
huge page is used for hugetlb or for anything else, it represents the 
way pages are described in the page tables.

I don't know what you mean by _ordinary_ huge pmd entry.

Let's take the exemple of powerpc 8xx which is the one I know best. This 
is a powerpc32, so it has two levels : PGD and PTE. PGD has 1024 entries 
and each entry covers a 4Mbytes area. Normal PTE has 1024 entries and 
each entry is a 4k page. When you use 8Mbytes pages, you don't use PTEs 
as it would be a waste of memory. You use a huge page directory that has 
a single entry, and you have two PGD entries pointing to the huge page 
directory.

Some time ago, hupgepd was also used for 512kbytes pages and 16kbytes 
pages:
- there was huge page directories with 8x 512kbytes pages,
- there was huge page directories with 256x 16kbytes pages,

And the PGD/PMD entry points to a huge page directory (HUGEPD) instead 
of pointing to a page table directory (PTE).

Since commit b250c8c08c79 ("powerpc/8xx: Manage 512k huge pages as 
standard pages."), the 8xx doesn't use anymore hugepd for 512k huge 
page, but other platforms like powerpc book3e extensively use huge page 
directories.

I hope this clarifies the subject, otherwise I'm happy to provide 
further details.

Christophe

  reply	other threads:[~2022-09-05  9:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220829234053.159158-1-mike.kravetz@oracle.com>
     [not found] ` <608934d4-466d-975e-6458-34a91ccb4669@redhat.com>
     [not found]   ` <Yw5AOZ/Kc5f3UP+s@monkey>
     [not found]     ` <Yw6Bpsow+gUMlHCU@monkey>
     [not found]       ` <739dc825-ece3-a59f-adc5-65861676e0ae@redhat.com>
     [not found]         ` <YxJQfGSsbXd3W4m/@monkey>
     [not found]           ` <323fdb0f-c5a5-e0e5-1ff4-ab971bc295cc@redhat.com>
2022-09-03  7:07             ` [PATCH] hugetlb: simplify hugetlb handling in follow_page_mask Christophe Leroy
2022-09-04 11:49               ` Michael Ellerman
2022-09-05  8:37               ` David Hildenbrand
2022-09-05  9:33                 ` Christophe Leroy [this message]
2022-09-05  9:46                   ` David Hildenbrand
2022-09-05 16:05                     ` Christophe Leroy
2022-09-05 16:09                       ` 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=ac9ef726-c465-ccec-363e-9cfb60c170e7@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@redhat.com \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mike.kravetz@oracle.com \
    --cc=naoya.horiguchi@linux.dev \
    --cc=songmuchun@bytedance.com \
    /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).