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 7DA01C433F5 for ; Fri, 11 Mar 2022 21:11:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B7BB28D0003; Fri, 11 Mar 2022 16:11:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B29898D0001; Fri, 11 Mar 2022 16:11:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F1578D0003; Fri, 11 Mar 2022 16:11:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 907448D0001 for ; Fri, 11 Mar 2022 16:11:42 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 83738120C06 for ; Fri, 11 Mar 2022 21:11:42 +0000 (UTC) X-FDA: 79233352044.02.E0A18D5 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf10.hostedemail.com (Postfix) with ESMTP id E94BEC0021 for ; Fri, 11 Mar 2022 21:11:41 +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=wWQbXRbezK3NRtMtSi3ATf+Wd1xnlwmrtyeo6SDza4g=; b=cscqcGcM1lLDTv+e62zL2JJ8/l cjyGSld5RQSrMMzrK/JdnjJVU6L6l3yRd7ZL235Cc91w7HF9VEiyo4+RBu+yHRkTGKLuf/UeNmFtw h1kA3VfBe0IKLd04WWWViDYGEDY0I/TyWjwZJMsdrLandRQ7XdxXsaCxuDDSS7AKWnD/omYWWKJOi swpIjr2rGRmLSPzOy1kjVyeUJDS45VVrW3b4iD2D/PWN59WP7YeZh1EOi0EeuMXi9vBMMsUCpsoq4 EAtBAJK/RHJagf/UtFneS5/33r4uOUE2vzUElJUvYzx+1JhK1siaKTTmGhzSH/ThdHQmeVoZv4s3O MnDl4fmw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nSmXf-001usC-TV; Fri, 11 Mar 2022 21:11:19 +0000 Date: Fri, 11 Mar 2022 21:11:19 +0000 From: Matthew Wilcox To: David Hildenbrand Cc: Linus Torvalds , Linux Kernel Mailing List , Andrew Morton , Hugh Dickins , David Rientjes , Shakeel Butt , John Hubbard , Jason Gunthorpe , Mike Kravetz , Mike Rapoport , Yang Shi , "Kirill A . Shutemov" , Vlastimil Babka , Jann Horn , Michal Hocko , Nadav Amit , Rik van Riel , Roman Gushchin , Andrea Arcangeli , Peter Xu , Donald Dutile , Christoph Hellwig , Oleg Nesterov , Jan Kara , Liang Zhang , Pedro Gomes , Oded Gabbay , Linux-MM Subject: Re: [PATCH v1 10/15] mm/page-flags: reuse PG_slab as PG_anon_exclusive for PageAnon() pages Message-ID: References: <20220308141437.144919-1-david@redhat.com> <20220308141437.144919-11-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: E94BEC0021 X-Stat-Signature: 4os9bis34f5rqshijyg3sg5b888icnif Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=cscqcGcM; spf=none (imf10.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: 1647033101-855973 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 Fri, Mar 11, 2022 at 08:36:37PM +0100, David Hildenbrand wrote: > I used PG_error before, but felt like using a bit that is never ever > valid to be set/cleared/checked on a subpage would be even a better fit: > > Note the: > > PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) __CLEARPAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) > > whereby PF_ONLY_HEAD translates to: > > "for compound page, callers only ever operate on the head page." > > > I can just switch to PG_error, but for the second subpage, PG_waiters > should be just fine (unless I am missing something important). I think you're missing something important that almost everybody misses when looking at this code (including me). PF_ANY flags can be set on individual pages. PF_HEAD means "we automatically redirect all operations to the head page". PF_ONLY_HEAD means "If you try to call this on a tail page, we BUG". PF_NO_TAIL means "If you try to read this flag on a tail page, we'll look at the head page instead, but if you try to set/clear this flag on a tail page, we BUG" PF_NO_COMPOUND means "We BUG() if you call this on a compound page" So really, you can reuse any flag as PF_SECOND that isn't PF_ANY. No, that's not what the documentation currently says. It should be. I had a patch to reword it at some point, but I guess it got lost. The current documentation reads like "We replicate the flag currently set on the head page to all tail pages", but that just isn't what the code does.