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=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 AA765C433E0 for ; Mon, 29 Jun 2020 15:20:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5BE1C246AE for ; Mon, 29 Jun 2020 15:20:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="rxRY+R2J" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5BE1C246AE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 04F976B0033; Mon, 29 Jun 2020 11:20:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 028386B0036; Mon, 29 Jun 2020 11:20:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E56B56B0037; Mon, 29 Jun 2020 11:20:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0126.hostedemail.com [216.40.44.126]) by kanga.kvack.org (Postfix) with ESMTP id CBEA06B0033 for ; Mon, 29 Jun 2020 11:20:09 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 8EB76181AC9C6 for ; Mon, 29 Jun 2020 15:20:09 +0000 (UTC) X-FDA: 76982610138.08.pets39_230309826e70 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id 5ECA21819E76B for ; Mon, 29 Jun 2020 15:20:09 +0000 (UTC) X-HE-Tag: pets39_230309826e70 X-Filterd-Recvd-Size: 4092 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Mon, 29 Jun 2020 15:20:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=VUEVNNECw/4mLTBYjmKDtM2Yal+jOfXT7Nzt4Wxvl/0=; b=rxRY+R2JmvAh6TJfGs+n+zuubF eza9rQx0nC3v5+XYJd8mMkMSvt4FyVqFzqZCL9c5N7gvCKBqgUJutEQp5ecY6NIAGMxL0AWmJvNyZ QCfwS+5t2sN/3oGVt8iYZqSW6sodBUuOjPZDOlCDtPC/Y62KnsL78S6pF20Aq9PA21w8o1wX4PhQ6 /0vmebOfB3mcvxA51lSW+9ucpXHBM3i9tt5NY43SZOrnev3LE6Cy/EOI7tNyR4JT9rNUDXSEu0OPY Dfw1G3RVhhab9VNjS4u9KW5ywksN4H5rTIfBDeBnOZyTaPLgQwKTxeA6hk7NMP9pYBxZBSzrJx2XW kGJ66+pw==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jpvZn-0004C0-GN; Mon, 29 Jun 2020 15:20:07 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 1/7] mm: Store compound_nr as well as compound_order Date: Mon, 29 Jun 2020 16:19:53 +0100 Message-Id: <20200629151959.15779-2-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200629151959.15779-1-willy@infradead.org> References: <20200629151959.15779-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5ECA21819E76B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 Content-Transfer-Encoding: quoted-printable 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: This removes a few instructions from functions which need to know how man= y 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 *pa= ge) static inline void set_compound_order(struct page *page, unsigned int or= der) { page[1].compound_order =3D order; + page[1].compound_nr =3D 1U << order; } =20 /* 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; } =20 /* 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 i= nt order) int i; int nr_pages =3D 1 << order; =20 - set_compound_page_dtor(page, COMPOUND_PAGE_DTOR); - set_compound_order(page, order); __SetPageHead(page); for (i =3D 1; i < nr_pages; i++) { struct page *p =3D page + i; @@ -682,6 +680,9 @@ void prep_compound_page(struct page *page, unsigned i= nt order) p->mapping =3D 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); --=20 2.27.0