linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: use the existing variable instead of a duplicate statement
@ 2019-11-25 14:53 Hao Lee
  2019-11-25 15:18 ` Mel Gorman
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Hao Lee @ 2019-11-25 14:53 UTC (permalink / raw)
  To: akpm; +Cc: mgorman, linux-mm, linux-kernel, haolee.swjtu

The address of zone has been stored in variable 'zone', so there is no need
to get it again with a duplicate statement.

Signed-off-by: Hao Lee <haolee.swjtu@gmail.com>
---
 mm/vmscan.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index ee4eecc7e1c2..de4b2d1e66be 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -363,22 +363,21 @@ unsigned long lruvec_lru_size(struct lruvec *lruvec, enum lru_list lru, int zone
 	for (zid = zone_idx + 1; zid < MAX_NR_ZONES; zid++) {
 		struct zone *zone = &lruvec_pgdat(lruvec)->node_zones[zid];
 		unsigned long size;
 
 		if (!managed_zone(zone))
 			continue;
 
 		if (!mem_cgroup_disabled())
 			size = mem_cgroup_get_zone_lru_size(lruvec, lru, zid);
 		else
-			size = zone_page_state(&lruvec_pgdat(lruvec)->node_zones[zid],
-				       NR_ZONE_LRU_BASE + lru);
+			size = zone_page_state(zone, NR_ZONE_LRU_BASE + lru);
 		lru_size -= min(size, lru_size);
 	}
 
 	return lru_size;
 
 }
 
 /*
  * Add a shrinker callback to be called from the vm.
  */
-- 
2.14.5


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

* Re: [PATCH] mm: use the existing variable instead of a duplicate statement
  2019-11-25 14:53 [PATCH] mm: use the existing variable instead of a duplicate statement Hao Lee
@ 2019-11-25 15:18 ` Mel Gorman
  2019-11-26 12:13 ` David Hildenbrand
  2019-11-28 10:02 ` Anshuman Khandual
  2 siblings, 0 replies; 6+ messages in thread
From: Mel Gorman @ 2019-11-25 15:18 UTC (permalink / raw)
  To: Hao Lee; +Cc: akpm, linux-mm, linux-kernel

On Mon, Nov 25, 2019 at 02:53:20PM +0000, Hao Lee wrote:
> The address of zone has been stored in variable 'zone', so there is no need
> to get it again with a duplicate statement.
> 
> Signed-off-by: Hao Lee <haolee.swjtu@gmail.com>

Acked-by: Mel Gorman <mgorman@suse.de>

-- 
Mel Gorman
SUSE Labs

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

* Re: [PATCH] mm: use the existing variable instead of a duplicate statement
  2019-11-25 14:53 [PATCH] mm: use the existing variable instead of a duplicate statement Hao Lee
  2019-11-25 15:18 ` Mel Gorman
@ 2019-11-26 12:13 ` David Hildenbrand
  2019-11-26 14:33   ` Hao Lee
  2019-11-28 10:02 ` Anshuman Khandual
  2 siblings, 1 reply; 6+ messages in thread
From: David Hildenbrand @ 2019-11-26 12:13 UTC (permalink / raw)
  To: Hao Lee, akpm; +Cc: mgorman, linux-mm, linux-kernel

On 25.11.19 15:53, Hao Lee wrote:
> The address of zone has been stored in variable 'zone', so there is no need
> to get it again with a duplicate statement.
> 
> Signed-off-by: Hao Lee <haolee.swjtu@gmail.com>
> ---
>  mm/vmscan.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index ee4eecc7e1c2..de4b2d1e66be 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -363,22 +363,21 @@ unsigned long lruvec_lru_size(struct lruvec *lruvec, enum lru_list lru, int zone
>  	for (zid = zone_idx + 1; zid < MAX_NR_ZONES; zid++) {
>  		struct zone *zone = &lruvec_pgdat(lruvec)->node_zones[zid];
>  		unsigned long size;
>  
>  		if (!managed_zone(zone))
>  			continue;
>  
>  		if (!mem_cgroup_disabled())
>  			size = mem_cgroup_get_zone_lru_size(lruvec, lru, zid);
>  		else
> -			size = zone_page_state(&lruvec_pgdat(lruvec)->node_zones[zid],
> -				       NR_ZONE_LRU_BASE + lru);
> +			size = zone_page_state(zone, NR_ZONE_LRU_BASE + lru);
>  		lru_size -= min(size, lru_size);
>  	}
>  
>  	return lru_size;
>  
>  }
>  
>  /*
>   * Add a shrinker callback to be called from the vm.
>   */
> 

Maybe tweak the subject to something meaningful:

"mm/vmscan: reuse stored zone in lruvec_lru_size()"

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb


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

* Re: [PATCH] mm: use the existing variable instead of a duplicate statement
  2019-11-26 12:13 ` David Hildenbrand
@ 2019-11-26 14:33   ` Hao Lee
  0 siblings, 0 replies; 6+ messages in thread
From: Hao Lee @ 2019-11-26 14:33 UTC (permalink / raw)
  To: David Hildenbrand; +Cc: akpm, Mel Gorman, linux-mm, linux-kernel

On Tue, 26 Nov 2019 at 20:13, David Hildenbrand <david@redhat.com> wrote:
>
> On 25.11.19 15:53, Hao Lee wrote:
> > The address of zone has been stored in variable 'zone', so there is no need
> > to get it again with a duplicate statement.
> >
> > --- a/mm/vmscan.c
> > +++ b/mm/vmscan.c
> > @@ -363,22 +363,21 @@ unsigned long lruvec_lru_size(struct lruvec *lruvec, enum lru_list lru, int zone
> >       for (zid = zone_idx + 1; zid < MAX_NR_ZONES; zid++) {
> >               struct zone *zone = &lruvec_pgdat(lruvec)->node_zones[zid];
> >               unsigned long size;
> >
> >               if (!managed_zone(zone))
> >                       continue;
> >
> >               if (!mem_cgroup_disabled())
> >                       size = mem_cgroup_get_zone_lru_size(lruvec, lru, zid);
> >               else
> > -                     size = zone_page_state(&lruvec_pgdat(lruvec)->node_zones[zid],
> > -                                    NR_ZONE_LRU_BASE + lru);
> > +                     size = zone_page_state(zone, NR_ZONE_LRU_BASE + lru);
> >               lru_size -= min(size, lru_size);
> >       }
> >
> >       return lru_size;
> >
> >  }
>
> Maybe tweak the subject to something meaningful:
>
> "mm/vmscan: reuse stored zone in lruvec_lru_size()"
>
> Reviewed-by: David Hildenbrand <david@redhat.com>
>
Thanks. I get it!

Regards,
Hao Lee

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

* Re: [PATCH] mm: use the existing variable instead of a duplicate statement
  2019-11-25 14:53 [PATCH] mm: use the existing variable instead of a duplicate statement Hao Lee
  2019-11-25 15:18 ` Mel Gorman
  2019-11-26 12:13 ` David Hildenbrand
@ 2019-11-28 10:02 ` Anshuman Khandual
  2019-11-28 15:12   ` Hao Lee
  2 siblings, 1 reply; 6+ messages in thread
From: Anshuman Khandual @ 2019-11-28 10:02 UTC (permalink / raw)
  To: Hao Lee, akpm; +Cc: mgorman, linux-mm, linux-kernel

On 11/25/2019 08:23 PM, Hao Lee wrote:
> The address of zone has been stored in variable 'zone', so there is no need
> to get it again with a duplicate statement.
> 
> Signed-off-by: Hao Lee <haolee.swjtu@gmail.com>
> ---
>  mm/vmscan.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index ee4eecc7e1c2..de4b2d1e66be 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -363,22 +363,21 @@ unsigned long lruvec_lru_size(struct lruvec *lruvec, enum lru_list lru, int zone
>  	for (zid = zone_idx + 1; zid < MAX_NR_ZONES; zid++) {
>  		struct zone *zone = &lruvec_pgdat(lruvec)->node_zones[zid];
>  		unsigned long size;
>  
>  		if (!managed_zone(zone))
>  			continue;
>  
>  		if (!mem_cgroup_disabled())
>  			size = mem_cgroup_get_zone_lru_size(lruvec, lru, zid);
>  		else
> -			size = zone_page_state(&lruvec_pgdat(lruvec)->node_zones[zid],
> -				       NR_ZONE_LRU_BASE + lru);
> +			size = zone_page_state(zone, NR_ZONE_LRU_BASE + lru);

Is not this already merged with following commit on next-20191126 ?

54eacdb0dd8f9a ("mm: vmscan: simplify lruvec_lru_size()")

>  		lru_size -= min(size, lru_size);
>  	}
>  
>  	return lru_size;
>  
>  }
>  
>  /*
>   * Add a shrinker callback to be called from the vm.
>   */
> 

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

* Re: [PATCH] mm: use the existing variable instead of a duplicate statement
  2019-11-28 10:02 ` Anshuman Khandual
@ 2019-11-28 15:12   ` Hao Lee
  0 siblings, 0 replies; 6+ messages in thread
From: Hao Lee @ 2019-11-28 15:12 UTC (permalink / raw)
  To: Anshuman Khandual; +Cc: akpm, Mel Gorman, linux-mm, linux-kernel

On Thu, 28 Nov 2019 at 18:02, Anshuman Khandual
<anshuman.khandual@arm.com> wrote:
>
> > diff --git a/mm/vmscan.c b/mm/vmscan.c
> > index ee4eecc7e1c2..de4b2d1e66be 100644
> > --- a/mm/vmscan.c
> > +++ b/mm/vmscan.c
> > @@ -363,22 +363,21 @@ unsigned long lruvec_lru_size(struct lruvec *lruvec, enum lru_list lru, int zone
> >       for (zid = zone_idx + 1; zid < MAX_NR_ZONES; zid++) {
> >               struct zone *zone = &lruvec_pgdat(lruvec)->node_zones[zid];
> >               unsigned long size;
> >
> >               if (!managed_zone(zone))
> >                       continue;
> >
> >               if (!mem_cgroup_disabled())
> >                       size = mem_cgroup_get_zone_lru_size(lruvec, lru, zid);
> >               else
> > -                     size = zone_page_state(&lruvec_pgdat(lruvec)->node_zones[zid],
> > -                                    NR_ZONE_LRU_BASE + lru);
> > +                     size = zone_page_state(zone, NR_ZONE_LRU_BASE + lru);
>
> Is not this already merged with following commit on next-20191126 ?
>
> 54eacdb0dd8f9a ("mm: vmscan: simplify lruvec_lru_size()")

Yes...That's really a coincidence... I use torvalds' tree to develop
but never think this function has been refactored on next tree just a
few days ago. Thank you.

Regards,
Hao Lee

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

end of thread, other threads:[~2019-11-28 15:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-25 14:53 [PATCH] mm: use the existing variable instead of a duplicate statement Hao Lee
2019-11-25 15:18 ` Mel Gorman
2019-11-26 12:13 ` David Hildenbrand
2019-11-26 14:33   ` Hao Lee
2019-11-28 10:02 ` Anshuman Khandual
2019-11-28 15:12   ` Hao Lee

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