[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CADrL8HWSym93=yNpTUdWebOEzUOTR2ffbfUk04XdK6O+PNJNoA@mail.gmail.com>
Date: Wed, 4 Jan 2023 19:34:00 +0000
From: James Houghton <jthoughton@...gle.com>
To: Peter Xu <peterx@...hat.com>
Cc: Mike Kravetz <mike.kravetz@...cle.com>,
Muchun Song <songmuchun@...edance.com>,
Axel Rasmussen <axelrasmussen@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] hugetlb: unshare some PMDs when splitting VMAs
> > @@ -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!
Powered by blists - more mailing lists