lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20230525082624.GU4967@kernel.org>
Date:   Thu, 25 May 2023 11:26:24 +0300
From:   Mike Rapoport <rppt@...nel.org>
To:     Haifeng Xu <haifeng.xu@...pee.com>
Cc:     akpm@...ux-foundation.org, mhocko@...e.com, david@...hat.com,
        linux-mm@...ck.org, linux-kernel@...r.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()

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@...pee.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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ