lkml.org 
[lkml]   [2006]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch 1/3] radix tree: RCU lockless read-side
Balbir Singh wrote:

><snip>
>
>>But we should have already rcu_dereference()ed "slot", right
>>(in the loop above this one)? That means we are now able to
>>dereference it, and the data at the other end will be valid.
>>
>>
>
>Yes, but my confusion is about the following piece of code
>
><begin code>
>
> for ( ; height > 1; height--) {
>
> for (i = (index >> shift) & RADIX_TREE_MAP_MASK ;
> i < RADIX_TREE_MAP_SIZE; i++) {
>- if (slot->slots[i] != NULL)
>+ __s = rcu_dereference(slot->slots[i]);
>+ if (__s != NULL)
> break;
> index &= ~((1UL << shift) - 1);
> index += 1UL << shift;
>@@ -531,14 +550,14 @@ __lookup(struct radix_tree_root *root, v
> goto out;
>
> shift -= RADIX_TREE_MAP_SHIFT;
>- slot = slot->slots[i];
>+ slot = __s;
> }
>
> /* Bottom level: grab some items */
> for (i = index & RADIX_TREE_MAP_MASK; i < RADIX_TREE_MAP_SIZE; i++) {
> index++;
> if (slot->slots[i]) {
>- results[nr_found++] = slot->slots[i];
>+ results[nr_found++] = &slot->slots[i];
> if (nr_found == max_items)
> goto out;
> }
><end code>
>
>In the for loop, lets say __s is *not* NULL, we break from the loop.
>In the loop below
>slot->slots[i] is derefenced without rcu, __s is not used. Is that not
>inconsistent?
>
>

The "slots" member is an array, not an RCU assigned pointer. As such, after
doing rcu_dereference(slot), you can access slot->slots[i] without further
memory barriers I think?

But I agree that code now is a bit inconsistent. I've cleaned things up a
bit in my tree now... but perhaps it is easier if you send a patch to show
what you mean (because sometimes I'm a bit dense, I'm afraid).

Thanks,
Nick

--

Send instant messages to your online friends http://au.messenger.yahoo.com

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

\
 
 \ /
  Last update: 2006-03-13 23:39    [W:0.085 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site