Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6169678rwr; Mon, 24 Apr 2023 15:06:40 -0700 (PDT) X-Google-Smtp-Source: AKy350Zwg/YfajCuUYE9lsS5E1I6n2sx2HuILrqDFYvNNLMJEZEp6JZt+rIzL8w6dO+TCubiGQej X-Received: by 2002:a17:90a:d246:b0:246:e9ab:aca5 with SMTP id o6-20020a17090ad24600b00246e9abaca5mr14509181pjw.18.1682374000356; Mon, 24 Apr 2023 15:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682374000; cv=none; d=google.com; s=arc-20160816; b=K4WV/Xk8OL9tMmLxJrILAqVs/Jr4wn2cfF+8UDadHAmt3zRwP6Dnpd0VzSCGLG12zL OGGtKtMOYIX3ugc9JShU0cKil8TJGHyp3YEu2BCxWNl7h/8eJb6KuNpvWJQKALBzRsda PzV+lU5giVUIEOeGR6IYDaWyxHrYvIxRVMRGEAGBsDvqOCUxPIoyJxdvfYXLGSUasFpG RzvT6IlyKK0Djs4D9iPmDNC+4KyioAnVIqteKEPOAP97wvFMMup4SBbUsV68TVNC8Nrh PxWSJyUjZfNVm1X5kqZ//l6i+atiswsbHQAMc4peNtt5/AAA9eFS6o8u92nDnqyBapFa nlFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=fKYrDa1ABjp9A/1j0g6ARfNwu3VzSLmuNZw1BK0LSzM=; b=c0ezEHmmkZnvxMe0QGFvaDoPvGiS1rxLwPPqvxruwW8TgieheDrx8298tZ5sHnwmUX e+EHSqj4mPEe4wx52LzN2rnVHAif7BiCzYxQQXXLwTjkmus4c5ZCGXNzAsMJwhdS1pAr c0VMSN8dzyNc63Sta9GVs7E1/949N+I6tgulOhxNm5S+BALNV5eJtbYC8GxmQFlBsO0z IyflflE0+pSGBBquHVkarTc77MRm5GJGC8T93F6Rw0HUNVwZeh4NOAAKwTSfKqQfMCn8 KU3h9QCafLeaH7lF8XvrgPAc3J/HdOxF/hhPgjukKC54Lxr5aBsk3SGFcURSe1pE0Mne xY8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=DqPKH6tO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mq11-20020a17090b380b00b002474fcf3bdasi13233706pjb.146.2023.04.24.15.06.05; Mon, 24 Apr 2023 15:06:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=DqPKH6tO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233020AbjDXV62 (ORCPT + 99 others); Mon, 24 Apr 2023 17:58:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232490AbjDXV61 (ORCPT ); Mon, 24 Apr 2023 17:58:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 048DE5596; Mon, 24 Apr 2023 14:58:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9178E61FEC; Mon, 24 Apr 2023 21:58:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E7A4C433EF; Mon, 24 Apr 2023 21:58:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1682373505; bh=GGIx+HG4RqLpRpWhwicWsnzwRbRDyOa6ai9UmyBpCL4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=DqPKH6tOcxN1rpWBfAP+OHlP6C3ty8wGvGNMxNEcqhAMTpFQWzhRcFgmjvzsD2iST +ayLkP6RlEH6L8SGKkhUoIisHVpcAGErbhUeQaaGMA5PA7AgyrJOFWL/2OLRfMrvoh EMEV/HZgqiOQSuYbsI5/soHCYkUyl3OhcalnvwAs= Date: Mon, 24 Apr 2023 14:58:23 -0700 From: Andrew Morton To: Matthew Wilcox Cc: Yajun Deng , david@redhat.com, osalvador@suse.de, gregkh@linuxfoundation.org, rafael@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH] mmzone: Introduce for_each_populated_zone_pgdat() Message-Id: <20230424145823.b8e8435dd3242614371be6d5@linux-foundation.org> In-Reply-To: References: <20230424030756.1795926-1-yajun.deng@linux.dev> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 24 Apr 2023 04:50:37 +0100 Matthew Wilcox wrote: > On Mon, Apr 24, 2023 at 11:07:56AM +0800, Yajun Deng wrote: > > Instead of define an index and determining if the zone has memory, > > introduce for_each_populated_zone_pgdat() helper that can be used > > to iterate over each populated zone in pgdat, and convert the most > > obvious users to it. > > I don't think the complexity of the helper justifies the simplification > of the users. Are you sure? > > +++ b/include/linux/mmzone.h > > @@ -1580,6 +1580,14 @@ extern struct zone *next_zone(struct zone *zone); > > ; /* do nothing */ \ > > else > > > > +#define for_each_populated_zone_pgdat(zone, pgdat, max) \ > > + for (zone = pgdat->node_zones; \ > > + zone < pgdat->node_zones + max; \ > > + zone++) \ > > + if (!populated_zone(zone)) \ > > + ; /* do nothing */ \ > > + else > > + But each of the call sites is doing this, so at least the complexity is now seen in only one place. btw, do we need to do the test that way? Why won't this work? #define for_each_populated_zone_pgdat(zone, pgdat, max) \ for (zone = pgdat->node_zones; \ zone < pgdat->node_zones + max; \ zone++) \ if (populated_zone(zone)) I suspect it was done the original way in order to save a tabstop, which is no longer needed.