linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mike Kravetz <mike.kravetz@oracle.com>
To: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Muchun Song <songmuchun@bytedance.com>,
	Michal Hocko <mhocko@suse.com>, Peter Xu <peterx@redhat.com>,
	Naoya Horiguchi <naoya.horiguchi@linux.dev>,
	James Houghton <jthoughton@google.com>,
	Mina Almasry <almasrymina@google.com>,
	"Aneesh Kumar K . V" <aneesh.kumar@linux.vnet.ibm.com>,
	Anshuman Khandual <anshuman.khandual@arm.com>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [RFC PATCH 1/3] hugetlb: skip to end of PT page mapping when pte not present
Date: Wed, 15 Jun 2022 14:22:34 -0700	[thread overview]
Message-ID: <YqpNmsLrbCowS1IE@monkey> (raw)
In-Reply-To: <437e45c5-c46a-46f4-f9cf-d8c2397c988d@linux.alibaba.com>

On 05/30/22 18:10, Baolin Wang wrote:
> 
> 
> On 5/28/2022 6:58 AM, Mike Kravetz wrote:
> > HugeTLB address ranges are linearly scanned during fork, unmap and
> > remap operations.  If a non-present entry is encountered, the code
> > currently continues to the next huge page aligned address.  However,
> > a non-present entry implies that the page table page for that entry
> > is not present.  Therefore, the linear scan can skip to the end of
> > range mapped by the page table page.  This can speed operations on
> > large sparsely populated hugetlb mappings.
> > 
> > Create a new routine hugetlb_mask_last_hp() that will return an
> > address mask.  When the mask is ORed with an address, the result
> > will be the address of the last huge page mapped by the associated
> > page table page.  Use this mask to update addresses in routines which
> > linearly scan hugetlb address ranges when a non-present pte is
> > encountered.
> > 
> > hugetlb_mask_last_hp is related to the implementation of huge_pte_offset
> > as hugetlb_mask_last_hp is called when huge_pte_offset returns NULL.
> > This patch only provides a complete hugetlb_mask_last_hp implementation
> > when CONFIG_ARCH_WANT_GENERAL_HUGETLB is defined.  Architectures which
> > provide their own versions of huge_pte_offset can also provide their own
> > version of hugetlb_mask_last_hp.
> 
> I tested on my ARM64 machine with implementing arm64 specific
> hugetlb_mask_last_hp() as below, and it works well.
> 
> Just a few nits inline, otherwise looks good to me.
> Tested-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> 
> diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
> index d93ba128a2b0..e04a097ffcc4 100644
> --- a/arch/arm64/mm/hugetlbpage.c
> +++ b/arch/arm64/mm/hugetlbpage.c
> @@ -376,6 +376,28 @@ pte_t *huge_pte_offset(struct mm_struct *mm,
>         return NULL;
>  }
> 
> +unsigned long hugetlb_mask_last_hp(struct hstate *h)
> +{
> +       unsigned long hp_size = huge_page_size(h);
> +
> +       switch (hp_size) {
> +       case P4D_SIZE:
> +               return PGDIR_SIZE - P4D_SIZE;
> +       case PUD_SIZE:
> +               return P4D_SIZE - PUD_SIZE;
> +       case CONT_PMD_SIZE:
> +               return PUD_SIZE - CONT_PMD_SIZE;
> +       case PMD_SIZE:
> +               return PUD_SIZE - PMD_SIZE;
> +       case CONT_PTE_SIZE:
> +               return PMD_SIZE - CONT_PTE_SIZE;
> +       default:
> +               break;
> +       }
> +
> +       return ~(0UL);
> +}

Hello Baolin,

Would you mind sending this as a proper patch with commit message and
'Signed-off-by:'?  I would like to include it in the upcoming patch series.

-- 
Mike Kravetz


  parent reply	other threads:[~2022-06-15 21:22 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-27 22:58 [RFC PATCH 0/3] hugetlb: speed up linear address scanning Mike Kravetz
2022-05-27 22:58 ` [RFC PATCH 1/3] hugetlb: skip to end of PT page mapping when pte not present Mike Kravetz
2022-05-30 10:10   ` Baolin Wang
2022-05-31 16:56     ` Mike Kravetz
2022-06-15 21:22     ` Mike Kravetz [this message]
2022-06-16  3:48       ` Baolin Wang
2022-05-30 19:56   ` Peter Xu
2022-05-31  2:04     ` Muchun Song
2022-05-31 17:05       ` Mike Kravetz
2022-06-01  6:58         ` Anshuman Khandual
2022-05-31 17:00     ` Mike Kravetz
2022-06-15 17:27       ` Mike Kravetz
2022-06-15 17:51         ` Peter Xu
2022-05-27 22:58 ` [RFC PATCH 2/3] hugetlb: do not update address in huge_pmd_unshare Mike Kravetz
2022-05-30 10:14   ` Baolin Wang
2022-05-30 15:36   ` Muchun Song
2022-05-31 17:06     ` Mike Kravetz
2022-05-27 22:58 ` [RFC PATCH 3/3] hugetlb: Lazy page table copies in fork() Mike Kravetz
2022-05-31 17:25   ` David Hildenbrand
2022-06-01  5:20   ` Muchun Song

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=YqpNmsLrbCowS1IE@monkey \
    --to=mike.kravetz@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=almasrymina@google.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=anshuman.khandual@arm.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=jthoughton@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=naoya.horiguchi@linux.dev \
    --cc=paul.walmsley@sifive.com \
    --cc=peterx@redhat.com \
    --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).