linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: Remove zone_id() and make use of zone_idx() in is_dev_zone()
@ 2018-07-30 13:37 osalvador
  2018-07-30 14:00 ` Michal Hocko
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: osalvador @ 2018-07-30 13:37 UTC (permalink / raw)
  To: akpm
  Cc: mhocko, vbabka, sfr, rientjes, pasha.tatashin, kemi.wang, jia.he,
	ptesarik, aryabinin, linux-mm, linux-kernel, dan.j.williams,
	Oscar Salvador

From: Oscar Salvador <osalvador@suse.de>

is_dev_zone() is using zone_id() to check if the zone is ZONE_DEVICE.
zone_id() looks pretty much the same as zone_idx(), and while the use of
zone_idx() is quite spread in the kernel, zone_id() is only being
used by is_dev_zone().

This patch removes zone_id() and makes is_dev_zone() use zone_idx()
to check the zone, so we do not have two things with the same
functionality around.

Signed-off-by: Oscar Salvador <osalvador@suse.de>
---
 include/linux/mmzone.h | 31 ++++++++++++-------------------
 1 file changed, 12 insertions(+), 19 deletions(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 83b1d11e90eb..dbe7635c33dd 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -755,25 +755,6 @@ static inline bool pgdat_is_empty(pg_data_t *pgdat)
 	return !pgdat->node_start_pfn && !pgdat->node_spanned_pages;
 }
 
-static inline int zone_id(const struct zone *zone)
-{
-	struct pglist_data *pgdat = zone->zone_pgdat;
-
-	return zone - pgdat->node_zones;
-}
-
-#ifdef CONFIG_ZONE_DEVICE
-static inline bool is_dev_zone(const struct zone *zone)
-{
-	return zone_id(zone) == ZONE_DEVICE;
-}
-#else
-static inline bool is_dev_zone(const struct zone *zone)
-{
-	return false;
-}
-#endif
-
 #include <linux/memory_hotplug.h>
 
 void build_all_zonelists(pg_data_t *pgdat);
@@ -824,6 +805,18 @@ static inline int local_memory_node(int node_id) { return node_id; };
  */
 #define zone_idx(zone)		((zone) - (zone)->zone_pgdat->node_zones)
 
+#ifdef CONFIG_ZONE_DEVICE
+static inline bool is_dev_zone(const struct zone *zone)
+{
+	return zone_idx(zone) == ZONE_DEVICE;
+}
+#else
+static inline bool is_dev_zone(const struct zone *zone)
+{
+	return false;
+}
+#endif
+
 /*
  * Returns true if a zone has pages managed by the buddy allocator.
  * All the reclaim decisions have to use this function rather than
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm: Remove zone_id() and make use of zone_idx() in is_dev_zone()
  2018-07-30 13:37 [PATCH] mm: Remove zone_id() and make use of zone_idx() in is_dev_zone() osalvador
@ 2018-07-30 14:00 ` Michal Hocko
  2018-07-30 14:07 ` Vlastimil Babka
  2018-07-30 14:10 ` Pavel Tatashin
  2 siblings, 0 replies; 4+ messages in thread
From: Michal Hocko @ 2018-07-30 14:00 UTC (permalink / raw)
  To: osalvador
  Cc: akpm, vbabka, sfr, rientjes, pasha.tatashin, kemi.wang, jia.he,
	ptesarik, aryabinin, linux-mm, linux-kernel, dan.j.williams,
	Oscar Salvador

On Mon 30-07-18 15:37:18, osalvador@techadventures.net wrote:
> From: Oscar Salvador <osalvador@suse.de>
> 
> is_dev_zone() is using zone_id() to check if the zone is ZONE_DEVICE.
> zone_id() looks pretty much the same as zone_idx(), and while the use of
> zone_idx() is quite spread in the kernel, zone_id() is only being
> used by is_dev_zone().
> 
> This patch removes zone_id() and makes is_dev_zone() use zone_idx()
> to check the zone, so we do not have two things with the same
> functionality around.

Yes this looks like a pointless code duplication. I guess Dan just
wasn't aware of zone_idx() macro.

> Signed-off-by: Oscar Salvador <osalvador@suse.de>

Acked-by: Michal Hocko <mhocko@suse.com>

> ---
>  include/linux/mmzone.h | 31 ++++++++++++-------------------
>  1 file changed, 12 insertions(+), 19 deletions(-)
> 
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index 83b1d11e90eb..dbe7635c33dd 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -755,25 +755,6 @@ static inline bool pgdat_is_empty(pg_data_t *pgdat)
>  	return !pgdat->node_start_pfn && !pgdat->node_spanned_pages;
>  }
>  
> -static inline int zone_id(const struct zone *zone)
> -{
> -	struct pglist_data *pgdat = zone->zone_pgdat;
> -
> -	return zone - pgdat->node_zones;
> -}
> -
> -#ifdef CONFIG_ZONE_DEVICE
> -static inline bool is_dev_zone(const struct zone *zone)
> -{
> -	return zone_id(zone) == ZONE_DEVICE;
> -}
> -#else
> -static inline bool is_dev_zone(const struct zone *zone)
> -{
> -	return false;
> -}
> -#endif
> -
>  #include <linux/memory_hotplug.h>
>  
>  void build_all_zonelists(pg_data_t *pgdat);
> @@ -824,6 +805,18 @@ static inline int local_memory_node(int node_id) { return node_id; };
>   */
>  #define zone_idx(zone)		((zone) - (zone)->zone_pgdat->node_zones)
>  
> +#ifdef CONFIG_ZONE_DEVICE
> +static inline bool is_dev_zone(const struct zone *zone)
> +{
> +	return zone_idx(zone) == ZONE_DEVICE;
> +}
> +#else
> +static inline bool is_dev_zone(const struct zone *zone)
> +{
> +	return false;
> +}
> +#endif
> +
>  /*
>   * Returns true if a zone has pages managed by the buddy allocator.
>   * All the reclaim decisions have to use this function rather than
> -- 
> 2.13.6
> 

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm: Remove zone_id() and make use of zone_idx() in is_dev_zone()
  2018-07-30 13:37 [PATCH] mm: Remove zone_id() and make use of zone_idx() in is_dev_zone() osalvador
  2018-07-30 14:00 ` Michal Hocko
@ 2018-07-30 14:07 ` Vlastimil Babka
  2018-07-30 14:10 ` Pavel Tatashin
  2 siblings, 0 replies; 4+ messages in thread
From: Vlastimil Babka @ 2018-07-30 14:07 UTC (permalink / raw)
  To: osalvador, akpm
  Cc: mhocko, sfr, rientjes, pasha.tatashin, kemi.wang, jia.he,
	ptesarik, aryabinin, linux-mm, linux-kernel, dan.j.williams,
	Oscar Salvador

On 07/30/2018 03:37 PM, osalvador@techadventures.net wrote:
> From: Oscar Salvador <osalvador@suse.de>
> 
> is_dev_zone() is using zone_id() to check if the zone is ZONE_DEVICE.
> zone_id() looks pretty much the same as zone_idx(), and while the use of
> zone_idx() is quite spread in the kernel, zone_id() is only being
> used by is_dev_zone().
> 
> This patch removes zone_id() and makes is_dev_zone() use zone_idx()
> to check the zone, so we do not have two things with the same
> functionality around.
> 
> Signed-off-by: Oscar Salvador <osalvador@suse.de>

Agreed.

Acked-by: Vlastimil Babka <vbabka@suse.cz>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm: Remove zone_id() and make use of zone_idx() in is_dev_zone()
  2018-07-30 13:37 [PATCH] mm: Remove zone_id() and make use of zone_idx() in is_dev_zone() osalvador
  2018-07-30 14:00 ` Michal Hocko
  2018-07-30 14:07 ` Vlastimil Babka
@ 2018-07-30 14:10 ` Pavel Tatashin
  2 siblings, 0 replies; 4+ messages in thread
From: Pavel Tatashin @ 2018-07-30 14:10 UTC (permalink / raw)
  To: osalvador
  Cc: Andrew Morton, Michal Hocko, Vlastimil Babka, Stephen Rothwell,
	rientjes, kemi.wang, jia.he, Petr Tesařík, aryabinin,
	Linux Memory Management List, LKML, dan.j.williams, osalvador

On Mon, Jul 30, 2018 at 9:37 AM <osalvador@techadventures.net> wrote:
>
> From: Oscar Salvador <osalvador@suse.de>
>
> is_dev_zone() is using zone_id() to check if the zone is ZONE_DEVICE.
> zone_id() looks pretty much the same as zone_idx(), and while the use of
> zone_idx() is quite spread in the kernel, zone_id() is only being
> used by is_dev_zone().
>
> This patch removes zone_id() and makes is_dev_zone() use zone_idx()
> to check the zone, so we do not have two things with the same
> functionality around.
>
> Signed-off-by: Oscar Salvador <osalvador@suse.de>

Thank you:
Reviewed-by: Pavel Tatashin <pasha.tatashin@oracle.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-07-30 14:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-30 13:37 [PATCH] mm: Remove zone_id() and make use of zone_idx() in is_dev_zone() osalvador
2018-07-30 14:00 ` Michal Hocko
2018-07-30 14:07 ` Vlastimil Babka
2018-07-30 14:10 ` Pavel Tatashin

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).