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 7B038C433F5 for ; Tue, 4 Jan 2022 18:25:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5B576B0071; Tue, 4 Jan 2022 13:25:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E0A996B0073; Tue, 4 Jan 2022 13:25:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD2296B0074; Tue, 4 Jan 2022 13:25:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0077.hostedemail.com [216.40.44.77]) by kanga.kvack.org (Postfix) with ESMTP id BE5586B0071 for ; Tue, 4 Jan 2022 13:25:47 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 819D893681 for ; Tue, 4 Jan 2022 18:25:47 +0000 (UTC) X-FDA: 78993433134.28.4119451 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf26.hostedemail.com (Postfix) with ESMTP id 2C4BE140006 for ; Tue, 4 Jan 2022 18:25:47 +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=SGfmVGu0pSiy8IKWqwu0JhXF2tN0Yv5ttnPpNwEfPnA=; b=BMuc70UCoz0zTNPCl01cODIs1a yj3iuMaSZypYFWlbeliRC0XrHCOZYpf4k9HxsNSzZzHIleTPlVh9jxXvbV3PGbGj/X35Qxa82IQ0j iFHg9/4VALER3FYrjg913K2mcsUMzUQAK3VvCWhYKsJAeAKr8hKWaOPxaPbaK08jL3TlAuIPJvpM5 oMumVs+TDYlBpRkZDmMets5K+7G0D10UR8+C4UMPFTQnWTmKr3KVVIXaXzDdWOdPoM20ax7ACsJbV HqgcODAICQ5PHOBdOeWUwkfvmPc/yXkUTZ5sApV0ygG3CVaSqU/RTpq+uLnhfQIObEWgaNlgvERNh IjKtceug==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1n4oVF-00DtkF-1J; Tue, 04 Jan 2022 18:25:45 +0000 Date: Tue, 4 Jan 2022 18:25:45 +0000 From: Matthew Wilcox To: Christoph Hellwig Cc: linux-mm@kvack.org, John Hubbard , Andrew Morton Subject: Re: [PATCH 02/17] mm: Add folio_pincount_available() Message-ID: References: <20220102215729.2943705-1-willy@infradead.org> <20220102215729.2943705-3-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 2C4BE140006 X-Stat-Signature: b8as1upnyhucdrwiy8ynb7phwnjnhc7e Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=BMuc70UC; spf=none (imf26.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-HE-Tag: 1641320747-889187 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 Tue, Jan 04, 2022 at 12:01:45AM -0800, Christoph Hellwig wrote: > On Sun, Jan 02, 2022 at 09:57:14PM +0000, Matthew Wilcox (Oracle) wrote: > > -static inline bool hpage_pincount_available(struct page *page) > > +static inline bool folio_pincount_available(struct folio *folio) > > { > > /* > > - * Can the page->hpage_pinned_refcount field be used? That field is in > > + * Can the folio->hpage_pinned_refcount field be used? That field is in > > * the 3rd page of the compound page, so the smallest (2-page) compound > > * pages cannot support it. > > */ > > + return folio_order(folio) > 1; > > +} > > Maybe convert the comment into a kerneldoc one? I'm actually thinking about getting rid of it by moving the hpage_pinned_refcount into page[1]: diff --git a/include/linux/mm.h b/include/linux/mm.h index 4e763a590c9c..07fa8af564ed 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -950,7 +950,9 @@ static inline int head_compound_pincount(struct page *head) static inline void set_compound_order(struct page *page, unsigned int order) { page[1].compound_order = order; +#ifdef CONFIG_64BIT page[1].compound_nr = 1U << order; +#endif } /* Returns the number of pages in this potentially compound page. */ @@ -958,7 +960,11 @@ static inline unsigned long compound_nr(struct page *page) { if (!PageHead(page)) return 1; +#ifdef CONFIG_64BIT return page[1].compound_nr; +#else + return 1UL << compound_order(page); +#endif } /* 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 09d9e2c4a2c5..e19af4a90a6c 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -150,11 +150,14 @@ struct page { unsigned char compound_dtor; unsigned char compound_order; atomic_t compound_mapcount; + atomic_t hpage_pinned_refcount; +#ifdef CONFIG_64BIT unsigned int compound_nr; /* 1 << compound_order */ +#endif }; struct { /* Second tail page of compound page */ unsigned long _compound_pad_1; /* compound_head */ - atomic_t hpage_pinned_refcount; + unsigned long _compound_pad_2; /* For both global and memcg */ struct list_head deferred_list; }; Now it's always available for every compound page.