Skip to contentSkip to conversation

mm/page_owner.c Clean up init_pages_in_zone()

PATCH Superseded Oscar Salvador 2 participants 3 messages Jan 9, 2018 – Jan 10, 2018

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/page_owner.c Clean up init_pages_in_zone()

This patch removes two redundant assignments in init_pages_in_zone function

---
 mm/page_owner.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
mm/page_owner.c +2 -7
index 8602fb41b293..7d20c6cc98e0 100644
@@ -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;
 
Signature · 7 lines
2.13.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
reviewer
#1 lore raw

On Tue 09-01-18 14:33:03, Oscar Salvador wrote:
[...]

Quoted 16 lines
mm/page_owner.c +1 -3
@@ -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;

mm/page_owner.c static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone) · line 580

Quoted 7 lines
mm/page_owner.c +1 -1
@@ -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.

Signature · 8 lines
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw
Quoted 21 lines · Michal Hocko

On Tue 09-01-18 14:33:03, Oscar Salvador wrote:
[...]

Quoted 19 lines
mm/page_owner.c +1 -3
@@ -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;
 
Quoted 8 lines

mm/page_owner.c static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone) · line 580

Quoted 4 lines
mm/page_owner.c +1 -1
-			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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>