[PATCH 06/13] Fix sub_alloc()
From: Nadia . Derbey
Date: Fri Apr 11 2008 - 12:21:57 EST
[PATCH 06/13]
This patch only fixes the sub_alloc() portion of ridr.c, to make it RCU based.
Signed-off-by: Nadia Derbey <Nadia.Derbey@xxxxxxxx>
---
lib/ridr.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
Index: linux-2.6.25-rc8-mm1/lib/ridr.c
===================================================================
--- linux-2.6.25-rc8-mm1.orig/lib/ridr.c 2008-04-11 17:47:48.000000000 +0200
+++ linux-2.6.25-rc8-mm1/lib/ridr.c 2008-04-11 17:51:34.000000000 +0200
@@ -135,9 +135,9 @@ static int sub_alloc(struct ridr *idp, i
id = *starting_id;
restart:
- p = idp->top;
+ rcu_assign_pointer(p, idp->top);
l = idp->layers;
- pa[l--] = NULL;
+ rcu_assign_pointer(pa[l--], NULL);
while (1) {
/*
* We run around this while until we reach the leaf node...
@@ -152,7 +152,7 @@ static int sub_alloc(struct ridr *idp, i
id = (id | ((1 << (IDR_BITS * l)) - 1)) + 1;
/* if already at the top layer, we need to grow */
- p = pa[l];
+ rcu_assign_pointer(p, pa[l]);
if (!p) {
*starting_id = id;
return -2;
@@ -182,14 +182,14 @@ static int sub_alloc(struct ridr *idp, i
new = alloc_layer(idp);
if (!new)
return -1;
- p->ary[m] = new;
+ rcu_assign_pointer(p->ary[m], new);
p->count++;
}
- pa[l--] = p;
+ rcu_assign_pointer(pa[l--], p);
p = p->ary[m];
}
- pa[l] = p;
+ rcu_assign_pointer(pa[l], p);
return id;
}
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/