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 562D5C61DA4 for ; Fri, 3 Feb 2023 16:20:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AFFAB6B0074; Fri, 3 Feb 2023 11:20:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AAFF16B0078; Fri, 3 Feb 2023 11:20:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 984E56B0074; Fri, 3 Feb 2023 11:20:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 86F3C6B0074 for ; Fri, 3 Feb 2023 11:20:09 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 54A1B1408C3 for ; Fri, 3 Feb 2023 16:20:09 +0000 (UTC) X-FDA: 80426492538.08.3745BEC Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf07.hostedemail.com (Postfix) with ESMTP id 9E75440016 for ; Fri, 3 Feb 2023 16:20:07 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=tmaSWrcn; spf=none (imf07.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675441207; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YwA5oZxTsgdZCuk6iQdoZuIPia4B4PZAcjwz/ukYwSs=; b=vL8Wv0iLK6inEed2T/tJdKab8z/Xr4YF2oGJA5hKw7QTF4i9SGiPrs5rYo6JgkXZDVwU1t zOjv46U3zq796TN/aeUv1jXfYnGwE5UAi1QlfkeC/Y3OKSYxuFJFpCp/PolXX18epV4j9i /f1o8pIF+++HKS2U9GM5U+IahDeu198= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=tmaSWrcn; spf=none (imf07.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675441207; a=rsa-sha256; cv=none; b=60vK731PxytjBBk86m0TpstLoNR5lScqosI0j6xuz4IULEfvDX4Z0q53XY00kx5Gui+tae toaM3+rzKI/RhgxEDNfmSOsWB6FLmd/RzA4sBPOKpAJXS2T5nX/DVW18044O5HbEGLPRzN KumzfaWCN2MtcvptSVdQtNHRfdcO2rg= 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=YwA5oZxTsgdZCuk6iQdoZuIPia4B4PZAcjwz/ukYwSs=; b=tmaSWrcntypXkwBwFpb63qybzP 8w3QqjoLya/iwsdF7wqtteWY63LO5JlHnJK9XP5bSOdVyjXAIQYoQhIu2QJIIGUP+0frQW0FWbWpX UeRzDZJ/1RkqUtDpyw2TdgU05fV7aI8Tggepzot6SQnoUqJZfl1QtMslUMLaph6HXjAIRTGlfoiLO 5dMFldgIBb4NWLpH3N8cKArdYrqD+Snq+ZFUQK4M01kSFpli+tVoKgW2J3wlBEiWKFzBquHehnc8L 5PseePs+aYF/ChEctoZJhxKTtClrzCC/EmbFatJ1h7z9LoQhryHHxczo2L32C1mJaOoSKB60L93lw qP4nZu0g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNymi-00ERz0-Ok; Fri, 03 Feb 2023 16:19:32 +0000 Date: Fri, 3 Feb 2023 16:19:32 +0000 From: Matthew Wilcox To: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Vlastimil Babka , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , HORIGUCHI =?utf-8?B?TkFPWUEo5aCA5Y+jIOebtOS5nyk=?= , Joe Perches , Petr Mladek , Andy Shevchenko , David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Alexander Potapenko , Marco Elver Subject: Re: [RFC v3 2/4] mm: move PG_slab flag to page_type Message-ID: References: <20221218101901.373450-1-42.hyeyoo@gmail.com> <20221218101901.373450-3-42.hyeyoo@gmail.com> <15fda061-72d9-2ee9-0e9f-6f0f732a7382@suse.cz> 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: 9E75440016 X-Stat-Signature: zjq1xwtz9yqyp5ewwr84t6e43rpcs6ui X-HE-Tag: 1675441207-144053 X-HE-Meta: U2FsdGVkX18jUprTONDXuoPGEoxETayv+9FUf0gg7+2mEyqY9TTL2qK9g4AG5/VUuAFotJ6QhHw+ieu9mrQ89A6FgR33nKXQV19+mg/0JstuUJlPSbyAvKJc2jDT1XYkde2pHYHPRa2YKLfb7kh+A/n4Uke0gG+klrXkeRbj8yLPsLsZAyCl2No0fFY7QLlMdsACq9s1LMnSC8OR/1JRmQgIMVmtM0ge5nuyrbwM86Ff4+YlZUXblSPNaJwRxY9PhHxK9GSi5RmTkhEwIGVVcGo2htdXm4h+TVW2LY5RJxN2fgmj8snLSplbGf7av+kxjOt3wf1MCIvy0hjni7Aa/GieahW6+ogHMFQ8VVuA9V6F57Q6+INYefM+BHViv+2AGy17mV7vJoa8ildZPZHOn8FtylkoZxoeZ7kuMnAoBMbbsKEvyfwKRutZx5sv+pz3PKYkFwLAs7i8mcC3zPcvKA4+A/8Jp4VHoBZxvmr0xXt5cIRSP8qsk2CARwmkAiltXtK4Du2nN/xOZbuTEvrx8OptPod4tb2pm6r5fmLzoNEtklimCEspRqjX511j4hT2X0LOmK9cfSzI7pSuHZ5NVFgsfMJDiHcHYElbDWpCyr5ZTiIB4m4ebEQ7EIuJXHOSKwc3Epyz/nufv/DxigC57k6NdgwWAFFYufsFl4AWWYBalnaVst1jfKKWa04MQp1yFtRAyLf1TLSh4bmKmMNSuXJsYrh/rxCnso2NbQfOa7BtU9EhLzAF9g2Fbj55anoEPztytHkmidFJLHQVq6jG6eLgfBwrZEQc72/0L8p2z0MpLwWddvLH9gMS0su+d5HYEfgfUyS0U1xF0FuGJlzJDYVRSQb5qEu7yfCLeR0f9PgExOt1XKSraPpysZQm1FbkdADZRQHjoCX1IJACbS9OGCOinuTtna+Z0ZSqBvb5KDWeHEK2SkwdGEAgo/ofE3fBK0jDjAA2mlqaaj8jbny toLgs4uA 61z1dTKKDhvndb5csEJgTTD8W6u3IafBmMGRM0R2ZJsd4+hcAqMDfeMJPV2hug9jZJhs3LU5USKwL4WG2jsJbJAkrL0PkmDsF9HQ9b9R3mM7Q40PxOY9Z3E6iDxOnYE+a40Ew1UEB6zGukMuwAkXPqbyGYUpVNK3LIWCe349F++ys2DpZqLrjxtoe0TRPe4lENYaeMotuOwdlktCDr3JGO+y/ru7hSnN1SN9oGP0eXalIGaO261+DgOcBZO+dhtbCm/AnxhWnpLL9N7aLdkqPjMijbA== 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, Feb 03, 2023 at 04:00:08PM +0000, Hyeonggon Yoo wrote: > On Mon, Jan 30, 2023 at 05:11:48AM +0000, Matthew Wilcox wrote: > > On Mon, Jan 30, 2023 at 01:34:59PM +0900, Hyeonggon Yoo wrote: > > > > Seems like quite some changes to page_type to accomodate SLAB, which is > > > > hopefully going away soon(TM). Could we perhaps avoid that? > > > > > > If it could be done with less changes, I'll try to avoid that. > > > > Let me outline the idea I had for removing PG_slab: > > > > Observe that PG_reserved and PG_slab are mutually exclusive. Also, > > if PG_reserved is set, no other flags are set. If PG_slab is set, only > > PG_locked is used. Many of the flags are only for use by anon/page > > cache pages (eg referenced, uptodate, dirty, lru, active, workingset, > > waiters, error, owner_priv_1, writeback, mappedtodisk, reclaim, > > swapbacked, unevictable, mlocked). > > > > Redefine PG_reserved as PG_kernel. Now we can use the other _15_ > > flags to indicate pagetype, as long as PG_kernel is set. > > So PG_kernel is a new special flag, I thought it indicates > "not usermappable pages", but considering PG_vmalloc it's not. Right, it means "The kernel allocated this page for its own purposes; what that purpose is might be available by looking at PG_type". ie it's not-anon, not-page-cache. > > So, eg > > PageSlab() can now be (page->flags & PG_type) == PG_slab where > > But if PG_xxx and PG_slab shares same bit, PG_xxx would be confused? Correct. Ideally those tests wouldn't be used on arbitrary pages, only pages which are already confirmed to be anon or file. I suspect we haven't been super-careful about that in the past, and so there would be some degree of "Oh, we need to fix this up". But flags like PG_mappedtodisk, PG_mlocked, PG_unevictable, PG_workingset should be all gated behind "We know this is anon/file". > > #define PG_kernel 0x00001 > > #define PG_type (PG_kernel | 0x7fff0) > > #define PG_slab (PG_kernel | 0x00010) > > #define PG_reserved (PG_kernel | 0x00020) > > #define PG_buddy (PG_kernel | 0x00030) > > #define PG_offline (PG_kernel | 0x00040) > > #define PG_table (PG_kernel | 0x00050) > > #define PG_guard (PG_kernel | 0x00060) > > > > That frees up the existing PG_slab, lets us drop the page_type field > > altogether and gives us space to define all the page types we might > > want (eg PG_vmalloc) > > > > We'll want to reorganise all the flags which are for anon/file pages > > into a contiguous block. And now that I think about it, vmalloc pages > > can be mapped to userspace, so they can get marked dirty, so only > > 14 bits are available. Maybe rearrange to ... > > > > PG_locked 0x000001 > > PG_writeback 0x000002 > > PG_head 0x000004 > > I think slab still needs PG_head, > but it seems to be okay with this layout. > (but these assumpstions are better documented, I think) Yes, slab need PG_head so it knows whether this is a multi-page slab or not. I forgot to mention it above as a bit that slab needs, but I put it in the low bits here. > > PG_dirty 0x000008 > > PG_owner_priv_1 0x000010 > > PG_arch_1 0x000020 > > PG_private 0x000040 > > PG_waiters 0x000080 > > PG_kernel 0x000100 > > PG_referenced 0x000200 > > PG_uptodate 0x000400 > > PG_lru 0x000800 > > PG_active 0x001000 > > PG_workingset 0x002000 > > PG_error 0x004000 > > PG_private_2 0x008000 > > PG_mappedtodisk 0x010000 > > PG_reclaim 0x020000 > > PG_swapbacked 0x040000 > > PG_unevictable 0x080000 > > PG_mlocked 0x100000 > > > > ... or something. There are a number of constraints and it may take > > a few iterations to get this right. Oh, and if this is the layout > > we use, then: > > > > PG_type 0x1fff00 > > PG_reserved (PG_kernel | 0x200) > > PG_slab (PG_kernel | 0x400) > > PG_buddy (PG_kernel | 0x600) > > PG_offline (PG_kernel | 0x800) > > PG_table (PG_kernel | 0xa00) > > PG_guard (PG_kernel | 0xc00) > > PG_vmalloc (PG_kernel | 0xe00) > > what is PG_vmalloc for, is it just an example for > explaining possible layout? I really want to mark pages as being allocated from vmalloc. It's one of the things we could do to make debugging better.