[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CADrL8HWT8-MZeL-G+Qj4vQHVrrMxd8EWkPWO9eDfwvvZvoh69A@mail.gmail.com>
Date: Thu, 9 Mar 2023 11:58:37 -0800
From: James Houghton <jthoughton@...gle.com>
To: Peter Xu <peterx@...hat.com>
Cc: Mike Kravetz <mike.kravetz@...cle.com>,
Hugh Dickins <hughd@...gle.com>,
Muchun Song <songmuchun@...edance.com>,
"Matthew Wilcox (Oracle)" <willy@...radead.org>,
Andrew Morton <akpm@...ux-foundation.org>,
"Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
David Hildenbrand <david@...hat.com>,
David Rientjes <rientjes@...gle.com>,
Axel Rasmussen <axelrasmussen@...gle.com>,
Jiaqi Yan <jiaqiyan@...gle.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] mm: rmap: make hugetlb pages participate in _nr_pages_mapped
On Wed, Mar 8, 2023 at 1:56 PM Peter Xu <peterx@...hat.com> wrote:
>
> On Tue, Mar 07, 2023 at 04:36:51PM -0800, James Houghton wrote:
> > > > if (likely(!compound)) {
> > > > + if (unlikely(folio_test_hugetlb(folio)))
> > > > + VM_BUG_ON_PAGE(HPageVmemmapOptimized(&folio->page),
> > > > + page);
>
> How about moving folio_test_hugetlb() into the BUG_ON()?
>
> VM_BUG_ON_PAGE(folio_test_hugetlb(folio) &&
> HPageVmemmapOptimized(&folio->page),
> page);
>
> Note that BUG_ON() already contains an "unlikely".
Ok I can do that. It's a little cleaner.
> > > > first = atomic_inc_and_test(&page->_mapcount);
> > > > nr = first;
> > > > if (first && folio_test_large(folio)) {
> > > > nr = atomic_inc_return_relaxed(mapped);
> > > > nr = (nr < COMPOUND_MAPPED);
> > > > }
> > > > - } else if (folio_test_pmd_mappable(folio)) {
> > > > - /* That test is redundant: it's for safety or to optimize out */
> > >
> > > I 'think' removing this check is OK. It would seem that the caller
> > > knows if the folio is mappable. If we want a similar test, we might be
> > > able to use something like:
> > >
> > > arch_hugetlb_valid_size(folio_size(folio))
> > >
> >
> > Ack. I think leaving the check(s) removed is fine.
>
> Would it still be good to keep that as another BUG_ON()?
Sure, that sounds reasonable to me. I'll add it unless someone disagrees.
As you suggested in your other email, I'll also add a BUG_ON() if we
attempt to do a non-compound mapping of a folio that is larger than
COMPOUND_MAPPED / 2. (Maybe a BUG_ON() in alloc_hugetlb_folio() to
check that the size of the folio we're allocating is less than
COMPOUND_MAPPED / 2 makes sense instead. Just an idea.)
- James
Powered by blists - more mailing lists