Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp953289lqb; Fri, 15 Mar 2024 10:48:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUuSxgDSbLFvx+yfNxupLMLLWbhIGyWS4UP0CJ04FjRgY9K2cWCv9+UHC6sRy/Km135an344vK1NjsvgvHsyvfQvipMBAD6QkLYc/RCGg== X-Google-Smtp-Source: AGHT+IEjQmeJ59g8e2cUtlVSSdzaTwkMSh3WZeADRmcYv3qs4i+mGhqRyftg+mXhFGj7zcXFPclS X-Received: by 2002:a05:6871:286:b0:21f:d1e6:d8e8 with SMTP id i6-20020a056871028600b0021fd1e6d8e8mr6328277oae.39.1710524925424; Fri, 15 Mar 2024 10:48:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710524925; cv=pass; d=google.com; s=arc-20160816; b=PW1zJrtg5qeBOUrVmrT2Y/W/yDfhLJetcslJhlSQbPzWKpmnleqMKU+po+t2qScNDS P5WsxdG+gWws8+Z2nRQ/9Htny2OnW5ML/lr38pnzkK0sFuH5n/BBQVhXB/ueb5tTYMlY Qhqe3+j6dP4hORxMYTLrNG3pgRNrnoUuF+nncxlUoCR9JWPQnZX7fsvtMOWOSUnOGNqD Tdk0DKfF0gRahtbRLWXTGPPJUI+FPpQ+mBnjkRC4e0MQWuPJJrdtchgz+78qsjPmldp1 UKuz/9BL99cyh3rQDU1E/m6hZf/xeOSBSQ3xVivJRy9f2/hUtaZAsNsrCtSpSa/9f8Jn +oKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=HFKGGKN+f0vBo92ILwKwd4CZp/WjaO7D1JcM7ZAAhnM=; fh=QfdVexZfr2Z1uJyDMUm39FMfuMUySAO4k+ze5FGjVuA=; b=XMT5gJbNlklBun00wRRM6w5pY0HBD6385qgbyUn95tJ3yhlCUef+tKdvmzE4Oe7Scf /LUVemQ8nxe5AB5ZJTHrZxnx4PIDzAI1Vt3tR9iM6K50I9yqfOmoqV0nlhXLMBAnEzij CvYSt18dcvRGhkU7elphliX7iglnqusdV7d4ShZ5gZwKjb6lJcwMNu686eLGM4gcK/AB kkfs2H8/MihDAcHs7kcxDynlkETSeHtLuMlpDbq79nEKYWKURDCkUoZxeYxPfioNJv4k CLDkdpFgcHwJKXEVBVbhS8qKXno+6eIjoODbKxbg6Xr7fyuTLHlTaIotrV6T/Rljq2HP 0X2A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=GECCR7bc; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-104745-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104745-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d2-20020a05620a166200b00789e49ce849si1751416qko.694.2024.03.15.10.48.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 10:48:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104745-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=GECCR7bc; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-104745-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104745-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 27FB41C21FD2 for ; Fri, 15 Mar 2024 17:48:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 320534CB23; Fri, 15 Mar 2024 17:48:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="GECCR7bc" 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 3C7D33BBD0 for ; Fri, 15 Mar 2024 17:48:36 +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=1710524917; cv=none; b=W/+zGb74o+TIu8YdtIvBsYijuiFSiFTzkC6Rr0V9ICs10NYxU6Ta1HE5j8LWaCrX8VEaiEYEzM0Kg5IZ7J7Gzn0lGmWsW8OnRoNAICddWvbbQ1Jy4Q69uW/L89NQNl5S9QJX3S/JEeIRhRZcd7h9QuyLsCaMeEa6ezhHi1ZRo4c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710524917; c=relaxed/simple; bh=KHrpDSUJQQs6+1i/tSJAHGRK500eSYM/hA2R396Hawg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TacixqpKObChrlxA/Qbdwrizh5k/yfFlWtB8TySPBbdZKAQ/h8BeMdJ9aU8DvJgSr8HjzLmp8ZEryU510urWkQYNG7vEEq9Oe9mYaIk79Y+zycZJ6SKRDeKQjV76Xj02+LrLlZy8caJOTqysALQUxCAqK8kmpMOKhTz7a5b/kow= 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=GECCR7bc; 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:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=HFKGGKN+f0vBo92ILwKwd4CZp/WjaO7D1JcM7ZAAhnM=; b=GECCR7bc4om9Eg+HFja4pmj6ft Y+qeRoneitJU+ZbzxBjUjRDt9BvQN1fgifstLw3yvuER/4FdGqyhPakC5NmIUf1Ewc13weBRsEat8 7rwNrkmY0RWTnkWbdHf6PDOA+5xXK5K9FdPjrmZlRa4krT5OGH7q0PQbsdsOhe6EXxj+uwTIucFHQ iTxLsbJpZiQgtgbFENUaBamsIc6VUQ58P77aX5nabLgRnDzczmZliMsyYV8lVu35Xc5XlxT11bgvu I/w3U68zePJ91kgv15kbk593vziVSFgBqdx6XYyZ0SkjQTqkGE3FmgiKg+DJdXXAcfUSVEmEpdOC4 cr7se9WQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rlBfU-0000000142g-1tko; Fri, 15 Mar 2024 17:48:32 +0000 Date: Fri, 15 Mar 2024 10:48:32 -0700 From: Luis Chamberlain To: Vlastimil Babka Cc: Baolin Wang , akpm@linux-foundation.org, jhubbard@nvidia.com, mgorman@suse.de, linux-mm@kvack.org, linux-kernel@vger.kernel.org, dave@stgolabs.net, p.raghav@samsung.com, da.gomez@samsung.com Subject: Re: [PATCH 2/3] mm/compaction: add and use for_each_populated_zone_pgdat() helper Message-ID: References: <20240314005436.2962962-1-mcgrof@kernel.org> <20240314005436.2962962-3-mcgrof@kernel.org> <532c9e93-e8cc-4f6f-bf08-b5625022dd4f@suse.cz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <532c9e93-e8cc-4f6f-bf08-b5625022dd4f@suse.cz> Sender: Luis Chamberlain On Fri, Mar 15, 2024 at 12:09:29PM +0100, Vlastimil Babka wrote: > On 3/15/24 06:38, Luis Chamberlain wrote: > > On Thu, Mar 14, 2024 at 03:19:45PM +0800, Baolin Wang wrote: > >> > >> > >> On 2024/3/14 08:54, Luis Chamberlain wrote: > >> > 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 > >> > >> I think this will break the original logics, since the next_zone() will > >> iterate over all memory zones, instead of only the memory zones of the > >> specified node. > > > > Definitely, thanks, so we'd need something like this in addition: > > IMHO that's unnecessarily complex, why not just do the iteration all inline > without this next_zone_pgdat() helper? Sure. > Also maybe you could find more users if you created just a > for_each_zone_pgdat() and left the populated_zone() in the user? Otherwise > it's quite a specific helper with just one user. Indeed, this was the only immediately clear user for_each_populated_zone_pgdat() which stood out, but I'll look more closely. I added this helper because in an RFC patch I had another use case: https://lkml.kernel.org/r/20240314005710.2964798-1-mcgrof@kernel.org Granted this is just an RFC. So happy to drop this if we don't have other users Luis