Re: [RFC 2/2] page_frag_cache: Store metadata in struct page

Eric Dumazet
2018-03-15T21:03:34Z

On 03/15/2018 12:53 PM, Matthew Wilcox wrote:
> From: Matthew Wilcox <mawilcox@microsoft.com>
>
> Shrink page_frag_cache from 24 to 8 bytes (a single pointer to the
> currently-in-use struct page) by using the page's refcount directly
> (instead of maintaining a bias) and storing our current progress through
> the page in the same bits currently used for page->index. We no longer
> need to reflect the page pfmemalloc state if we're storing the page
> directly.
>
> On the downside, we now call page_address() on every allocation, and we
> do an atomic_inc() rather than a non-atomic decrement, but we should
> touch the same number of cachelines and there is far less code (and
> the code is less complex).
>
> Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
> ---

One point about storing metadata not in struct page was to avoid false sharing.

consumers of page frags call put_page() thus touching page refcount.

With the pagecnt_bias (and other fields) we store in another cache line
(private to the producer) we amortize the access to the shared cache line only when needed.