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 A265CC433FE for ; Fri, 28 Jan 2022 21:48:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 161686B00BF; Fri, 28 Jan 2022 16:48:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0EA2D6B00E2; Fri, 28 Jan 2022 16:48:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA4DA6B00F4; Fri, 28 Jan 2022 16:48:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0174.hostedemail.com [216.40.44.174]) by kanga.kvack.org (Postfix) with ESMTP id D83FD6B00BF for ; Fri, 28 Jan 2022 16:48:46 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9113196F3D for ; Fri, 28 Jan 2022 21:48:46 +0000 (UTC) X-FDA: 79081035852.18.F3C615E Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by imf26.hostedemail.com (Postfix) with ESMTP id C9CCF140012 for ; Fri, 28 Jan 2022 21:48:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643406525; x=1674942525; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=c3DfHy4UfybaUGWpZe7ypxB5nT4Kqu/2JshXAhBJsV8=; b=MfX2DD/EF3TXyR3mYBZtoLcT8U/7c+pQ7m/GjN5XZHEALSWX6HPblMCZ vrS50kNAj9467/n+4W6MlVIsHFnyIyo2PPxlN+a/eEQ/UXD0M4hTrwCt+ SpVSRCHxDGcMUn9M5tmeEt/pbxeBtC07wgtJkhWAcAJzT1Bk+B/VIFVGK vls36i+/N9tw6BoFl8stJjn6SRC1alKJLb3APyXhors0bolTCsiW/4KZC fKlN47TpYQGg/uoKxmQtusoYqKhgb5qjD/2gZMXIJ1wls8vz3Ivr0CILP 53lUBHeNKy7Pd75e8lIUvXQMDvV5WUUVMIe7JRZGhVfmeUaIkZDdxrvkh A==; X-IronPort-AV: E=McAfee;i="6200,9189,10241"; a="271664774" X-IronPort-AV: E=Sophos;i="5.88,325,1635231600"; d="scan'208";a="271664774" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2022 13:48:44 -0800 X-IronPort-AV: E=Sophos;i="5.88,325,1635231600"; d="scan'208";a="536304846" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2022 13:48:43 -0800 Date: Fri, 28 Jan 2022 13:48:43 -0800 From: Ira Weiny To: Waiman Long Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Rafael Aquini Subject: Re: [PATCH 2/2] mm/page_owner: Dump memcg information Message-ID: <20220128214843.GJ785175@iweiny-DESK2.sc.intel.com> References: <20220128195642.416743-1-longman@redhat.com> <20220128195642.416743-3-longman@redhat.com> <20220128212249.GI785175@iweiny-DESK2.sc.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.1 (2018-12-01) X-Rspam-User: nil X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: C9CCF140012 X-Stat-Signature: gz3ao86fp5p3xz7ou9hjf8jsx3r17yjp Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="MfX2DD/E"; spf=none (imf26.hostedemail.com: domain of ira.weiny@intel.com has no SPF policy when checking 192.55.52.88) smtp.mailfrom=ira.weiny@intel.com; dmarc=pass (policy=none) header.from=intel.com X-HE-Tag: 1643406525-904340 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 Fri, Jan 28, 2022 at 04:31:07PM -0500, Waiman Long wrote: > On 1/28/22 16:22, Ira Weiny wrote: > > On Fri, Jan 28, 2022 at 02:56:42PM -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 | 28 ++++++++++++++++++++++++++++ > > > 1 file changed, 28 insertions(+) > > > > > > diff --git a/mm/page_owner.c b/mm/page_owner.c > > > index c52ce9d6bc3b..e5d8c642296b 100644 > > > --- a/mm/page_owner.c > > > +++ b/mm/page_owner.c > > > @@ -10,6 +10,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include "internal.h" > > > @@ -339,6 +340,7 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn, > > > depot_stack_handle_t handle) > > > { > > > int ret = 0, pageblock_mt, page_mt; > > > + unsigned long __maybe_unused memcg_data; > > > char *kbuf; > > > count = min_t(size_t, count, PAGE_SIZE); > > > @@ -371,6 +373,32 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn, > > > "Page has been migrated, last migrate reason: %s\n", > > > migrate_reason_names[page_owner->last_migrate_reason]); > > > +#ifdef CONFIG_MEMCG > > > + /* > > > + * 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) > > > + SNPRINTF(kbuf, count, ret, err, "Slab cache page\n"); > > > + > > > + if (!memcg) > > > + goto copy_out; > > > + > > > + onlined = (memcg->css.flags & CSS_ONLINE); > > > + cgroup_name(memcg->css.cgroup, name, sizeof(name) - 1); > > > + SNPRINTF(kbuf, count, ret, err, "Charged %sto %smemcg %s\n", > > ^^^ > > Extra specifier? > > > > Did this compile without warnings? > > Yes, there was no warning. But isn't that an extra specifier? Ira > > Cheers, > Longmna > > > Ira > > > > > + PageMemcgKmem(page) ? "(via objcg) " : "", > > > + onlined ? "" : "offlined ", name); > > > + } > > > + > > > +copy_out: > > > +#endif > > > + > > > SNPRINTF(kbuf, count, ret, err, "\n"); > > > if (copy_to_user(buf, kbuf, ret)) > > > -- > > > 2.27.0 > > > > > > >