From patchwork Tue Apr 23 05:18:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shakeel Butt X-Patchwork-Id: 13639355 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 F0D54C4345F for ; Tue, 23 Apr 2024 05:19:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F4AD6B00B7; Tue, 23 Apr 2024 01:19:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A51A6B00B9; Tue, 23 Apr 2024 01:19:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 66CD26B00BA; Tue, 23 Apr 2024 01:19:04 -0400 (EDT) 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 4702A6B00B7 for ; Tue, 23 Apr 2024 01:19:04 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E9F0D120C37 for ; Tue, 23 Apr 2024 05:19:03 +0000 (UTC) X-FDA: 82039642566.24.B62F7A7 Received: from out-189.mta0.migadu.com (out-189.mta0.migadu.com [91.218.175.189]) by imf27.hostedemail.com (Postfix) with ESMTP id 2A7D440009 for ; Tue, 23 Apr 2024 05:19:01 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=I4F4bHP1; spf=pass (imf27.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.189 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713849542; a=rsa-sha256; cv=none; b=wzdmX4u04qx+Of6NMb1rtGNcpOj4/D1pHIat7fKpIo35+OYP6wBUvBDPjsJJuo7w6t0wYN 53U97ooDav4RaxOsZwIMGe90XEMZClj6fkhUl7h47sfHbLYbhjF08CS5qe7c72fbMg7R35 6K3ygx6DZz5a6LX/qIlZV05M6LL8oXI= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=I4F4bHP1; spf=pass (imf27.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.189 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713849542; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bmlC5V1svJt9xuRUdyZMky0nyZvqteAMmSbcGNRQ+Ug=; b=upN3qTMkNNLBkAr7Wl6YUabi8ZkoY5cMYCLETyuWWstqKGxKuVs79sZgXvsQz3yUAS/IAE 7w9Nvt7AY+oLdTNW5HVGb8UZB3Wj2Bhd6wDz/IHLn/as3NGYEC0HMnCg5XO6zbAi+bdKhS 6Gmh5ZrWoT/y1OesKQZWYzFIKubqFx0= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1713849540; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bmlC5V1svJt9xuRUdyZMky0nyZvqteAMmSbcGNRQ+Ug=; b=I4F4bHP1pHL9StE0oEfUCq18gVSk6V5wUHsNH2r4mbFqr3BWQqPEZJK6aDP5C5HBbpIZbm 7qNg7St16OMmZI9IF5XHvpKb6ahSRJqZ0Zorrf3bW8J+CXso/2RX9xjYMLMCnj2Tim11hK zgXSePbl3UN1y1lt9gtQCIJB2FGhKJk= From: Shakeel Butt To: Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] mm: rearrange node_stat_item to put memcg stats at start Date: Mon, 22 Apr 2024 22:18:23 -0700 Message-ID: <20240423051826.791934-2-shakeel.butt@linux.dev> In-Reply-To: <20240423051826.791934-1-shakeel.butt@linux.dev> References: <20240423051826.791934-1-shakeel.butt@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 2A7D440009 X-Stat-Signature: fnc3ccynewrje3kj913m4ifc39pkyhy3 X-Rspam-User: X-HE-Tag: 1713849541-491353 X-HE-Meta: U2FsdGVkX1880JaekNR7vdGs7suZmMqmcPi0d2jql9NsFAG1AdwlZLsSYUsIcjCH378foEXcm7R8Ee2BvqEjMCEX9Ddgc5tHukrrJSEDlmM+U3Lztnc4d+8HBdjeY/q2lQ16Ed+1enMG/SkRV82lddNeeHZsSMcHwI+XB1r5VSdZJ6a16GTT4HaxFKjpGYSXt80YhLXD17KCH3zpSM3sxsYgqb1huAy6NC7SXOKi7RETfB614wj/wYZGPx0rt3z4ypjhsSXjKQeY+C/In4bK2I5BbAK0Y6MhLYbQtgjMHElvtu+XtrKCH7AdSrQzID3R7snuf50OzOJdayxKDsinofYLZuvMkXCmJGzVimLq6da4vY3W7TmDLXPHepa/mtMbjVWAR6ppvQCmdaQXAsF7ZMNS8fOCKujDdQiRs4UsP5Ib7it0Pahh2ZfI7bF2EK+4EPiK9SWvqr6JepfLPc+QUlx108FG/HQ2zNsS6SZ1rVb5qaGitAsio6SZJzUyvBxWY4iGhucbNaT6B8b5RCMNnPFvpwhSnQOhRE0NTOXrisSxrGoD5TkD7gPNRhQWF8IafJley2L8JPN20t+VYZKVFiwVl6bwJaNfBiPvjuH4Qwi9dN0GhoS6jvYOLeEvfdmcmurdRBzdGBUocJdiPLpz6VRFLjmS8RK9F2B4a8JXdmDil6Lv3lrJTBVVy+Fg3R0YVYqUTU0zBAL/95iO4gFwthEk/YqtXnYgxnQ5BIpY8eSFzVjCY4hE9AT5V674FFdsGiPEgl7HvWgSio7E7hhxAH64M+1U8WNxJ9cuQgxfhiP/X5QVAEJTNrahyhCLWbbA6b4wxIq0KksZFuUdQT/9YrUlgyRQ7ofzQDXbcYbYpza/5pBDLAu288cxLec6AhYgfhNy51yT5IRQOXKWazPNBAZp231bA4YJxxY+GwzxlyT+W0EpR53bCIad1RJ2GloCcZ0KhEUOziwpyq+VaGE OGQ4oNG5 OJK+5gf+zBagllj7v8kmFR6ZLQLM48urnhLZwpO5zewx/KasWV/N4zeY9jzyifVa7x2YZOkOCCjvDyAYcIutdnFnEW6WYwylGDWsZdD8PC6xK5ylH8Ao7iHC4nVUmaBjf6kBV 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: List-Subscribe: List-Unsubscribe: At the moment the memcg stats are sized based on the size of enum node_stat_item but not all fields in node_stat_item corresponds to memcg stats. So, rearrage the contents of node_stat_item such that all the memcg specific stats are at the top and then the later patches will make sure that the memcg code will not waste space for non-memcg stats. Signed-off-by: Shakeel Butt --- include/linux/mmzone.h | 25 +++++++++++++------------ mm/vmstat.c | 24 ++++++++++++------------ 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 8f9c9590a42c..989ca97402c6 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -166,9 +166,6 @@ enum node_stat_item { NR_UNEVICTABLE, /* " " " " " */ NR_SLAB_RECLAIMABLE_B, NR_SLAB_UNRECLAIMABLE_B, - NR_ISOLATED_ANON, /* Temporary isolated pages from anon lru */ - NR_ISOLATED_FILE, /* Temporary isolated pages from file lru */ - WORKINGSET_NODES, WORKINGSET_REFAULT_BASE, WORKINGSET_REFAULT_ANON = WORKINGSET_REFAULT_BASE, WORKINGSET_REFAULT_FILE, @@ -179,39 +176,43 @@ enum node_stat_item { WORKINGSET_RESTORE_ANON = WORKINGSET_RESTORE_BASE, WORKINGSET_RESTORE_FILE, WORKINGSET_NODERECLAIM, + NR_PAGETABLE, /* used for pagetables */ + NR_SECONDARY_PAGETABLE, /* secondary pagetables, KVM & IOMMU */ + NR_KERNEL_STACK_KB, /* measured in KiB */ NR_ANON_MAPPED, /* Mapped anonymous pages */ NR_FILE_MAPPED, /* pagecache pages mapped into pagetables. only modified from process context */ NR_FILE_PAGES, +#ifdef CONFIG_SWAP + NR_SWAPCACHE, +#endif NR_FILE_DIRTY, NR_WRITEBACK, - NR_WRITEBACK_TEMP, /* Writeback using temporary buffers */ NR_SHMEM, /* shmem pages (included tmpfs/GEM pages) */ NR_SHMEM_THPS, - NR_SHMEM_PMDMAPPED, NR_FILE_THPS, - NR_FILE_PMDMAPPED, NR_ANON_THPS, + /* No memcg stats for the following fields. */ + NR_SHMEM_PMDMAPPED, + NR_FILE_PMDMAPPED, + NR_WRITEBACK_TEMP, /* Writeback using temporary buffers */ NR_VMSCAN_WRITE, NR_VMSCAN_IMMEDIATE, /* Prioritise for reclaim when writeback ends */ + NR_ISOLATED_ANON, /* Temporary isolated pages from anon lru */ + NR_ISOLATED_FILE, /* Temporary isolated pages from file lru */ + WORKINGSET_NODES, NR_DIRTIED, /* page dirtyings since bootup */ NR_WRITTEN, /* page writings since bootup */ NR_THROTTLED_WRITTEN, /* NR_WRITTEN while reclaim throttled */ NR_KERNEL_MISC_RECLAIMABLE, /* reclaimable non-slab kernel pages */ NR_FOLL_PIN_ACQUIRED, /* via: pin_user_page(), gup flag: FOLL_PIN */ NR_FOLL_PIN_RELEASED, /* pages returned via unpin_user_page() */ - NR_KERNEL_STACK_KB, /* measured in KiB */ #if IS_ENABLED(CONFIG_SHADOW_CALL_STACK) NR_KERNEL_SCS_KB, /* measured in KiB */ #endif - NR_PAGETABLE, /* used for pagetables */ - NR_SECONDARY_PAGETABLE, /* secondary pagetables, KVM & IOMMU */ #ifdef CONFIG_IOMMU_SUPPORT NR_IOMMU_PAGES, /* # of pages allocated by IOMMU */ #endif -#ifdef CONFIG_SWAP - NR_SWAPCACHE, -#endif #ifdef CONFIG_NUMA_BALANCING PGPROMOTE_SUCCESS, /* promote successfully */ PGPROMOTE_CANDIDATE, /* candidate pages to promote */ diff --git a/mm/vmstat.c b/mm/vmstat.c index 8507c497218b..4eac2f6322a3 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1206,9 +1206,6 @@ const char * const vmstat_text[] = { "nr_unevictable", "nr_slab_reclaimable", "nr_slab_unreclaimable", - "nr_isolated_anon", - "nr_isolated_file", - "workingset_nodes", "workingset_refault_anon", "workingset_refault_file", "workingset_activate_anon", @@ -1216,38 +1213,41 @@ const char * const vmstat_text[] = { "workingset_restore_anon", "workingset_restore_file", "workingset_nodereclaim", + "nr_page_table_pages", + "nr_sec_page_table_pages", + "nr_kernel_stack", "nr_anon_pages", "nr_mapped", "nr_file_pages", +#ifdef CONFIG_SWAP + "nr_swapcached", +#endif "nr_dirty", "nr_writeback", - "nr_writeback_temp", "nr_shmem", "nr_shmem_hugepages", - "nr_shmem_pmdmapped", "nr_file_hugepages", - "nr_file_pmdmapped", "nr_anon_transparent_hugepages", + "nr_shmem_pmdmapped", + "nr_file_pmdmapped", + "nr_writeback_temp", "nr_vmscan_write", "nr_vmscan_immediate_reclaim", + "nr_isolated_anon", + "nr_isolated_file", + "workingset_nodes", "nr_dirtied", "nr_written", "nr_throttled_written", "nr_kernel_misc_reclaimable", "nr_foll_pin_acquired", "nr_foll_pin_released", - "nr_kernel_stack", #if IS_ENABLED(CONFIG_SHADOW_CALL_STACK) "nr_shadow_call_stack", #endif - "nr_page_table_pages", - "nr_sec_page_table_pages", #ifdef CONFIG_IOMMU_SUPPORT "nr_iommu_pages", #endif -#ifdef CONFIG_SWAP - "nr_swapcached", -#endif #ifdef CONFIG_NUMA_BALANCING "pgpromote_success", "pgpromote_candidate",