Skip to contentSkip to conversation

mm: fix declarations of nr, delta and nr_pagecache_reclaimable

PATCH NAK Alexandru Moise 2 participants 5 messages Sep 27, 2015 – Sep 30, 2015

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

PATCH 2/2 mm: fix declarations of nr, delta and nr_pagecache_reclaimable

The nr variable is meant to be returned by a function which is declared as returning "unsigned long", so declare nr as such.

Lower down we should also declare delta and nr_pagecache_reclaimable as being unsigned longs because they're used to store the values returned by zone_page_state() and zone_unmapped_file_pages() which also happen to return unsigned integers.

---
 mm/vmscan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
mm/vmscan.c +3 -3
index 7f63a93..41e254e 100644
@@ -194,7 +194,7 @@ static bool sane_reclaim(struct scan_control *sc)
 
 static unsigned long zone_reclaimable_pages(struct zone *zone)
 {
-	int nr;
+	unsigned long nr;
 
 	nr = zone_page_state(zone, NR_ACTIVE_FILE) +
 	     zone_page_state(zone, NR_INACTIVE_FILE);
@@ -3698,8 +3698,8 @@ static inline unsigned long zone_unmapped_file_pages(struct zone *zone)
 /* Work out how many page cache pages we can reclaim in this reclaim_mode */
 static long zone_pagecache_reclaimable(struct zone *zone)
 {
-	long nr_pagecache_reclaimable;
-	long delta = 0;
+	unsigned long nr_pagecache_reclaimable;
+	unsigned long delta = 0;
 
 	/*
 	 * If RECLAIM_UNMAP is set, then all file pages are considered
Signature · 7 lines
2.5.3

--
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>
maintainer
#1 lore raw
Quoted 7 lines · On Sun, 27 Sep 2015 21:04:25 +0000 Alexandru Moise…

The nr variable is meant to be returned by a function which is declared as returning "unsigned long", so declare nr as such.

Lower down we should also declare delta and nr_pagecache_reclaimable as being unsigned longs because they're used to store the values returned by zone_page_state() and zone_unmapped_file_pages() which also happen to return unsigned integers.

I rewrote the changelog rather a lot:

Subject: mm/vmscan.c: fix types of some locals

In zone_reclaimable_pages(), `nr' is returned by a function which is declared as returning "unsigned long", so declare it such. Negative values are meaningless here.

In zone_pagecache_reclaimable() we should also declare delta' and nr_pagecache_reclaimable' as being unsigned longs because they're used to store the values returned by zone_page_state() and zone_unmapped_file_pages() which also happen to return unsigned integers.

mm/vmscan.c static bool sane_reclaim(struct scan_control *sc) · line 200

Quoted 11 lines
mm/vmscan.c +1 -1
@@ -194,7 +194,7 @@ static bool sane_reclaim(struct scan_control *sc)
 
 static unsigned long zone_reclaimable_pages(struct zone *zone)
 {
-	int nr;
+	unsigned long nr;
 
 	nr = zone_page_state(zone, NR_ACTIVE_FILE) +
 	     zone_page_state(zone, NR_INACTIVE_FILE);

OK.

mm/vmscan.c static inline unsigned long zone_unmapped_file_pages(struct zone *zone) · line 3705

Quoted 11 lines
mm/vmscan.c +2 -2
@@ -3698,8 +3698,8 @@ static inline unsigned long zone_unmapped_file_pages(struct zone *zone)
 /* Work out how many page cache pages we can reclaim in this reclaim_mode */
 static long zone_pagecache_reclaimable(struct zone *zone)
 {
-	long nr_pagecache_reclaimable;
-	long delta = 0;
+	unsigned long nr_pagecache_reclaimable;
+	unsigned long delta = 0;
 
 	/*
 	 * If RECLAIM_UNMAP is set, then all file pages are considered

Also OK, because zone_pagecache_reclaimable() takes care to avoid returning any negative values.

In fact I believe we should also do this:

mm/vmscan.c renamed from mm/vmscan.c~mm-fix-declarations-of-nr-delta-and-nr_pagecache_reclaimable-fix +1 -1
@@ -3693,7 +3693,7 @@ static inline unsigned long zone_unmappe
 }
 
 /* Work out how many page cache pages we can reclaim in this reclaim_mode */
-static long zone_pagecache_reclaimable(struct zone *zone)
+static unsigned long zone_pagecache_reclaimable(struct zone *zone)
 {
 	unsigned long nr_pagecache_reclaimable;
 	unsigned long delta = 0;

_

--
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 9 lines
Quoted 9 lines
mm/vmscan.c +1 -1
@@ -194,7 +194,7 @@ static bool sane_reclaim(struct scan_control *sc)
 
 static unsigned long zone_reclaimable_pages(struct zone *zone)
 {
-	int nr;
+	unsigned long nr;
 
Quoted 5 lines

mm/vmscan.c static bool sane_reclaim(struct scan_control *sc) · line 200

Quoted 2 lines
mm/vmscan.c +0 -0
 	nr = zone_page_state(zone, NR_ACTIVE_FILE) +
 	     zone_page_state(zone, NR_INACTIVE_FILE);

OK.

Are you sure? Mel Gorman raised the following issue on patch 1/2:

https://lkml.org/lkml/2015/9/29/253

Thanks for the review.

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

maintainer
#3 lore raw
Quoted 15 lines · On Wed, 30 Sep 2015 08:10:04 +0300 Alexandru Moise…
Quoted 9 lines
Quoted 9 lines
mm/vmscan.c +1 -1
@@ -194,7 +194,7 @@ static bool sane_reclaim(struct scan_control *sc)
 
 static unsigned long zone_reclaimable_pages(struct zone *zone)
 {
-	int nr;
+	unsigned long nr;
 
Quoted 5 lines

mm/vmscan.c static bool sane_reclaim(struct scan_control *sc) · line 200

Quoted 2 lines
mm/vmscan.c +0 -0
 	nr = zone_page_state(zone, NR_ACTIVE_FILE) +
 	     zone_page_state(zone, NR_INACTIVE_FILE);

OK.

Quoted 3 lines

Are you sure? Mel Gorman raised the following issue on patch 1/2:

https://lkml.org/lkml/2015/9/29/253

__zone_watermark_ok() is very different from zone_reclaimable_pages().

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

#4 lore raw
Quoted 17 lines · Andrew Morton
Quoted 15 lines · On Wed, 30 Sep 2015 08:10:04 +0300 Alexandru Moise…
Quoted 14 lines

mm/vmscan.c static bool sane_reclaim(struct scan_control *sc) · line 200

Quoted 11 lines
mm/vmscan.c +1 -1
@@ -194,7 +194,7 @@ static bool sane_reclaim(struct scan_control *sc)
 
 static unsigned long zone_reclaimable_pages(struct zone *zone)
 {
-	int nr;
+	unsigned long nr;
 
 	nr = zone_page_state(zone, NR_ACTIVE_FILE) +
 	     zone_page_state(zone, NR_INACTIVE_FILE);

OK.

Quoted 5 lines
Quoted 3 lines

Are you sure? Mel Gorman raised the following issue on patch 1/2:

https://lkml.org/lkml/2015/9/29/253

__zone_watermark_ok() is very different from zone_reclaimable_pages().

Alright, in time I will gain a better understanding of this. Thanks again.

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