Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1233716 > unrolled thread

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

Started byAlexandru Moise <00moses.alexander00@gmail.com>
First post2015-09-27 20:10 +0200
Last post2015-09-30 07:40 +0200
Articles 5 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 2/2] mm: fix declarations of nr, delta and  nr_pagecache_reclaimable Alexandru Moise <00moses.alexander00@gmail.com> - 2015-09-27 20:10 +0200
    Re: [PATCH 2/2] mm: fix declarations of nr, delta and  nr_pagecache_reclaimable Andrew Morton <akpm@linux-foundation.org> - 2015-09-30 01:10 +0200
      Re: [PATCH 2/2] mm: fix declarations of nr, delta and  nr_pagecache_reclaimable Alexandru Moise <00moses.alexander00@gmail.com> - 2015-09-30 07:20 +0200
        Re: [PATCH 2/2] mm: fix declarations of nr, delta and  nr_pagecache_reclaimable Andrew Morton <akpm@linux-foundation.org> - 2015-09-30 07:30 +0200
          Re: [PATCH 2/2] mm: fix declarations of nr, delta and  nr_pagecache_reclaimable Alexandru Moise <00moses.alexander00@gmail.com> - 2015-09-30 07:40 +0200

#1233716 — [PATCH 2/2] mm: fix declarations of nr, delta and nr_pagecache_reclaimable

FromAlexandru Moise <00moses.alexander00@gmail.com>
Date2015-09-27 20:10 +0200
Subject[PATCH 2/2] mm: fix declarations of nr, delta and nr_pagecache_reclaimable
Message-ID<qdoyC-6jq-1@gated-at.bofh.it>
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.

Signed-off-by: Alexandru Moise <00moses.alexander00@gmail.com>
---
 mm/vmscan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 7f63a93..41e254e 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -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
-- 
2.5.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1235626

FromAndrew Morton <akpm@linux-foundation.org>
Date2015-09-30 01:10 +0200
Message-ID<qecc2-3RU-13@gated-at.bofh.it>
In reply to#1233716
On Sun, 27 Sep 2015 21:04:25 +0000 Alexandru Moise <00moses.alexander00@gmail.com> wrote:

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



> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -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.

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

--- a/mm/vmscan.c~mm-fix-declarations-of-nr-delta-and-nr_pagecache_reclaimable-fix
+++ a/mm/vmscan.c
@@ -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 from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1235756

FromAlexandru Moise <00moses.alexander00@gmail.com>
Date2015-09-30 07:20 +0200
Message-ID<qehY5-3It-5@gated-at.bofh.it>
In reply to#1235626
> > --- a/mm/vmscan.c
> > +++ b/mm/vmscan.c
> > @@ -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.
> 

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 from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1235758

FromAndrew Morton <akpm@linux-foundation.org>
Date2015-09-30 07:30 +0200
Message-ID<qei7L-3TG-1@gated-at.bofh.it>
In reply to#1235756
On Wed, 30 Sep 2015 08:10:04 +0300 Alexandru Moise <00moses.alexander00@gmail.com> wrote:

> > > --- a/mm/vmscan.c
> > > +++ b/mm/vmscan.c
> > > @@ -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.
> > 
> 
> 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 from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1235762

FromAlexandru Moise <00moses.alexander00@gmail.com>
Date2015-09-30 07:40 +0200
Message-ID<qeiht-44N-11@gated-at.bofh.it>
In reply to#1235758
On Tue, Sep 29, 2015 at 10:28:57PM -0700, Andrew Morton wrote:
> On Wed, 30 Sep 2015 08:10:04 +0300 Alexandru Moise <00moses.alexander00@gmail.com> wrote:
> 
> > > > --- a/mm/vmscan.c
> > > > +++ b/mm/vmscan.c
> > > > @@ -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.
> > > 
> > 
> > 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 from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web