From patchwork Thu Jul 4 00:27:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 13723088 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 D4FD4C2BD09 for ; Thu, 4 Jul 2024 00:27:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D25176B0082; Wed, 3 Jul 2024 20:27:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CD5426B0085; Wed, 3 Jul 2024 20:27:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B75A46B0088; Wed, 3 Jul 2024 20:27:27 -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 9849B6B0082 for ; Wed, 3 Jul 2024 20:27:27 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 06C1B80A35 for ; Thu, 4 Jul 2024 00:27:27 +0000 (UTC) X-FDA: 82300181334.02.4F38256 Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) by imf28.hostedemail.com (Postfix) with ESMTP id 77948C0005 for ; Thu, 4 Jul 2024 00:27:24 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="k3+S1qz/"; spf=pass (imf28.hostedemail.com: domain of roman.gushchin@linux.dev designates 91.218.175.177 as permitted sender) smtp.mailfrom=roman.gushchin@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=1720052826; 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:references:dkim-signature; bh=18SXq9zdacMnKFolMWLOVh2I+0mEmI4Fh14/DgUnfRo=; b=6T/ruD1SgEueNiHv+uwVbDxTuFZGS1Ip8fwK1pnrXs0jGsnE6S0zf3xKysY4eOGmEHHfJt CaeG1ROcvH7QdORjpj+kgYDCquFyJazFna+sU5tfcRGKIs+ZgXpK4Iy/Wj33yfT7QhFXNE uF+diinsBfOl20bsRsFEoK4QbxCpqHw= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="k3+S1qz/"; spf=pass (imf28.hostedemail.com: domain of roman.gushchin@linux.dev designates 91.218.175.177 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720052826; a=rsa-sha256; cv=none; b=lPrCIivZIHIDw0+806MQfeEexrWY+dILj0Mx/67UJSZQZyW3HE6sjP6s0KvQ066SABekBh eZFeAJikyQEqrsWSnmQe5PEP04XaWbjmzGm6t2YUqU5mqCJXbkwsKUkLe8XT4YecvWoaN1 x+wXztvDY7OcTmyk150A+2ahS2PQhEc= X-Envelope-To: akpm@linux-foundation.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1720052841; 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; bh=18SXq9zdacMnKFolMWLOVh2I+0mEmI4Fh14/DgUnfRo=; b=k3+S1qz/sE1uhjVXG/0uXEKKTowa54j/Khu/XHDQRhRwqLt05ACF2p99NiCQLWW9R436NB LPp4LIulNJ59MIFZypB5s9kuFWq0XN1H2jicrFXlARMwxxnEF4D1vl6n7GGAxrjY0dSrtW XUi8XzZ+5XZcV8gm/Q1Obgelt7MhmAg= X-Envelope-To: shakeel.butt@linux.dev X-Envelope-To: linux-mm@kvack.org X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: hannes@cmpxchg.org X-Envelope-To: mhocko@kernel.org X-Envelope-To: muchun.song@linux.dev X-Envelope-To: roman.gushchin@linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Andrew Morton , Shakeel Butt Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Johannes Weiner , Michal Hocko , Muchun Song , Roman Gushchin Subject: [PATCH] mm: memcg: move cgroup v1 oom handling code into memcontrol-v1.c: fixup Date: Thu, 4 Jul 2024 00:27:12 +0000 Message-ID: <20240704002712.2077812-1-roman.gushchin@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Stat-Signature: 8wwyj6x96ijxy3qa16s83tyhsc4fgs3c X-Rspam-User: X-Rspamd-Queue-Id: 77948C0005 X-Rspamd-Server: rspam02 X-HE-Tag: 1720052844-737580 X-HE-Meta: U2FsdGVkX1/FdK403ndDh80r1a1mjTUIiDnn1m4+KkL5P0kuhfYIyRseK2oHr3NKoOY4OLNWtHblJ8P6BeJcjoeLasIBSYXKdA+KPueefOnxztErRJA7i7AsY9YnVvUws8VA85ACpEnsTDwAYa7Z9sbCkXZPFlfFDneUuwbmpLLFrEUojcz9sLLAub9mn18gVNIK5cf9YMW76Ydu4kllIIf3flv6MK+b4I4zcIn2tRGsbn96DITtCbDjV67Mmchl+zeqFc+k9/JjHulIgzgip1omxNO1m9OcqVOKKlsp5MhElgC0pakta2we5fKTqc9jKPnkePguqTVUXe98dczOclE3Atqoy1HQp6wLXBrFOlFo/szPWnjLiiRIFwAUXj7TrXIUwq7gS/wiP/gc0OipbUH262FoJa+Htb9/2+Mvp3LfVzV5aD9z3cMXDt6nwCYp7E5v26gbK7hwEVCiwymHxcATtav96l7TWpbGR2IhULza9Pu2ElU72gNp5cNUck9dg1sefC5219W5TZ02DLYeU3pM3+QgYznUf1kn0zcp2iyx5ojmzA9JjSYxhYO5D1pGrK2Plyu59S//o8uiMYGxIKt0g8CASxXbqXN7NT7DFPS5zoLKQ0TlE44ql2ZLK/s7ohYS371xR8QlaevySi6efHlLarui49S/myPzV5OczrbAMcvXO6N+2l0nzrkMVDUUsGInoksL3BbkYvJD97QAWSgtTi4dk7wUaJiztD1mNVKMLQc5cm3hFgapjvWNc0mtYBYIluz0T5s3W8kDMOhtK5IG2gtw2WpERNx5d+Hz5LwWbqExyVUFWvP8KRrq0ieoSFOBDv+CKriOLoI/9El1RKaoxppAhFc3BDQs0ru269lPItnGJGS4P8Hc6baUgY1cCqffh00A9R58Xk560kkInmGNMLwXpP2m5PP/eHfmcNsVY+2Fy/AVGudSleOkvcFls6yxlfCA6xlQER8y68l ujvQA1Bn 9cRNepY5rFW7pIIO2IgVh3+zLmtCIkCPHuF58dmk9hezh4y4bbsvr3TVvjXSG39qzTSHTGNVzB5moCLE+YjiNb6xcW7Guct8oOmBRpd/wiuqzVFs= 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: This is a small fixup for the commit "mm: memcg: move cgroup v1 oom handling code into memcontrol-v1.c". I forgot to actually move two functions mem_cgroup_node_nr_lru_pages() and mem_cgroup_nr_lru_pages() into mm/memcontrol-v1.c, so that they remain in mm/memcontrol.c and their commented out duplicated versions in mm/memcontrol-v1.c. Andrew, can you, please, squash it into the original commit? I checked that the rest of mm-unstable tree can be rebased automatically without any merge conflicts. Signed-off-by: Roman Gushchin --- mm/memcontrol-v1.c | 74 +++++++++++++++++++++++----------------------- mm/memcontrol-v1.h | 5 ---- mm/memcontrol.c | 38 ------------------------ 3 files changed, 37 insertions(+), 80 deletions(-) diff --git a/mm/memcontrol-v1.c b/mm/memcontrol-v1.c index 42829cbf7b48..597b03ee9e35 100644 --- a/mm/memcontrol-v1.c +++ b/mm/memcontrol-v1.c @@ -2494,43 +2494,43 @@ static ssize_t mem_cgroup_reset(struct kernfs_open_file *of, char *buf, #define LRU_ALL_ANON (BIT(LRU_INACTIVE_ANON) | BIT(LRU_ACTIVE_ANON)) #define LRU_ALL ((1 << NR_LRU_LISTS) - 1) -/* static unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg, */ -/* int nid, unsigned int lru_mask, bool tree) */ -/* { */ -/* struct lruvec *lruvec = mem_cgroup_lruvec(memcg, NODE_DATA(nid)); */ -/* unsigned long nr = 0; */ -/* enum lru_list lru; */ - -/* VM_BUG_ON((unsigned)nid >= nr_node_ids); */ - -/* for_each_lru(lru) { */ -/* if (!(BIT(lru) & lru_mask)) */ -/* continue; */ -/* if (tree) */ -/* nr += lruvec_page_state(lruvec, NR_LRU_BASE + lru); */ -/* else */ -/* nr += lruvec_page_state_local(lruvec, NR_LRU_BASE + lru); */ -/* } */ -/* return nr; */ -/* } */ - -/* static unsigned long mem_cgroup_nr_lru_pages(struct mem_cgroup *memcg, */ -/* unsigned int lru_mask, */ -/* bool tree) */ -/* { */ -/* unsigned long nr = 0; */ -/* enum lru_list lru; */ - -/* for_each_lru(lru) { */ -/* if (!(BIT(lru) & lru_mask)) */ -/* continue; */ -/* if (tree) */ -/* nr += memcg_page_state(memcg, NR_LRU_BASE + lru); */ -/* else */ -/* nr += memcg_page_state_local(memcg, NR_LRU_BASE + lru); */ -/* } */ -/* return nr; */ -/* } */ +static unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg, + int nid, unsigned int lru_mask, bool tree) +{ + struct lruvec *lruvec = mem_cgroup_lruvec(memcg, NODE_DATA(nid)); + unsigned long nr = 0; + enum lru_list lru; + + VM_BUG_ON((unsigned)nid >= nr_node_ids); + + for_each_lru(lru) { + if (!(BIT(lru) & lru_mask)) + continue; + if (tree) + nr += lruvec_page_state(lruvec, NR_LRU_BASE + lru); + else + nr += lruvec_page_state_local(lruvec, NR_LRU_BASE + lru); + } + return nr; +} + +static unsigned long mem_cgroup_nr_lru_pages(struct mem_cgroup *memcg, + unsigned int lru_mask, + bool tree) +{ + unsigned long nr = 0; + enum lru_list lru; + + for_each_lru(lru) { + if (!(BIT(lru) & lru_mask)) + continue; + if (tree) + nr += memcg_page_state(memcg, NR_LRU_BASE + lru); + else + nr += memcg_page_state_local(memcg, NR_LRU_BASE + lru); + } + return nr; +} static int memcg_numa_stat_show(struct seq_file *m, void *v) { diff --git a/mm/memcontrol-v1.h b/mm/memcontrol-v1.h index 7be4670d9abb..0a4d5092c51b 100644 --- a/mm/memcontrol-v1.h +++ b/mm/memcontrol-v1.h @@ -88,11 +88,6 @@ void memcg1_oom_finish(struct mem_cgroup *memcg, bool locked); void memcg1_oom_recover(struct mem_cgroup *memcg); void drain_all_stock(struct mem_cgroup *root_memcg); -unsigned long mem_cgroup_nr_lru_pages(struct mem_cgroup *memcg, - unsigned int lru_mask, bool tree); -unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg, - int nid, unsigned int lru_mask, - bool tree); unsigned long memcg_events(struct mem_cgroup *memcg, int event); unsigned long memcg_events_local(struct mem_cgroup *memcg, int event); diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 11e4a3c65437..f35ed6655992 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3188,44 +3188,6 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg) } #endif /* CONFIG_MEMCG_KMEM */ -unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg, - int nid, unsigned int lru_mask, - bool tree) -{ - struct lruvec *lruvec = mem_cgroup_lruvec(memcg, NODE_DATA(nid)); - unsigned long nr = 0; - enum lru_list lru; - - VM_BUG_ON((unsigned)nid >= nr_node_ids); - - for_each_lru(lru) { - if (!(BIT(lru) & lru_mask)) - continue; - if (tree) - nr += lruvec_page_state(lruvec, NR_LRU_BASE + lru); - else - nr += lruvec_page_state_local(lruvec, NR_LRU_BASE + lru); - } - return nr; -} - -unsigned long mem_cgroup_nr_lru_pages(struct mem_cgroup *memcg, - unsigned int lru_mask, bool tree) -{ - unsigned long nr = 0; - enum lru_list lru; - - for_each_lru(lru) { - if (!(BIT(lru) & lru_mask)) - continue; - if (tree) - nr += memcg_page_state(memcg, NR_LRU_BASE + lru); - else - nr += memcg_page_state_local(memcg, NR_LRU_BASE + lru); - } - return nr; -} - #ifdef CONFIG_CGROUP_WRITEBACK #include