idr: Print a stack dump after ida_remove warning
Subsystems (2)
PATCH 1/1 idr: Print a stack dump after ida_remove warning
We print a dump stack after idr_remove warning. This is useful to find the faulty piece of code. Let's do the same for ida_remove, as it would be equally useful there.
--- lib/idr.c | 1 + 1 file changed, 1 insertion(+)
lib/idr.c +1 -0
@@ -1066,6 +1066,7 @@ void ida_remove(struct ida *ida, int id) err:printk (KERN_WARNING "ida_remove called for id=%d which is not allocated.\n" , id); +dump_stack (); }EXPORT_SYMBOL (ida_remove);
Signature · 2 lines
Jean Delvare Suse L3
Andrew Morton
maintainerQuoted 9 lines · On Sun, 05 May 2013 11:32:03 +0200 Jean Delvare <[email protected]> wrote:
We print a dump stack after
idr_removewarning. This is useful to find the faulty piece of code. Let's do the same forida_remove, as it would be equally useful there....
lib/idr.c void ida_remove(struct ida *ida, int id) · line 1071
Quoted 6 lines
lib/idr.c +1
-0@@ -1066,6 +1066,7 @@ void ida_remove(struct ida *ida, int id) err:printk (KERN_WARNING "ida_remove called for id=%d which is not allocated.\n" , id); +dump_stack (); }EXPORT_SYMBOL (ida_remove);
If we're going to do this, we should make that printk a KERN_EMERG or something, otherwise users might see a stack dump with no explanation why it occurred.
We can do all that with plain old WARN(). How does this look?
From: Andrew Morton <[email protected]>
Subject: idr-print-a-stack-dump-after-ida_remove-warning-fix
convert the open-coded printk+dump_stack into WARN()
---
lib/idr.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
lib/idr.c renamed from lib/idr.c~idr-print-a-stack-dump-after-ida_remove-warning-fix +2 -6
@@ -524,9 +524,7 @@ EXPORT_SYMBOL(idr_alloc_cyclic);static void idr_remove_warning (int id) { -printk (KERN_WARNING -"idr_remove called for id=%d which is not allocated.\n" , id); -dump_stack (); +WARN (1 ,"idr_remove called for id=%d which is not allocated.\n" , id); }static void sub_remove (struct idr *idp,int shift,int id)
@@ -1064,9 +1062,7 @@ void ida_remove(struct ida *ida, int id)return ; err: -printk (KERN_WARNING -"ida_remove called for id=%d which is not allocated.\n" , id); -dump_stack (); +WARN (1 ,"ida_remove called for id=%d which is not allocated.\n" , id); }EXPORT_SYMBOL (ida_remove);
_
At Tue, 7 May 2013 16:34:22 -0700,
Quoted 23 lines · Andrew Morton
Quoted 9 lines · On Sun, 05 May 2013 11:32:03 +0200 Jean Delvare <[email protected]> wrote:
We print a dump stack after
idr_removewarning. This is useful to find the faulty piece of code. Let's do the same forida_remove, as it would be equally useful there....
lib/idr.c void ida_remove(struct ida *ida, int id) · line 1071
Quoted 6 lines
lib/idr.c +1
-0@@ -1066,6 +1066,7 @@ void ida_remove(struct ida *ida, int id) err:printk (KERN_WARNING "ida_remove called for id=%d which is not allocated.\n" , id); +dump_stack (); }EXPORT_SYMBOL (ida_remove);If we're going to do this, we should make that printk a
KERN_EMERGor something, otherwise users might see a stack dump with no explanation why it occurred.
Quoted 1 line
We can do all that with plain old
WARN(). How does this look?
Nice, it reduces even 4 more lines! :)
Takashi
Quoted 43 lines
From: Andrew Morton <[email protected]>
Subject: idr-print-a-stack-dump-after-ida_remove-warning-fixconvert the open-coded printk+dump_stack into
WARN()Cc Jean Delvare <[email protected]>Cc Takashi Iwai <[email protected]>Cc Tejun Heo <[email protected]>Signed-off-by Andrew Morton <[email protected]>---
lib/idr.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)diff -puN
lib/idr.c~idr-print-a-stack-dump-after-ida_remove-warning-fixlib/idr.clib/idr.c renamed from lib/idr.c~idr-print-a-stack-dump-after-ida_remove-warning-fix +2
-6@@ -524,9 +524,7 @@ EXPORT_SYMBOL(idr_alloc_cyclic);static void idr_remove_warning (int id) { -printk (KERN_WARNING -"idr_remove called for id=%d which is not allocated.\n" , id); -dump_stack (); +WARN (1 ,"idr_remove called for id=%d which is not allocated.\n" , id); }static void sub_remove (struct idr *idp,int shift,int id)@@ -1064,9 +1062,7 @@ void ida_remove(struct ida *ida, int id)return ; err: -printk (KERN_WARNING -"ida_remove called for id=%d which is not allocated.\n" , id); -dump_stack (); +WARN (1 ,"ida_remove called for id=%d which is not allocated.\n" , id); }EXPORT_SYMBOL (ida_remove);_
Jean Delvare
Acked-byHi Andrew,
Quoted 54 lines · Andrew Morton
Quoted 9 lines · On Sun, 05 May 2013 11:32:03 +0200 Jean Delvare <[email protected]> wrote:
We print a dump stack after
idr_removewarning. This is useful to find the faulty piece of code. Let's do the same forida_remove, as it would be equally useful there....
lib/idr.c void ida_remove(struct ida *ida, int id) · line 1071
Quoted 6 lines
lib/idr.c +1
-0@@ -1066,6 +1066,7 @@ void ida_remove(struct ida *ida, int id) err:printk (KERN_WARNING "ida_remove called for id=%d which is not allocated.\n" , id); +dump_stack (); }EXPORT_SYMBOL (ida_remove);If we're going to do this, we should make that printk a
KERN_EMERGor something, otherwise users might see a stack dump with no explanation why it occurred.We can do all that with plain old
WARN(). How does this look?From: Andrew Morton <[email protected]>
Subject: idr-print-a-stack-dump-after-ida_remove-warning-fixconvert the open-coded printk+dump_stack into
WARN()Cc Jean Delvare <[email protected]>Cc Takashi Iwai <[email protected]>Cc Tejun Heo <[email protected]>Signed-off-by Andrew Morton <[email protected]>---
lib/idr.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)diff -puN
lib/idr.c~idr-print-a-stack-dump-after-ida_remove-warning-fixlib/idr.clib/idr.c renamed from lib/idr.c~idr-print-a-stack-dump-after-ida_remove-warning-fix +1
-3@@ -524,9 +524,7 @@ EXPORT_SYMBOL(idr_alloc_cyclic);static void idr_remove_warning (int id) { -printk (KERN_WARNING -"idr_remove called for id=%d which is not allocated.\n" , id); -dump_stack (); +WARN (1 ,"idr_remove called for id=%d which is not allocated.\n" , id); }static void sub_remove (struct idr *idp,int shift,int id)
lib/idr.c void ida_remove(struct ida *ida, int id) · line 1068
Quoted 10 lines
lib/idr.c renamed from lib/idr.c~idr-print-a-stack-dump-after-ida_remove-warning-fix +1
-3@@ -1064,9 +1062,7 @@ void ida_remove(struct ida *ida, int id)return ; err: -printk (KERN_WARNING -"ida_remove called for id=%d which is not allocated.\n" , id); -dump_stack (); +WARN (1 ,"ida_remove called for id=%d which is not allocated.\n" , id); }EXPORT_SYMBOL (ida_remove);
Signature · 2 lines
Jean Delvare Suse L3