linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Alexander Duyck <alexander.duyck@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Vlastimil Babka <vbabka@suse.cz>, linux-mm <linux-mm@kvack.org>
Subject: Re: [PATCH] mm: Make PageType more efficient
Date: Wed, 11 Mar 2020 06:13:04 -0700	[thread overview]
Message-ID: <20200311131304.GD22433@bombadil.infradead.org> (raw)
In-Reply-To: <CAKgT0Uf+6AEpMCewGogowCf_24cimFq5ChmjneiA62kwFCS4Rg@mail.gmail.com>

On Tue, Mar 10, 2020 at 02:50:50PM -0700, Alexander Duyck wrote:
> On Tue, Mar 10, 2020 at 1:37 PM Matthew Wilcox <willy@infradead.org> wrote:
> > > > -#define PageType(page, flag)                                           \
> > > > -       ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE)
> > > > -
> 
> >From what I can tell this is the only consumer of PAGE_TYPE_BASE.
> Since it is removed you can probably remove that definition as well.

I _could_ ... I do want to indicate to people that they probably
shouldn't use those bits in order to leave space for overflow and
wraparound of _mapcount.

> > > > +#define PageType(page, flag)                                           \
> > > > +       (page_has_type(page) && (~page->page_type & flag))
> 
> You can probably spare a cycle or two here by testing for
> "!(page->page_type & flag)". That way you avoid the extra bit flipping
> since the compiler can just handle the result of the AND op as it sees
> fit.

GCC already knows to do that optimisation; mm/page_alloc.o is identical
(same md5sum) when changing from (~page->page_type & flag) to
!(page->page_type & flag).  So it's just a question of which one is
easier for humans to read and reason about.  Do you have an opinion
which one you'd like to see?



  reply	other threads:[~2020-03-11 13:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-10 18:56 [PATCH] mm: Make PageType more efficient Matthew Wilcox
2020-03-10 20:17 ` Alexander Duyck
2020-03-10 20:37   ` Matthew Wilcox
2020-03-10 21:50     ` Alexander Duyck
2020-03-11 13:13       ` Matthew Wilcox [this message]
2020-03-11 17:14         ` Ira Weiny
2020-03-11 17:22         ` Alexander Duyck
2020-03-11  1:10 ` Andrew Morton
2020-03-11 13:21   ` Matthew Wilcox

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=20200311131304.GD22433@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.duyck@gmail.com \
    --cc=linux-mm@kvack.org \
    --cc=vbabka@suse.cz \
    /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).