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.