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 78412C433F5 for ; Sat, 29 Jan 2022 04:05:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 892FF6B00BF; Fri, 28 Jan 2022 23:05:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 842706B00C2; Fri, 28 Jan 2022 23:05:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70AA76B00C4; Fri, 28 Jan 2022 23:05:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id 6230A6B00BF for ; Fri, 28 Jan 2022 23:05:42 -0500 (EST) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E42A1181DF751 for ; Sat, 29 Jan 2022 04:05:41 +0000 (UTC) X-FDA: 79081985682.31.434B790 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by imf14.hostedemail.com (Postfix) with ESMTP id 7680F100002 for ; Sat, 29 Jan 2022 04:05:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643429140; x=1674965140; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=pq7zHWakzHtq/Q7I3xjAFcH86XLtbzbQffOAcTHn3cQ=; b=jEhmqesV5dWJ1fwN6NKZ89fF0Eeah22ZPK5NP85J5sjCOO4WyoWh3zAa 9W37pE7ZOn4hkbkIQd8z+G6y4AieJMcPMh44IsESGuulxMa7GnQAXosZR t67NG2hePEU8gMh5zBpuMbhNHT2+stEokD2tcRuZRI3S+ximb8/j4imZi omYFn3dvq/mD1XcpnPp5ZqKOs/VV4hwVOandtoN7n06W8vifB5XHXs9DU ERmSaNH5LCWW7j8eIJiofyEz69U9H2Sig+Doc2n8cqo4+ZZFxHL9/fW1g CKH6+JKIES5vMFsNupVaEg43myByhWh3hWWXpP4Y6D2fQ40APWSwwHzNq w==; X-IronPort-AV: E=McAfee;i="6200,9189,10241"; a="244839015" X-IronPort-AV: E=Sophos;i="5.88,326,1635231600"; d="scan'208";a="244839015" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2022 20:05:39 -0800 X-IronPort-AV: E=Sophos;i="5.88,326,1635231600"; d="scan'208";a="521943076" 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 20:05:38 -0800 Date: Fri, 28 Jan 2022 20:05:38 -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: <20220129040538.GN785175@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> <20220128214843.GJ785175@iweiny-DESK2.sc.intel.com> <1badb3ac-6631-68ac-364d-69dee237583c@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1badb3ac-6631-68ac-364d-69dee237583c@redhat.com> User-Agent: Mutt/1.11.1 (2018-12-01) X-Stat-Signature: p1zgjhxhsjp1bmiwzj51uaitsfbuxoo7 X-Rspam-User: nil Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=jEhmqesV; spf=none (imf14.hostedemail.com: domain of ira.weiny@intel.com has no SPF policy when checking 192.55.52.93) smtp.mailfrom=ira.weiny@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 7680F100002 X-HE-Tag: 1643429140-648477 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 10:35:22PM -0500, Waiman Long wrote: > On 1/28/22 16:48, Ira Weiny wrote: > > 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? > > There are 3 arguments to the format string that match the 3 "%s" in it: > > 1) PageMemcgKmem(page) ? "(via objcg) " : "" > 2) onlined ? "" : "offlined > 3) name My apologies. My parsing of the ? statements was off. FWIW putting ', name' on the next line would make it more clear... But I see now... Sorry, Ira > > Cheers, > Longman >