patches.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <swboyd@chromium.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev,
	Guenter Roeck <groeck@chromium.org>
Subject: [PATCH] debugobjects: Print object pointer in debug_print_object()
Date: Thu, 19 May 2022 13:22:01 -0700	[thread overview]
Message-ID: <20220519202201.2348343-1-swboyd@chromium.org> (raw)

Delayed kobject debugging (CONFIG_DEBUG_KOBJECT_RELEASE) prints the
kobject pointer that's being released in kobject_release() before
scheduling a randomly delayed work to do the actual release work. If the
caller of kobject_put() frees the kobject upon return then we'll
typically see a debugobject warning about freeing an active timer.
Usually the release function is the function that does the kfree() of
the struct containing the kobject.

For example the following print is seen

 kobject: 'queue' (ffff888114236190): kobject_release, parent 0000000000000000 (delayed 1000)
 ------------[ cut here ]------------
 ODEBUG: free active (active state 0) object type: timer_list hint: kobject_delayed_cleanup+0x0/0x390

but we can't match up the kobject printk with the debug object printk
because it could be any number of kobjects that was released around that
time. The random delay for the work doesn't help either.

Print the address of the object being tracked to help us figure out
which kobject is the problem here. Note that we don't use %px here to
match the other %p usage in debugobject debugging. Due to %p usage we'll
have to disable pointer hashing to correlate the two pointer printks.

Cc: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---
 lib/debugobjects.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index 6946f8e204e3..a1c987e967e0 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -503,9 +503,9 @@ static void debug_print_object(struct debug_obj *obj, char *msg)
 			descr->debug_hint(obj->object) : NULL;
 		limit++;
 		WARN(1, KERN_ERR "ODEBUG: %s %s (active state %u) "
-				 "object type: %s hint: %pS\n",
+				 "object: %p object type: %s hint: %pS\n",
 			msg, obj_states[obj->state], obj->astate,
-			descr->name, hint);
+			obj->object, descr->name, hint);
 	}
 	debug_objects_warnings++;
 }

base-commit: ffb217a13a2eaf6d5bd974fc83036a53ca69f1e2
-- 
https://chromeos.dev


             reply	other threads:[~2022-05-19 20:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-19 20:22 Stephen Boyd [this message]
2022-10-04 22:58 ` [PATCH] debugobjects: Print object pointer in debug_print_object() Guenter Roeck
2022-10-05 13:29   ` 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=20220519202201.2348343-1-swboyd@chromium.org \
    --to=swboyd@chromium.org \
    --cc=groeck@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@lists.linux.dev \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).