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 F266AC433FE for ; Fri, 28 Jan 2022 21:22:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 80C386B00F2; Fri, 28 Jan 2022 16:22:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7BC716B00F4; Fri, 28 Jan 2022 16:22:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 685066B00F6; Fri, 28 Jan 2022 16:22:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0031.hostedemail.com [216.40.44.31]) by kanga.kvack.org (Postfix) with ESMTP id 57B046B00F2 for ; Fri, 28 Jan 2022 16:22:53 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id CFE80987AF for ; Fri, 28 Jan 2022 21:22:52 +0000 (UTC) X-FDA: 79080970584.08.85C50D0 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by imf26.hostedemail.com (Postfix) with ESMTP id DCDFA140036 for ; Fri, 28 Jan 2022 21:22:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643404972; x=1674940972; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=dpOFTowJuy7FP6yz3n7YQmC/tWQqCIDscNtq/3bOefk=; b=bzrsD1csH9+qYPmupGl44qvYsKHLzXPRuAuPz+xwBjWNkGXp1Yme5+eI utnlcu/1f1kWhEUw6pgkK6FlNJABScFcgAhPF48evfZkeGsjw/uanP0a/ aMrSaRwoueBiFnoD1phDNeJUr9KUvRYaOj7pPKSl6pp+d+aMAO3h1RNhv RMwHyaTP6Wbzh9UkHDBiXrn/nsyFnJjp84se4oRyANIOVkfZphV6049pr Qe7fOdcbn98Nq2XTDLNiy7nY+dGs0ayUofvx1J+6Cvn0LLVVvn4TsLem6 6TWMk2Ue1gk4WOenJ28e21TpQnroWc6i8oaFLIwZjjUpqAdSB37e/lzkQ Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10241"; a="333553617" X-IronPort-AV: E=Sophos;i="5.88,325,1635231600"; d="scan'208";a="333553617" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2022 13:22:50 -0800 X-IronPort-AV: E=Sophos;i="5.88,325,1635231600"; d="scan'208";a="521857653" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2022 13:22:49 -0800 Date: Fri, 28 Jan 2022 13:22:49 -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: <20220128212249.GI785175@iweiny-DESK2.sc.intel.com> References: <20220128195642.416743-1-longman@redhat.com> <20220128195642.416743-3-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220128195642.416743-3-longman@redhat.com> User-Agent: Mutt/1.11.1 (2018-12-01) X-Rspamd-Queue-Id: DCDFA140036 X-Rspam-User: nil Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=bzrsD1cs; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf26.hostedemail.com: domain of ira.weiny@intel.com has no SPF policy when checking 192.55.52.43) smtp.mailfrom=ira.weiny@intel.com X-Stat-Signature: hqcpa9nf95rjw6simpzycfbmgp8nzre3 X-Rspamd-Server: rspam08 X-HE-Tag: 1643404971-395148 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 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? 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 > >