From: Ye Liu <ye.liu@linux.dev>
To: Hu Song <husong@kylinos.cn>,
Andrew Morton <akpm@linux-foundation.org>,
Vlastimil Babka <vbabka@suse.cz>
Cc: Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Brendan Jackman <jackmanb@google.com>,
Johannes Weiner <hannes@cmpxchg.org>, Zi Yan <ziy@nvidia.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] mm/page_owner: simplify zone iteration logic in init_early_allocated_pages()
Date: Thu, 2 Oct 2025 10:00:39 +0800 [thread overview]
Message-ID: <7afdf764-35f4-47fb-9a26-14aba34ec1f2@linux.dev> (raw)
In-Reply-To: <20250930092153.843109-2-husong@kylinos.cn>
在 2025/9/30 17:21, Hu Song 写道:
> From: Song Hu <husong@kylinos.cn>
>
> The current implementation uses nested loops: first iterating over all
> online nodes, then over zones within each node. This can be simplified
> by using the for_each_populated_zone() macro which directly iterates
> through all populated zones.
>
> This change:
> 1. Removes the intermediate init_zones_in_node() function
> 2. Simplifies init_early_allocated_pages() to use direct zone iteration
> 3. Updates init_pages_in_zone() to take only zone parameter and access
> node_id via zone->zone_pgdat
>
> The functionality remains identical, but the code is cleaner and more
> maintainable.
>
> Signed-off-by: Song Hu <husong@kylinos.cn>
Reviewed-by: Ye Liu <liuye@kylinos.cn>
> ---
> mm/page_owner.c | 23 +++++------------------
> 1 file changed, 5 insertions(+), 18 deletions(-)
>
> diff --git a/mm/page_owner.c b/mm/page_owner.c
> index bb88b72b6062..b170b27d87a1 100644
> --- a/mm/page_owner.c
> +++ b/mm/page_owner.c
> @@ -757,7 +757,7 @@ static loff_t lseek_page_owner(struct file *file, loff_t offset, int orig)
> return file->f_pos;
> }
>
> -static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone)
> +static void init_pages_in_zone(struct zone *zone)
> {
> unsigned long pfn = zone->zone_start_pfn;
> unsigned long end_pfn = zone_end_pfn(zone);
> @@ -824,28 +824,15 @@ static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone)
> }
>
> pr_info("Node %d, zone %8s: page owner found early allocated %lu pages\n",
> - pgdat->node_id, zone->name, count);
> -}
> -
> -static void init_zones_in_node(pg_data_t *pgdat)
> -{
> - struct zone *zone;
> - struct zone *node_zones = pgdat->node_zones;
> -
> - for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) {
> - if (!populated_zone(zone))
> - continue;
> -
> - init_pages_in_zone(pgdat, zone);
> - }
> + zone->zone_pgdat->node_id, zone->name, count);
> }
>
> static void init_early_allocated_pages(void)
> {
> - pg_data_t *pgdat;
> + struct zone *zone;
>
> - for_each_online_pgdat(pgdat)
> - init_zones_in_node(pgdat);
> + for_each_populated_zone(zone)
> + init_pages_in_zone(zone);
> }
>
> static const struct file_operations page_owner_fops = {
--
Thanks,
Ye Liu
next prev parent reply other threads:[~2025-10-02 2:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-30 9:21 [PATCH 1/2] mm/page_owner: Rename proc-prefixed variables for clarity Hu Song
2025-09-30 9:21 ` [PATCH 2/2] mm/page_owner: simplify zone iteration logic in init_early_allocated_pages() Hu Song
2025-10-01 13:47 ` Vlastimil Babka
2025-10-02 2:00 ` Ye Liu [this message]
2025-10-01 13:19 ` [PATCH 1/2] mm/page_owner: Rename proc-prefixed variables for clarity Vlastimil Babka
2025-10-02 1:58 ` Ye Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7afdf764-35f4-47fb-9a26-14aba34ec1f2@linux.dev \
--to=ye.liu@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=husong@kylinos.cn \
--cc=jackmanb@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox