[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20180322173450.GI28468@bombadil.infradead.org>
Date: Thu, 22 Mar 2018 10:34:50 -0700
From: Matthew Wilcox <willy@...radead.org>
To: Alexander Duyck <alexander.duyck@...il.com>
Cc: Matthew Wilcox <mawilcox@...rosoft.com>,
Netdev <netdev@...r.kernel.org>, linux-mm <linux-mm@...ck.org>,
Jesper Dangaard Brouer <brouer@...hat.com>,
Eric Dumazet <eric.dumazet@...il.com>
Subject: Re: [PATCH v2 6/8] page_frag_cache: Use a mask instead of offset
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.
Powered by blists - more mailing lists