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", From patchwork Tue Apr 23 05:18:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shakeel Butt X-Patchwork-Id: 13639356 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 11F13C4345F for ; Tue, 23 Apr 2024 05:19:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9CB3E6B00B9; Tue, 23 Apr 2024 01:19:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 97A496B00BB; Tue, 23 Apr 2024 01:19:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 81A8E6B00BC; Tue, 23 Apr 2024 01:19:11 -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 62DB46B00B9 for ; Tue, 23 Apr 2024 01:19:11 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 25FBA1C0A6D for ; Tue, 23 Apr 2024 05:19:11 +0000 (UTC) X-FDA: 82039642902.27.225D04D Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) by imf22.hostedemail.com (Postfix) with ESMTP id 71B48C000A for ; Tue, 23 Apr 2024 05:19:09 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=rs11xhPn; spf=pass (imf22.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.173 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=1713849549; a=rsa-sha256; cv=none; b=A+Xv+810JtnYbSHXyofFWKnYWJtSsQeWZOxoP3V8sf1f4/AIT5H0ifAX8aPanLORhN2lFF YuPauBh/K6ZcrZksivujlS8Sjmf5kX6XY7AjMFgcUof3/7Iow3zsEffjtJgN9F2R+QHp86 7FDSrTnayddEe/pG22aS/cAZIOvl7f4= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=rs11xhPn; spf=pass (imf22.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.173 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=1713849549; 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=mPVb/7bJYg0jCXHlUHlEkoC8VRMDznvlUA6F/qpq0LU=; b=L3voLyuvizt9uJ/pJ+XViyLN9ORrCFeLi+CzZgqXzdsaZtHM6gE4+/y18jE3wzgH7f9x/v 5XHZpZNoLP5WAPDapmsIjRw49NqL33xZ6odfpbhahEzRR1aS9WH6uFf9TmgXil0YnFJahD /9ipPWuXsqrU7QmVNL3tG4TTK/boq2s= 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=1713849547; 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=mPVb/7bJYg0jCXHlUHlEkoC8VRMDznvlUA6F/qpq0LU=; b=rs11xhPnd+9ujJmxyiwAvIbaHbCvJYdPVIddaFlw5SnCPmRJf2G7uYXy12IKeEAF5st3Lj b59FvyJ5wKuhH/XVQ6PnB0vVo8qJTGEnv4SY4rfkSAgFn0xbURo2o9NiV0/PjYCL0/JEeB Uv0DlU5Nl1YornvPTybWThJ/C1flxus= 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 2/4] memcg: reduce memory for the lruvec and memcg stats Date: Mon, 22 Apr 2024 22:18:24 -0700 Message-ID: <20240423051826.791934-3-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: rspam03 X-Rspamd-Queue-Id: 71B48C000A X-Stat-Signature: ts958rwtn5wa9wa6j4hfepwyhj4kzs7n X-Rspam-User: X-HE-Tag: 1713849549-591814 X-HE-Meta: U2FsdGVkX19llFHoJIbnRidd4IRvrZtqoPvbzxqBUT6Cq5jGHepsEfGGKud53Z1T5Je9XouTF0HVx7MVSJv70p9KqSpWP+5M8/N0F8XjJAgzkdKPZUPzyD3Iodb6C1gG+F1V+8JiKfoRPHdTdyIiJRT5LHJcczQRRrHyrMOV/TmdneUMe/d6iH0xQXxK0QH2Ak/UkVzEH7ZQiR1nLYE6mBU1DfD3EPZAX/Lyjrs4Yf8vJk/t3F/E5IooducQqVGEtG5IidfEjadUSOJI8MS5CJq2sLY1qTo/7nnq2n9dnhqju8tYH37WAeKQyDE2J4TDzcHnijJ2h1heXRvzYdDzRMiK+hfqSE81RxzDlXrCYP1qT/Ck2LuV1b80eiPyYDva7VOwr1yyhg/M+NVK3MN+u7FD6Bg2axa4SY1HFcj+7iuRQEvaKRBj67ttYLHdFEj4a/eJFyvR4qQYpX0NeX8c02ZGZ4UYvIOZHGgm8v2LF7kvAGJ2iIIecJBIH1x+akDDr3qYZ5xXhxeAhe8ixBRZS+PO9zb9C1KD+HE2ose2L4k7HvY3e69CW6c7wDtGluOcB8xsszvH5n6ySB5et8TaP5HwGy3GTVXV53jjlG9VZySoTHicpPgO8dBnAa/jO2vL5uhGLSKkasfwMccG5NDt7zTbZwp1Bf1ceMhdbVminUyjxIpksrmcnHONu3x85ZWr0N4QsFk8BjVbodbvcBtqRdXQCbQykgkufkVv0EvNVh682Yo4I5HWDQI/tBJPphx/i4uyfJCL11qemd8Q4PMHzzT4dergtuRrvZpQbPv8s0BxRcIGlbtnqqANBdEFdcYuxEm3glUxo4H5STxKqOotuCOTK/T8uiJhuQrftQ8sxcT0Kap/FM/LiO8CY8FPnf8Pv0pUYAIrWIUu5lqCgVgVUHNroen8vZgBdQk71ZiYeHBXQCwzr28NXVKdn1STSxnHHlwsuR2Vkb+9mtBFpOU gJqWgwjg Mro1AEhPq+P1pBoB0T8JgZcBtDO7vMNWqzKB3/LCo8/xfRGZdsjNwVWgZ2V99zrrqkr9LW23je6xjuT0= 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 amount of memory allocated for stats related structs in the mem_cgroup corresponds to the size of enum node_stat_item. However not all fields in enum node_stat_item has corresponding memcg stats. The fields of enum node_stat_item is sorted in such a way that all the fields with corresponding memcg stats are at the start of the enum node_stat_item. So, let's just make an explicit boundary within enum node_stat_item and use that boundary to allocate memory for stats related structs of memcgs. For a given x86_64 config, the size of stats with and without patch is: structs size in bytes w/o with struct lruvec_stats 1128 648 struct lruvec_stats_percpu 752 432 struct memcg_vmstats 1832 1352 struct memcg_vmstats_percpu 1280 960 The memory savings is further compounded by the fact that these structs are allocated for each cpu and for node. To be precise, for each memcg, the memory saved would be: Memory saved = ((21 * 3 * NR_NODES) + (21 * 2 * NR_NODS * NR_CPUS) + (21 * 3) + (21 * 2 * NR_CPUS)) * sizeof(long) Where 21 is the number of fields eliminated. Signed-off-by: Shakeel Butt --- include/linux/memcontrol.h | 12 ++++++------ include/linux/mmzone.h | 8 ++++++-- mm/memcontrol.c | 5 ++++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 9aba0d0462ca..d68db7a0e829 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -32,7 +32,7 @@ struct kmem_cache; /* Cgroup-specific page state, on top of universal node page state */ enum memcg_stat_item { - MEMCG_SWAP = NR_VM_NODE_STAT_ITEMS, + MEMCG_SWAP = NR_VM_NODE_MEMCG_STAT_ITEMS, MEMCG_SOCK, MEMCG_PERCPU_B, MEMCG_VMALLOC, @@ -92,21 +92,21 @@ struct mem_cgroup_reclaim_iter { struct lruvec_stats_percpu { /* Local (CPU and cgroup) state */ - long state[NR_VM_NODE_STAT_ITEMS]; + long state[NR_VM_NODE_MEMCG_STAT_ITEMS]; /* Delta calculation for lockless upward propagation */ - long state_prev[NR_VM_NODE_STAT_ITEMS]; + long state_prev[NR_VM_NODE_MEMCG_STAT_ITEMS]; }; struct lruvec_stats { /* Aggregated (CPU and subtree) state */ - long state[NR_VM_NODE_STAT_ITEMS]; + long state[NR_VM_NODE_MEMCG_STAT_ITEMS]; /* Non-hierarchical (CPU aggregated) state */ - long state_local[NR_VM_NODE_STAT_ITEMS]; + long state_local[NR_VM_NODE_MEMCG_STAT_ITEMS]; /* Pending child counts during tree propagation */ - long state_pending[NR_VM_NODE_STAT_ITEMS]; + long state_pending[NR_VM_NODE_MEMCG_STAT_ITEMS]; }; /* diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 989ca97402c6..59592f3c7d9b 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -192,8 +192,12 @@ enum node_stat_item { NR_SHMEM_THPS, NR_FILE_THPS, NR_ANON_THPS, - /* No memcg stats for the following fields. */ - NR_SHMEM_PMDMAPPED, + /* + * No memcg stats for the following fields. Please add stats which have + * memcg counterpart above NR_VM_NODE_MEMCG_STAT_ITEMS. + */ + NR_VM_NODE_MEMCG_STAT_ITEMS, + NR_SHMEM_PMDMAPPED = NR_VM_NODE_MEMCG_STAT_ITEMS, NR_FILE_PMDMAPPED, NR_WRITEBACK_TEMP, /* Writeback using temporary buffers */ NR_VMSCAN_WRITE, diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 833d09c1d523..bb1bbf417a46 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1648,6 +1648,9 @@ static void memcg_stat_format(struct mem_cgroup *memcg, struct seq_buf *s) { int i; + /* Reduce by 1 for MEMCG_SWAP as that is not exposed in v2. */ + BUILD_BUG_ON(ARRAY_SIZE(memory_stats) != MEMCG_NR_STAT - 1); + /* * Provide statistics on the state of the memory subsystem as * well as cumulative event counters that show past behavior. @@ -5869,7 +5872,7 @@ static void mem_cgroup_css_rstat_flush(struct cgroup_subsys_state *css, int cpu) lstatc = per_cpu_ptr(pn->lruvec_stats_percpu, cpu); - for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++) { + for (i = 0; i < NR_VM_NODE_MEMCG_STAT_ITEMS; i++) { delta = pn->lruvec_stats.state_pending[i]; if (delta) pn->lruvec_stats.state_pending[i] = 0; From patchwork Tue Apr 23 05:22:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shakeel Butt X-Patchwork-Id: 13639357 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 86461C4345F for ; Tue, 23 Apr 2024 05:22:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B6726B00BC; Tue, 23 Apr 2024 01:22:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 166EF6B00BD; Tue, 23 Apr 2024 01:22:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 02ED36B00BE; Tue, 23 Apr 2024 01:22:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D85B06B00BC for ; Tue, 23 Apr 2024 01:22:38 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 71781140CB8 for ; Tue, 23 Apr 2024 05:22:38 +0000 (UTC) X-FDA: 82039651596.20.CE38B3F Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) by imf05.hostedemail.com (Postfix) with ESMTP id 9678B100007 for ; Tue, 23 Apr 2024 05:22:36 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="Kg8z/ycj"; spf=pass (imf05.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.174 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=1713849756; a=rsa-sha256; cv=none; b=gRAb1TM4rk22cENo5G+P/Pk2vLcPIUJE6+en4eocXWKO5+IOcnzpMng8kym1UnxmuQqs48 HkYpFFc3jw/0lUVCpD/W3rYeqx+OGoK/2GD9xvkE+Q20V3Q5eB7FN8+tRFhVRbllLECWJL CvsEqq3xjP0PCQWnZrt1TNg8wHEUelY= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="Kg8z/ycj"; spf=pass (imf05.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.174 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=1713849756; 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=Xvtrhcgh7fYw/hL4J7A9xLofIUItI4MUTx9KgzBK7Qg=; b=hRmxz7DRoCur8Rd4JyQPs4kgtXcdx0S3myhGlbWn1+4HtOUoG2it5Mf2gMvpU/N8cH0r2k 7v1XT4mttvHnu2rq6RcD6OZlC9MXMtUVnOfybzd3+gLLZpOwrqZbjDuJl9BKtfDiPEJBi/ VHu06zpgtiJUv0FqU+ZsAx7ong+vFBc= 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=1713849755; 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=Xvtrhcgh7fYw/hL4J7A9xLofIUItI4MUTx9KgzBK7Qg=; b=Kg8z/ycj3MaZtANqRXeXZ1V1ivb5UyCYaTC6fzquwAx9gFlUEGBEKvzgDhNh7mEcTNL/k3 WRxxJuWwU3W+VgCJtRWkcSRsf/BEniqbK3VdB4qrShdr0rH/A2X69hcvnsLCoYAK8V9K8T zT2Y0SQoTIKTxVMMBKi3pnG3FszC4P0= 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 3/4] memcg: use proper type for mod_memcg_state Date: Mon, 22 Apr 2024 22:22:27 -0700 Message-ID: <20240423052227.804788-1-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: rspam03 X-Rspamd-Queue-Id: 9678B100007 X-Stat-Signature: r7mxqaa43cij9kpehk4jjiy19m3wghxz X-Rspam-User: X-HE-Tag: 1713849756-126764 X-HE-Meta: U2FsdGVkX1/ArWSadMvgiOBhFUCAOIRbXbYW+JnOlHDuc6lE9nKn1rtCyfJIZ4MU0s/CWwLU1tjkqEvS3cxtozTA6eQh9BrCK1jwWQ8RmZT713aDCGhj5svooxGbSF5yjoQossNnPPILIxPoM04e9P3Mpq5SAmvQ0EDkGmup+n5QbknN+dLwYKhBu7F6ZwFPrWczaoK77LORJDf6Oy2oEUe6pdBa1TN97eRxB2mvmbD6BTL5jJkVMiSy0SUmlER5pNpbDv06CKhq5nYMwcoL/zZ5Q2i7rb7RGUAdgzd+8p7LRqCzmWMxJSVuKq57aOe5ChGYAfzx1C+C+Tvmsk7f9sr8mrL3W46zZjJA1PlWPw73gqRDzLk15DR2M7nIAhePFsBJiJYaRj9OkJgwi6RUA9yxTXVaqGI0iqceyCn649I9bphajOBMZXDLGSIzmVwFchS9ow5SH7pdbNN5O+dV9efPJG5k73v4AAx0bTgxzCuBoQpB7AGxdAG/ywj0/GRi/oxHKydd/HKSmX2kYgAfWmmpJnrjDpHbWfrHqlXM3ku9Ze3KnJD3O0JXbTZG/9HHh/uhpyToGYkMKxNqNik9GoVAkDWkv4kI5wfyxS/F79bCUzfUq5MzMtXKflMKvXhJH6grvuL0YhPiim8kZHFhveUQ11+Iy6YmuBWi6iNovFCUodvcIlsImr2afdJTllsZEvTrlwDNm0zbxCdtvMJnKSF6cPoF4PcXsX1CA1wZi1dSDEiA4A+fQpFWrHq8J5mqSr66FtMea2rr4EIXukxQkSwyWtZ3mKl8afsdYHfSw3966Xy5EmfMi2FFETCh567i598VOlSSl0U9AwTg91UIQGPPRJJGaOeKXWpUGpL9hFJ7gq9EdWdLAZlds+4BmQe+ZxX0Twx4LTnlcP00WjdGBDcDxXyiMEvanOH8sca8gTQzGza7OYO78dd8I/jJIjfdW+5AO78O8T6eegSqOLE l9AyrrNB 5RQjhFIQx/kiWEnn0x0/PrIzTU5uHxe+uimGz2TNlOYAzMk7PYhgQs9Y5XJevR+60BwFRO83XujXGXEA7T/H/Ayat/9xdR0SW0pYVQHj9Xj4zry7dy6nfVdiykG9OlyDGDaKH 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: The memcg stats update functions can take arbitrary integer but the only input which make sense is enum memcg_stat_item and we don't want these functions to be called with arbitrary integer, so replace the parameter type with enum memcg_stat_item and compiler will be able to warn if memcg stat update functions are called with incorrect index value. Signed-off-by: Shakeel Butt --- include/linux/memcontrol.h | 13 +++++++------ mm/memcontrol.c | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index d68db7a0e829..1b4a6201c78c 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -991,7 +991,8 @@ void mem_cgroup_print_oom_group(struct mem_cgroup *memcg); void folio_memcg_lock(struct folio *folio); void folio_memcg_unlock(struct folio *folio); -void __mod_memcg_state(struct mem_cgroup *memcg, int idx, int val); +void __mod_memcg_state(struct mem_cgroup *memcg, enum memcg_stat_item idx, + int val); /* try to stablize folio_memcg() for all the pages in a memcg */ static inline bool mem_cgroup_trylock_pages(struct mem_cgroup *memcg) @@ -1012,7 +1013,7 @@ static inline void mem_cgroup_unlock_pages(void) /* idx can be of type enum memcg_stat_item or node_stat_item */ static inline void mod_memcg_state(struct mem_cgroup *memcg, - int idx, int val) + enum memcg_stat_item idx, int val) { unsigned long flags; @@ -1022,7 +1023,7 @@ static inline void mod_memcg_state(struct mem_cgroup *memcg, } static inline void mod_memcg_page_state(struct page *page, - int idx, int val) + enum memcg_stat_item idx, int val) { struct mem_cgroup *memcg; @@ -1541,19 +1542,19 @@ static inline void mem_cgroup_print_oom_group(struct mem_cgroup *memcg) } static inline void __mod_memcg_state(struct mem_cgroup *memcg, - int idx, + enum memcg_stat_item idx, int nr) { } static inline void mod_memcg_state(struct mem_cgroup *memcg, - int idx, + enum memcg_stat_item idx, int nr) { } static inline void mod_memcg_page_state(struct page *page, - int idx, int val) + enum memcg_stat_item idx, int val) { } diff --git a/mm/memcontrol.c b/mm/memcontrol.c index bb1bbf417a46..4e991e913393 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -816,7 +816,8 @@ static int memcg_state_val_in_pages(int idx, int val) * @idx: the stat item - can be enum memcg_stat_item or enum node_stat_item * @val: delta to add to the counter, can be negative */ -void __mod_memcg_state(struct mem_cgroup *memcg, int idx, int val) +void __mod_memcg_state(struct mem_cgroup *memcg, enum memcg_stat_item idx, + int val) { if (mem_cgroup_disabled()) return; From patchwork Tue Apr 23 05:23:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shakeel Butt X-Patchwork-Id: 13639358 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 0A466C4345F for ; Tue, 23 Apr 2024 05:23:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9314F6B00BE; Tue, 23 Apr 2024 01:23:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E17A6B00BF; Tue, 23 Apr 2024 01:23:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F8A56B00C0; Tue, 23 Apr 2024 01:23:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5F5C06B00BE for ; Tue, 23 Apr 2024 01:23:51 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id EBAC614025D for ; Tue, 23 Apr 2024 05:23:50 +0000 (UTC) X-FDA: 82039654620.19.705F351 Received: from out-180.mta0.migadu.com (out-180.mta0.migadu.com [91.218.175.180]) by imf19.hostedemail.com (Postfix) with ESMTP id 3EA1A1A000B for ; Tue, 23 Apr 2024 05:23:49 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=OvsiSo2V; spf=pass (imf19.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.180 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=1713849829; 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=7wZMRsMyHQHXjFKrcDnWCD1NMGczgsTlPNC9ZrGXAJ8=; b=W5CSsyKe4MIlTnkOrQ6b2iYq0bRSknkigSybbY/lXZjpo65CkhgzIdJ3a1qEzNSGffQsgt 8fD5/Np2zwh9G5d0/F3n5lpkXcNKNz1F7hQmT4p/tpncT/Gft8WiU9W+uPJpSbV7IvAROY XSgGtO/A0bd6asuIw0akjCJU/RkFKG8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713849829; a=rsa-sha256; cv=none; b=FYZ/WKp/98TOtYZ0YqzsGSl6jclxLzMWSh+2VdqaYlzKuLRuWSgiEB2vujp/x47pozqjZr m6NERzYLtjxB87RqDHWnwX5lLo6l96hXEHcqTYaC8atJ6gs5Z6orO/4NWxKoDw+iuBgozg gd76Ar+aGwEXKO7z133IeiYK/8Iy7RA= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=OvsiSo2V; spf=pass (imf19.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.180 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev 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=1713849827; 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=7wZMRsMyHQHXjFKrcDnWCD1NMGczgsTlPNC9ZrGXAJ8=; b=OvsiSo2VciEz80V+ECLlsVWhu9VrKAZMMiT5JyhaIJpiJCaRlCFNPBSSnIM/oQ0A13NJ6j Q0M6ktSc75eUe/FEsbEGO8Xw0LzcxsIBnDqZmgTIXd3X28/O0v+b8GHm92PPzMRnAkJ0U6 /BuPKk6hpDPgJz/MbeeRSvhhJ5MUOLI= 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 4/4] memcg: restrict __mod_memcg_lruvec_state to memcg stats Date: Mon, 22 Apr 2024 22:23:43 -0700 Message-ID: <20240423052343.811563-1-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: rspam12 X-Rspamd-Queue-Id: 3EA1A1A000B X-Rspam-User: X-Stat-Signature: ri4ch78tcybtogmf59dq5dt64zbuao68 X-HE-Tag: 1713849829-291192 X-HE-Meta: U2FsdGVkX18ISl58GNvfrOvP6Ji+rEWriJnoZBd/UAmnAmokr3i3SqS0EchFItTYWHwhlt4ati2X8nvGaECr0aRkjiLfI3d0dBjjjHIoj7bY3DLBXWK8W/+yuHbz/0Vo3wYn7ARgOTQTcn335W/V8BkLehgH4fLdzlz1iAK/BfkUudj5s1KGbNJL6FCJ6E3AeAoCD/3qMLTbjVE6QFcCvNtH2jWWB7Y/mGpZ5BhUJbcFUq7Ai+yBYHQexTjDS5VogUG3v11QrJgc9cexgA09lTPdb58yPVjdbzNDu2L2hf8ik8gyQWe9OLay+cEF16u/gT+4MyE0DxjBHnODmWk3Cc6lol0iT9T5DKjGnEhhbxqLIx9QIutNvPu9MvSmewwpjgzLTST0VBTVOBDbMPnu4ILwOIMA3JCvOqnwxG2A3IMyOGUt5OoAhAXS10xkysxtLBbdaNoKstyQr7zcssmQTY8YZZYTkvpj8GWO9QTFcnXfj0y5EoxPzAaC026YK6MoaJBsmMT9uLIZE1QxBptQ5U/RJU89tX+tUjoEPm+ul4nsElo7nGFDeFxhb4oRfDFxDV/EiE5GkZ7ha+vwac2ZVo4XcKbpRv5dCQqN05RaPlZdmNb3lsdaZpKlvbC2OpQG6zZoFDdhsy7Jno24BUPK1l7dawlekC4dV2bjVJxja3Wr7PDdhiVC95aCOqaRvlZBFLajQkYCy8YKCLWv3/8LSA0j/rGNbehDnCAJ5fwpCP3Wi/Remesweqvdop7KP1kmWSn96X3MXHY9YT/DGBr4Z0BGuKMd1R1e7Q9YqC+mtHR5bOXcfJniN55SzwoMbq/c4e4jXA9uNEZPRGVo2gIsUCp7wElpdNBuF+fFKEi5pwtm4uCPyRjr2wCBsy4/oH/zQBZj9kIAHAuDmfwfjJ68PG1YuxvH9r5aRXNLC/VGj4lZFPF9BQokLrWBJMN/nbmHbdfTQlLvR+3mbEyUlno SCHrY/jq 6RyYK7YooGIuuyuuyvc/LgsDIwIpaL+a0tZuuhzc72uDUQgsLExj6BH9+525wlZDYsp2rT8po6zV15fdnt1YNXZ5xwKcJBAOe/n4vmMAca1RSXWilRtUZ2eBjrPLa/OQoGx0/ 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: Currently __mod_memcg_lruvec_state takes enum node_stat_item as a parameter and enum node_stat_item contains both memcg and non-memcg stats but __mod_memcg_lruvec_state can only handle the memcg stats, so simply only call __mod_memcg_lruvec_state for memcg stats. Signed-off-by: Shakeel Butt --- mm/memcontrol.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 4e991e913393..531b6ff711c7 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -860,8 +860,6 @@ static void __mod_memcg_lruvec_state(struct lruvec *lruvec, case NR_ANON_MAPPED: case NR_FILE_MAPPED: case NR_ANON_THPS: - case NR_SHMEM_PMDMAPPED: - case NR_FILE_PMDMAPPED: if (WARN_ON_ONCE(!in_task())) pr_warn("stat item index: %d\n", idx); break; @@ -899,7 +897,7 @@ void __mod_lruvec_state(struct lruvec *lruvec, enum node_stat_item idx, __mod_node_page_state(lruvec_pgdat(lruvec), idx, val); /* Update memcg and lruvec */ - if (!mem_cgroup_disabled()) + if (!mem_cgroup_disabled() && idx < NR_VM_NODE_MEMCG_STAT_ITEMS) __mod_memcg_lruvec_state(lruvec, idx, val); }