* Re: [PATCH] idr: Print a stack dump after ida_remove warning
2013-05-07 23:34 ` Andrew Morton
@ 2013-05-08 14:54 ` Takashi Iwai
2013-05-13 9:30 ` Jean Delvare
1 sibling, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2013-05-08 14:54 UTC (permalink / raw)
To: Andrew Morton; +Cc: Jean Delvare, linux-kernel, Tejun Heo
At Tue, 7 May 2013 16:34:22 -0700,
Andrew Morton wrote:
>
> On Sun, 05 May 2013 11:32:03 +0200 Jean Delvare <jdelvare@suse.de> wrote:
>
> > 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.
> >
> > ...
> >
> > --- linux-3.10-rc0.orig/lib/idr.c 2013-05-05 10:17:03.086198024 +0200
> > +++ linux-3.10-rc0/lib/idr.c 2013-05-05 10:41:11.939134735 +0200
> > @@ -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?
Nice, it reduces even 4 more lines! :)
Takashi
>
>
> From: Andrew Morton <akpm@linux-foundation.org>
> Subject: idr-print-a-stack-dump-after-ida_remove-warning-fix
>
> convert the open-coded printk+dump_stack into WARN()
>
> Cc: Jean Delvare <jdelvare@suse.de>
> Cc: Takashi Iwai <tiwai@suse.de>
> Cc: Tejun Heo <tj@kernel.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
>
> 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-fix lib/idr.c
> --- a/lib/idr.c~idr-print-a-stack-dump-after-ida_remove-warning-fix
> +++ a/lib/idr.c
> @@ -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);
>
> _
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] idr: Print a stack dump after ida_remove warning
2013-05-07 23:34 ` Andrew Morton
2013-05-08 14:54 ` Takashi Iwai
@ 2013-05-13 9:30 ` Jean Delvare
1 sibling, 0 replies; 4+ messages in thread
From: Jean Delvare @ 2013-05-13 9:30 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, Tejun Heo, Takashi Iwai
Hi Andrew,
Le Tuesday 07 May 2013 à 16:34 -0700, Andrew Morton a écrit :
> On Sun, 05 May 2013 11:32:03 +0200 Jean Delvare <jdelvare@suse.de> wrote:
>
> > 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.
> >
> > ...
> >
> > --- linux-3.10-rc0.orig/lib/idr.c 2013-05-05 10:17:03.086198024 +0200
> > +++ linux-3.10-rc0/lib/idr.c 2013-05-05 10:41:11.939134735 +0200
> > @@ -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 <akpm@linux-foundation.org>
> Subject: idr-print-a-stack-dump-after-ida_remove-warning-fix
>
> convert the open-coded printk+dump_stack into WARN()
>
> Cc: Jean Delvare <jdelvare@suse.de>
> Cc: Takashi Iwai <tiwai@suse.de>
> Cc: Tejun Heo <tj@kernel.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
>
> 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-fix lib/idr.c
> --- a/lib/idr.c~idr-print-a-stack-dump-after-ida_remove-warning-fix
> +++ a/lib/idr.c
> @@ -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);
>
Acked-by: Jean Delvare <jdelvare@suse.de>
--
Jean Delvare
Suse L3
^ permalink raw reply [flat|nested] 4+ messages in thread