linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] radix-tree: fix radix_tree_prev_hole underflow case
@ 2010-05-14  2:05 Cesar Eduardo Barros
  2010-05-14  2:15 ` Wu Fengguang
  0 siblings, 1 reply; 4+ messages in thread
From: Cesar Eduardo Barros @ 2010-05-14  2:05 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-mm, Andrew Morton, Wu Fengguang, Cesar Eduardo Barros

radix_tree_prev_hole() used LONG_MAX to detect underflow; however,
ULONG_MAX is clearly what was intended, both here and by its only user
(count_history_pages at mm/readahead.c).

Cc: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Cesar Eduardo Barros <cesarb@cesarb.net>
---
 lib/radix-tree.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index b69031f..be40980 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -656,7 +656,7 @@ EXPORT_SYMBOL(radix_tree_next_hole);
  *
  *	Returns: the index of the hole if found, otherwise returns an index
  *	outside of the set specified (in which case 'index - return >= max_scan'
- *	will be true). In rare cases of wrap-around, LONG_MAX will be returned.
+ *	will be true). In rare cases of wrap-around, ULONG_MAX will be returned.
  *
  *	radix_tree_next_hole may be called under rcu_read_lock. However, like
  *	radix_tree_gang_lookup, this will not atomically search a snapshot of
@@ -674,7 +674,7 @@ unsigned long radix_tree_prev_hole(struct radix_tree_root *root,
 		if (!radix_tree_lookup(root, index))
 			break;
 		index--;
-		if (index == LONG_MAX)
+		if (index == ULONG_MAX)
 			break;
 	}
 
-- 
1.6.6.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] radix-tree: fix radix_tree_prev_hole underflow case
  2010-05-14  2:05 [PATCH] radix-tree: fix radix_tree_prev_hole underflow case Cesar Eduardo Barros
@ 2010-05-14  2:15 ` Wu Fengguang
  2010-05-14  2:28   ` Cesar Eduardo Barros
  0 siblings, 1 reply; 4+ messages in thread
From: Wu Fengguang @ 2010-05-14  2:15 UTC (permalink / raw)
  To: Cesar Eduardo Barros
  Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton

On Fri, May 14, 2010 at 10:05:24AM +0800, Cesar Eduardo Barros wrote:
> radix_tree_prev_hole() used LONG_MAX to detect underflow; however,
> ULONG_MAX is clearly what was intended, both here and by its only user
> (count_history_pages at mm/readahead.c).
 
Good catch, thanks! I actually have a more smart
radix_tree_prev_hole() that uses ULONG_MAX.

Andrew, fortunately this bug has little impact on readahead.

Reviewed-by: Wu Fengguang <fengguang.wu@intel.com>

> Cc: Wu Fengguang <fengguang.wu@intel.com>
> Signed-off-by: Cesar Eduardo Barros <cesarb@cesarb.net>
> ---
>  lib/radix-tree.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/radix-tree.c b/lib/radix-tree.c
> index b69031f..be40980 100644
> --- a/lib/radix-tree.c
> +++ b/lib/radix-tree.c
> @@ -656,7 +656,7 @@ EXPORT_SYMBOL(radix_tree_next_hole);
>   *
>   *	Returns: the index of the hole if found, otherwise returns an index
>   *	outside of the set specified (in which case 'index - return >= max_scan'
> - *	will be true). In rare cases of wrap-around, LONG_MAX will be returned.
> + *	will be true). In rare cases of wrap-around, ULONG_MAX will be returned.
>   *
>   *	radix_tree_next_hole may be called under rcu_read_lock. However, like
>   *	radix_tree_gang_lookup, this will not atomically search a snapshot of
> @@ -674,7 +674,7 @@ unsigned long radix_tree_prev_hole(struct radix_tree_root *root,
>  		if (!radix_tree_lookup(root, index))
>  			break;
>  		index--;
> -		if (index == LONG_MAX)
> +		if (index == ULONG_MAX)
>  			break;
>  	}
>  
> -- 
> 1.6.6.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] radix-tree: fix radix_tree_prev_hole underflow case
  2010-05-14  2:15 ` Wu Fengguang
@ 2010-05-14  2:28   ` Cesar Eduardo Barros
  2010-05-14  2:37     ` Wu Fengguang
  0 siblings, 1 reply; 4+ messages in thread
From: Cesar Eduardo Barros @ 2010-05-14  2:28 UTC (permalink / raw)
  To: Wu Fengguang
  Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton

Em 13-05-2010 23:15, Wu Fengguang escreveu:
> On Fri, May 14, 2010 at 10:05:24AM +0800, Cesar Eduardo Barros wrote:
>> radix_tree_prev_hole() used LONG_MAX to detect underflow; however,
>> ULONG_MAX is clearly what was intended, both here and by its only user
>> (count_history_pages at mm/readahead.c).
>
> Good catch, thanks! I actually have a more smart
> radix_tree_prev_hole() that uses ULONG_MAX.

I saw it already ([PATCH 14/16] radixtree: speed up the search for 
hole), but it misses the LONG_MAX in the documentation comment.

> Andrew, fortunately this bug has little impact on readahead.

I agree, if I read it correctly it should only have any impact either 
when very near LONG_MAX or in the unlikely case that there is no hole at 
ULONG_MAX. And even then, the impact should be limited.

-- 
Cesar Eduardo Barros
cesarb@cesarb.net
cesar.barros@gmail.com

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] radix-tree: fix radix_tree_prev_hole underflow case
  2010-05-14  2:28   ` Cesar Eduardo Barros
@ 2010-05-14  2:37     ` Wu Fengguang
  0 siblings, 0 replies; 4+ messages in thread
From: Wu Fengguang @ 2010-05-14  2:37 UTC (permalink / raw)
  To: Cesar Eduardo Barros
  Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton

On Fri, May 14, 2010 at 10:28:50AM +0800, Cesar Eduardo Barros wrote:
> Em 13-05-2010 23:15, Wu Fengguang escreveu:
> > On Fri, May 14, 2010 at 10:05:24AM +0800, Cesar Eduardo Barros wrote:
> >> radix_tree_prev_hole() used LONG_MAX to detect underflow; however,
> >> ULONG_MAX is clearly what was intended, both here and by its only user
> >> (count_history_pages at mm/readahead.c).
> >
> > Good catch, thanks! I actually have a more smart
> > radix_tree_prev_hole() that uses ULONG_MAX.
> 
> I saw it already ([PATCH 14/16] radixtree: speed up the search for 
> hole), but it misses the LONG_MAX in the documentation comment.

Yes, thanks!

> > Andrew, fortunately this bug has little impact on readahead.
> 
> I agree, if I read it correctly it should only have any impact either 
> when very near LONG_MAX or in the unlikely case that there is no hole at 
> ULONG_MAX. And even then, the impact should be limited.

Right.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2010-05-14  2:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-14  2:05 [PATCH] radix-tree: fix radix_tree_prev_hole underflow case Cesar Eduardo Barros
2010-05-14  2:15 ` Wu Fengguang
2010-05-14  2:28   ` Cesar Eduardo Barros
2010-05-14  2:37     ` Wu Fengguang

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