Re: [patch 2/4] kref debugging config option

From: Greg KH
Date: Mon Apr 24 2006 - 23:53:23 EST


On Mon, Apr 24, 2006 at 04:33:35PM +0800, Akinobu Mita wrote:
> This patch converts all WARN_ON() in kref code to BUG_ON().
> And split them into new DEBUG_KREF config option.
>
> Signed-off-by: Akinobu Mita <mita@xxxxxxxxxxxxxxxx>
>
> lib/Kconfig.debug | 7 +++++++
> lib/kref.c | 30 +++++++++++++++++++++++++-----
> 2 files changed, 32 insertions(+), 5 deletions(-)
>
> Index: 2.6-git/lib/Kconfig.debug
> ===================================================================
> --- 2.6-git.orig/lib/Kconfig.debug
> +++ 2.6-git/lib/Kconfig.debug
> @@ -130,6 +130,13 @@ config DEBUG_KOBJECT
> If you say Y here, some extra kobject debugging messages will be sent
> to the syslog.
>
> +config DEBUG_KREF
> + bool "kref debugging"
> + depends on DEBUG_KERNEL
> + help
> + This option enables addition error checking for kref,
> + library routines for handling generic reference counted objects.
> +
> config DEBUG_HIGHMEM
> bool "Highmem debugging"
> depends on DEBUG_KERNEL && HIGHMEM
> Index: 2.6-git/lib/kref.c
> ===================================================================
> --- 2.6-git.orig/lib/kref.c
> +++ 2.6-git/lib/kref.c
> @@ -20,16 +20,38 @@
> */
> void kref_init(struct kref *kref)
> {
> - atomic_set(&kref->refcount,1);
> + atomic_set(&kref->refcount, 1);
> }
>
> +#ifdef CONFIG_DEBUG_KREF
> +static void kref_get_debug_check(struct kref *kref)
> +{
> + BUG_ON(!atomic_read(&kref->refcount));
> +}

Eeek, no, you do not want to do this. Unless you never want to get a
bug report with this enabled :)

thanks,

greg k-h
-
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/