From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl0-f66.google.com ([209.85.160.66]:39708 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751546AbeCOVDe (ORCPT ); Thu, 15 Mar 2018 17:03:34 -0400 Subject: Re: [RFC 2/2] page_frag_cache: Store metadata in struct page To: Matthew Wilcox , Alexander Duyck Cc: linux-mm@vger.kernel.org, netdev@vger.kernel.org, Matthew Wilcox References: <20180315195329.7787-1-willy@infradead.org> <20180315195329.7787-3-willy@infradead.org> From: Eric Dumazet Message-ID: <29246b53-11c6-13ab-b364-272e564da458@gmail.com> Date: Thu, 15 Mar 2018 14:03:32 -0700 MIME-Version: 1.0 In-Reply-To: <20180315195329.7787-3-willy@infradead.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org List-ID: On 03/15/2018 12:53 PM, Matthew Wilcox wrote: > From: Matthew Wilcox > > 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 > --- 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.