linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/highmem: simplify is_highmem()
@ 2016-03-30  4:43 Chanho Min
  2016-03-30  6:34 ` Dan Williams
  2016-03-30  9:24 ` Michal Hocko
  0 siblings, 2 replies; 4+ messages in thread
From: Chanho Min @ 2016-03-30  4:43 UTC (permalink / raw)
  To: Andrew Morton, Mel Gorman, Vlastimil Babka, David Rientjes,
	Michal Hocko, Dan Williams, Zhang Zhen
  Cc: linux-mm, linux-kernel, Gunho Lee, Chanho Min

The is_highmem() is can be simplified by use of is_highmem_idx().
This patch removes redundant code and will make it easier to maintain
if the zone policy is changed or a new zone is added.

Signed-off-by: Chanho Min <chanho.min@lge.com>
---
 include/linux/mmzone.h |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index e23a9e7..9ac90c3 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -817,10 +817,7 @@ static inline int is_highmem_idx(enum zone_type idx)
 static inline int is_highmem(struct zone *zone)
 {
 #ifdef CONFIG_HIGHMEM
-	int zone_off = (char *)zone - (char *)zone->zone_pgdat->node_zones;
-	return zone_off == ZONE_HIGHMEM * sizeof(*zone) ||
-	       (zone_off == ZONE_MOVABLE * sizeof(*zone) &&
-		zone_movable_is_highmem());
+	return is_highmem_idx(zone_idx(zone));
 #else
 	return 0;
 #endif
-- 
1.7.9.5

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

* Re: [PATCH] mm/highmem: simplify is_highmem()
  2016-03-30  4:43 [PATCH] mm/highmem: simplify is_highmem() Chanho Min
@ 2016-03-30  6:34 ` Dan Williams
  2016-03-30  9:24 ` Michal Hocko
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Williams @ 2016-03-30  6:34 UTC (permalink / raw)
  To: Chanho Min
  Cc: Andrew Morton, Mel Gorman, Vlastimil Babka, David Rientjes,
	Michal Hocko, Zhang Zhen, Linux MM, linux-kernel, Gunho Lee

On Tue, Mar 29, 2016 at 9:43 PM, Chanho Min <chanho.min@lge.com> wrote:
> The is_highmem() is can be simplified by use of is_highmem_idx().
> This patch removes redundant code and will make it easier to maintain
> if the zone policy is changed or a new zone is added.
>
> Signed-off-by: Chanho Min <chanho.min@lge.com>
> ---
>  include/linux/mmzone.h |    5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index e23a9e7..9ac90c3 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -817,10 +817,7 @@ static inline int is_highmem_idx(enum zone_type idx)
>  static inline int is_highmem(struct zone *zone)
>  {
>  #ifdef CONFIG_HIGHMEM
> -       int zone_off = (char *)zone - (char *)zone->zone_pgdat->node_zones;
> -       return zone_off == ZONE_HIGHMEM * sizeof(*zone) ||
> -              (zone_off == ZONE_MOVABLE * sizeof(*zone) &&
> -               zone_movable_is_highmem());
> +       return is_highmem_idx(zone_idx(zone));
>  #else
>         return 0;
>  #endif

Yup, looks like a straightforward replacement of open coded versions
of the same routines.

Reviewed-by: Dan Williams <dan.j.williams@intel.com>

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

* Re: [PATCH] mm/highmem: simplify is_highmem()
  2016-03-30  4:43 [PATCH] mm/highmem: simplify is_highmem() Chanho Min
  2016-03-30  6:34 ` Dan Williams
@ 2016-03-30  9:24 ` Michal Hocko
  2016-03-31 22:38   ` Andrew Morton
  1 sibling, 1 reply; 4+ messages in thread
From: Michal Hocko @ 2016-03-30  9:24 UTC (permalink / raw)
  To: Chanho Min
  Cc: Andrew Morton, Mel Gorman, Vlastimil Babka, David Rientjes,
	Dan Williams, Zhang Zhen, linux-mm, linux-kernel, Gunho Lee

On Wed 30-03-16 13:43:42, Chanho Min wrote:
> The is_highmem() is can be simplified by use of is_highmem_idx().
> This patch removes redundant code and will make it easier to maintain
> if the zone policy is changed or a new zone is added.
> 
> Signed-off-by: Chanho Min <chanho.min@lge.com>
> ---
>  include/linux/mmzone.h |    5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index e23a9e7..9ac90c3 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -817,10 +817,7 @@ static inline int is_highmem_idx(enum zone_type idx)
>  static inline int is_highmem(struct zone *zone)
>  {
>  #ifdef CONFIG_HIGHMEM
> -	int zone_off = (char *)zone - (char *)zone->zone_pgdat->node_zones;
> -	return zone_off == ZONE_HIGHMEM * sizeof(*zone) ||
> -	       (zone_off == ZONE_MOVABLE * sizeof(*zone) &&
> -		zone_movable_is_highmem());
> +	return is_highmem_idx(zone_idx(zone));

This will reintroduce the pointer arithmetic removed by ddc81ed2c5d4
("remove sparse warning for mmzone.h") AFAICS. I have no idea how much
that matters though. The mentioned commit doesn't tell much about saves
except for
"
	On X86_32 this saves a sar, but code size increases by one byte per
        is_highmem() use due to 32-bit cmps rather than 16 bit cmps.
"

>  #else
>  	return 0;
>  #endif
> -- 
> 1.7.9.5
> 

-- 
Michal Hocko
SUSE Labs

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

* Re: [PATCH] mm/highmem: simplify is_highmem()
  2016-03-30  9:24 ` Michal Hocko
@ 2016-03-31 22:38   ` Andrew Morton
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2016-03-31 22:38 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Chanho Min, Mel Gorman, Vlastimil Babka, David Rientjes,
	Dan Williams, Zhang Zhen, linux-mm, linux-kernel, Gunho Lee

On Wed, 30 Mar 2016 11:24:38 +0200 Michal Hocko <mhocko@kernel.org> wrote:

> On Wed 30-03-16 13:43:42, Chanho Min wrote:
> > The is_highmem() is can be simplified by use of is_highmem_idx().
> > This patch removes redundant code and will make it easier to maintain
> > if the zone policy is changed or a new zone is added.
> > 
> > Signed-off-by: Chanho Min <chanho.min@lge.com>
> > ---
> >  include/linux/mmzone.h |    5 +----
> >  1 file changed, 1 insertion(+), 4 deletions(-)
> > 
> > diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> > index e23a9e7..9ac90c3 100644
> > --- a/include/linux/mmzone.h
> > +++ b/include/linux/mmzone.h
> > @@ -817,10 +817,7 @@ static inline int is_highmem_idx(enum zone_type idx)
> >  static inline int is_highmem(struct zone *zone)
> >  {
> >  #ifdef CONFIG_HIGHMEM
> > -	int zone_off = (char *)zone - (char *)zone->zone_pgdat->node_zones;
> > -	return zone_off == ZONE_HIGHMEM * sizeof(*zone) ||
> > -	       (zone_off == ZONE_MOVABLE * sizeof(*zone) &&
> > -		zone_movable_is_highmem());
> > +	return is_highmem_idx(zone_idx(zone));
> 
> This will reintroduce the pointer arithmetic removed by ddc81ed2c5d4
> ("remove sparse warning for mmzone.h") AFAICS. I have no idea how much
> that matters though. The mentioned commit doesn't tell much about saves
> except for
> "
> 	On X86_32 this saves a sar, but code size increases by one byte per
>         is_highmem() use due to 32-bit cmps rather than 16 bit cmps.
> "

The patch shrinks my i386 allmodconfig page_alloc.o by 50 bytes, and
that has just two is_highmem() callsites.  So I think it's OK from a
code-size and performance piont of view

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

end of thread, other threads:[~2016-03-31 22:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-30  4:43 [PATCH] mm/highmem: simplify is_highmem() Chanho Min
2016-03-30  6:34 ` Dan Williams
2016-03-30  9:24 ` Michal Hocko
2016-03-31 22:38   ` Andrew Morton

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