linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/page_owner.c Clean up init_pages_in_zone()
@ 2018-01-09 13:33 Oscar Salvador
  2018-01-09 17:18 ` Michal Hocko
  0 siblings, 1 reply; 3+ messages in thread
From: Oscar Salvador @ 2018-01-09 13:33 UTC (permalink / raw)
  To: linux-mm; +Cc: vbabka, akpm, mhocko

This patch removes two redundant assignments in init_pages_in_zone function

Signed-off-by: Oscar Salvador <osalvador@techadventures.net>
---
 mm/page_owner.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/mm/page_owner.c b/mm/page_owner.c
index 8602fb41b293..7d20c6cc98e0 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -528,14 +528,11 @@ read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 
 static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone)
 {
-	struct page *page;
-	struct page_ext *page_ext;
 	unsigned long pfn = zone->zone_start_pfn, block_end_pfn;
 	unsigned long end_pfn = pfn + zone->spanned_pages;
 	unsigned long count = 0;
 
 	/* Scan block by block. First and last block may be incomplete */
-	pfn = zone->zone_start_pfn;
 
 	/*
 	 * Walk the zone in pageblock_nr_pages steps. If a page block spans
@@ -551,13 +548,11 @@ static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone)
 		block_end_pfn = ALIGN(pfn + 1, pageblock_nr_pages);
 		block_end_pfn = min(block_end_pfn, end_pfn);
 
-		page = pfn_to_page(pfn);
-
 		for (; pfn < block_end_pfn; pfn++) {
 			if (!pfn_valid_within(pfn))
 				continue;
 
-			page = pfn_to_page(pfn);
+			struct page *page = pfn_to_page(pfn);
 
 			if (page_zone(page) != zone)
 				continue;
@@ -580,7 +575,7 @@ static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone)
 			if (PageReserved(page))
 				continue;
 
-			page_ext = lookup_page_ext(page);
+			struct page_ext *page_ext = lookup_page_ext(page);
 			if (unlikely(!page_ext))
 				continue;
 
-- 
2.13.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm/page_owner.c Clean up init_pages_in_zone()
  2018-01-09 13:33 [PATCH] mm/page_owner.c Clean up init_pages_in_zone() Oscar Salvador
@ 2018-01-09 17:18 ` Michal Hocko
  2018-01-10  8:05   ` Oscar Salvador
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Hocko @ 2018-01-09 17:18 UTC (permalink / raw)
  To: Oscar Salvador; +Cc: linux-mm, vbabka, akpm

On Tue 09-01-18 14:33:03, Oscar Salvador wrote:
[...]
> @@ -551,13 +548,11 @@ static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone)
>  		block_end_pfn = ALIGN(pfn + 1, pageblock_nr_pages);
>  		block_end_pfn = min(block_end_pfn, end_pfn);
>  
> -		page = pfn_to_page(pfn);
> -
>  		for (; pfn < block_end_pfn; pfn++) {
>  			if (!pfn_valid_within(pfn))
>  				continue;
>  
> -			page = pfn_to_page(pfn);
> +			struct page *page = pfn_to_page(pfn);
>  
>  			if (page_zone(page) != zone)
>  				continue;
> @@ -580,7 +575,7 @@ static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone)
>  			if (PageReserved(page))
>  				continue;
>  
> -			page_ext = lookup_page_ext(page);
> +			struct page_ext *page_ext = lookup_page_ext(page);
>  			if (unlikely(!page_ext))
>  				continue;

we do not interleave declarations with the code in the kernel. You can
move those from the function scope to the loop scope and remove the
pointless pfn and page initialization outside of the loop.
-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm/page_owner.c Clean up init_pages_in_zone()
  2018-01-09 17:18 ` Michal Hocko
@ 2018-01-10  8:05   ` Oscar Salvador
  0 siblings, 0 replies; 3+ messages in thread
From: Oscar Salvador @ 2018-01-10  8:05 UTC (permalink / raw)
  To: Michal Hocko; +Cc: linux-mm, vbabka, akpm

On Tue, Jan 09, 2018 at 06:18:20PM +0100, Michal Hocko wrote:
> On Tue 09-01-18 14:33:03, Oscar Salvador wrote:
> [...]
> > @@ -551,13 +548,11 @@ static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone)
> >  		block_end_pfn = ALIGN(pfn + 1, pageblock_nr_pages);
> >  		block_end_pfn = min(block_end_pfn, end_pfn);
> >  
> > -		page = pfn_to_page(pfn);
> > -
> >  		for (; pfn < block_end_pfn; pfn++) {
> >  			if (!pfn_valid_within(pfn))
> >  				continue;
> >  
> > -			page = pfn_to_page(pfn);
> > +			struct page *page = pfn_to_page(pfn);
> >  
> >  			if (page_zone(page) != zone)
> >  				continue;
> > @@ -580,7 +575,7 @@ static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone)
> >  			if (PageReserved(page))
> >  				continue;
> >  
> > -			page_ext = lookup_page_ext(page);
> > +			struct page_ext *page_ext = lookup_page_ext(page);
> >  			if (unlikely(!page_ext))
> >  				continue;
> 
> we do not interleave declarations with the code in the kernel. You can
> move those from the function scope to the loop scope and remove the
> pointless pfn and page initialization outside of the loop.

I will send a v2 fixing this.

Thanks!

Oscar Salvador

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2018-01-10  8:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-09 13:33 [PATCH] mm/page_owner.c Clean up init_pages_in_zone() Oscar Salvador
2018-01-09 17:18 ` Michal Hocko
2018-01-10  8:05   ` Oscar Salvador

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