Skip to contentSkip to conversation

mm/page_owner: Clean up init_pages_in_zone()

PATCH Superseded Oscar Salvador 3 participants 4 messages Jan 10, 2018 – Jan 17, 2018

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mm/page_owner: Clean up init_pages_in_zone()

This patch removes two redundant assignments in init_pages_in_zone function.

---
 mm/page_owner.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
mm/page_owner.c +2 -5
index 69f83fc763bb..b361781e5ab6 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,9 +548,9 @@ 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++) {
+			struct page *page;
+			struct page_ext *page_ext;
 			if (!pfn_valid_within(pfn))
 				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 Acked-by on v2 1/1
#1 lore raw
Quoted 3 lines · Oscar Salvador

This patch removes two redundant assignments in init_pages_in_zone function.

Quoted 38 lines
---
 mm/page_owner.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
mm/page_owner.c +2 -5
index 69f83fc763bb..b361781e5ab6 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,9 +548,9 @@ 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++) {
+			struct page *page;
+			struct page_ext *page_ext;
 			if (!pfn_valid_within(pfn))
 				continue;
 
Signature · 1 line
2.13.5
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>
Acked-by on v2 1/1
#2 lore raw
In reply to Oscar Salvador
Quoted 3 lines · Oscar Salvador

This patch removes two redundant assignments in init_pages_in_zone function.

A nitpick below.

Quoted 9 lines
---
 mm/page_owner.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
mm/page_owner.c +0 -0
index 69f83fc763bb..b361781e5ab6 100644

mm/page_owner.c read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos) · line 531

Quoted 6 lines
mm/page_owner.c +0 -2
@@ -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;

block_end_pfn declaration could be moved to the outer for loop

mm/page_owner.c read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos) · line 532

Quoted 1 line
mm/page_owner.c +0 -0
 	unsigned long end_pfn = pfn + zone->spanned_pages;

While here, I would use zone_end_pfn() on the line above.

mm/page_owner.c read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos) · line 535

Quoted 3 lines
mm/page_owner.c +0 -0
 	unsigned long count = 0;
 
 	/* Scan block by block. First and last block may be incomplete */

Now the comment is stray, I would just remove it too.

Quoted 7 lines
mm/page_owner.c +0 -1
-	pfn = zone->zone_start_pfn;
 
 	/*
 	 * Walk the zone in pageblock_nr_pages steps. If a page block spans
@@ -551,9 +548,9 @@ static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone)
 		block_end_pfn = ALIGN(pfn + 1, pageblock_nr_pages);

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

Quoted 10 lines
mm/page_owner.c +2 -2
 		block_end_pfn = min(block_end_pfn, end_pfn);
 
-		page = pfn_to_page(pfn);
-
 		for (; pfn < block_end_pfn; pfn++) {
+			struct page *page;
+			struct page_ext *page_ext;
 			if (!pfn_valid_within(pfn))
 				continue;
 

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

#3 lore raw
Quoted 29 lines · Vlastimil Babka
Quoted 3 lines · Oscar Salvador

This patch removes two redundant assignments in init_pages_in_zone function.

A nitpick below.

Quoted 9 lines
---
 mm/page_owner.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
mm/page_owner.c +0 -0
index 69f83fc763bb..b361781e5ab6 100644

mm/page_owner.c read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos) · line 531

Quoted 6 lines
mm/page_owner.c +0 -2
@@ -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;

block_end_pfn declaration could be moved to the outer for loop

mm/page_owner.c read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos) · line 532

Quoted 1 line
mm/page_owner.c +0 -0
 	unsigned long end_pfn = pfn + zone->spanned_pages;
Quoted 7 lines

While here, I would use zone_end_pfn() on the line above.

mm/page_owner.c read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos) · line 535

Quoted 3 lines
mm/page_owner.c +0 -0
 	unsigned long count = 0;
 
 	/* Scan block by block. First and last block may be incomplete */

Now the comment is stray, I would just remove it too.

Hi Vlastimil, thanks for the fixes.
I'll send v3 with your suggestions.

Thanks

Quoted 6 lines

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

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