Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5101362rwr; Sun, 23 Apr 2023 21:28:53 -0700 (PDT) X-Google-Smtp-Source: AKy350at21tOcxGZMJdEBzt1ipaMWTsp4sdSLApVdpisM4g/HWqy8yKW+EdjM/bhOirYwCDOkCmE X-Received: by 2002:a05:6a20:8c2f:b0:f0:f2a:ff4f with SMTP id j47-20020a056a208c2f00b000f00f2aff4fmr12499856pzh.8.1682310533646; Sun, 23 Apr 2023 21:28:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682310533; cv=none; d=google.com; s=arc-20160816; b=FlBeIV5/P+Dcm90lYXbCHmzvRAy2pUPo5Mz3wiTHmkrJ7d4ivclMjvp+wZWYXiCJTs WPtcF+uGO17H9JAaGNOQbepN+T/gTGQRh68tJbQe+0pFHKS7wFwo9dbsOHaSktT70tE/ mXfkXR0diJ7JG2UpniSldLkrGJhV8wry/9padO/kPIzWTwTo2+BNH8JVBFOEpzNKOMb6 ChrECrDC6RS9fjsjwpnC2PxQaEyj5QlBOSFdXLXZ95IkBDbBX+oLZ2bSqUWpOW8taScq ThhqKv3XO7y+vYTQG377pYdO29S542PRgbL9rmPB1n5YgowEQMMrKze/P3b5gs9Q6Whd ndxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=uMKfR83C0B9dH2cTA6vwCV+ysD6ryGT7DeWsaB7/c50=; b=OMrOJQ1VjPxqR2aa+ddgogzoThTj62Ihc2eAadTPaCGJhKL8K+4Qk+GWdsO/b417/0 wNd6ept6smsW9mhODkPhis5gAxObgUeoSKJCP0SeFub9H2eRThvr1h144Lyn31RaEkqe pqFmO+ctLW9EKZ4/kaubEcF290wBGkaDZxUxWiqcO2ixSGcC1VXGe4R5sTITk/7v+BmX 1wu21Jruk8PIzFDa/lklEPyVdWB+ERPx96vE2gDO6P0TdNiSQiPj2RqL588MNgslHRJD L/fK1GgYCImHpl7zwhzX20emTvqAqnH+qY+KHJD2QA64Obh1s6ViMlfbJYRsgTCsOZm1 gN1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=N0bDuxkm; 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 c206-20020a624ed7000000b005a9cfb6ee90si10339333pfb.84.2023.04.23.21.28.38; Sun, 23 Apr 2023 21:28:53 -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=@infradead.org header.s=casper.20170209 header.b=N0bDuxkm; 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 S230235AbjDXDuy (ORCPT + 99 others); Sun, 23 Apr 2023 23:50:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229521AbjDXDuw (ORCPT ); Sun, 23 Apr 2023 23:50:52 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92167E67; Sun, 23 Apr 2023 20:50:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=uMKfR83C0B9dH2cTA6vwCV+ysD6ryGT7DeWsaB7/c50=; b=N0bDuxkmi9sVSIOfVXutZqafhZ 0AVoZT5UTfmlDIZIveXnpkydkBXLTY6lQ+kGH3SbF4/FPb5f+byVW8CZ/sQaLwhzhSKz4YXmxK/pR 47m8xz+tbvD+KpDB6UIQhZTkGm9OMf2MNroA6WguHK3l75As47J05GKaLwVgJ8Enzo8jGR4OrwVH1 wNGUejgNjW8RcnAj74fzudaKH9Ja28uweMncZl9j7ohZf4GZPf9QVjvJRsw1WuEUNsHYdlQCOgkxq DmEnii623QUp5pfcLLs1KTEuXJ8Qk5y9gxy998/CUSojHgP7qg+n68aHQE4/AKrYqXrxM0r13YrKO u816BZ+Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pqnDp-00046U-JS; Mon, 24 Apr 2023 03:50:37 +0000 Date: Mon, 24 Apr 2023 04:50:37 +0100 From: Matthew Wilcox To: Yajun Deng Cc: david@redhat.com, osalvador@suse.de, gregkh@linuxfoundation.org, rafael@kernel.org, akpm@linux-foundation.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: References: <20230424030756.1795926-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230424030756.1795926-1-yajun.deng@linux.dev> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,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, 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. > +++ 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 > +