From nobody Tue Feb 10 20:46:54 2026 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9349D8C10 for ; Thu, 14 Mar 2024 00:54:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710377682; cv=none; b=LZSOyMMiySgj9zd/4bJ5dIErKtFpQUgWVtaj/lsc8zD79Mbh3CsWNvnMpRmIPl072wp9RlSz6LTRwtUxWEVf2yr68pazsb5BlJ7ia8jgaApfrG+3ROronvBP23Xzhb+yXVsWmIW7Ln+LKjeYMwETqOAjRClf6OcrUMG3IZ2MW+A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710377682; c=relaxed/simple; bh=5oQw0Jc4fccd2QAnymYMdxiP3SqsguZWdc+975ecfnk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Lx98MV2N/bCXMEciZatnt8gFafiG4MACBrDdPo4t6yMSPC2bR2LSDX8bEgigdZdny9vn6DBNxwtI+k9CiDQA6wqz8A8HlKognTtA3sDyTPL9Tmk4XESoNpQa9EheH15ca/sdobZ6ev1M9mLpxNnDaR6EpK/w6tZJXvpbWiOqlWI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=r0hduQlU; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="r0hduQlU" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=7afOyl7nv+Mi2FyolEBEsVPtXVCWDMinpJ3b7YCSncQ=; b=r0hduQlUY10mSUkoM9CAoK9lkY yTEkaLMR27xDBoYJKGbslC7WZIvQXb4tlMjx+hEm/VkTWjjgeaw6Dh4AS48tbKqqNwv/oVRFt/2ta 8dWEbIaV4Z4BQuqcN1A+OoK/m5xwTbjJ5iqq9SObSEGbyZo4zlqplKXYlWI1k6bUDwY273nsRqykB 7RehX2u5lZDO1JbzAel4LeqG3LjmL07vw/Wv0/tZJt/8kzLfBjKJ/LMnqg01l8UKJ6T+0I9TshIxN A/66N/n4PAoQQw/KTp/hDAZ79HtS9FuEf/NDkv/loDe+kcCcTMjQU8I492IF9burTzY94jLRQMWPH XhLuJErQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkZMj-0000000CQo2-0f9b; Thu, 14 Mar 2024 00:54:37 +0000 From: Luis Chamberlain To: akpm@linux-foundation.org, jhubbard@nvidia.com, vbabka@suse.cz, mgorman@suse.de, linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, dave@stgolabs.net, p.raghav@samsung.com, da.gomez@samsung.com, mcgrof@kernel.org Subject: [PATCH 1/3] mm/show_mem: simplify ifdef on si_meminfo_node() Date: Wed, 13 Mar 2024 17:54:33 -0700 Message-ID: <20240314005436.2962962-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240314005436.2962962-1-mcgrof@kernel.org> References: <20240314005436.2962962-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Luis Chamberlain Content-Type: text/plain; charset="utf-8" There is an ifdef where the same exact values are used at the end, so remove the else and keep the same values for both conditions. Signed-off-by: Luis Chamberlain --- mm/show_mem.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mm/show_mem.c b/mm/show_mem.c index 8dcfafbd283c..529d2f9b6410 100644 --- a/mm/show_mem.c +++ b/mm/show_mem.c @@ -108,12 +108,9 @@ void si_meminfo_node(struct sysinfo *val, int nid) free_highpages +=3D zone_page_state(zone, NR_FREE_PAGES); } } +#endif val->totalhigh =3D managed_highpages; val->freehigh =3D free_highpages; -#else - val->totalhigh =3D managed_highpages; - val->freehigh =3D free_highpages; -#endif val->mem_unit =3D PAGE_SIZE; } #endif --=20 2.43.0 From nobody Tue Feb 10 20:46:54 2026 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA4EC8F62 for ; Thu, 14 Mar 2024 00:54:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710377683; cv=none; b=TzjVNpw0QacqJsk99hfo6RolNY9rXtrEg80g1Nk7QqPxHcK8juObpOnPBamrFcYpHSvpbPjvDEmHJMTUWGSvR+dq/7nhOlr0Y0J+k4neIerwiQ+OdFh7a6mrPiqCTeiy4q/yKhJ9ihmraxwxfAYxFNj57ccPA7DYMEn8jZHeCS4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710377683; c=relaxed/simple; bh=fERwqyDgx9PvBlsJI0XpErqvohPCsQlGNvyKE6D5xE0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=diJFmpRvCtndsJJhPD/joMLVvmBJec6lHvbnrMaUSy8cX98R2xXOQFmumoGlX90O7ThznFAZkyIMbiB+Ag1YDPYCPsCfmYlu/OdvwCfR5z4+9yR6ghdLjBj6qdgyrG0vIdcPEIaU3Vb7oYLEHpqzqd72fHDxT6LvCD000g8CSQ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=WprG9LXx; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="WprG9LXx" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=IlrnMbOqpJ2/S6gj5kQQ6CnmyYoOw3Yg8bRGX3sCghg=; b=WprG9LXxkpkrd2J/PoJcJt1Zi/ AXp+bYR1AcF0qAtAKEWut8ddrHSpIg3sP5Gnh5Yq3548iivB+Kp3j+ccbsjktXIuOxHHVvdsk//dD LxqHD7UmSi8A7EIthtU7CxqOu5Yw0d1tRuuqrneTbeqayayJVS4GNqL7LfGgsLQHP3sbeVGOv+4/4 O3vLr1RrHBG+6ZJ54ftmdIUUlHRfuav8JasAp0ootpUZOlLrmmFM3LqV76FoZ4IPfRZdtklj9C0Nw 5S6w/VDtaLYk1h+yj7bfW1pJnrpji0jVAnvUPoVqRLeN13XZkX6AkYuggSSXLu1HCkiLmzcyLWHCS 7ZK9ckdw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkZMj-0000000CQo5-0pYM; Thu, 14 Mar 2024 00:54:37 +0000 From: Luis Chamberlain To: akpm@linux-foundation.org, jhubbard@nvidia.com, vbabka@suse.cz, mgorman@suse.de, linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, dave@stgolabs.net, p.raghav@samsung.com, da.gomez@samsung.com, mcgrof@kernel.org Subject: [PATCH 2/3] mm/compaction: add and use for_each_populated_zone_pgdat() helper Date: Wed, 13 Mar 2024 17:54:34 -0700 Message-ID: <20240314005436.2962962-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240314005436.2962962-1-mcgrof@kernel.org> References: <20240314005436.2962962-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Luis Chamberlain Content-Type: text/plain; charset="utf-8" We can just wrap most of the work done on fragmentation_score_node() into a pgdat helper for populated zones. Add the helper and use it. Signed-off-by: Luis Chamberlain --- include/linux/mmzone.h | 8 ++++++++ mm/compaction.c | 9 ++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index a497f189d988..1fd74c7100ec 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1597,6 +1597,14 @@ extern struct zone *next_zone(struct zone *zone); ; /* do nothing */ \ else =20 +#define for_each_populated_zone_pgdat(zone, pgdat) \ + for (zone =3D pgdat->node_zones; \ + zone; \ + zone =3D next_zone(zone)) \ + if (!populated_zone(zone)) \ + ; /* do nothing */ \ + else + static inline struct zone *zonelist_zone(struct zoneref *zoneref) { return zoneref->zone; diff --git a/mm/compaction.c b/mm/compaction.c index b961db601df4..023a09d0786d 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -2151,16 +2151,11 @@ static unsigned int fragmentation_score_zone_weight= ed(struct zone *zone) static unsigned int fragmentation_score_node(pg_data_t *pgdat) { unsigned int score =3D 0; + struct zone *zone; int zoneid; =20 - for (zoneid =3D 0; zoneid < MAX_NR_ZONES; zoneid++) { - struct zone *zone; - - zone =3D &pgdat->node_zones[zoneid]; - if (!populated_zone(zone)) - continue; + for_each_populated_zone_pgdat(zone, pgdat) score +=3D fragmentation_score_zone_weighted(zone); - } =20 return score; } --=20 2.43.0 From nobody Tue Feb 10 20:46:54 2026 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD22B8F55 for ; Thu, 14 Mar 2024 00:54:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710377683; cv=none; b=TZutsL0DVe3556rP8BiVZyNMxUasdvomBiCWQdK76k5CqI+7Df3p5gUVTe1FPI/u0z5JLLXFXT6KaU8kvwG4cPDQwosEuFFwhfGTcNdsNVQlkIJFLzE6W1cBL4bToGiCjEO4Qdbz0YTvcmp15AixHHIgGbNQ8RwzhO6kNw96Egk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710377683; c=relaxed/simple; bh=urZYEhkOjhiW7omV6Hau96GGQsXjogpoamI/c12JFlY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hvTEqFniVTh5bGlVz96HZ3Wd1MIWTnykGVvyiKX18aJh8idM0NLz1X0G4BmfYAlS/Xokw7ATWOhr6G5xEmXe1g0cjw/uuDIuMP9gL9JCUjUgg2zvgRTzWBXA5du2BrxC14x6IYNoTqKMg5YntUXWBA+SJKKqFoJIBmUWA0An9Sc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=dAi9n/RM; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="dAi9n/RM" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=y16FDE8fAPRzoyd3hzzZJsRMIkVkBbl8vnhWWzqELbo=; b=dAi9n/RMn/ptj6OJSi9OgXjOyR tDZPFaq5sSp4732/6rUz9KaNge5wN9Zqu05E9be1vnRnUXw2oDL9DEskCzo1gQRWyhbhWbVN3tQGc plqtMNv8ADqUgRHsc8cMlmwt9icx7Y7UCXL7xpQeQ7mR4vl/5axUYOFB439UAgpMMzHQzHjb01kAO M/2Evz9y4hSCSyDqomxADHXr+OBK2Ehk4hDuVAY6oSrAiX99kLW8g6vvfJa90E99ME3ORcgvz+kBI KQnmLb3FDo0FpGpwFdGiSzwisjOQGoipYTTNFskzCn9X87prdTbIXzJs9XwU4XM6yZweuUzXBAMS4 rc8dcZRw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkZMj-0000000CQo7-13QE; Thu, 14 Mar 2024 00:54:37 +0000 From: Luis Chamberlain To: akpm@linux-foundation.org, jhubbard@nvidia.com, vbabka@suse.cz, mgorman@suse.de, linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, dave@stgolabs.net, p.raghav@samsung.com, da.gomez@samsung.com, mcgrof@kernel.org Subject: [PATCH 3/3] mm/vmstat: simplfy extfrag_show_print with fragmentation_index() Date: Wed, 13 Mar 2024 17:54:35 -0700 Message-ID: <20240314005436.2962962-4-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240314005436.2962962-1-mcgrof@kernel.org> References: <20240314005436.2962962-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Luis Chamberlain Content-Type: text/plain; charset="utf-8" fragmentation_index() already uses the stack for the struct contig_page_inf= o, so just use that and enhance the documentation for fragmentation_index(). Signed-off-by: Luis Chamberlain Reviewed-by: Davidlohr Bueso Reviewed-by: Vlastimil Babka --- mm/vmstat.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mm/vmstat.c b/mm/vmstat.c index db79935e4a54..582f89b37ccf 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1129,7 +1129,10 @@ unsigned int extfrag_for_order(struct zone *zone, un= signed int order) info.free_pages); } =20 -/* Same as __fragmentation index but allocs contig_page_info on stack */ +/* + * Same as __fragmentation index but allocs contig_page_info on stack, + * useful when walking a zone as interrupts are disabled. + */ int fragmentation_index(struct zone *zone, unsigned int order) { struct contig_page_info info; @@ -2227,15 +2230,11 @@ static void extfrag_show_print(struct seq_file *m, unsigned int order; int index; =20 - /* Alloc on stack as interrupts are disabled for zone walk */ - struct contig_page_info info; - seq_printf(m, "Node %d, zone %8s ", pgdat->node_id, zone->name); for (order =3D 0; order < NR_PAGE_ORDERS; ++order) { - fill_contig_page_info(zone, order, &info); - index =3D __fragmentation_index(order, &info); + index =3D fragmentation_index(zone, order); seq_printf(m, "%2d.%03d ", index / 1000, index % 1000); } =20 --=20 2.43.0