* [PATCH] lib/idr.c: Fix bug introduced by RCU fix
@ 2008-12-10 17:17 Manfred Spraul
2008-12-10 17:39 ` Linus Torvalds
2008-12-10 23:46 ` Dave Airlie
0 siblings, 2 replies; 3+ messages in thread
From: Manfred Spraul @ 2008-12-10 17:17 UTC (permalink / raw)
To: torvalds; +Cc: linux-kernel, cebbert, airlied, akpm
The last patch to lib/idr.c caused a bug if idr_get_new_above() was
called on an empty idr:
Usually, nodes stay on the same layer. New layers are added to the top
of the tree.
The exception is idr_get_new_above() on an empty tree: In this case,
the new root node is first added on layer 0, then moved upwards.
p->layer was not updated.
As usual: You shall never rely on the source code comments, they
will only mislead you.
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
---
lib/idr.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/lib/idr.c b/lib/idr.c
index 7a785a0..1c4f928 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -220,8 +220,14 @@ build_up:
*/
while ((layers < (MAX_LEVEL - 1)) && (id >= (1 << (layers*IDR_BITS)))) {
layers++;
- if (!p->count)
+ if (!p->count) {
+ /* special case: if the tree is currently empty,
+ * then we grow the tree by moving the top node
+ * upwards.
+ */
+ p->layer++;
continue;
+ }
if (!(new = get_from_free_list(idp))) {
/*
* The allocation failed. If we built part of
--
1.5.6.5
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] lib/idr.c: Fix bug introduced by RCU fix
2008-12-10 17:17 [PATCH] lib/idr.c: Fix bug introduced by RCU fix Manfred Spraul
@ 2008-12-10 17:39 ` Linus Torvalds
2008-12-10 23:46 ` Dave Airlie
1 sibling, 0 replies; 3+ messages in thread
From: Linus Torvalds @ 2008-12-10 17:39 UTC (permalink / raw)
To: Manfred Spraul; +Cc: linux-kernel, cebbert, airlied, akpm
On Wed, 10 Dec 2008, Manfred Spraul wrote:
>
> The last patch to lib/idr.c caused a bug if idr_get_new_above() was
> called on an empty idr:
> Usually, nodes stay on the same layer. New layers are added to the top
> of the tree.
> The exception is idr_get_new_above() on an empty tree: In this case,
> the new root node is first added on layer 0, then moved upwards.
> p->layer was not updated.
>
> As usual: You shall never rely on the source code comments, they
> will only mislead you.
>
> Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
Dave Airlie - can you get this tested and acked with the people who saw
this problem with DRI?
Linus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] lib/idr.c: Fix bug introduced by RCU fix
2008-12-10 17:17 [PATCH] lib/idr.c: Fix bug introduced by RCU fix Manfred Spraul
2008-12-10 17:39 ` Linus Torvalds
@ 2008-12-10 23:46 ` Dave Airlie
1 sibling, 0 replies; 3+ messages in thread
From: Dave Airlie @ 2008-12-10 23:46 UTC (permalink / raw)
To: Manfred Spraul; +Cc: torvalds, linux-kernel, cebbert, akpm
On Thu, Dec 11, 2008 at 3:17 AM, Manfred Spraul
<manfred@colorfullife.com> wrote:
> The last patch to lib/idr.c caused a bug if idr_get_new_above() was
> called on an empty idr:
> Usually, nodes stay on the same layer. New layers are added to the top
> of the tree.
> The exception is idr_get_new_above() on an empty tree: In this case,
> the new root node is first added on layer 0, then moved upwards.
> p->layer was not updated.
>
> As usual: You shall never rely on the source code comments, they
> will only mislead you.
>
> Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
I've given this a run on my dri system and it appears to work great.
Tested-by: Dave Airlie <airlied@redhat.com>
> ---
> lib/idr.c | 8 +++++++-
> 1 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/lib/idr.c b/lib/idr.c
> index 7a785a0..1c4f928 100644
> --- a/lib/idr.c
> +++ b/lib/idr.c
> @@ -220,8 +220,14 @@ build_up:
> */
> while ((layers < (MAX_LEVEL - 1)) && (id >= (1 << (layers*IDR_BITS)))) {
> layers++;
> - if (!p->count)
> + if (!p->count) {
> + /* special case: if the tree is currently empty,
> + * then we grow the tree by moving the top node
> + * upwards.
> + */
> + p->layer++;
> continue;
> + }
> if (!(new = get_from_free_list(idp))) {
> /*
> * The allocation failed. If we built part of
> --
> 1.5.6.5
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-12-10 23:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-10 17:17 [PATCH] lib/idr.c: Fix bug introduced by RCU fix Manfred Spraul
2008-12-10 17:39 ` Linus Torvalds
2008-12-10 23:46 ` Dave Airlie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®