Skip to contentSkip to conversation

mm: fix dubious code in __count_immobile_pages()

PATCH In review Namhyung Kim 3 participants 4 messages Feb 18, 2011 – Feb 21, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: fix dubious code in __count_immobile_pages()

When pfn_valid_within() failed 'iter' was incremented twice.

Cc KAMEZAWA Hiroyuki <[email protected]>
---
 mm/page_alloc.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
mm/page_alloc.c +2 -3
index e8b02771ccea..bf83d1c1d648 100644
@@ -5380,10 +5380,9 @@ __count_immobile_pages(struct zone *zone, struct page *page, int count)
 	for (found = 0, iter = 0; iter < pageblock_nr_pages; iter++) {
 		unsigned long check = pfn + iter;
 
-		if (!pfn_valid_within(check)) {
-			iter++;
+		if (!pfn_valid_within(check))
 			continue;
-		}
+
 		page = pfn_to_page(check);
 		if (!page_count(page)) {
 			if (PageBuddy(page))
Signature · 8 lines
1.7.4

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Namhyung Kim

When pfn_valid_within() failed 'iter' was incremented twice.

Cc KAMEZAWA Hiroyuki <[email protected]>

Nitpick.

I am not sure it's best. I don't like below trick. iter += (1 << page_order(page)) - 1;

So we can change for loop with while as removing -1 trick of PageBuddy. But if you don't like it, I don't mind it. :)

Thanks!

Signature · 9 lines
Kind regards,
Minchan Kim

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw

2011-02-18 (e,?), 11:26 +0900, Minchan Kim:

Quoted 9 lines · Namhyung Kim
Quoted 4 lines

When pfn_valid_within() failed 'iter' was incremented twice.

Cc KAMEZAWA Hiroyuki <[email protected]>

Nitpick.

Quoted 8 lines

I am not sure it's best. I don't like below trick. iter += (1 << page_order(page)) - 1;

So we can change for loop with while as removing -1 trick of PageBuddy. But if you don't like it, I don't mind it. :)

Thanks!

Hi Minchan,

Either is fine to me. But I think current code would be shorter.

Signature · 10 lines
Regards,
Namhyung Kim


--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Reviewed-by on v1 1/1
#3 lore raw
In reply to Namhyung Kim
Quoted 4 lines · On Fri, 18 Feb 2011 10:46:26 +0900 Namhyung Kim <[email protected]> wrote:

When pfn_valid_within() failed 'iter' was incremented twice.

Cc KAMEZAWA Hiroyuki <[email protected]>

Thank you.

Quoted 25 lines
---
 mm/page_alloc.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
mm/page_alloc.c +2 -3
index e8b02771ccea..bf83d1c1d648 100644
@@ -5380,10 +5380,9 @@ __count_immobile_pages(struct zone *zone, struct page *page, int count)
 	for (found = 0, iter = 0; iter < pageblock_nr_pages; iter++) {
 		unsigned long check = pfn + iter;
 
-		if (!pfn_valid_within(check)) {
-			iter++;
+		if (!pfn_valid_within(check))
 			continue;
-		}
+
 		page = pfn_to_page(check);
 		if (!page_count(page)) {
 			if (PageBuddy(page))
Signature · 1 line
1.7.4

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>