From nobody Tue Feb 10 23:01:51 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BF84C77B7C for ; Thu, 11 May 2023 06:57:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237197AbjEKG5l (ORCPT ); Thu, 11 May 2023 02:57:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237177AbjEKG5G (ORCPT ); Thu, 11 May 2023 02:57:06 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C9C746A6 for ; Wed, 10 May 2023 23:57:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683788224; x=1715324224; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KdrDQdJZ6+h4q+PuPHT7D4LwVdhv/LqAu3N0e9ln1IM=; b=kBN0cnE5ZTRuhXugNKq3Nlbk4iuDzajbkRtKii2t7TERV9qPMLtmziNu GAMD5x28rpO361VnnvFRTDoFTWvl+w5xD59AMM3T9vraYmD8yKxjTVz2w llNoa90Af/SN0JHpxO0OssX6eCm4yAxaXmaL/0QBjQydbjVnqzvDmHaCA MtplotJE5pf5bAjJ0Ug6NchFnwAXsI9l8zrQdo4QyfIUuUPya/YixGXlK 5api8qc/U95HcY45v+5pVDJv3UUNpl6fpOsYKzyDrnZ/TPah5Tly/1cWH TEoNjLYCXI45w9lLVIqP3B58D+or84Zt/XTBU1ThorHC2Ktsl/lF65eP0 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10706"; a="436744522" X-IronPort-AV: E=Sophos;i="5.99,266,1677571200"; d="scan'208";a="436744522" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2023 23:56:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10706"; a="823855310" X-IronPort-AV: E=Sophos;i="5.99,266,1677571200"; d="scan'208";a="823855310" Received: from chaoyan1-mobl2.ccr.corp.intel.com (HELO yhuang6-mobl2.ccr.corp.intel.com) ([10.255.31.95]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2023 23:56:43 -0700 From: Huang Ying To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Arjan Van De Ven , Andrew Morton , Huang Ying , Mel Gorman , Vlastimil Babka , David Hildenbrand , Johannes Weiner , Dave Hansen , Michal Hocko , Pavel Tatashin , Matthew Wilcox Subject: [RFC 4/6] mm: avoid show invalid zone in /proc/zoneinfo Date: Thu, 11 May 2023 14:56:05 +0800 Message-Id: <20230511065607.37407-5-ying.huang@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230511065607.37407-1-ying.huang@intel.com> References: <20230511065607.37407-1-ying.huang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In the following patch of the series, one or multiple zone instances may be created for one zone type. So the total number of zone instances of a node becomes dynamic based on system configurations. So, the real zone instance number instead of static max zone number is used to show zone information in /proc/zoneinfo. Signed-off-by: "Huang, Ying" Cc: Mel Gorman Cc: Vlastimil Babka Cc: David Hildenbrand Cc: Johannes Weiner Cc: Dave Hansen Cc: Michal Hocko Cc: Pavel Tatashin Cc: Matthew Wilcox --- include/linux/mmzone.h | 5 +++++ mm/vmstat.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 0c569c5fa0d1..18d64cf1263c 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1809,6 +1809,11 @@ static inline int last_zone_idx(pg_data_t *pgdat, en= um zone_type zt) return pgdat->node_zone_types[zt].last_zone_idx; } =20 +static inline int last_zone_idx_pgdat(pg_data_t *pgdat) +{ + return last_zone_idx(pgdat, MAX_NR_ZONE_TYPES - 1); +} + #ifdef CONFIG_SPARSEMEM #include #endif diff --git a/mm/vmstat.c b/mm/vmstat.c index 1ea6a5ce1c41..bade3f50d1f8 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1441,8 +1441,9 @@ static void walk_zones_in_node(struct seq_file *m, pg= _data_t *pgdat, struct zone *zone; struct zone *node_zones =3D pgdat->node_zones; unsigned long flags; + int last_zone_idx =3D last_zone_idx_pgdat(pgdat); =20 - for (zone =3D node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) { + for (zone =3D node_zones; zone - node_zones <=3D last_zone_idx; ++zone) { if (assert_populated && !populated_zone(zone)) continue; =20 --=20 2.39.2