From: Douglas Miller <dougmill@linux.vnet.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Subject: [xmon PATCH 1/1] RFC: Add xmon command to dump process/task similar to ps(1)
Date: Tue, 10 Nov 2015 09:31:14 -0600 [thread overview]
Message-ID: <56420DC2.3070500@linux.vnet.ibm.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 615 bytes --]
RFC: Not sure if I need locking when accessing task structs from xmon.
Please comment.
I found this new xmon command indispensable while debugging a KDUMP
problem. It dumps some task information similar to the ps(1) command,
plus includes the kernel stack pointer for use with "t" traceback
command. In the case of KDUMP on PKVM, it was running single-CPU so
locking issues would likely not have shown up. Certainly if xmon runs in
an environment where some CPUs are still running tasks, this information
can be very fleeting.
Let me know what else needs to be done to make this patch ready.
Thanks,
Doug
[-- Attachment #2: 0001-Add-xmon-command-to-dump-process-task-similar-to-ps-.patch --]
[-- Type: text/x-patch, Size: 2093 bytes --]
>From 5f2dd7c955443332835de86cfde2097e298fc657 Mon Sep 17 00:00:00 2001
From: Douglas Miller <dougmill@linux.vnet.ibm.com>
Date: Thu, 5 Nov 2015 07:55:33 -0600
Subject: [PATCH] Add xmon command to dump process/task similar to ps(1)
---
arch/powerpc/xmon/xmon.c | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 13c6e20..745ecf5 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -149,6 +149,7 @@ static int cpu_cmd(void);
static void csum(void);
static void bootcmds(void);
static void proccall(void);
+static void proclist(void);
void dump_segments(void);
static void symbol_lookup(void);
static void xmon_show_stack(unsigned long sp, unsigned long lr,
@@ -228,6 +229,7 @@ Commands:\n\
mz zero a block of memory\n\
mi show information about memory allocation\n\
p call a procedure\n\
+ P list processes/tasks\n\
r print registers\n\
s single step\n"
#ifdef CONFIG_SPU_BASE
@@ -947,6 +949,9 @@ cmds(struct pt_regs *excp)
case 'p':
proccall();
break;
+ case 'P':
+ proclist();
+ break;
#ifdef CONFIG_PPC_STD_MMU
case 'u':
dump_segments();
@@ -2450,6 +2455,38 @@ memzcan(void)
printf("%.8x\n", a - mskip);
}
+static void procshow(struct task_struct *tsk)
+{
+ char state;
+ state = (tsk->state == 0) ? 'R' :
+ (tsk->state < 0) ? 'U' :
+ (tsk->state & TASK_UNINTERRUPTIBLE) ? 'D' :
+ (tsk->state & TASK_STOPPED) ? 'T' :
+ (tsk->state & TASK_TRACED) ? 'C' :
+ (tsk->exit_state & EXIT_ZOMBIE) ? 'Z' :
+ (tsk->exit_state & EXIT_DEAD) ? 'E' :
+ (tsk->state & TASK_INTERRUPTIBLE) ? 'S' : '?';
+
+ printf("%p %016lx %6d %6d %c %2d %s\n", tsk,
+ tsk->thread.ksp,
+ tsk->pid, tsk->parent->pid,
+ state, task_thread_info(tsk)->cpu,
+ tsk->comm);
+}
+
+static void proclist(void)
+{
+ struct task_struct *tsk;
+
+ if (scanhex(&tsk)) {
+ procshow(tsk);
+ } else {
+ for_each_process(tsk) {
+ procshow(tsk);
+ }
+ }
+}
+
static void proccall(void)
{
unsigned long args[8];
--
1.7.1
next reply other threads:[~2015-11-10 15:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-10 15:31 Douglas Miller [this message]
2015-11-10 16:50 ` [xmon PATCH 1/1] RFC: Add xmon command to dump process/task similar to ps(1) Douglas Miller
2015-11-11 8:09 ` Benjamin Herrenschmidt
2015-11-13 15:58 ` Douglas Miller
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=56420DC2.3070500@linux.vnet.ibm.com \
--to=dougmill@linux.vnet.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.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 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).