linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: accurately document nr_free_*_pages functions with code comments
@ 2013-02-06  8:25 Zhang Yanfei
  2013-02-07  0:55 ` Randy Dunlap
  0 siblings, 1 reply; 5+ messages in thread
From: Zhang Yanfei @ 2013-02-06  8:25 UTC (permalink / raw)
  To: Andrew Morton, mgorman, minchan, kamezawa.hiroyu; +Cc: Linux MM, linux-kernel

Functions nr_free_zone_pages, nr_free_buffer_pages and nr_free_pagecache_pages
are horribly badly named, so accurately document them with code comments
in case of the misuse of them.

Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
---
 mm/page_alloc.c |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index df2022f..0790716 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2785,6 +2785,15 @@ void free_pages_exact(void *virt, size_t size)
 }
 EXPORT_SYMBOL(free_pages_exact);
 
+/**
+ * nr_free_zone_pages - get pages that is beyond high watermark
+ * @offset - The zone index of the highest zone
+ *
+ * The function counts pages which are beyond high watermark within
+ * all zones at or below a given zone index. For each zone, the
+ * amount of pages is calculated as:
+ *     present_pages - high_pages
+ */
 static unsigned int nr_free_zone_pages(int offset)
 {
 	struct zoneref *z;
@@ -2805,8 +2814,11 @@ static unsigned int nr_free_zone_pages(int offset)
 	return sum;
 }
 
-/*
- * Amount of free RAM allocatable within ZONE_DMA and ZONE_NORMAL
+/**
+ * nr_free_buffer_pages - get pages that is beyond high watermark
+ *
+ * The function counts pages which are beyond high watermark within
+ * ZONE_DMA and ZONE_NORMAL.
  */
 unsigned int nr_free_buffer_pages(void)
 {
@@ -2814,8 +2826,11 @@ unsigned int nr_free_buffer_pages(void)
 }
 EXPORT_SYMBOL_GPL(nr_free_buffer_pages);
 
-/*
- * Amount of free RAM allocatable within all zones
+/**
+ * nr_free_pagecache_pages - get pages that is beyond high watermark
+ *
+ * The function counts pages which are beyond high watermark within
+ * all zones.
  */
 unsigned int nr_free_pagecache_pages(void)
 {
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm: accurately document nr_free_*_pages functions with code comments
  2013-02-06  8:25 [PATCH] mm: accurately document nr_free_*_pages functions with code comments Zhang Yanfei
@ 2013-02-07  0:55 ` Randy Dunlap
  2013-02-07  1:53   ` Zhang Yanfei
  2013-02-07  1:57   ` [PATCH RESEND] " Zhang Yanfei
  0 siblings, 2 replies; 5+ messages in thread
From: Randy Dunlap @ 2013-02-07  0:55 UTC (permalink / raw)
  To: Zhang Yanfei
  Cc: Andrew Morton, mgorman, minchan, kamezawa.hiroyu, Linux MM, linux-kernel

On 02/06/13 00:25, Zhang Yanfei wrote:
> Functions nr_free_zone_pages, nr_free_buffer_pages and nr_free_pagecache_pages
> are horribly badly named, so accurately document them with code comments
> in case of the misuse of them.
> 
> Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
> ---
>  mm/page_alloc.c |   23 +++++++++++++++++++----
>  1 files changed, 19 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index df2022f..0790716 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -2785,6 +2785,15 @@ void free_pages_exact(void *virt, size_t size)
>  }
>  EXPORT_SYMBOL(free_pages_exact);
>  
> +/**
> + * nr_free_zone_pages - get pages that is beyond high watermark
> + * @offset - The zone index of the highest zone

Function parameter format uses a ':', not a '-'.  E.g.,

 * @offset: the zone index of the highest zone


> + *
> + * The function counts pages which are beyond high watermark within
> + * all zones at or below a given zone index. For each zone, the
> + * amount of pages is calculated as:
> + *     present_pages - high_pages
> + */
>  static unsigned int nr_free_zone_pages(int offset)
>  {
>  	struct zoneref *z;
> @@ -2805,8 +2814,11 @@ static unsigned int nr_free_zone_pages(int offset)
>  	return sum;
>  }
>  
> -/*
> - * Amount of free RAM allocatable within ZONE_DMA and ZONE_NORMAL
> +/**
> + * nr_free_buffer_pages - get pages that is beyond high watermark
> + *
> + * The function counts pages which are beyond high watermark within
> + * ZONE_DMA and ZONE_NORMAL.
>   */
>  unsigned int nr_free_buffer_pages(void)
>  {
> @@ -2814,8 +2826,11 @@ unsigned int nr_free_buffer_pages(void)
>  }
>  EXPORT_SYMBOL_GPL(nr_free_buffer_pages);
>  
> -/*
> - * Amount of free RAM allocatable within all zones
> +/**
> + * nr_free_pagecache_pages - get pages that is beyond high watermark
> + *
> + * The function counts pages which are beyond high watermark within
> + * all zones.
>   */
>  unsigned int nr_free_pagecache_pages(void)
>  {
> 


-- 
~Randy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm: accurately document nr_free_*_pages functions with code comments
  2013-02-07  0:55 ` Randy Dunlap
@ 2013-02-07  1:53   ` Zhang Yanfei
  2013-02-07  1:57   ` [PATCH RESEND] " Zhang Yanfei
  1 sibling, 0 replies; 5+ messages in thread
From: Zhang Yanfei @ 2013-02-07  1:53 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Andrew Morton, mgorman, minchan, kamezawa.hiroyu, Linux MM, linux-kernel

于 2013年02月07日 08:55, Randy Dunlap 写道:
> On 02/06/13 00:25, Zhang Yanfei wrote:
>> Functions nr_free_zone_pages, nr_free_buffer_pages and nr_free_pagecache_pages
>> are horribly badly named, so accurately document them with code comments
>> in case of the misuse of them.
>>
>> Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
>> ---
>>  mm/page_alloc.c |   23 +++++++++++++++++++----
>>  1 files changed, 19 insertions(+), 4 deletions(-)
>>
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index df2022f..0790716 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -2785,6 +2785,15 @@ void free_pages_exact(void *virt, size_t size)
>>  }
>>  EXPORT_SYMBOL(free_pages_exact);
>>  
>> +/**
>> + * nr_free_zone_pages - get pages that is beyond high watermark
>> + * @offset - The zone index of the highest zone
> 
> Function parameter format uses a ':', not a '-'.  E.g.,
> 
>  * @offset: the zone index of the highest zone

Sorry for my mistake. Thanks for your review.

> 
> 
>> + *
>> + * The function counts pages which are beyond high watermark within
>> + * all zones at or below a given zone index. For each zone, the
>> + * amount of pages is calculated as:
>> + *     present_pages - high_pages
>> + */
>>  static unsigned int nr_free_zone_pages(int offset)
>>  {
>>  	struct zoneref *z;
>> @@ -2805,8 +2814,11 @@ static unsigned int nr_free_zone_pages(int offset)
>>  	return sum;
>>  }
>>  
>> -/*
>> - * Amount of free RAM allocatable within ZONE_DMA and ZONE_NORMAL
>> +/**
>> + * nr_free_buffer_pages - get pages that is beyond high watermark
>> + *
>> + * The function counts pages which are beyond high watermark within
>> + * ZONE_DMA and ZONE_NORMAL.
>>   */
>>  unsigned int nr_free_buffer_pages(void)
>>  {
>> @@ -2814,8 +2826,11 @@ unsigned int nr_free_buffer_pages(void)
>>  }
>>  EXPORT_SYMBOL_GPL(nr_free_buffer_pages);
>>  
>> -/*
>> - * Amount of free RAM allocatable within all zones
>> +/**
>> + * nr_free_pagecache_pages - get pages that is beyond high watermark
>> + *
>> + * The function counts pages which are beyond high watermark within
>> + * all zones.
>>   */
>>  unsigned int nr_free_pagecache_pages(void)
>>  {
>>
> 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH RESEND] mm: accurately document nr_free_*_pages functions with code comments
  2013-02-07  0:55 ` Randy Dunlap
  2013-02-07  1:53   ` Zhang Yanfei
@ 2013-02-07  1:57   ` Zhang Yanfei
  2013-02-07 23:26     ` Andrew Morton
  1 sibling, 1 reply; 5+ messages in thread
From: Zhang Yanfei @ 2013-02-07  1:57 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Andrew Morton, mgorman, minchan, kamezawa.hiroyu, Linux MM, linux-kernel

Functions nr_free_zone_pages, nr_free_buffer_pages and nr_free_pagecache_pages
are horribly badly named, so accurately document them with code comments
in case of the misuse of them.

Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
---
 mm/page_alloc.c |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index df2022f..0790716 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2785,6 +2785,15 @@ void free_pages_exact(void *virt, size_t size)
 }
 EXPORT_SYMBOL(free_pages_exact);
 
+/**
+ * nr_free_zone_pages - get pages that is beyond high watermark
+ * @offset: The zone index of the highest zone
+ *
+ * The function counts pages which are beyond high watermark within
+ * all zones at or below a given zone index. For each zone, the
+ * amount of pages is calculated as:
+ *     present_pages - high_pages
+ */
 static unsigned int nr_free_zone_pages(int offset)
 {
 	struct zoneref *z;
@@ -2805,8 +2814,11 @@ static unsigned int nr_free_zone_pages(int offset)
 	return sum;
 }
 
-/*
- * Amount of free RAM allocatable within ZONE_DMA and ZONE_NORMAL
+/**
+ * nr_free_buffer_pages - get pages that is beyond high watermark
+ *
+ * The function counts pages which are beyond high watermark within
+ * ZONE_DMA and ZONE_NORMAL.
  */
 unsigned int nr_free_buffer_pages(void)
 {
@@ -2814,8 +2826,11 @@ unsigned int nr_free_buffer_pages(void)
 }
 EXPORT_SYMBOL_GPL(nr_free_buffer_pages);
 
-/*
- * Amount of free RAM allocatable within all zones
+/**
+ * nr_free_pagecache_pages - get pages that is beyond high watermark
+ *
+ * The function counts pages which are beyond high watermark within
+ * all zones.
  */
 unsigned int nr_free_pagecache_pages(void)
 {
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH RESEND] mm: accurately document nr_free_*_pages functions with code comments
  2013-02-07  1:57   ` [PATCH RESEND] " Zhang Yanfei
@ 2013-02-07 23:26     ` Andrew Morton
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2013-02-07 23:26 UTC (permalink / raw)
  To: Zhang Yanfei
  Cc: Randy Dunlap, mgorman, minchan, kamezawa.hiroyu, Linux MM, linux-kernel

On Thu, 07 Feb 2013 09:57:27 +0800
Zhang Yanfei <zhangyanfei@cn.fujitsu.com> wrote:

> Functions nr_free_zone_pages, nr_free_buffer_pages and nr_free_pagecache_pages
> are horribly badly named, so accurately document them with code comments
> in case of the misuse of them.

Looks OK.  I fiddled with it a bit:

--- a/mm/page_alloc.c~mm-accurately-document-nr_free__pages-functions-with-code-comments-fix
+++ a/mm/page_alloc.c
@@ -2813,12 +2813,12 @@ void free_pages_exact(void *virt, size_t
 EXPORT_SYMBOL(free_pages_exact);
 
 /**
- * nr_free_zone_pages - get pages that is beyond high watermark
+ * nr_free_zone_pages - count number of pages beyond high watermark
  * @offset: The zone index of the highest zone
  *
- * The function counts pages which are beyond high watermark within
- * all zones at or below a given zone index. For each zone, the
- * amount of pages is calculated as:
+ * nr_free_zone_pages() counts the number of counts pages which are beyond the
+ * high watermark within all zones at or below a given zone index.  For each
+ * zone, the number of pages is calculated as:
  *     present_pages - high_pages
  */
 static unsigned long nr_free_zone_pages(int offset)
@@ -2842,10 +2842,10 @@ static unsigned long nr_free_zone_pages(
 }
 
 /**
- * nr_free_buffer_pages - get pages that is beyond high watermark
+ * nr_free_buffer_pages - count number of pages beyond high watermark
  *
- * The function counts pages which are beyond high watermark within
- * ZONE_DMA and ZONE_NORMAL.
+ * nr_free_buffer_pages() counts the number of pages which are beyond the high
+ * watermark within ZONE_DMA and ZONE_NORMAL.
  */
 unsigned long nr_free_buffer_pages(void)
 {
@@ -2854,10 +2854,10 @@ unsigned long nr_free_buffer_pages(void)
 EXPORT_SYMBOL_GPL(nr_free_buffer_pages);
 
 /**
- * nr_free_pagecache_pages - get pages that is beyond high watermark
+ * nr_free_pagecache_pages - count number of pages beyond high watermark
  *
- * The function counts pages which are beyond high watermark within
- * all zones.
+ * nr_free_pagecache_pages() counts the number of pages which are beyond the
+ * high watermark within all zones.
  */
 unsigned long nr_free_pagecache_pages(void)
 {
_


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-02-07 23:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-06  8:25 [PATCH] mm: accurately document nr_free_*_pages functions with code comments Zhang Yanfei
2013-02-07  0:55 ` Randy Dunlap
2013-02-07  1:53   ` Zhang Yanfei
2013-02-07  1:57   ` [PATCH RESEND] " Zhang Yanfei
2013-02-07 23:26     ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).