Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp51703pxb; Mon, 31 Jan 2022 15:00:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwH6o6+KMot8/yxXKegoLhd7MEUSORoUtXda+IAz17wxrf4dZgbjqvIyI9YlWktgAx/6ltf X-Received: by 2002:a65:6e07:: with SMTP id bd7mr18521906pgb.457.1643670053885; Mon, 31 Jan 2022 15:00:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643670053; cv=none; d=google.com; s=arc-20160816; b=v/QL8OpLDQJ+FYbQBNqqCa+r6yibW2J6ANAyBJsEejiARCn6t8m24G8n6ePPpEmvSg ravs73N+b4EbB+gF5CkBf62xi5uwLghDuXTtd7W48OwZDq8X5tmYmzybh+6xoOb00Dnm QoJRsXoU4FXxcVKS6QPdYsuNymgWccNd7N8vEVTXVcPjFSZbn2ZuGZCSHCXKV7IEefDN gjzZBbC2YhNEsmYN5LC1C/6tdcDVudllaKwtr/cr8nZDU0uLMhkBA8GHEUyMC9VvNYFL oIxfeyLMqq+Dm4qCfdnY9MQddCzFch+fdv0WFH+dvcmcHo2Pfwtf+tr409q+nui+GY+U jIxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=kznHcPmHhDaYYm1HxLNPdlPIfC+YAsx6Iwtpp1V5PR4=; b=Ij7pr1Da/Ow+xBD2hOqtw1pfzP3EIqQnsgA1epEZYldq91IL5E8/MGjAr3S6hdvzi1 JWTQ7ZPaZneGhxi0RXK9XzdAm+bWy4srW3WRT0d/AzGXQEAZ+Kq5m2PnjcxQnwNPIeM/ EWSxM0oKrSS66pDl4r7mKEOOSHklt94b5cWvkxJq4jqvb4+6sriRwZdT4JMVkEBrmyPJ SyPVdm0n2Gt3LL7yUL0Eb62s9H+5tOjsoLxxBvsUxj63OVB7dFCaeHqXO/1d/FPAcDcr yHQEdVoER7MDGnoN83NMOmipE1Wt5IRrLWLYtt3pYV4c5ngMvaWBbkPVvMTXRm4kGO2C KcdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=B5a13m6O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g5si15355689pgc.136.2022.01.31.15.00.42; Mon, 31 Jan 2022 15:00:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=B5a13m6O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352336AbiA2EFl (ORCPT + 99 others); Fri, 28 Jan 2022 23:05:41 -0500 Received: from mga06.intel.com ([134.134.136.31]:29142 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238931AbiA2EFj (ORCPT ); Fri, 28 Jan 2022 23:05:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643429139; x=1674965139; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=pq7zHWakzHtq/Q7I3xjAFcH86XLtbzbQffOAcTHn3cQ=; b=B5a13m6OZ932TDiGG39mJGhFLGYL6o/jfwG0j4Xngx4e2ugSR4V9B9M0 pQV+dZw5PrpMOp0g1v1VUyDxNMIhFsnstiGkD9Tj+CNtZ85QdJg0zDvhp 2Z/3ykW+p1W/+Dxw8Wr6Ijb8QtzZT40j+Smm1QOSrzDpMuelTvhlCbvnq 2qxhOUTzp5UsTt0Ukk5z3gnSWnLdbzu3eJeQTRdikNMMS+1gINraFoBBu CqE4F79RtQuu8htFfq+1p5I3CpxHDO/21V3+yOW2kdBboHu30jdnQTax4 y7MWppcXsCkDj14uLugsxG20VMxJYezKGVGxin61zbuQwskzvsHflAhT8 Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10241"; a="307969611" X-IronPort-AV: E=Sophos;i="5.88,326,1635231600"; d="scan'208";a="307969611" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2022 20:05:38 -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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >