linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anshuman Khandual <anshuman.khandual@arm.com>
To: Mike Rapoport <rppt@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Jonathan Corbet <corbet@lwn.net>,
	Mike Rapoport <rppt@linux.ibm.com>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org
Subject: Re: [PATCH 2/2] mm/mmzone.h: simplify is_highmem_idx()
Date: Mon, 26 Apr 2021 11:49:25 +0530	[thread overview]
Message-ID: <df17080c-8867-259e-5a09-1f0ec053f68e@arm.com> (raw)
In-Reply-To: <20210423203811.1247508-3-rppt@kernel.org>



On 4/24/21 2:08 AM, Mike Rapoport wrote:
> From: Mike Rapoport <rppt@linux.ibm.com>
> 
> There is a lot of historical ifdefery in is_highmem_idx() and its helper
> zone_movable_is_highmem() that was required because of two different paths
> for nodes and zones initialization that were selected at compile time.
> 
> Until commit 3f08a302f533 ("mm: remove CONFIG_HAVE_MEMBLOCK_NODE_MAP
> option") the movable_zone variable was only available for configurations
> that had CONFIG_HAVE_MEMBLOCK_NODE_MAP enabled so the test in
> zone_movable_is_highmem() used that variable only for such configurations.
> For other configurations the test checked if the index of ZONE_MOVABLE was
> greater by 1 than the index of ZONE_HIGMEM and then movable zone was
> considered a highmem zone. Needless to say, ZONE_MOVABLE - 1 equals
> ZONE_HIGMEM by definition when CONFIG_HIGHMEM=y.

Right with CONFIG_HIGHMEM is enabled, ZONE_MOVABLE = ZONE_HIGHMEM + 1 holds
always true from the very definition in enum zone_type { }.

> 
> Commit 3f08a302f533 ("mm: remove CONFIG_HAVE_MEMBLOCK_NODE_MAP option")
> made movable_zone variable always available. Since this variable is set to
> ZONE_HIGHMEM if CONFIG_HIGHMEM is enabled and highmem zone is populated, it
> is enough to check whether
> 
> 	zone_idx == ZONE_MOVABLE && movable_zone == ZONE_HIGMEM

Right. A small nit. s/HIGMEM/HIGHMEM

> 
> to test if zone index points to a highmem zone.

If the CONFIG_HIGHMEM is enabled but ZONE_HIGHMEM is not populated, then
movable_node would point to a zone below ZONE_HIGHMEM and is_highmem_idx()
would also return false.

> 
> Remove zone_movable_is_highmem() that is not used anywhere except
> is_highmem_idx() and use the test above in is_highmem_idx() instead.
> 
> Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
> ---
>  include/linux/mmzone.h | 13 +------------
>  1 file changed, 1 insertion(+), 12 deletions(-)
> 
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index 3b2205741048..6a1ac643b65e 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -968,22 +968,11 @@ static inline void zone_set_nid(struct zone *zone, int nid) {}
>  
>  extern int movable_zone;
>  
> -#ifdef CONFIG_HIGHMEM
> -static inline int zone_movable_is_highmem(void)
> -{
> -#ifdef CONFIG_NEED_MULTIPLE_NODES
> -	return movable_zone == ZONE_HIGHMEM;
> -#else
> -	return (ZONE_MOVABLE - 1) == ZONE_HIGHMEM;
> -#endif
> -}
> -#endif
> -
>  static inline int is_highmem_idx(enum zone_type idx)
>  {
>  #ifdef CONFIG_HIGHMEM
>  	return (idx == ZONE_HIGHMEM ||
> -		(idx == ZONE_MOVABLE && zone_movable_is_highmem()));
> +		(idx == ZONE_MOVABLE && movable_zone == ZONE_HIGHMEM));
>  #else
>  	return 0;
>  #endif
> 

LGTM.

Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>

      reply	other threads:[~2021-04-26  6:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-23 20:38 [PATCH 0/2] mmzone.h: fix kernel-doc and simplify is_highmem_idx Mike Rapoport
2021-04-23 20:38 ` [PATCH 1/2] mm/mmzone.h: fix existing kernel-doc comments and link them to core-api Mike Rapoport
2021-04-24  0:08   ` Matthew Wilcox
2021-04-26  5:06   ` Anshuman Khandual
2021-04-23 20:38 ` [PATCH 2/2] mm/mmzone.h: simplify is_highmem_idx() Mike Rapoport
2021-04-26  6:19   ` Anshuman Khandual [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=df17080c-8867-259e-5a09-1f0ec053f68e@arm.com \
    --to=anshuman.khandual@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rppt@kernel.org \
    --cc=rppt@linux.ibm.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;
as well as URLs for NNTP newsgroup(s).