From: Mike Rapoport <rppt@kernel.org>
To: Haifeng Xu <haifeng.xu@shopee.com>
Cc: akpm@linux-foundation.org, mhocko@suse.com, david@redhat.com,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] mm/mm_init.c: do not calculate zone_start_pfn/zone_end_pfn in zone_absent_pages_in_node()
Date: Thu, 25 May 2023 11:26:24 +0300 [thread overview]
Message-ID: <20230525082624.GU4967@kernel.org> (raw)
In-Reply-To: <20230525040150.1588-3-haifeng.xu@shopee.com>
On Thu, May 25, 2023 at 04:01:50AM +0000, Haifeng Xu wrote:
> In calculate_node_totalpages(), zone_start_pfn/zone_end_pfn are
> calculated in zone_spanned_pages_in_node(), so use them as parameters
> instead of node_start_pfn/node_end_pfn and the duplicated calculation
> process can de dropped.
>
> Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>
> ---
> mm/mm_init.c | 35 ++++++++++++-----------------------
> 1 file changed, 12 insertions(+), 23 deletions(-)
>
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index 898af4eb9ce2..88c4a9266e2a 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -1166,23 +1166,11 @@ unsigned long __init absent_pages_in_range(unsigned long start_pfn,
> /* Return the number of page frames in holes in a zone on a node */
> static unsigned long __init zone_absent_pages_in_node(int nid,
> unsigned long zone_type,
> - unsigned long node_start_pfn,
> - unsigned long node_end_pfn)
> + unsigned long zone_start_pfn,
> + unsigned long zone_end_pfn)
> {
> - unsigned long zone_low = arch_zone_lowest_possible_pfn[zone_type];
> - unsigned long zone_high = arch_zone_highest_possible_pfn[zone_type];
> - unsigned long zone_start_pfn, zone_end_pfn;
> unsigned long nr_absent;
>
> - if (!node_start_pfn && !node_end_pfn)
> - return 0;
> -
> - zone_start_pfn = clamp(node_start_pfn, zone_low, zone_high);
> - zone_end_pfn = clamp(node_end_pfn, zone_low, zone_high);
> -
> - adjust_zone_range_for_zone_movable(nid, zone_type,
> - node_start_pfn, node_end_pfn,
> - &zone_start_pfn, &zone_end_pfn);
> nr_absent = __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
>
> /*
> @@ -1254,6 +1242,7 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat,
> unsigned long node_end_pfn)
> {
> unsigned long realtotalpages = 0, totalpages = 0;
> + int nid = pgdat->node_id;
> enum zone_type i;
>
> for (i = 0; i < MAX_NR_ZONES; i++) {
> @@ -1262,15 +1251,15 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat,
> unsigned long spanned, absent;
> unsigned long real_size;
>
> - spanned = zone_spanned_pages_in_node(pgdat->node_id, i,
> - node_start_pfn,
> - node_end_pfn,
> - &zone_start_pfn,
> - &zone_end_pfn);
> + spanned = zone_spanned_pages_in_node(nid, i,
> + node_start_pfn,
> + node_end_pfn,
> + &zone_start_pfn,
> + &zone_end_pfn);
Please remove unrelated whitespace changes.
Also I don't see a strong need to replace pgdat->node_id with a local
variable here and below.
> if (spanned) {
> - absent = zone_absent_pages_in_node(pgdat->node_id, i,
> - node_start_pfn,
> - node_end_pfn);
> + absent = zone_absent_pages_in_node(nid, i,
> + zone_start_pfn,
> + zone_end_pfn);
> real_size = spanned - absent;
> zone->zone_start_pfn = zone_start_pfn;
> } else {
> @@ -1289,7 +1278,7 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat,
>
> pgdat->node_spanned_pages = totalpages;
> pgdat->node_present_pages = realtotalpages;
> - pr_debug("On node %d totalpages: %lu\n", pgdat->node_id, realtotalpages);
> + pr_debug("On node %d totalpages: %lu\n", nid, realtotalpages);
> }
>
> static unsigned long __init calc_memmap_size(unsigned long spanned_pages,
> --
> 2.25.1
>
>
--
Sincerely yours,
Mike.
prev parent reply other threads:[~2023-05-25 8:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-25 4:01 Haifeng Xu
2023-05-25 8:26 ` Mike Rapoport [this message]
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=20230525082624.GU4967@kernel.org \
--to=rppt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=haifeng.xu@shopee.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.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