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 X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9465EC433E0 for ; Thu, 28 Jan 2021 10:22:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0CF5760235 for ; Thu, 28 Jan 2021 10:22:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0CF5760235 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4900A6B0006; Thu, 28 Jan 2021 05:22:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 441916B006C; Thu, 28 Jan 2021 05:22:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 330BA6B0070; Thu, 28 Jan 2021 05:22:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id 1AC356B0006 for ; Thu, 28 Jan 2021 05:22:41 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D0264180AD807 for ; Thu, 28 Jan 2021 10:22:40 +0000 (UTC) X-FDA: 77754794880.05.bikes24_35181002759e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin05.hostedemail.com (Postfix) with ESMTP id B192118016858 for ; Thu, 28 Jan 2021 10:22:40 +0000 (UTC) X-HE-Tag: bikes24_35181002759e X-Filterd-Recvd-Size: 5551 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Thu, 28 Jan 2021 10:22:40 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C0515ACC6; Thu, 28 Jan 2021 10:22:38 +0000 (UTC) Date: Thu, 28 Jan 2021 11:22:34 +0100 From: Oscar Salvador To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Thomas Gleixner , "Peter Zijlstra (Intel)" , Mike Rapoport , Michal Hocko , Wei Yang Subject: Re: [PATCH v1 2/2] mm/page_alloc: count CMA pages per zone and print them in /proc/zoneinfo Message-ID: <20210128102234.GB5250@localhost.localdomain> References: <20210127101813.6370-1-david@redhat.com> <20210127101813.6370-3-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210127101813.6370-3-david@redhat.com> 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 Wed, Jan 27, 2021 at 11:18:13AM +0100, David Hildenbrand wrote: > Let's count the number of CMA pages per zone and print them in > /proc/zoneinfo. > > Having access to the total number of CMA pages per zone is helpful for > debugging purposes to know where exactly the CMA pages ended up, and to > figure out how many pages of a zone might behave differently (e.g., like > ZONE_MOVABLE) - even after some of these pages might already have been > allocated. My knowledge of CMA tends to be quite low, actually I though that CMA was somehow tied to ZONE_MOVABLE. I see how tracking CMA pages per zona might give you a clue, but what do you mean by "might behave differently - even after some of these pages might already have been allocated" > For now, we are only able to get the global nr+free cma pages from > /proc/meminfo and the free cma pages per zone from /proc/zoneinfo. > > Note: Track/print that information even without CONFIG_CMA, similar to > "nr_free_cma" in /proc/zoneinfo. This is different to /proc/meminfo - > maybe we want to make that consistent in the future (however, changing > /proc/zoneinfo output might uglify the code a bit). > Cc: Andrew Morton > Cc: Thomas Gleixner > Cc: "Peter Zijlstra (Intel)" > Cc: Mike Rapoport > Cc: Oscar Salvador > Cc: Michal Hocko > Cc: Wei Yang > Signed-off-by: David Hildenbrand > --- > include/linux/mmzone.h | 4 ++++ > mm/page_alloc.c | 1 + > mm/vmstat.c | 6 ++++-- > 3 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h > index ae588b2f87ef..3bc18c9976fd 100644 > --- a/include/linux/mmzone.h > +++ b/include/linux/mmzone.h > @@ -503,6 +503,9 @@ struct zone { > * bootmem allocator): > * managed_pages = present_pages - reserved_pages; > * > + * cma pages is present pages that are assigned for CMA use > + * (MIGRATE_CMA). > + * > * So present_pages may be used by memory hotplug or memory power > * management logic to figure out unmanaged pages by checking > * (present_pages - managed_pages). And managed_pages should be used > @@ -527,6 +530,7 @@ struct zone { > atomic_long_t managed_pages; > unsigned long spanned_pages; > unsigned long present_pages; > + unsigned long cma_pages; I see that NR_FREE_CMA_PAGES is there even without CONFIG_CMA, as you said, but I am not sure about adding size to a zone unconditionally. I mean, it is not terrible as IIRC, the maximum MAX_NUMNODES can get is 1024, and on x86_64 that would be (1024 * 4 zones) * 8 = 32K. So not a big deal, but still. Besides following NR_FREE_CMA_PAGES, is there any reason for not doing: diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 1e22d96734e0..2d8a830d168d 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -436,6 +436,9 @@ struct zone { unsigned long managed_pages; unsigned long spanned_pages; unsigned long present_pages; +#ifdef CONFIG_CMA + unsigned long cma_pages; +#endif const char *name; diff --git a/mm/vmstat.c b/mm/vmstat.c index 8ba0870ecddd..5757df4bfd45 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1559,13 +1559,15 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat, "\n spanned %lu" "\n present %lu" "\n managed %lu", + "\n cma %lu", zone_page_state(zone, NR_FREE_PAGES), min_wmark_pages(zone), low_wmark_pages(zone), high_wmark_pages(zone), zone->spanned_pages, zone->present_pages, - zone->managed_pages); + zone->managed_pages, + IS_ENABLED(CONFIG_CMA) ? zone->cma_pages : 0); seq_printf(m, "\n protection: (%ld", I do not see it that ugly, but just my taste. -- Oscar Salvador SUSE L3