linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Boqun Feng <boqun.feng@gmail.com>
To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Cc: Boqun Feng <boqun.feng@gmail.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Andrew Donnellan <andrew.donnellan@au1.ibm.com>,
	Christophe Leroy <christophe.leroy@c-s.fr>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
	Rashmica Gupta <rashmicy@gmail.com>,
	Douglas Miller <dougmill@linux.vnet.ibm.com>
Subject: [RFC] powerpc: xmon: Add address lookup for percpu symbols
Date: Thu, 17 Nov 2016 17:40:35 +0800	[thread overview]
Message-ID: <20161117094051.21606-1-boqun.feng@gmail.com> (raw)

Currently, in xmon, there is no obvious way to get an address for a
percpu symbol for a particular cpu. Having such an ability would be good
for debugging the system when percpu variables got involved.

Therefore, this patch introduces a new xmon command "lp" to lookup the
address for percpu symbols. Usage of "lp" is similar to "ls", except
that we could add a cpu number to choose the variable of which cpu we
want to lookup. If no cpu number is given, lookup for current cpu.

Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
 arch/powerpc/xmon/xmon.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 760545519a0b..3556966a29a5 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -229,6 +229,7 @@ Commands:\n\
   f	flush cache\n\
   la	lookup symbol+offset of specified address\n\
   ls	lookup address of specified symbol\n\
+  lp s [#]	lookup address of percpu symbol s for current cpu, or cpu #\n\
   m	examine/change memory\n\
   mm	move a block of memory\n\
   ms	set a block of memory\n\
@@ -2943,7 +2944,7 @@ static void
 symbol_lookup(void)
 {
 	int type = inchar();
-	unsigned long addr;
+	unsigned long addr, cpu, offset;
 	static char tmp[64];
 
 	switch (type) {
@@ -2967,6 +2968,31 @@ symbol_lookup(void)
 		catch_memory_errors = 0;
 		termch = 0;
 		break;
+	case 'p':
+		getstring(tmp, 64);
+		if (setjmp(bus_error_jmp) == 0) {
+			catch_memory_errors = 1;
+			sync();
+			addr = kallsyms_lookup_name(tmp);
+			sync();
+		}
+
+		if (scanhex(&cpu) && cpu < num_possible_cpus())
+			offset = per_cpu_offset(cpu);
+		else {
+			offset = my_cpu_offset;
+			cpu = raw_smp_processor_id();
+		}
+
+		if (addr)
+			printf("%s for cpu 0x%lx: %lx\n", tmp, cpu,
+							  addr + offset);
+		else
+			printf("Percpu symbol '%s' not found.\n", tmp);
+
+		catch_memory_errors = 0;
+		termch = 0;
+		break;
 	}
 }
 
-- 
2.10.1

             reply	other threads:[~2016-11-17  9:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-17  9:40 Boqun Feng [this message]
2016-11-22  9:20 ` [RFC v2] powerpc: xmon: Add address lookup for percpu symbols Boqun Feng
2018-08-13 11:22   ` [RFC,v2] " Michael Ellerman

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=20161117094051.21606-1-boqun.feng@gmail.com \
    --to=boqun.feng@gmail.com \
    --cc=andrew.donnellan@au1.ibm.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=benh@kernel.crashing.org \
    --cc=christophe.leroy@c-s.fr \
    --cc=dougmill@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    --cc=rashmicy@gmail.com \
    /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).