Received: by 2002:ab2:5c0e:0:b0:1ef:a325:1205 with SMTP id i14csp91098lqk; Wed, 13 Mar 2024 17:55:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUI3qN/8+NCjPYF0TCUCU6gfmlFocAoslkEMjEq4EOS3Idst2Du4CbZRO1xc2o14tmO5+5ZGX7QTpEGaqktnmuDz5ygRvXRoYIloYpg/g== X-Google-Smtp-Source: AGHT+IHOqiUKEAY6ycQpnMMBToKz4Z97gJ32X306cbSVsxpCvrva2ll/EBWOoMNkrovsAcGAGzp8 X-Received: by 2002:a05:6402:1cca:b0:568:1882:651f with SMTP id ds10-20020a0564021cca00b005681882651fmr95783edb.25.1710377702773; Wed, 13 Mar 2024 17:55:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710377702; cv=pass; d=google.com; s=arc-20160816; b=N0FGUOzHPgXbFHiNVXcN2HTZar+hhfaGVQKKjPUb7jJcB9cQBAbuwe/H6EkxwA3ydO R7J69x2ushoCNe89RN4cproFjMc9v0lrL+sQV45OreIlXCLAMlE0tSWgHIfNKwx7T5mX 81uM+h0knLV9kUAQqBsHvUESMv3moFDT6K28SXGWdIBDkb3aIlsYvbFxzlbBq7jY6WZj 3TO9TrWSp76lPnKTc20drc7LXqYi9a41edqtp3l9OYDm9UwVCrySiPsX/Yff3SWIjExn bW6850ALExSHzmz1xYxBOT7zC/cCkI2zt2UYJ29CYUhj7YZNTPnvOSWkLy+mPHYB35CH 74rg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=IlrnMbOqpJ2/S6gj5kQQ6CnmyYoOw3Yg8bRGX3sCghg=; fh=4o9ju8uW9tMUTrj362tSKuZawyKTvPM2ZAEJFdvfDvU=; b=CpBPXz5/a4uYuRorCMkosoAoMunX4UQf/vUQJgTs3N3+rxiuz/MUATj/EUx5SjPmIy eIAboyPP6CZ5B/sVlLUyiA7QpbtisV4OxAxhec1kwA8w4Q7Z0NT4AxE9vxAT4YBi2lT0 vYBJamX1+n+LGBM0XZ7qbDeiGGVmfa0fHabeUq4X13lX8c2IheN5pLarueUmV1lEkLIM +8uNwFrnSx3xykWcYNAMrKqowyTZr1cYbFGJkjUoHl/9T37pWLktK36bd8NhUAhvMJEI eQJxLC1MwMHY89TKXxBotkT87vTg21MDeb3vmEICLO7wVkE7BdqyeiKVmq3QlDsKbcPw 6gzQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=WprG9LXx; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-102688-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102688-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h12-20020a0564020e0c00b0056864e7a9d7si179323edh.519.2024.03.13.17.55.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 17:55:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102688-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=WprG9LXx; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-102688-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102688-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 53EAE1F22FB4 for ; Thu, 14 Mar 2024 00:55:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C7A62D267; Thu, 14 Mar 2024 00:54:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="WprG9LXx" 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 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: 8bit Sender: Luis Chamberlain 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; } -- 2.43.0