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 8F535C61DA4 for ; Fri, 3 Feb 2023 16:00:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF45A6B0071; Fri, 3 Feb 2023 11:00:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DA4BE6B0072; Fri, 3 Feb 2023 11:00:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6C9A6B0074; Fri, 3 Feb 2023 11:00:27 -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 B7FE56B0071 for ; Fri, 3 Feb 2023 11:00:27 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 8DE98A11D1 for ; Fri, 3 Feb 2023 16:00:27 +0000 (UTC) X-FDA: 80426442894.26.878AD59 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by imf03.hostedemail.com (Postfix) with ESMTP id 93C8120023 for ; Fri, 3 Feb 2023 16:00:25 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=LdHnyTMy; spf=pass (imf03.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.50 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675440025; 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=NiUaOu2iRNFq5Ksk1hK+QZW45BRCm1sHgZZrxPYsFTY=; b=Q25sydapT3HTpwUUkS6Tk3eh16Iv5pfPfjh3fG5eKsdOBCiYp1sO3R+Dgt/KXfXpt6A+Z+ TsK7QMHNi06XzvRQqbeJOho1ZbeED9Zp9lZh9Klc4F7kkUgVRHXlW3y+xVbOSCIbkbPyWA 0FZXxRjSEaT0YfB82eMIsa8NCUmwnTI= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=LdHnyTMy; spf=pass (imf03.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.50 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675440025; a=rsa-sha256; cv=none; b=pI+TxFZpwjJTb4hv4R0mUv14U39s8rd5H9zs9b740mhlvhhNi7EL0Qbj0KFLLWyOPI/Kuk 3bosgb/WAxbyTAKjUuAYQBuIzdJHBUnJJHbRNuJYylw1kJCsI8lvC1IhJpCCl7d3UbL7E6 IAt7DtVXGVWtDTsjV4b4/retEwSKaUU= Received: by mail-pj1-f50.google.com with SMTP id pj3so5453906pjb.1 for ; Fri, 03 Feb 2023 08:00:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=NiUaOu2iRNFq5Ksk1hK+QZW45BRCm1sHgZZrxPYsFTY=; b=LdHnyTMyjfLCGEpqKc2l2ei9SRkgdyVLJ+Vmg+SQbx6C0yTT+URBKPXf6SVb5imyLH lAD+wV5PjcylMQ8D1/aKwZN3hZIFhMhdeCHNcr19TVW6QTPn6aX2hEcX/EZzw9D7x4Nh vPgyjGUtydo5jDrf1+YrxDbzNuZWdLwbGEje7cyct9uGGkeJJn3Ew/CrYP9OAADYhKHy A0WZr8+JWa72ymrMHcmPU+aKRt0dPjGwYu3MSzQ7kBus7BP7KATl8KZDJAIC+CNUkOhG qj83/3MVojpw3w7I9GbJgTlqnwsKLD+x20LZzLDJLJyEMHKfW7QVfEHrBy32Q2t+Pozq S6qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=NiUaOu2iRNFq5Ksk1hK+QZW45BRCm1sHgZZrxPYsFTY=; b=wnhDLFWWARd88FxaSpbyKTE9nbqFQihOB/TNBs+LwyPIarZkcMZn2ep+OJM/GsBYmz 48FJ2ZO2lkaQGVDETTmTE7+bZZ1RVnmDHuFB6/YFxEWJ4yTyLj3KnFhILLw2vpnTdgzU lE5Nyo9lVkU8UO3Nnd4o08QHy0GVWrJagKUjwXiY1cuUkwzYmJoDofAY/OLIXe7GZt6x YGy8wV6o6iCvgqYCPY1LOA317yOIF6Z685jfRmMxr9UgHmZge9SNa9x5kuTNH9ctJQkm oiQztGkON6DMgykcdxSW54uEI0o+cfgvFFc8j5uZ4QkHogKkxMwDYZtVXerqJPkDYLkX kLOw== X-Gm-Message-State: AO0yUKWXrj4uSzANGrRlkCbu0S2Nox15fGyfccA2uuSLhVulndlF1gtc ZQDWybwPAq/B2ci+ahg5nUE= X-Google-Smtp-Source: AK7set+XKBRFSgUA7sYAqnOPC8tU2gAKsM8mbu9pGDCG+jk3gL7B44cIoIvKmKNIlMA20DBQiRgjwQ== X-Received: by 2002:a17:902:d0d3:b0:194:8c75:29d with SMTP id n19-20020a170902d0d300b001948c75029dmr8883687pln.12.1675440024125; Fri, 03 Feb 2023 08:00:24 -0800 (PST) Received: from localhost ([2400:8902::f03c:93ff:fe27:642a]) by smtp.gmail.com with ESMTPSA id d7-20020a170902654700b0017ec1b1bf9fsm1767327pln.217.2023.02.03.08.00.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 08:00:23 -0800 (PST) Date: Fri, 3 Feb 2023 16:00:08 +0000 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Matthew Wilcox 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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 93C8120023 X-Rspam-User: X-Stat-Signature: nbk6tt9n15fccdbm99k4jntqpubq5jck X-HE-Tag: 1675440025-665417 X-HE-Meta: U2FsdGVkX1+Mnc468ZJ77TPLPQ/liuc/HUyInNLCzHiueHF5lrC4YATBqNu4wJ65ALYAsvhbWYPl1TgIBj3U/EuAccoA2IpVAEDpvEwNwfL6Whn5Fmqdf5qjg6zUhFzZQxOTSFetk1f3wFOnmSMSEzb2voMlA1gSpuATGKlsMAdZVIEObmynpytcgjBJyQMuoYU7+mY+S/oDtY+BatQgdn2mr3esma2S8SRX/DgKgy/ohzMD2FfahnswMohY3rW+kfUORDRurd5KfjxpUETH6khuK2aqHcJUovVtpWttTrV1FTD8xN5sMzIsrYoaGGFbET6U2JyvZg5lvLpMq3IYHU8AD4bWkt3yhBaU7SMnHCdcdJieyM0ODz91t/RguuYLOYQH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JiiBhlUVzKWdhhHS2idhGOa0w15XRO9TsY 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 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. > 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? > #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) > 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? > This is going to make show_page_flags() more complex :-P > > Oh, and while we're doing this, we should just make PG_mlocked > unconditional. NOMMU doesn't need the extra space in page flags > (for what? their large number of NUMA nodes?)