From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Rapoport Subject: Re: [PATCH v2 3/3] mm/page_owner: Dump memcg information Date: Sun, 30 Jan 2022 08:33:09 +0200 Message-ID: References: <20220129205315.478628-1-longman@redhat.com> <20220129205315.478628-4-longman@redhat.com> Mime-Version: 1.0 Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643524400; bh=/cIdn3XGZbN01cqnIxUhf4QjDFd+RjN9h/GNFpqHBx4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=V+JJuEWZcnyvKQ4HBFshhORdDO3wl1baZ/MEmOSMA2ycX0QORFHD9sG+pkfY6t74b qzHqRUOJ1ukf4x4FPzevBh4425WXcs28BiSkQ+1Gtn4D3Nv8iwWjDVgzuYW/pOHjji axNJGCW5sLHHwFEzGvJ2di99X8+7oUT3WqDpEmC8J7P7Spf2cYHhlIbUt27rV5D1vK O//w3AAxUvjQAoVZaSyOe+GwnJrXjaleSvBNwOWXJ43F/WV9Ei1rCimn5Q1RQlptI4 m7vro243wjTnidHvtFmc1cK8C2biVDrVd7T5X1j4jt/jUZxZzN8/zRvlmeZCsAH4d+ l84dEpLXmuhEA== Content-Disposition: inline In-Reply-To: <20220129205315.478628-4-longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Waiman Long Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Andy Shevchenko , Rasmus Villemoes , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, Ira Weiny , Rafael Aquini On Sat, Jan 29, 2022 at 03:53:15PM -0500, Waiman Long wrote: > It was found that a number of offlined memcgs were not freed because > they were pinned by some charged pages that were present. Even "echo > 1 > /proc/sys/vm/drop_caches" wasn't able to free those pages. These > offlined but not freed memcgs tend to increase in number over time with > the side effect that percpu memory consumption as shown in /proc/meminfo > also increases over time. > > In order to find out more information about those pages that pin > offlined memcgs, the page_owner feature is extended to dump memory > cgroup information especially whether the cgroup is offlined or not. > > Signed-off-by: Waiman Long > --- > mm/page_owner.c | 31 +++++++++++++++++++++++++++++++ > 1 file changed, 31 insertions(+) > > diff --git a/mm/page_owner.c b/mm/page_owner.c > index 28dac73e0542..8dc5cd0fa227 100644 > --- a/mm/page_owner.c > +++ b/mm/page_owner.c > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include > #include > > #include "internal.h" > @@ -331,6 +332,7 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn, > depot_stack_handle_t handle) > { > int ret, pageblock_mt, page_mt; > + unsigned long __maybe_unused memcg_data; > char *kbuf; > > count = min_t(size_t, count, PAGE_SIZE); > @@ -365,6 +367,35 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn, > migrate_reason_names[page_owner->last_migrate_reason]); > } > > +#ifdef CONFIG_MEMCG Can we put all this along with the declaration of memcg_data in a helper function please? > + /* > + * Look for memcg information and print it out > + */ > + memcg_data = READ_ONCE(page->memcg_data); > + if (memcg_data) { > + struct mem_cgroup *memcg = page_memcg_check(page); > + bool onlined; > + char name[80]; > + > + if (memcg_data & MEMCG_DATA_OBJCGS) > + ret += scnprintf(kbuf + ret, count - ret, > + "Slab cache page\n"); > + > + if (!memcg) > + goto copy_out; > + > + onlined = (memcg->css.flags & CSS_ONLINE); > + cgroup_name(memcg->css.cgroup, name, sizeof(name)); > + ret += scnprintf(kbuf + ret, count - ret, > + "Charged %sto %smemcg %s\n", > + PageMemcgKmem(page) ? "(via objcg) " : "", > + onlined ? "" : "offlined ", > + name); > + } > + > +copy_out: > +#endif > + > ret += snprintf(kbuf + ret, count - ret, "\n"); > if (ret >= count) > goto err; > -- > 2.27.0 > > -- Sincerely yours, Mike. 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 6B67DC433F5 for ; Sun, 30 Jan 2022 06:33:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC7C76B0072; Sun, 30 Jan 2022 01:33:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A50726B0073; Sun, 30 Jan 2022 01:33:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F0DE6B0074; Sun, 30 Jan 2022 01:33:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0136.hostedemail.com [216.40.44.136]) by kanga.kvack.org (Postfix) with ESMTP id 7C1C66B0072 for ; Sun, 30 Jan 2022 01:33:24 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 2309C18259E51 for ; Sun, 30 Jan 2022 06:33:24 +0000 (UTC) X-FDA: 79085986728.12.E73A9B5 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf06.hostedemail.com (Postfix) with ESMTP id 71416180003 for ; Sun, 30 Jan 2022 06:33:23 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 81B01B82768; Sun, 30 Jan 2022 06:33:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0977CC340E4; Sun, 30 Jan 2022 06:33:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643524400; bh=/cIdn3XGZbN01cqnIxUhf4QjDFd+RjN9h/GNFpqHBx4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=V+JJuEWZcnyvKQ4HBFshhORdDO3wl1baZ/MEmOSMA2ycX0QORFHD9sG+pkfY6t74b qzHqRUOJ1ukf4x4FPzevBh4425WXcs28BiSkQ+1Gtn4D3Nv8iwWjDVgzuYW/pOHjji axNJGCW5sLHHwFEzGvJ2di99X8+7oUT3WqDpEmC8J7P7Spf2cYHhlIbUt27rV5D1vK O//w3AAxUvjQAoVZaSyOe+GwnJrXjaleSvBNwOWXJ43F/WV9Ei1rCimn5Q1RQlptI4 m7vro243wjTnidHvtFmc1cK8C2biVDrVd7T5X1j4jt/jUZxZzN8/zRvlmeZCsAH4d+ l84dEpLXmuhEA== Date: Sun, 30 Jan 2022 08:33:09 +0200 From: Mike Rapoport To: Waiman Long Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Andy Shevchenko , Rasmus Villemoes , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Ira Weiny , Rafael Aquini Subject: Re: [PATCH v2 3/3] mm/page_owner: Dump memcg information Message-ID: References: <20220129205315.478628-1-longman@redhat.com> <20220129205315.478628-4-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220129205315.478628-4-longman@redhat.com> Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=V+JJuEWZ; spf=pass (imf06.hostedemail.com: domain of rppt@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspam-User: nil X-Rspamd-Queue-Id: 71416180003 X-Stat-Signature: zx595xd8yhrybjs3nrqeaqw3yxcndrrc X-Rspamd-Server: rspam12 X-HE-Tag: 1643524403-176853 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 Sat, Jan 29, 2022 at 03:53:15PM -0500, Waiman Long wrote: > It was found that a number of offlined memcgs were not freed because > they were pinned by some charged pages that were present. Even "echo > 1 > /proc/sys/vm/drop_caches" wasn't able to free those pages. These > offlined but not freed memcgs tend to increase in number over time with > the side effect that percpu memory consumption as shown in /proc/meminfo > also increases over time. > > In order to find out more information about those pages that pin > offlined memcgs, the page_owner feature is extended to dump memory > cgroup information especially whether the cgroup is offlined or not. > > Signed-off-by: Waiman Long > --- > mm/page_owner.c | 31 +++++++++++++++++++++++++++++++ > 1 file changed, 31 insertions(+) > > diff --git a/mm/page_owner.c b/mm/page_owner.c > index 28dac73e0542..8dc5cd0fa227 100644 > --- a/mm/page_owner.c > +++ b/mm/page_owner.c > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include > #include > > #include "internal.h" > @@ -331,6 +332,7 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn, > depot_stack_handle_t handle) > { > int ret, pageblock_mt, page_mt; > + unsigned long __maybe_unused memcg_data; > char *kbuf; > > count = min_t(size_t, count, PAGE_SIZE); > @@ -365,6 +367,35 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn, > migrate_reason_names[page_owner->last_migrate_reason]); > } > > +#ifdef CONFIG_MEMCG Can we put all this along with the declaration of memcg_data in a helper function please? > + /* > + * Look for memcg information and print it out > + */ > + memcg_data = READ_ONCE(page->memcg_data); > + if (memcg_data) { > + struct mem_cgroup *memcg = page_memcg_check(page); > + bool onlined; > + char name[80]; > + > + if (memcg_data & MEMCG_DATA_OBJCGS) > + ret += scnprintf(kbuf + ret, count - ret, > + "Slab cache page\n"); > + > + if (!memcg) > + goto copy_out; > + > + onlined = (memcg->css.flags & CSS_ONLINE); > + cgroup_name(memcg->css.cgroup, name, sizeof(name)); > + ret += scnprintf(kbuf + ret, count - ret, > + "Charged %sto %smemcg %s\n", > + PageMemcgKmem(page) ? "(via objcg) " : "", > + onlined ? "" : "offlined ", > + name); > + } > + > +copy_out: > +#endif > + > ret += snprintf(kbuf + ret, count - ret, "\n"); > if (ret >= count) > goto err; > -- > 2.27.0 > > -- Sincerely yours, Mike.