From patchwork Thu Mar 14 00:54:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13592018 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 021DAC54E67 for ; Thu, 14 Mar 2024 00:54:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B63E8D006B; Wed, 13 Mar 2024 20:54:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EFB2280073; Wed, 13 Mar 2024 20:54:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CAB8880071; Wed, 13 Mar 2024 20:54:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9D5DD8D006B for ; Wed, 13 Mar 2024 20:54:43 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7802D40473 for ; Thu, 14 Mar 2024 00:54:43 +0000 (UTC) X-FDA: 81893824446.27.56CB252 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf25.hostedemail.com (Postfix) with ESMTP id 00B97A0007 for ; Thu, 14 Mar 2024 00:54:40 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=WprG9LXx; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=none (imf25.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710377681; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=IlrnMbOqpJ2/S6gj5kQQ6CnmyYoOw3Yg8bRGX3sCghg=; b=SvwNQyi2FkSQ8yWwXpumRjL17N5SpvFXYIpzkxaSQi5GqIPO03bQH+IAuVEpFpEZMzay0v u4D3NP3uw+yyQOk9dw3FbEUeJBGOeMNoa0z/HBbiaroaI+YT+Q35ehtRdFZ+l+1DW3UPma ltReYWEM4SNxYC4jxOGTeGIxIhbBnDI= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=WprG9LXx; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=none (imf25.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710377681; a=rsa-sha256; cv=none; b=7gWYPOBY4QUKVEsrn26GtqrcHjyf/YJTLPTNBkD9fxy6XzPJYpckZh9LWffP0HML5b7ZwY G5n8d2QLT7iYpiHmgL1oyfpuN/Ly3BXJSI58QP/G1fPs0JuGSRwfUdt1gDr+1/hvPKzRlg +6/KVJunQ9b6QlnQMrAW6NyA7xWIJGg= 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> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 00B97A0007 X-Stat-Signature: xw7dwoyyqbatyi3k7nedbgppai9ikg3d X-HE-Tag: 1710377680-241462 X-HE-Meta: U2FsdGVkX18Ezlu+TTC6xCysl+ZCvQ9f/zKXNQbeZsXs5ALNvTo9W5aJNEgZdl8NZAbY4hoXVgdQoq+qMPtVHy8C690Xma7/drJ4E71rqVMnFcMgnI7yQXurE3yC2+Gnqz6JnqrB4YEfe4ftjqk5NUyeii727Lg/c7VYYLrNCytltsZrdfyH14t1i7Aj4EN8eexvZdTCg9usMi/fh/Sj1n/NGKUHxyxBi5RL3P3aXBdD4URxZ8ym6MHu9iqF7sQXY7IoVqLO6l4+5t06gA46hfS3uEtr6VHP1tOd6N0Dv+2Nc2tLfeIoFnNqCD2reKS/wEbCvcdohrGGc5dASMsSObKcvvIjTYlkbx/Uj4CJ78EsD2tq6UrfC+FBnpwyCmRfYzKtAse9CTFL2d09QhnGrwHZdaUsNyB9XwCjFE5PGoG+1HoCouJjf4i/kT/Dd7oMNZtpchCtmQEufG/sI7i0lXbsQnIg01mRkna6BnjQg0qHNJcGuemNzk0GpPGcRWKl0ezv5VQyj+sPA/AYO/7wwLlY6Kr4l3jn2z200ur5EMBO6jZF67Fxj10Q+69GyH29wAkiC3xyKU7tq3gcMRaIQUKxmVvMydhIVYFJD8WHBcQkFJbnRmq6WWl332ouSydNhXNRMeTCLvrxN/ezZf4aP6+qjOGGLUMceTsEh89Nej64xd/Pwx/y7brJPSV421u9RX9jbFh0pQxCicYS2CtTKcYHLgYOnl+CjGMSbE8xVj6YalySFzQJtDCrbZ8mZF9jZ9zmYVxSNiqIwBomVTPmkCRIeMuls6H6vMT/QNG5hn5w7IfW9rTgvPjEXQ0qgxqdftiVC8fr/LLB7nyrXcO1Lh69YAQSx2lLCXgMMVgWmOsdYa3LASa/uIvL5XENCOQrlJIJfGOxexG38Pgf1seBMMKd1qr8pVWx8Oag6sqW4rPTYgJCkdR3nyH7ik1STecTTirhrf8ORxjEVgP6nOD p4r4GhbS 94dsWwZbR6vtKE82kvpaPvlXmamys7ZsCpwV+vJI38XzRZPpwLN5Tuxntg/A1wFWybTOjFvWxZIktdxLuxFavIWguG3qS7UDKok/oTLDGEBMSYwEoRZeUchCHJk/oAQ8ybtrMb/HT1FhvpcSV4DstJpHJgLhcP0NJQyL2 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: List-Subscribe: List-Unsubscribe: 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 +#define for_each_populated_zone_pgdat(zone, pgdat) \ + for (zone = pgdat->node_zones; \ + zone; \ + zone = 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_weighted(struct zone *zone) static unsigned int fragmentation_score_node(pg_data_t *pgdat) { unsigned int score = 0; + struct zone *zone; int zoneid; - for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) { - struct zone *zone; - - zone = &pgdat->node_zones[zoneid]; - if (!populated_zone(zone)) - continue; + for_each_populated_zone_pgdat(zone, pgdat) score += fragmentation_score_zone_weighted(zone); - } return score; }