From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB1EAC433E0 for ; Mon, 29 Jun 2020 16:22:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 84C962558B for ; Mon, 29 Jun 2020 16:22:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 84C962558B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F03326B008A; Mon, 29 Jun 2020 12:22:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E8D2D8D0005; Mon, 29 Jun 2020 12:22:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D531F6B0093; Mon, 29 Jun 2020 12:22:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0056.hostedemail.com [216.40.44.56]) by kanga.kvack.org (Postfix) with ESMTP id BA8F36B008A for ; Mon, 29 Jun 2020 12:22:33 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 30743181AC9BF for ; Mon, 29 Jun 2020 16:22:33 +0000 (UTC) X-FDA: 76982767386.04.fold27_110fa3e26e70 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 00AD68000076 for ; Mon, 29 Jun 2020 16:22:32 +0000 (UTC) X-HE-Tag: fold27_110fa3e26e70 X-Filterd-Recvd-Size: 4421 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Mon, 29 Jun 2020 16:22:31 +0000 (UTC) IronPort-SDR: zkObQatTwYNj1HkwpDc3o0KHTewjlth7eVK1DGnLUVuJTk/ssEq5K6VltGgKexEnUSl7MdgrgU /KOBQZwuW3FQ== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="134315106" X-IronPort-AV: E=Sophos;i="5.75,295,1589266800"; d="scan'208";a="134315106" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2020 09:22:28 -0700 IronPort-SDR: os2Ht+UR7dpHX226R9l8Q3duEk2cndGzRWQEHWdR0n0I5B84JCw2azs6EJ3GRY7fy6lfd7qlyy R0/3FZf3sxpg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,295,1589266800"; d="scan'208";a="294929029" Received: from iweiny-desk2.sc.intel.com ([10.3.52.147]) by orsmga002.jf.intel.com with ESMTP; 29 Jun 2020 09:22:27 -0700 Date: Mon, 29 Jun 2020 09:22:27 -0700 From: Ira Weiny To: "Matthew Wilcox (Oracle)" Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton Subject: Re: [PATCH 1/7] mm: Store compound_nr as well as compound_order Message-ID: <20200629162227.GF2454695@iweiny-DESK2.sc.intel.com> References: <20200629151959.15779-1-willy@infradead.org> <20200629151959.15779-2-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200629151959.15779-2-willy@infradead.org> User-Agent: Mutt/1.11.1 (2018-12-01) X-Rspamd-Queue-Id: 00AD68000076 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Jun 29, 2020 at 04:19:53PM +0100, Matthew Wilcox wrote: > This removes a few instructions from functions which need to know how many > pages are in a compound page. The storage used is either page->mapping > on 64-bit or page->index on 32-bit. Both of these are fine to overlay > on tail pages. > > Signed-off-by: Matthew Wilcox (Oracle) > --- > include/linux/mm.h | 5 ++++- > include/linux/mm_types.h | 1 + > mm/page_alloc.c | 5 +++-- > 3 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index dc7b87310c10..af0305ad090f 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -911,12 +911,15 @@ static inline int compound_pincount(struct page *page) > static inline void set_compound_order(struct page *page, unsigned int order) > { > page[1].compound_order = order; > + page[1].compound_nr = 1U << order; ^^^ 1UL? Ira > } > > /* Returns the number of pages in this potentially compound page. */ > static inline unsigned long compound_nr(struct page *page) > { > - return 1UL << compound_order(page); > + if (!PageHead(page)) > + return 1; > + return page[1].compound_nr; > } > > /* Returns the number of bytes in this potentially compound page. */ > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > index 64ede5f150dc..561ed987ab44 100644 > --- a/include/linux/mm_types.h > +++ b/include/linux/mm_types.h > @@ -134,6 +134,7 @@ struct page { > unsigned char compound_dtor; > unsigned char compound_order; > atomic_t compound_mapcount; > + unsigned int compound_nr; /* 1 << compound_order */ > }; > struct { /* Second tail page of compound page */ > unsigned long _compound_pad_1; /* compound_head */ > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 48eb0f1410d4..c7beb5f13193 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -673,8 +673,6 @@ void prep_compound_page(struct page *page, unsigned int order) > int i; > int nr_pages = 1 << order; > > - set_compound_page_dtor(page, COMPOUND_PAGE_DTOR); > - set_compound_order(page, order); > __SetPageHead(page); > for (i = 1; i < nr_pages; i++) { > struct page *p = page + i; > @@ -682,6 +680,9 @@ void prep_compound_page(struct page *page, unsigned int order) > p->mapping = TAIL_MAPPING; > set_compound_head(p, page); > } > + > + set_compound_page_dtor(page, COMPOUND_PAGE_DTOR); > + set_compound_order(page, order); > atomic_set(compound_mapcount_ptr(page), -1); > if (hpage_pincount_available(page)) > atomic_set(compound_pincount_ptr(page), 0); > -- > 2.27.0 > >