linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: James Houghton <jthoughton@google.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>,
	Hugh Dickins <hughd@google.com>,
	Muchun Song <songmuchun@bytedance.com>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
	David Hildenbrand <david@redhat.com>,
	David Rientjes <rientjes@google.com>,
	Axel Rasmussen <axelrasmussen@google.com>,
	Jiaqi Yan <jiaqiyan@google.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] mm: rmap: make hugetlb pages participate in _nr_pages_mapped
Date: Wed, 8 Mar 2023 16:56:09 -0500	[thread overview]
Message-ID: <ZAkEecMShUAGwZ62@x1n> (raw)
In-Reply-To: <CADrL8HVa3vzmrfFJD5hx_GuXVnsWhSo9hzJFb4TTzzjMhWG+sQ@mail.gmail.com>

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".

> > >               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()?

-- 
Peter Xu



  reply	other threads:[~2023-03-08 21:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-06 23:00 [PATCH 0/2] mm: rmap: merge HugeTLB mapcount logic with THPs James Houghton
2023-03-06 23:00 ` [PATCH 1/2] mm: rmap: make hugetlb pages participate in _nr_pages_mapped James Houghton
2023-03-07 21:54   ` Mike Kravetz
2023-03-08  0:36     ` James Houghton
2023-03-08 21:56       ` Peter Xu [this message]
2023-03-09 19:58         ` James Houghton
2023-03-06 23:00 ` [PATCH 2/2] mm: rmap: increase COMPOUND_MAPPED to support 512G HugeTLB pages James Houghton
2023-03-08 22:10 ` [PATCH 0/2] mm: rmap: merge HugeTLB mapcount logic with THPs Peter Xu
2023-03-09 18:05   ` James Houghton
2023-03-09 19:29     ` 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=ZAkEecMShUAGwZ62@x1n \
    --to=peterx@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=david@redhat.com \
    --cc=hughd@google.com \
    --cc=jiaqiyan@google.com \
    --cc=jthoughton@google.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    --cc=rientjes@google.com \
    --cc=songmuchun@bytedance.com \
    --cc=willy@infradead.org \
    /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