All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@quicinc.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] vsprintf: Fix %ps on non symbols when using kallsyms
Date: Wed, 25 Jul 2012 18:38:00 -0700	[thread overview]
Message-ID: <50109F78.4040409@quicinc.com> (raw)
In-Reply-To: <20120423145545.e7c41906.akpm@linux-foundation.org>

Hi Andrew,

On 4/23/2012 2:55 PM, Andrew Morton wrote:
> On Mon, 23 Apr 2012 14:45:24 -0700
> Stephen Boyd <sboyd@codeaurora.org> wrote:
>
>> Using %ps in a printk format will sometimes fail silently and
>> print the empty string if the address passed in does not match a
>> symbol that kallsyms knows about.

A coworker pointed out that the second patch in this series now prints
the symbol closest to the address passed in if kallsyms sees the address
is between two symbols. So if I have a pointer to some member of a
structure %ps prints the symbol for the containing structure, which is
not really helpful.

For example

struct test {
  int i;
  int j;
} my_test;

printk("%ps\n", &my_test.j)


would print out "my_test" instead of "0xc4523400".

This is especially bad for the spinlock debugging case where there could
be two locks embedded in some static structure. I think it would be a
good idea to apply this patch so we get a good middle ground by printing
the name and the offset. Or we can revert the patch and I'll add more
info by printing lockdep information about the lock.

-----8<------

From: Stephen Boyd <sboyd@codeaurora.org>
Subject: [PATCH] spinlock_debug: Print offset in addition to symbol name

If there are two spinlocks embedded in a structure that kallsyms
knows about and one of the spinlocks locks up we will print the
name of the containing structure instead of the address of the
lock. This is quite bad, so let's use %pS instead of %ps so we
get an offset in addition to the symbol so we can determine which
particular lock is having problems.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
 lib/spinlock_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/spinlock_debug.c b/lib/spinlock_debug.c
index e91fbc2..eb10578 100644
--- a/lib/spinlock_debug.c
+++ b/lib/spinlock_debug.c
@@ -58,7 +58,7 @@ static void spin_dump(raw_spinlock_t *lock, const char *msg)
 	printk(KERN_EMERG "BUG: spinlock %s on CPU#%d, %s/%d\n",
 		msg, raw_smp_processor_id(),
 		current->comm, task_pid_nr(current));
-	printk(KERN_EMERG " lock: %ps, .magic: %08x, .owner: %s/%d, "
+	printk(KERN_EMERG " lock: %pS, .magic: %08x, .owner: %s/%d, "
 			".owner_cpu: %d\n",
 		lock, lock->magic,
 		owner ? owner->comm : "<none>",

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.


      reply	other threads:[~2012-07-26  1:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-23 21:45 [PATCH 1/2] vsprintf: Fix %ps on non symbols when using kallsyms Stephen Boyd
2012-04-23 21:45 ` [PATCH 2/2] spinlock_debug: Print kallsyms name for lock Stephen Boyd
2012-04-23 21:54   ` Andrew Morton
2012-04-24  3:17     ` Stephen Boyd
2012-04-24 21:54       ` Andrew Morton
2012-05-10 18:53         ` Stephen Boyd
2012-04-23 21:55 ` [PATCH 1/2] vsprintf: Fix %ps on non symbols when using kallsyms Andrew Morton
2012-07-26  1:38   ` Stephen Boyd [this message]

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=50109F78.4040409@quicinc.com \
    --to=sboyd@quicinc.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /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.