All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Houghton <jthoughton@google.com>
To: Peter Xu <peterx@redhat.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>,
	Muchun Song <songmuchun@bytedance.com>,
	Axel Rasmussen <axelrasmussen@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hugetlb: unshare some PMDs when splitting VMAs
Date: Wed, 4 Jan 2023 19:34:00 +0000	[thread overview]
Message-ID: <CADrL8HWSym93=yNpTUdWebOEzUOTR2ffbfUk04XdK6O+PNJNoA@mail.gmail.com> (raw)
In-Reply-To: <Y7S0lDCeBYLMHBvR@x1n>

> > @@ -4828,6 +4830,23 @@ static int hugetlb_vm_op_split(struct vm_area_struct *vma, unsigned long addr)
> >  {
> >       if (addr & ~(huge_page_mask(hstate_vma(vma))))
> >               return -EINVAL;
> > +
> > +     /* We require PUD_SIZE VMA alignment for PMD sharing. */
>
> I can get the point, but it reads slightly awkward.  How about:
>
>         /*
>          * If the address to split can be in the middle of a shared pmd
>          * range, unshare before split the vma.
>          */
>

How about:

/*
 * PMD sharing is only possible for PUD_SIZE-aligned address ranges
 * in HugeTLB VMAs. If we will lose PUD_SIZE alignment due to this split,
 * unshare PMDs in the PUD_SIZE interval surrounding addr now.
 */

> I remember you had a helper to check pmd sharing possibility.  Can use here
> depending on whether that existed in the code base or in your hgm series
> (or just pick that up with this one?).

Right, it introduces `pmd_sharing_possible` but I don't think it helps here.

>
> > +     if (addr & ~PUD_MASK) {
> > +             /*
> > +              * hugetlb_vm_op_split is called right before we attempt to
> > +              * split the VMA. We will need to unshare PMDs in the old and
> > +              * new VMAs, so let's unshare before we split.
> > +              */
> > +             unsigned long floor = addr & PUD_MASK;
> > +             unsigned long ceil = floor + PUD_SIZE;
> > +
> > +             if (floor < vma->vm_start || ceil >= vma->vm_end)
>
> s/>=/>/?

Indeed, thanks.

>
> > +                     /* PMD sharing is already impossible. */
> > +                     return 0;
>
> IMHO slightly cleaner to write in the reversed way and let it fall through:
>
>   if (floor >= vma->vm_start && ceil <= vma->vm_end)
>       hugetlb_unshare_pmds(vma, floor, ceil);

Will do.

>
> Thanks,
>

Thanks Peter!

  reply	other threads:[~2023-01-04 19:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-01 23:00 [PATCH] hugetlb: unshare some PMDs when splitting VMAs James Houghton
2023-01-03 19:24 ` Mike Kravetz
2023-01-03 20:26   ` James Houghton
2023-01-03 20:27     ` James Houghton
2023-01-03 22:23     ` Mike Kravetz
2023-01-04 19:10       ` James Houghton
2023-01-04 20:03         ` Peter Xu
2023-01-04 23:12           ` James Houghton
2023-01-03 23:04 ` Peter Xu
2023-01-04 19:34   ` James Houghton [this message]
2023-01-04 20:04     ` Peter Xu

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='CADrL8HWSym93=yNpTUdWebOEzUOTR2ffbfUk04XdK6O+PNJNoA@mail.gmail.com' \
    --to=jthoughton@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.