All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@elte.hu>
Subject: Re: [patch 0/5] object debugging infrastructure V2
Date: Wed, 5 Mar 2008 17:48:11 -0800	[thread overview]
Message-ID: <20080306014810.GA4927@kroah.com> (raw)
In-Reply-To: <20080305154829.185609547@linutronix.de>

On Wed, Mar 05, 2008 at 04:03:33PM -0000, Thomas Gleixner wrote:
> This is version 2 of the object debugging infrastructure. Changes
> versus V1:
> 
> - review comments processed:
>   - multiplexing interfaces replaced
>   - object type is determined by a caller provided pointer to 
>     a debug structure which replaces the object type identifier
>     -> No changes to the core code for new users
>   - new debug state "destroyed" (kobject wishlist)
>   - various cleanups
> 
> - complete detachment of the tracker object from the real object
>   (no change to the real objects data structure necessary anymore)
> 
> - improved robustness (object memory management, oom cleanup)
> 
> - full set of self tests
> 
> - debugfs statistics 
> 
> - docbook documentation

Here's a patch adding kobjects to this infrastructure (I didn't use a
new CONFIG option, which it probably should be.)

Does this look correct?  I can't tell if this is going to catch
anything, as my trees all seem to have these kinds of bugs worked out
now, as we are already catching a number of these types of things
already with kobjects.

Should I be doing more checks?  Different things based on the state of
the object?

thanks,

greg k-h

-------------------

From: Greg Kroah-Hartman <gregkh@suse.de>
Subject: kobjects: hook them up to the debugobjects infrastructure

I think this is right, but it's hard to tell...

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 lib/kobject.c |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -18,8 +18,59 @@
 #include <linux/stat.h>
 #include <linux/slab.h>
 #include <linux/kallsyms.h>
+#include <linux/debugobjects.h>
 #include <asm-generic/sections.h>
 
+#ifdef CONFIG_DEBUG_OBJECTS
+static int kobject_fixup_init(void *addr, enum debug_obj_state state)
+{
+	struct kobject *kobj = addr;
+
+	switch (state) {
+	case ODEBUG_STATE_ACTIVE:
+		printk("kobject: '%s' (%p): is being initialized after "
+			"it was already active\n", kobject_name(kobj), kobj);
+		return 1;
+	default:
+		return 0;
+	}
+}
+
+static int kobject_fixup_destroy(void *addr, enum debug_obj_state state)
+{
+	struct kobject *kobj = addr;
+
+	switch (state) {
+	case ODEBUG_STATE_ACTIVE:
+		printk("kobject: '%s' (%p): is being destroyed yet it is "
+			"still active\n", kobject_name(kobj), kobj);
+		return 1;
+	default:
+		return 0;
+	}
+}
+
+static struct debug_obj_descr kobject_debug_descr = {
+	.name = "kobjects",
+	.fixup_init = kobject_fixup_init,
+	.fixup_destroy = kobject_fixup_destroy,
+};
+
+static void debug_kobject_init(struct kobject *kobj)
+{
+	debug_object_init(kobj, &kobject_debug_descr);
+}
+
+static void debug_kobject_destroy(struct kobject *kobj)
+{
+	debug_object_destroy(kobj, &kobject_debug_descr);
+}
+
+#else
+static inline void debug_kobject_init(struct kobject *kobj) { }
+static inline void debug_kobject_destroy(struct kobject *kobj) { }
+#endif
+
 #ifdef CONFIG_X86_32
 static int ptr_in_range(void *ptr, void *start, void *end)
 {
@@ -202,6 +253,7 @@ static void kobject_init_internal(struct
 {
 	if (!kobj)
 		return;
+	debug_kobject_init(kobj);
 	kref_init(&kobj->kref);
 	INIT_LIST_HEAD(&kobj->entry);
 	kobj->state_in_sysfs = 0;
@@ -599,6 +651,7 @@ static void kobject_cleanup(struct kobje
 	pr_debug("kobject: '%s' (%p): %s\n",
 		 kobject_name(kobj), kobj, __FUNCTION__);
 
+	debug_kobject_destroy(kobj);
 	if (t && !t->release)
 		pr_debug("kobject: '%s' (%p): does not have a release() "
 			 "function, it is broken and must be fixed.\n",

  parent reply	other threads:[~2008-03-06  1:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-05 16:03 [patch 0/5] object debugging infrastructure V2 Thomas Gleixner
2008-03-05 16:03 ` [patch 1/5] vmalloc: do not check for freed locks on user maps Thomas Gleixner
2008-03-05 16:28   ` Nick Piggin
2008-03-05 17:20     ` Thomas Gleixner
2008-03-05 22:56       ` Nick Piggin
2008-03-05 23:31         ` Thomas Gleixner
2008-03-06  2:34           ` Nick Piggin
2008-03-05 16:03 ` [patch 2/5] slab: add a flag to prevent debug_free checks on a kmem_cache Thomas Gleixner
2008-03-05 16:03 ` [patch 3/5] infrastructure to debug (dynamic) objects Thomas Gleixner
2008-03-05 16:04 ` [patch 4/5] debugobjects: add documentation Thomas Gleixner
2008-03-10 20:13   ` Randy Dunlap
2008-03-21 14:25     ` Thomas Gleixner
2008-03-05 16:04 ` [patch 5/5] debugobjects: add timer specific object debugging code Thomas Gleixner
2008-03-05 20:14   ` Thomas Gleixner
2008-03-05 18:53 ` [patch 0/5] object debugging infrastructure V2 Greg KH
2008-03-06  1:48 ` Greg KH [this message]
2008-03-06  7:54   ` Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080306014810.GA4927@kroah.com \
    --to=greg@kroah.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.