Skip to contentSkip to conversation

core kernel fixes

GIT PULL Ingo Molnar 3 participants 7 messages Jun 30, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Linus,

Please pull the latest core kernel fixes git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git core-fixes-for-linus

Thanks,

Ingo

------------------>
Vegard Nossum (1):
debugobjects: fix lockdep warning

 lib/debugobjects.c |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)
lib/debugobjects.c +6 -9
index a76a5e1..85b18d7 100644
@@ -68,6 +68,7 @@ static int fill_pool(void)
 {
 	gfp_t gfp = GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN;
 	struct debug_obj *new;
+	unsigned long flags;
 
 	if (likely(obj_pool_free >= ODEBUG_POOL_MIN_LEVEL))
 		return obj_pool_free;
@@ -81,10 +82,10 @@ static int fill_pool(void)
 		if (!new)
 			return obj_pool_free;
 
-		spin_lock(&pool_lock);
+		spin_lock_irqsave(&pool_lock, flags);
 		hlist_add_head(&new->node, &obj_pool);
 		obj_pool_free++;
-		spin_unlock(&pool_lock);
+		spin_unlock_irqrestore(&pool_lock, flags);
 	}
 	return obj_pool_free;
 }
@@ -110,16 +111,13 @@ static struct debug_obj *lookup_object(void *addr, struct debug_bucket *b)
 }
 
 /*
- * Allocate a new object. If the pool is empty and no refill possible,
- * switch off the debugger.
+ * Allocate a new object. If the pool is empty, switch off the debugger.
  */
 static struct debug_obj *
 alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr)
 {
 	struct debug_obj *obj = NULL;
-	int retry = 0;
 
-repeat:
 	spin_lock(&pool_lock);
 	if (obj_pool.first) {
 		obj	    = hlist_entry(obj_pool.first, typeof(*obj), node);
@@ -141,9 +139,6 @@ repeat:
 	}
 	spin_unlock(&pool_lock);
 
-	if (fill_pool() && !obj && !retry++)
-		goto repeat;
-
 	return obj;
 }
 
@@ -261,6 +256,8 @@ __debug_object_init(void *addr, struct debug_obj_descr *descr, int onstack)
 	struct debug_obj *obj;
 	unsigned long flags;
 
+	fill_pool();
+
 	db = get_bucket((unsigned long) addr);
 
 	spin_lock_irqsave(&db->lock, flags);
#1 lore raw
Quoted 54 lines · Ingo Molnar
lib/debugobjects.c +4 -9
index a76a5e1..85b18d7 100644
@@ -68,6 +68,7 @@ static int fill_pool(void)
 {
       gfp_t gfp = GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN;
       struct debug_obj *new;
+       unsigned long flags;
 
       if (likely(obj_pool_free >= ODEBUG_POOL_MIN_LEVEL))
               return obj_pool_free;
@@ -81,10 +82,10 @@ static int fill_pool(void)
               if (!new)
                       return obj_pool_free;
 
-               spin_lock(&pool_lock);
+               spin_lock_irqsave(&pool_lock, flags);
               hlist_add_head(&new->node, &obj_pool);
               obj_pool_free++;
-               spin_unlock(&pool_lock);
+               spin_unlock_irqrestore(&pool_lock, flags);
       }
       return obj_pool_free;
 }
@@ -110,16 +111,13 @@ static struct debug_obj *lookup_object(void *addr, struct debug_bucket *b)
 }
 
 /*
- * Allocate a new object. If the pool is empty and no refill possible,
- * switch off the debugger.
+ * Allocate a new object. If the pool is empty, switch off the debugger.
 */
 static struct debug_obj *
 alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr)
 {
       struct debug_obj *obj = NULL;
-       int retry = 0;
 
-repeat:
       spin_lock(&pool_lock);
       if (obj_pool.first) {
               obj         = hlist_entry(obj_pool.first, typeof(*obj), node);
@@ -141,9 +139,6 @@ repeat:
       }
       spin_unlock(&pool_lock);
 
-       if (fill_pool() && !obj && !retry++)
-               goto repeat;
-
       return obj;
 }
 

lib/debugobjects.c __debug_object_init(void *addr, struct debug_obj_descr *descr, int onstack)

Quoted 9 lines
lib/debugobjects.c +2 -1
@@ -261,6 +256,8 @@ __debug_object_init(void *addr, struct debug_obj_descr *descr, int onstack)
       struct debug_obj *obj;
       unsigned long flags;
 
+       fill_pool();
+
       db = get_bucket((unsigned long) addr);
 
       spin_lock_irqsave(&db->lock, flags);
--

Hm. I have to wonder where this patch came from.

This was my (faulty) patch: http://lkml.org/lkml/2008/6/14/193
and Daniel J Blueman followed up with this: http://lkml.org/lkml/2008/6/15/27

..but this one looks different from both. I am guessing the last bits were added (or removed?) by Thomas?

I am wondering if the final patch was tested with the reproducible test case (if so, by whom?) and whether should be credited to Daniel (or Thomas?) instead...

?

Vegard

Signature · 4 lines
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
	-- E. W. Dijkstra, EWD1036
#2 lore raw
Quoted 70 lines · Vegard Nossum
Quoted 54 lines · Ingo Molnar
lib/debugobjects.c +4 -9
index a76a5e1..85b18d7 100644
@@ -68,6 +68,7 @@ static int fill_pool(void)
 {
       gfp_t gfp = GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN;
       struct debug_obj *new;
+       unsigned long flags;
 
       if (likely(obj_pool_free >= ODEBUG_POOL_MIN_LEVEL))
               return obj_pool_free;
@@ -81,10 +82,10 @@ static int fill_pool(void)
               if (!new)
                       return obj_pool_free;
 
-               spin_lock(&pool_lock);
+               spin_lock_irqsave(&pool_lock, flags);
               hlist_add_head(&new->node, &obj_pool);
               obj_pool_free++;
-               spin_unlock(&pool_lock);
+               spin_unlock_irqrestore(&pool_lock, flags);
       }
       return obj_pool_free;
 }
@@ -110,16 +111,13 @@ static struct debug_obj *lookup_object(void *addr, struct debug_bucket *b)
 }
 
 /*
- * Allocate a new object. If the pool is empty and no refill possible,
- * switch off the debugger.
+ * Allocate a new object. If the pool is empty, switch off the debugger.
 */
 static struct debug_obj *
 alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr)
 {
       struct debug_obj *obj = NULL;
-       int retry = 0;
 
-repeat:
       spin_lock(&pool_lock);
       if (obj_pool.first) {
               obj         = hlist_entry(obj_pool.first, typeof(*obj), node);
@@ -141,9 +139,6 @@ repeat:
       }
       spin_unlock(&pool_lock);
 
-       if (fill_pool() && !obj && !retry++)
-               goto repeat;
-
       return obj;
 }
 

lib/debugobjects.c __debug_object_init(void *addr, struct debug_obj_descr *descr, int onstack)

Quoted 9 lines
lib/debugobjects.c +2 -1
@@ -261,6 +256,8 @@ __debug_object_init(void *addr, struct debug_obj_descr *descr, int onstack)
       struct debug_obj *obj;
       unsigned long flags;
 
+       fill_pool();
+
       db = get_bucket((unsigned long) addr);
 
       spin_lock_irqsave(&db->lock, flags);
--

Hm. I have to wonder where this patch came from.

This was my (faulty) patch: http://lkml.org/lkml/2008/6/14/193
and Daniel J Blueman followed up with this: http://lkml.org/lkml/2008/6/15/27

Quoted 6 lines

..but this one looks different from both. I am guessing the last bits were added (or removed?) by Thomas?

I am wondering if the final patch was tested with the reproducible test case (if so, by whom?) and whether should be credited to Daniel (or Thomas?) instead...

You can use "git log -1 -p --pretty=fuller 50db04dd9c" to see the exact details of the commit:

----------

| commit 50db04dd9c74178e68a981a7127c37252ffb3242
| Author:     Vegard Nossum <[email protected]>
| AuthorDate: Sun Jun 15 00:47:36 2008 +0200
| Commit:     Thomas Gleixner <[email protected]>
| CommitDate: Wed Jun 18 11:09:54 2008 +0200
|
| [...]
|
|   [ [email protected]: pool_lock needs to be taken irq safe in fill_pool ]
|
|   Reported-by: Daniel J Blueman <[email protected]>
|   Signed-off-by: Vegard Nossum <[email protected]>
|   Signed-off-by: Thomas Gleixner <[email protected]>

----------

As you can see it from the Commit line, it was committed by Thomas.

The "[ daniel.blueman: pool_lock ... ]" line shows that Thomas - instead of creating two commits - merged the two fixes into a single commit and credited Daniel for the irq-safe fix. This is the standard technique to squash small patches and to make fixes multi-authored.

The patch was tested with our standard tests so it's certainly good in practice - but i havent specifically tried your testcase (maybe Thomas has). Can you see any problem with the fix?

Ingo

#3 lore raw
Quoted 3 lines · Ingo Molnar

The patch was tested with our standard tests so it's certainly good in practice - but i havent specifically tried your testcase (maybe Thomas has). Can you see any problem with the fix?

Well, what I can see is that the patch that was committed has some missing changes. In Daniel's patch:

-repeat:
- spin_lock(&pool_lock);
+ spin_lock_irqsave(&pool_lock, flags);
if (obj_pool.first) {
obj = hlist_entry(obj_pool.first, typeof(*obj), node);

The patch that was committed:

-repeat:

        spin_lock(&pool_lock);
        if (obj_pool.first) {
                obj         = hlist_entry(obj_pool.first, typeof(*obj), node);

Was it not necessary to make the pool lock irq-safe in this place?

For reference:

Daniel's patch: http://lkml.org/lkml/2008/6/15/27
Actual commit: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=70c85057e0bde35eb56352a293ecb5d1641a0334;hp=e6100f23375c0c71ce595d04551fa6553b611918

Vegard

Signature · 4 lines
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
	-- E. W. Dijkstra, EWD1036
#4 lore raw
Quoted 21 lines · Vegard Nossum
Quoted 3 lines · Ingo Molnar

The patch was tested with our standard tests so it's certainly good in practice - but i havent specifically tried your testcase (maybe Thomas has). Can you see any problem with the fix?

Well, what I can see is that the patch that was committed has some missing changes. In Daniel's patch:

lib/debugobjects.c +1 -2
-repeat:
-	spin_lock(&pool_lock);
+	spin_lock_irqsave(&pool_lock, flags);
 	if (obj_pool.first) {
 		obj	    = hlist_entry(obj_pool.first, typeof(*obj), node);

The patch that was committed:

-repeat:

        spin_lock(&pool_lock);
        if (obj_pool.first) {
                obj         = hlist_entry(obj_pool.first, typeof(*obj), node);
Quoted 6 lines

Was it not necessary to make the pool lock irq-safe in this place?

For reference:

Daniel's patch: http://lkml.org/lkml/2008/6/15/27
Actual commit: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=70c85057e0bde35eb56352a293ecb5d1641a0334;hp=e6100f23375c0c71ce595d04551fa6553b611918

alloc_object() is called with interrupts disabled from __debug_object_init()

Thanks,
tglx

#5 lore raw
Quoted 22 lines · Thomas Gleixner
Quoted 21 lines · Vegard Nossum
Quoted 3 lines · Ingo Molnar

The patch was tested with our standard tests so it's certainly good in practice - but i havent specifically tried your testcase (maybe Thomas has). Can you see any problem with the fix?

Well, what I can see is that the patch that was committed has some missing changes. In Daniel's patch:

lib/debugobjects.c +1 -2
-repeat:
-     spin_lock(&pool_lock);
+     spin_lock_irqsave(&pool_lock, flags);
      if (obj_pool.first) {
              obj         = hlist_entry(obj_pool.first, typeof(*obj), node);

The patch that was committed:

-repeat:

        spin_lock(&pool_lock);
        if (obj_pool.first) {
                obj         = hlist_entry(obj_pool.first, typeof(*obj), node);
Quoted 8 lines
Quoted 6 lines

Was it not necessary to make the pool lock irq-safe in this place?

For reference:

Daniel's patch: http://lkml.org/lkml/2008/6/15/27
Actual commit: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=70c85057e0bde35eb56352a293ecb5d1641a0334;hp=e6100f23375c0c71ce595d04551fa6553b611918

alloc_object() is called with interrupts disabled from __debug_object_init()

Ok, thanks for clearing that up! :-)

(I'm just wary of patches that mutate when they have my name on the top...)

Vegard

Signature · 4 lines
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
	-- E. W. Dijkstra, EWD1036
#6 lore raw
Quoted 6 lines · Vegard Nossum
Quoted 2 lines

alloc_object() is called with interrupts disabled from __debug_object_init()

Ok, thanks for clearing that up! :-)

(I'm just wary of patches that mutate when they have my name on the top...)

Yeah, that's why I added:

[ [email protected]: pool_lock needs to be taken irq safe in fill_pool ]

Thanks,
tglx