From: Matthew Wilcox <willy@infradead.org>
To: Alexander Duyck <alexander.duyck@gmail.com>
Cc: Matthew Wilcox <mawilcox@microsoft.com>,
Netdev <netdev@vger.kernel.org>, linux-mm <linux-mm@kvack.org>,
Jesper Dangaard Brouer <brouer@redhat.com>,
Eric Dumazet <eric.dumazet@gmail.com>
Subject: Re: [PATCH v2 6/8] page_frag_cache: Use a mask instead of offset
Date: Thu, 22 Mar 2018 10:34:50 -0700 [thread overview]
Message-ID: <20180322173450.GI28468@bombadil.infradead.org> (raw)
In-Reply-To: <20180322164157.GE28468@bombadil.infradead.org>
On Thu, Mar 22, 2018 at 09:41:57AM -0700, Matthew Wilcox wrote:
> On Thu, Mar 22, 2018 at 09:22:31AM -0700, Alexander Duyck wrote:
> > You could just use the pfc->mask here instead of size - 1 just to
> > avoid having to do the subtraction more than once assuming the
> > compiler doesn't optimize it.
>
> Either way I'm assuming a compiler optimisation -- that it won't reload
> from memory, or that it'll remember the subtraction. I don't much care
> which, and I'll happily use the page_frag_cache_mask() if that reads better
> for you.
Looks like it does reload from memory if I make that change. Before:
37e7: c7 43 08 ff 7f 00 00 movl $0x7fff,0x8(%rbx)
37ee: b9 00 80 00 00 mov $0x8000,%ecx
37f3: be ff 7f 00 00 mov $0x7fff,%esi
37f8: ba 00 80 00 00 mov $0x8000,%edx
...
380b: 01 70 1c add %esi,0x1c(%rax)
After:
37e7: c7 43 08 ff 7f 00 00 movl $0x7fff,0x8(%rbx)
37ee: b9 00 80 00 00 mov $0x8000,%ecx
37f3: ba 00 80 00 00 mov $0x8000,%edx
...
3806: 8b 73 08 mov 0x8(%rbx),%esi
3809: 01 70 1c add %esi,0x1c(%rax)
Of course, it's shorter because it's fewer bytes to reload from memory
than it is to put a 32-bit immediate in the instruction stream, but
it's one additional memory reference (cache-hot, of course). I don't
really care because it's the cold path.
next prev parent reply other threads:[~2018-03-22 17:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-22 15:31 [PATCH v2 0/8] page_frag_cache improvements Matthew Wilcox
2018-03-22 15:31 ` [PATCH v2 1/8] page_frag_cache: Remove pfmemalloc bool Matthew Wilcox
2018-03-22 16:39 ` Alexander Duyck
2018-03-22 17:08 ` Matthew Wilcox
2018-03-22 15:31 ` [PATCH v2 2/8] page_frag_cache: Move slowpath code from page_frag_alloc Matthew Wilcox
2018-03-22 15:31 ` [PATCH v2 3/8] page_frag_cache: Rename 'nc' to 'pfc' Matthew Wilcox
2018-03-22 15:31 ` [PATCH v2 4/8] page_frag_cache: Rename fragsz to size Matthew Wilcox
2018-03-22 15:31 ` [PATCH v2 5/8] page_frag_cache: Save memory on small machines Matthew Wilcox
2018-03-22 15:31 ` [PATCH v2 6/8] page_frag_cache: Use a mask instead of offset Matthew Wilcox
2018-03-22 16:22 ` Alexander Duyck
2018-03-22 16:41 ` Matthew Wilcox
2018-03-22 17:31 ` Alexander Duyck
2018-03-22 17:34 ` Matthew Wilcox [this message]
2018-03-22 15:31 ` [PATCH v2 7/8] page_frag: Update documentation Matthew Wilcox
2018-03-22 15:31 ` [PATCH v2 8/8] page_frag: Account allocations 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=20180322173450.GI28468@bombadil.infradead.org \
--to=willy@infradead.org \
--cc=alexander.duyck@gmail.com \
--cc=brouer@redhat.com \
--cc=eric.dumazet@gmail.com \
--cc=linux-mm@kvack.org \
--cc=mawilcox@microsoft.com \
--cc=netdev@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).