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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21809C433EF for ; Tue, 11 Jan 2022 04:38:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A344B6B0072; Mon, 10 Jan 2022 23:38:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E39F6B0073; Mon, 10 Jan 2022 23:38:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 905206B0074; Mon, 10 Jan 2022 23:38:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0114.hostedemail.com [216.40.44.114]) by kanga.kvack.org (Postfix) with ESMTP id 812DF6B0072 for ; Mon, 10 Jan 2022 23:38:58 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 3608280D2B18 for ; Tue, 11 Jan 2022 04:38:58 +0000 (UTC) X-FDA: 79016751156.22.D164AB3 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id DC37FA0006 for ; Tue, 11 Jan 2022 04:38:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=M3Qjf/WLm4+ja7B2psDBJO0nkAUuZjPYlJC4t81KgB8=; b=nC0OO2CRfA6Aw5yvhBU9t3n9q2 taR9jEkT+AvH3wVhQYw4AFl0zTG9+Wx2b9TKovCxbfTY2O+mRQyjSKa1y8BPuQHMUdo1X5L5Ieql2 QC0SKNl3EBvthNo7D73HmvXwdamBDTWzWC793iMad40GiBMgFyTCOJjCNcoBE9w8vlel+jQafE2ds wdngzMAvmASo7YklEcJHRYLPxWuwJcv0GbL4v9HnFmZOLh5+LmBMz6thUg/D+7uI9kedjf5HNj2GQ 4oHw6QimulpcmlhG+GhMnwa3o82nxtfZKajhsojUuKNRCc3DubNEW7RhwYueroFSe7c8QxqTF5jjk 868DazvA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1n78vt-002yEu-3b; Tue, 11 Jan 2022 04:38:53 +0000 Date: Tue, 11 Jan 2022 04:38:53 +0000 From: Matthew Wilcox To: John Hubbard Cc: linux-mm@kvack.org, Christoph Hellwig , William Kucharski , linux-kernel@vger.kernel.org, Jason Gunthorpe Subject: Re: [PATCH v2 11/28] mm: Make compound_pincount always available Message-ID: References: <20220110042406.499429-1-willy@infradead.org> <20220110042406.499429-12-willy@infradead.org> <279070af-4ac8-942f-5096-f7f61db9aeb6@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <279070af-4ac8-942f-5096-f7f61db9aeb6@nvidia.com> X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: DC37FA0006 X-Stat-Signature: 5pkt9nsi65n8oc6tpcizzhfhdpxutci7 Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=nC0OO2CR; dmarc=none; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1641875937-742159 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000027, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Jan 10, 2022 at 08:06:54PM -0800, John Hubbard wrote: > > +#ifdef CONFIG_64BIT > > return page[1].compound_nr; > > +#else > > + return 1UL << compound_order(page); > > +#endif > > Now that you are highlighting this, I have this persistent feeling (not > yet confirmed by any testing) that compound_nr is a micro-optimization > that is actually invisible at runtime--but is now slicing up our code > with ifdefs, and using space in a fairly valuable location. > > Not for this patch or series, but maybe a separate patch or series > should just remove the compound_nr field entirely, yes? It is > surprising to carry around both compound_order and (1 << > compound_order), right next to each other. It would be different if this > were an expensive calculation, but it's just a shift. > > Maybe testing would prove that that's a bad idea, and maybe someone has > already looked into it, but I wanted to point it out. It' probably worth looking at the patch which added it ... 1378a5ee451a in August 2020. I didn't provide any performance numbers, but code size definitely went down. > > @@ -52,7 +51,7 @@ static int page_pincount_sub(struct page *page, int refs) > > { > > VM_BUG_ON_PAGE(page != compound_head(page), page); > > - if (hpage_pincount_available(page)) > > + if (PageHead(page)) > > OK, so we just verified (via VM_BUG_ON_PAGE(), which is not always active) > that this is not a tail page. And so PageHead() effectively means PageCompound(). > > I wonder if it would be better to just use PageCompound() here and in similar > cases. Because that's what is logically being checked, after all. It seems > slightly more accurate. Well PageCompound() is defined as PageHead() || PageTail(). I don't think the intent was for people to always ask "Is this a compound page", more "This is a good shorthand to replace PageHead() || PageTail()". It's kind of moot anyway because this gets replaced with folio_test_large() further down the patch series.