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 A6D67C54EED for ; Mon, 30 Jan 2023 05:12:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D5186B0072; Mon, 30 Jan 2023 00:12:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2ACE06B0073; Mon, 30 Jan 2023 00:12:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 14BB58E0001; Mon, 30 Jan 2023 00:12:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 048AF6B0072 for ; Mon, 30 Jan 2023 00:12:30 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A39D31406C1 for ; Mon, 30 Jan 2023 05:12:29 +0000 (UTC) X-FDA: 80410294818.15.ACA4C7F Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id 0654A180014 for ; Mon, 30 Jan 2023 05:12:27 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=QNdah6QK; dmarc=none; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675055548; 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=MS+Rl30LKC38gIgaEPBq9Y744hbvgXHkTTwFaNB2Z2k=; b=XOBhtL9+KaabsSz+hZhewpnWejnpA31zP/5pT98RqUWE8Xyr0ynbOCcSbJECuWuembI16p HoHtdVJ1nsrkRDi+MNjHCYsqXj0SCUhYXirYTrUTQ2gkKiXWA3vufI+cubqcEpKQV+jwOG QiSCBlxQI8s4//sVwk7aVSYfk1L5Ehs= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=QNdah6QK; dmarc=none; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675055548; a=rsa-sha256; cv=none; b=k8SKwuefJYEju6wk/uFhwISCnQkS+x5u3u0yDkk+9p1QMbR+/j2j1IhNHTwYgqikxoC42O UdY+A/0m8cRZWUemkNUZ9xTlXr/qwF9wp0iKlfyOsRTk9nQsox7IwhaPz8L4q72P9tiGvX QD0pZgzbFi5FaES38htbh7XvOJYQ31k= 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=MS+Rl30LKC38gIgaEPBq9Y744hbvgXHkTTwFaNB2Z2k=; b=QNdah6QKy+fPpeNSIHVQ4PzJOu kZI1oBvm6NEf/LPSMGgVsDmqhZHbeIxOkFZvP7deHvCja4Qn+GbBO3Uhx2bu6jTI9tbTtqEaj74ie BunXceY8RNH29YEm32oF7/cYRZtJ3HTk5cAtk1M/RkqTDLNg4AuAIP5sH8akYCqoml/oaimpRw5XF V/SIzi6OxH6vdl6g+twfTYUwbOXgRYcf1XoaQ4MuJ3EMav4ReJIW8hZWWjigh1Iab48kNqhAIgoGV CRlYRp01GNd+i4B7qtrg75MHTHQZsn+UZZ4Ov4oyl+rHojUmau8sBvAemjxmnfQ3hNzPQalOy207r /v2+Gqqg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMMSK-00A3xt-5q; Mon, 30 Jan 2023 05:11:48 +0000 Date: Mon, 30 Jan 2023 05:11:48 +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: rspam02 X-Rspamd-Queue-Id: 0654A180014 X-Stat-Signature: zj317xnryac7kzhwhdizib745sxgnac6 X-HE-Tag: 1675055547-614387 X-HE-Meta: U2FsdGVkX1+g2kc2Y/fjqLe4lmzXwm4BUihNIxi/pvgAnEYEqhwYvFvczPX+OJwZoecr+lZgDMPp9hc81stCAFFNrBxay9JFzpQtL2NMIwbMXlGOpZjl2XJUL19m7luTpc3iYvA2f5gHa6uzjrXfCCNGFSyWfViONvi6Y7cy2oDtDxPgYScKaQ5mXhcLitg9oTZZbccyTt24rxeDJl8AvwFYVRnjU3oiBQN2qh/ij8zVMG3ttkyiXFsNhXV0PHhFe+kvW08aQahWJI4UICIbDKkIq0xoMZvczZvXd0o3K3IWpAHD31p3oeJKtSey2sesy+KPHXFDd2gj4xAnlYdFldEMmW5wU7jvfQ2muLvSVlBZByunJ8eGg8pSi3uW1+2nGCxGTYox7efNjLBRMZ35fBXZ+L8iWBXLIn0cO4W11PdjCypTI66J3G9pBwJqwl+/HZcnsMISUEa7HJc5rYax+Yh708ZdE70YDDCGMYcOiYRq9mFsRja7C22ne7zAzslmq9XG6AvRzECT7906tf9Q3WEr9VGS0uMunBmZvvep8ro4R/EdKUhH5/su9Z3eZfyZnO+63mHXfuZ8BAULBg7G1zjus7hLUiEMblsA3If2+bW8NQGCwm5Pt+6e+1/ixocBUMGr3gsZhkfzTTvW6XR4IrFOWCCf+N4Rdi3Y2SQ36+T+vcTZKdgWRbHDlK74s6nLpwr6O3rwZylWwsnSnfh4n3sAlecelyIabBxy/7vBQs8/mTX4B9T8n62wAsjoM+cRxXykWWpkFZ+YSgLZJG3z0Yex0c9xwPwh7ud0F27W9uy17dnxDVB2YT+J81QMq7XtxAvuEG2rBlLpi0TsJ9ix8kgYXOdln4zFpshoS3f9N0Zcns9OFknq6y61IrvYJxr74NYuQUs7a2JfSVhkMLgCkvYwEppUVn9rgal+8xwbpfl9TPiYUBtIbfh2tr8LRUbdjiG2NbiATVwhLKo67Jv +r4NigHu hR/PoTRtAm6apmGG+y5B5yU+PR0D+zGWvelqiRHZVkWCzpWUd+lpRb8k75TKr41AmXZw1SvlnP8i9S2CSjXMLadfvxRCTdcVT+ZjtZJ3Ja38Faeu1rGD5/k0cOAJcouNlKZqcifrlKpMARsMgYI4xY1TIBjatsZeP5Ls3MyekxLNAJYFFwmpkZCdLwCxcBmIM/TGtjPOXolXcNWyCIfQZ55phLCIF9ZV389Meyipc14lhiGmski/rt3D1ys7o8E9TwS6PtbWG7Elck4MNxJQE8Ase9Q== 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 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, eg PageSlab() can now be (page->flags & PG_type) == PG_slab where #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 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) 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?)