Skip to contentSkip to conversation

powerpc/xmon: Paged output for paca display

PATCH Superseded Sam Bobroff 2 participants 5 messages Aug 21, 2015 – Oct 8, 2015 PowerPC

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover powerpc/xmon: Paged output for paca display

Changes v1 -> v2:

* Removed pagination parameters from commands, replaced with new command to set page size. This works better for multiple commands and produces simpler code.
* Switched from encoding the page position in the command buffer to using some globals. Saves some memory and is less invasive to the command code.
* Added a patch to paginate the kernel log buffer display.

Sam Bobroff (2):
powerpc/xmon: Paged output for paca display powerpc/xmon: Paginate kernel log buffer display

 arch/powerpc/xmon/xmon.c | 89 +++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 73 insertions(+), 16 deletions(-)
Signature · 1 line
2.1.4
#1 lore raw

PATCH v2 1/2 powerpc/xmon: Paged output for paca display

The paca display is already more than 24 lines, which can be problematic if you have an old school 80x24 terminal, or more likely you are on a virtual terminal which does not scroll for whatever reason.

This patch adds a new command ".", which takes a single (hex) numeric
argument: lines per page. It will cause the output of "dp" and "dpa" to be broken into pages, if necessary.

This is implemented by running over the entire output both for the initial command and for each subsequent page: the visible part is clipped out by checking line numbers. This is a simplistic approach but minimally invasive; it is intended to be easily reusable for other commands.

Sample output:

0:mon> .10
0:mon> dp1
paca for cpu 0x1 @ c00000000fdc0480:

 possible         = yes
 present          = yes
 online           = yes
 lock_token       = 0x8000            	(0x8)
 paca_index       = 0x1               	(0xa)
 kernel_toc       = 0xc000000000eb2400	(0x10)
 kernelbase       = 0xc000000000000000	(0x18)
 kernel_msr       = 0xb000000000001032	(0x20)
 emergency_sp     = 0xc00000003ffe8000	(0x28)
 mc_emergency_sp  = 0xc00000003ffe4000	(0x2e0)
 in_mce           = 0x0               	(0x2e8)
 data_offset      = 0x7f170000        	(0x30)
 hw_cpu_id        = 0x8               	(0x38)
 cpu_start        = 0x1               	(0x3a)
 kexec_state      = 0x0               	(0x3b)
[Enter for next page]
0:mon>
 __current        = 0xc00000007e696620	(0x290)
 kstack           = 0xc00000007e6ebe30	(0x298)
 stab_rr          = 0xb               	(0x2a0)
 saved_r1         = 0xc00000007ef37860	(0x2a8)
 trap_save        = 0x0               	(0x2b8)
 soft_enabled     = 0x0               	(0x2ba)
 irq_happened     = 0x1               	(0x2bb)
 io_sync          = 0x0               	(0x2bc)

irq_work_pending = 0x0 (0x2bd)
nap_state_lost = 0x0 (0x2be)
0:mon>

(Based on a similar patch by Michael Ellerman <[email protected]> "[v2] powerpc/xmon: Allow limiting the size of the paca display". This patch is an alternative and cannot coexist with the original.)

---
 arch/powerpc/xmon/xmon.c | 86 +++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 71 insertions(+), 15 deletions(-)
arch/powerpc/xmon/xmon.c +71 -15
index e599259..9ce9e7d 100644
@@ -72,6 +72,12 @@ static int xmon_gate;
 
 static unsigned long in_xmon __read_mostly = 0;
 
+#define XMON_PRINTF(...) do { if (paged_vis()) printf(__VA_ARGS__); } while (0)
+#define MAX_PAGED_SIZE 1024
+static unsigned long paged_size = 0, paged_pos, paged_cur_page;
+#ifdef CONFIG_PPC64
+static unsigned long paca_cpu;
+#endif
 static unsigned long adrs;
 static int size = 1;
 #define MAX_DUMP (128 * 1024)
@@ -242,6 +248,9 @@ Commands:\n\
 "  u	dump TLB\n"
 #endif
 "  ?	help\n"
+#ifdef CONFIG_PPC64
+"  .#	limit output to # lines per page (dump paca only)\n"
+#endif
 "  zr	reboot\n\
   zh	halt\n"
 ;
@@ -833,6 +842,19 @@ static void remove_cpu_bpts(void)
 	write_ciabr(0);
 }
 
+static void paged_set_size(void)
+{
+	if (!scanhex(&paged_size) || (paged_size > MAX_PAGED_SIZE)) {
+		printf("Invalid number of lines per page (max: %d).\n",
+		       MAX_PAGED_SIZE);
+		paged_size = 0;
+	}
+}
+static void paged_reset(void)
+{
+	paged_cur_page = 0;
+}
+
 /* Command interpreting routine */
 static char *last_cmd;
 
@@ -863,7 +885,8 @@ cmds(struct pt_regs *excp)
 			take_input(last_cmd);
 			last_cmd = NULL;
 			cmd = inchar();
-		}
+		} else
+			paged_reset();
 		switch (cmd) {
 		case 'm':
 			cmd = inchar();
@@ -924,6 +947,9 @@ cmds(struct pt_regs *excp)
 		case '?':
 			xmon_puts(help_string);
 			break;
+		case '.':
+			paged_set_size();
+			break;
 		case 'b':
 			bpt_cmds();
 			break;
@@ -2069,6 +2095,31 @@ static void xmon_rawdump (unsigned long adrs, long ndump)
 	printf("\n");
 }
 
+static void paged_start(void)
+{
+	paged_pos = 0;
+}
+
+static void paged_end(char *next_cmd)
+{
+	unsigned long next_page_start = ++paged_cur_page * paged_size;
+
+	if (paged_size && (paged_pos > next_page_start)) {
+		last_cmd = next_cmd;
+		printf("[Enter for next page]\n");
+	}
+}
+
+static bool paged_vis(void)
+{
+	bool rv = (!paged_size
+	|| ((paged_pos >= (paged_size * paged_cur_page))
+	&& (paged_pos < (paged_size * (paged_cur_page + 1)))));
+
+	paged_pos++;
+	return rv;
+}
+
 #ifdef CONFIG_PPC64
 static void dump_one_paca(int cpu)
 {
@@ -2084,15 +2135,17 @@ static void dump_one_paca(int cpu)
 
 	p = &paca[cpu];
 
-	printf("paca for cpu 0x%x @ %p:\n", cpu, p);
+	XMON_PRINTF("paca for cpu 0x%x @ %p:\n", cpu, p);
 
-	printf(" %-*s = %s\n", 16, "possible", cpu_possible(cpu) ? "yes" : "no");
-	printf(" %-*s = %s\n", 16, "present", cpu_present(cpu) ? "yes" : "no");
-	printf(" %-*s = %s\n", 16, "online", cpu_online(cpu) ? "yes" : "no");
+	XMON_PRINTF(" %-*s = %s\n", 16, "possible", cpu_possible(cpu) ? "yes" : "no");
+	XMON_PRINTF(" %-*s = %s\n", 16, "present", cpu_present(cpu) ? "yes" : "no");
+	XMON_PRINTF(" %-*s = %s\n", 16, "online", cpu_online(cpu) ? "yes" : "no");
 
-#define DUMP(paca, name, format) \
-	printf(" %-*s = %#-*"format"\t(0x%lx)\n", 16, #name, 18, paca->name, \
-		offsetof(struct paca_struct, name));
+#define DUMP(paca, name, format) do { \
+		if (paged_vis()) \
+			printf(" %-*s = %#-*"format"\t(0x%lx)\n", 16, #name, 18, \
+			       paca->name, offsetof(struct paca_struct, name)); \
+} while (0)
 
 	DUMP(p, lock_token, "x");
 	DUMP(p, paca_index, "x");
@@ -2134,13 +2187,14 @@ static void dump_all_pacas(void)
 		return;
 	}
 
+	paged_start();
 	for_each_possible_cpu(cpu)
 		dump_one_paca(cpu);
+	paged_end("dpa\n");
 }
 
 static void dump_pacas(void)
 {
-	unsigned long num;
 	int c;
 
 	c = inchar();
@@ -2148,13 +2202,15 @@ static void dump_pacas(void)
 		dump_all_pacas();
 		return;
 	}
+	if (c != '_') {
+		termch = c;
+		if (!scanhex(&paca_cpu))
+			paca_cpu = xmon_owner;
+	}
 
-	termch = c;	/* Put c back, it wasn't 'a' */
-
-	if (scanhex(&num))
-		dump_one_paca(num);
-	else
-		dump_one_paca(xmon_owner);
+	paged_start();
+	dump_one_paca(paca_cpu);
+	paged_end("dp_\n");
 }
 #endif
 
Signature · 1 line
2.1.4
#4 lore raw

PATCH v2 2/2 powerpc/xmon: Paginate kernel log buffer display

In reply to Sam Bobroff

The kernel log buffer is often much longer than the size of a terminal so paginate it's output.

---
 arch/powerpc/xmon/xmon.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
arch/powerpc/xmon/xmon.c +5 -4
index 9ce9e7d..fdd765e 100644
@@ -248,9 +248,7 @@ Commands:\n\
 "  u	dump TLB\n"
 #endif
 "  ?	help\n"
-#ifdef CONFIG_PPC64
-"  .#	limit output to # lines per page (dump paca only)\n"
-#endif
+"  .#	limit output to # lines per page (for dp#, dpa, dl)\n"
 "  zr	reboot\n\
   zh	halt\n"
 ;
@@ -850,6 +848,7 @@ static void paged_set_size(void)
 		paged_size = 0;
 	}
 }
+
 static void paged_reset(void)
 {
 	paged_cur_page = 0;
@@ -2372,10 +2371,12 @@ dump_log_buf(void)
 	sync();
 
 	kmsg_dump_rewind_nolock(&dumper);
+	paged_start();
 	while (kmsg_dump_get_line_nolock(&dumper, false, buf, sizeof(buf), &len)) {
 		buf[len] = '\0';
-		printf("%s", buf);
+		XMON_PRINTF("%s", buf);
 	}
+	paged_end("dl\n");
 
 	sync();
 	/* wait a little while to see if we get a machine check */
Signature · 1 line
2.1.4
#2 lore raw
In reply to Sam Bobroff
Quoted 62 lines · Sam bobroff

The paca display is already more than 24 lines, which can be problematic if you have an old school 80x24 terminal, or more likely you are on a virtual terminal which does not scroll for whatever reason.

This patch adds a new command ".", which takes a single (hex) numeric
argument: lines per page. It will cause the output of "dp" and "dpa" to be broken into pages, if necessary.

This is implemented by running over the entire output both for the initial command and for each subsequent page: the visible part is clipped out by checking line numbers. This is a simplistic approach but minimally invasive; it is intended to be easily reusable for other commands.

Sample output:

0:mon> .10
0:mon> dp1
paca for cpu 0x1 @ c00000000fdc0480:

 possible         = yes
 present          = yes
 online           = yes
 lock_token       = 0x8000            	(0x8)
 paca_index       = 0x1               	(0xa)
 kernel_toc       = 0xc000000000eb2400	(0x10)
 kernelbase       = 0xc000000000000000	(0x18)
 kernel_msr       = 0xb000000000001032	(0x20)
 emergency_sp     = 0xc00000003ffe8000	(0x28)
 mc_emergency_sp  = 0xc00000003ffe4000	(0x2e0)
 in_mce           = 0x0               	(0x2e8)
 data_offset      = 0x7f170000        	(0x30)
 hw_cpu_id        = 0x8               	(0x38)
 cpu_start        = 0x1               	(0x3a)
 kexec_state      = 0x0               	(0x3b)
[Enter for next page]
0:mon>
 __current        = 0xc00000007e696620	(0x290)
 kstack           = 0xc00000007e6ebe30	(0x298)
 stab_rr          = 0xb               	(0x2a0)
 saved_r1         = 0xc00000007ef37860	(0x2a8)
 trap_save        = 0x0               	(0x2b8)
 soft_enabled     = 0x0               	(0x2ba)
 irq_happened     = 0x1               	(0x2bb)
 io_sync          = 0x0               	(0x2bc)

irq_work_pending = 0x0 (0x2bd)
nap_state_lost = 0x0 (0x2be)
0:mon>

(Based on a similar patch by Michael Ellerman <[email protected]> "[v2] powerpc/xmon: Allow limiting the size of the paca display". This patch is an alternative and cannot coexist with the original.)

---
 arch/powerpc/xmon/xmon.c | 86 +++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 71 insertions(+), 15 deletions(-)
arch/powerpc/xmon/xmon.c +0 -0
index e599259..9ce9e7d 100644

arch/powerpc/xmon/xmon.c static int xmon_gate; · line 75

Quoted 4 lines
arch/powerpc/xmon/xmon.c +1 -0
@@ -72,6 +72,12 @@ static int xmon_gate;
 
 static unsigned long in_xmon __read_mostly = 0;
 
+#define XMON_PRINTF(...) do { if (paged_vis()) printf(__VA_ARGS__); } while (0)

Can you do this is a proper function. I know it will need to be varargs, but that shouldn't be too ugly.

arch/powerpc/xmon/xmon.c static int xmon_gate; · line 76

Quoted 1 line
arch/powerpc/xmon/xmon.c +1 -0
+#define MAX_PAGED_SIZE 1024

Why do we need a max at all?

arch/powerpc/xmon/xmon.c static int xmon_gate; · line 80

Quoted 5 lines
arch/powerpc/xmon/xmon.c +4 -0
+static unsigned long paged_size = 0, paged_pos, paged_cur_page;
 
+#ifdef CONFIG_PPC64
+static unsigned long paca_cpu;
+#endif

That can just be static in dump_pacas() by the looks.

arch/powerpc/xmon/xmon.c Commands:\n\ · line 253

Quoted 10 lines
arch/powerpc/xmon/xmon.c +0 -0
 static unsigned long adrs;
 static int size = 1;

#define MAX_DUMP (128 * 1024)

arch/powerpc/xmon/xmon.c +3 -0
@@ -242,6 +248,9 @@ Commands:\n\
 "  u	dump TLB\n"
 #endif
 "  ?	help\n"
+#ifdef CONFIG_PPC64
+"  .#	limit output to # lines per page (dump paca only)\n"
+#endif

Don't make it 64-bit only.

arch/powerpc/xmon/xmon.c static void remove_cpu_bpts(void) · line 845

Quoted 8 lines
arch/powerpc/xmon/xmon.c +1 -0
 "  zr	reboot\n\
   zh	halt\n"
 ;
@@ -833,6 +842,19 @@ static void remove_cpu_bpts(void)
 	write_ciabr(0);
 }
 
+static void paged_set_size(void)

"paged" isn't reading very well for me. Can we use "pagination" instead? I know it's longer but monitors are wide these days.

Also I prefer verb first usually, so set_pagination_size() etc.

arch/powerpc/xmon/xmon.c static void remove_cpu_bpts(void) · line 856

Quoted 11 lines
arch/powerpc/xmon/xmon.c +11 -0
+{
+	if (!scanhex(&paged_size) || (paged_size > MAX_PAGED_SIZE)) {
+		printf("Invalid number of lines per page (max: %d).\n",
+		       MAX_PAGED_SIZE);
+		paged_size = 0;
+	}
+}
+static void paged_reset(void)
+{
+	paged_cur_page = 0;
+}

You only call that once so a function seems like over kill.

Quoted 37 lines
arch/powerpc/xmon/xmon.c +15 -1
 /* Command interpreting routine */
 static char *last_cmd;
 
@@ -863,7 +885,8 @@ cmds(struct pt_regs *excp)
 			take_input(last_cmd);
 			last_cmd = NULL;
 			cmd = inchar();
-		}
+		} else
+			paged_reset();
 		switch (cmd) {
 		case 'm':
 			cmd = inchar();
@@ -924,6 +947,9 @@ cmds(struct pt_regs *excp)
 		case '?':
 			xmon_puts(help_string);
 			break;
+		case '.':
+			paged_set_size();
+			break;
 		case 'b':
 			bpt_cmds();
 			break;
@@ -2069,6 +2095,31 @@ static void xmon_rawdump (unsigned long adrs, long ndump)
 	printf("\n");
 }
 
+static void paged_start(void)
+{
+	paged_pos = 0;
+}
+
+static void paged_end(char *next_cmd)
+{
+	unsigned long next_page_start = ++paged_cur_page * paged_size;
+
+	if (paged_size && (paged_pos > next_page_start)) {

arch/powerpc/xmon/xmon.c static void xmon_rawdump (unsigned long adrs, long ndump) · line 2117

Quoted 10 lines
arch/powerpc/xmon/xmon.c +10 -0
+		last_cmd = next_cmd;
+		printf("[Enter for next page]\n");
+	}
+}
+
+static bool paged_vis(void)
+{
+	bool rv = (!paged_size
+	|| ((paged_pos >= (paged_size * paged_cur_page))
+	&& (paged_pos < (paged_size * (paged_cur_page + 1)))));

Erm.

Quoted 50 lines
arch/powerpc/xmon/xmon.c +16 -8
+
+	paged_pos++;
+	return rv;
+}
+
 #ifdef CONFIG_PPC64
 static void dump_one_paca(int cpu)
 {
@@ -2084,15 +2135,17 @@ static void dump_one_paca(int cpu)
 
 	p = &paca[cpu];
 
-	printf("paca for cpu 0x%x @ %p:\n", cpu, p);
+	XMON_PRINTF("paca for cpu 0x%x @ %p:\n", cpu, p);
 
-	printf(" %-*s = %s\n", 16, "possible", cpu_possible(cpu) ? "yes" : "no");
-	printf(" %-*s = %s\n", 16, "present", cpu_present(cpu) ? "yes" : "no");
-	printf(" %-*s = %s\n", 16, "online", cpu_online(cpu) ? "yes" : "no");
+	XMON_PRINTF(" %-*s = %s\n", 16, "possible", cpu_possible(cpu) ? "yes" : "no");
+	XMON_PRINTF(" %-*s = %s\n", 16, "present", cpu_present(cpu) ? "yes" : "no");
+	XMON_PRINTF(" %-*s = %s\n", 16, "online", cpu_online(cpu) ? "yes" : "no");
 
-#define DUMP(paca, name, format) \
-	printf(" %-*s = %#-*"format"\t(0x%lx)\n", 16, #name, 18, paca->name, \
-		offsetof(struct paca_struct, name));
+#define DUMP(paca, name, format) do { \
+		if (paged_vis()) \
+			printf(" %-*s = %#-*"format"\t(0x%lx)\n", 16, #name, 18, \
+			       paca->name, offsetof(struct paca_struct, name)); \
+} while (0)
 
 	DUMP(p, lock_token, "x");
 	DUMP(p, paca_index, "x");
@@ -2134,13 +2187,14 @@ static void dump_all_pacas(void)
 		return;
 	}
 
+	paged_start();
 	for_each_possible_cpu(cpu)
 		dump_one_paca(cpu);
+	paged_end("dpa\n");
 }
 
 static void dump_pacas(void)
 {
-	unsigned long num;
 	int c;
 
 	c = inchar();

arch/powerpc/xmon/xmon.c static void dump_pacas(void) · line 2205

Quoted 4 lines
arch/powerpc/xmon/xmon.c +1 -0
@@ -2148,13 +2202,15 @@ static void dump_pacas(void)
 		dump_all_pacas();
 		return;
 	}
+	if (c != '_') {

What's that about?

Quoted 6 lines
arch/powerpc/xmon/xmon.c +4 -1
+		termch = c;
+		if (!scanhex(&paca_cpu))
+			paca_cpu = xmon_owner;
+	}
 
-	termch = c;	/* Put c back, it wasn't 'a' */

arch/powerpc/xmon/xmon.c static void dump_pacas(void) · line 2215

Quoted 10 lines
arch/powerpc/xmon/xmon.c +3 -5
-
-	if (scanhex(&num))
-		dump_one_paca(num);
-	else
-		dump_one_paca(xmon_owner);
+	paged_start();
+	dump_one_paca(paca_cpu);
+	paged_end("dp_\n");
 }
 #endif

cheers

#3 lore raw
Quoted 64 lines · Michael Ellerman
Quoted 63 lines · Sam bobroff

The paca display is already more than 24 lines, which can be problematic if you have an old school 80x24 terminal, or more likely you are on a virtual terminal which does not scroll for whatever reason.

This patch adds a new command ".", which takes a single (hex) numeric
argument: lines per page. It will cause the output of "dp" and "dpa" to be broken into pages, if necessary.

This is implemented by running over the entire output both for the initial command and for each subsequent page: the visible part is clipped out by checking line numbers. This is a simplistic approach but minimally invasive; it is intended to be easily reusable for other commands.

Sample output:

0:mon> .10
0:mon> dp1
paca for cpu 0x1 @ c00000000fdc0480:

 possible         = yes
 present          = yes
 online           = yes
 lock_token       = 0x8000            	(0x8)
 paca_index       = 0x1               	(0xa)
 kernel_toc       = 0xc000000000eb2400	(0x10)
 kernelbase       = 0xc000000000000000	(0x18)
 kernel_msr       = 0xb000000000001032	(0x20)
 emergency_sp     = 0xc00000003ffe8000	(0x28)
 mc_emergency_sp  = 0xc00000003ffe4000	(0x2e0)
 in_mce           = 0x0               	(0x2e8)
 data_offset      = 0x7f170000        	(0x30)
 hw_cpu_id        = 0x8               	(0x38)
 cpu_start        = 0x1               	(0x3a)
 kexec_state      = 0x0               	(0x3b)
[Enter for next page]
0:mon>
 __current        = 0xc00000007e696620	(0x290)
 kstack           = 0xc00000007e6ebe30	(0x298)
 stab_rr          = 0xb               	(0x2a0)
 saved_r1         = 0xc00000007ef37860	(0x2a8)
 trap_save        = 0x0               	(0x2b8)
 soft_enabled     = 0x0               	(0x2ba)
 irq_happened     = 0x1               	(0x2bb)
 io_sync          = 0x0               	(0x2bc)

irq_work_pending = 0x0 (0x2bd)
nap_state_lost = 0x0 (0x2be)
0:mon>

(Based on a similar patch by Michael Ellerman <[email protected]> "[v2] powerpc/xmon: Allow limiting the size of the paca display". This patch is an alternative and cannot coexist with the original.)

---
 arch/powerpc/xmon/xmon.c | 86 +++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 71 insertions(+), 15 deletions(-)
arch/powerpc/xmon/xmon.c +0 -0
index e599259..9ce9e7d 100644
@@ -72,6 +72,12 @@ static int xmon_gate;
 
Quoted 6 lines

arch/powerpc/xmon/xmon.c static int xmon_gate; · line 75

Quoted 3 lines
arch/powerpc/xmon/xmon.c +1 -0
 static unsigned long in_xmon __read_mostly = 0;
 
+#define XMON_PRINTF(...) do { if (paged_vis()) printf(__VA_ARGS__); } while (0)

Can you do this is a proper function. I know it will need to be varargs, but that shouldn't be too ugly.

Sure, but I think I'll re-work the core of the logic and place it directly into nonstdio.c. That will allow me to implement it directly in xmon_write() and there won't need to be any change here at all. It will also allow blocking during the output which will remove the whole 'run the command several times and print a slice of it' system.

I'll post a v3.

Quoted 4 lines

arch/powerpc/xmon/xmon.c static int xmon_gate; · line 76

Quoted 2 lines
arch/powerpc/xmon/xmon.c +1 -0
+#define MAX_PAGED_SIZE 1024

Why do we need a max at all?

OK, removed.

Quoted 7 lines

arch/powerpc/xmon/xmon.c static int xmon_gate; · line 80

Quoted 5 lines
arch/powerpc/xmon/xmon.c +4 -0
+static unsigned long paged_size = 0, paged_pos, paged_cur_page;
 
+#ifdef CONFIG_PPC64
+static unsigned long paca_cpu;
+#endif

That can just be static in dump_pacas() by the looks.

This won't be needed in the new version.

Quoted 4 lines
Quoted 4 lines
arch/powerpc/xmon/xmon.c +0 -0
 static unsigned long adrs;
 static int size = 1;

#define MAX_DUMP (128 * 1024)

arch/powerpc/xmon/xmon.c +0 -0
@@ -242,6 +248,9 @@ Commands:\n\
Quoted 8 lines

arch/powerpc/xmon/xmon.c Commands:\n\ · line 253

Quoted 6 lines
arch/powerpc/xmon/xmon.c +3 -0
 "  u	dump TLB\n"
 #endif
 "  ?	help\n"
+#ifdef CONFIG_PPC64
+"  .#	limit output to # lines per page (dump paca only)\n"
+#endif

Don't make it 64-bit only.

It's only because the paca display itself is 64 bit only.

Quoted 7 lines
Quoted 7 lines
arch/powerpc/xmon/xmon.c +0 -0
 "  zr	reboot\n\
   zh	halt\n"
 ;
@@ -833,6 +842,19 @@ static void remove_cpu_bpts(void)
 	write_ciabr(0);
 }
 
Quoted 6 lines

arch/powerpc/xmon/xmon.c static void remove_cpu_bpts(void) · line 845

Quoted 1 line
arch/powerpc/xmon/xmon.c +1 -0
+static void paged_set_size(void)

"paged" isn't reading very well for me. Can we use "pagination" instead? I know it's longer but monitors are wide these days.

Also I prefer verb first usually, so set_pagination_size() etc.

Sure thing.

Quoted 5 lines
Quoted 5 lines
arch/powerpc/xmon/xmon.c +5 -0
+{
+	if (!scanhex(&paged_size) || (paged_size > MAX_PAGED_SIZE)) {
+		printf("Invalid number of lines per page (max: %d).\n",
+		       MAX_PAGED_SIZE);
+		paged_size = 0;
Quoted 8 lines

arch/powerpc/xmon/xmon.c static void remove_cpu_bpts(void) · line 856

Quoted 6 lines
arch/powerpc/xmon/xmon.c +6 -0
+	}
+}
+static void paged_reset(void)
+{
+	paged_cur_page = 0;
+}

You only call that once so a function seems like over kill.

Not needed in next version.

Quoted 41 lines
Quoted 41 lines
arch/powerpc/xmon/xmon.c +19 -1
 /* Command interpreting routine */
 static char *last_cmd;
 
@@ -863,7 +885,8 @@ cmds(struct pt_regs *excp)
 			take_input(last_cmd);
 			last_cmd = NULL;
 			cmd = inchar();
-		}
+		} else
+			paged_reset();
 		switch (cmd) {
 		case 'm':
 			cmd = inchar();
@@ -924,6 +947,9 @@ cmds(struct pt_regs *excp)
 		case '?':
 			xmon_puts(help_string);
 			break;
+		case '.':
+			paged_set_size();
+			break;
 		case 'b':
 			bpt_cmds();
 			break;
@@ -2069,6 +2095,31 @@ static void xmon_rawdump (unsigned long adrs, long ndump)
 	printf("\n");
 }
 
+static void paged_start(void)
+{
+	paged_pos = 0;
+}
+
+static void paged_end(char *next_cmd)
+{
+	unsigned long next_page_start = ++paged_cur_page * paged_size;
+
+	if (paged_size && (paged_pos > next_page_start)) {
+		last_cmd = next_cmd;
+		printf("[Enter for next page]\n");
+	}
+}
Quoted 8 lines

arch/powerpc/xmon/xmon.c static void xmon_rawdump (unsigned long adrs, long ndump) · line 2117

Quoted 6 lines
arch/powerpc/xmon/xmon.c +6 -0
+
+static bool paged_vis(void)
+{
+	bool rv = (!paged_size
+	|| ((paged_pos >= (paged_size * paged_cur_page))
+	&& (paged_pos < (paged_size * (paged_cur_page + 1)))));

Erm.

Not needed in next version :-)

Quoted 48 lines
Quoted 48 lines
arch/powerpc/xmon/xmon.c +16 -8
+
+	paged_pos++;
+	return rv;
+}
+
 #ifdef CONFIG_PPC64
 static void dump_one_paca(int cpu)
 {
@@ -2084,15 +2135,17 @@ static void dump_one_paca(int cpu)
 
 	p = &paca[cpu];
 
-	printf("paca for cpu 0x%x @ %p:\n", cpu, p);
+	XMON_PRINTF("paca for cpu 0x%x @ %p:\n", cpu, p);
 
-	printf(" %-*s = %s\n", 16, "possible", cpu_possible(cpu) ? "yes" : "no");
-	printf(" %-*s = %s\n", 16, "present", cpu_present(cpu) ? "yes" : "no");
-	printf(" %-*s = %s\n", 16, "online", cpu_online(cpu) ? "yes" : "no");
+	XMON_PRINTF(" %-*s = %s\n", 16, "possible", cpu_possible(cpu) ? "yes" : "no");
+	XMON_PRINTF(" %-*s = %s\n", 16, "present", cpu_present(cpu) ? "yes" : "no");
+	XMON_PRINTF(" %-*s = %s\n", 16, "online", cpu_online(cpu) ? "yes" : "no");
 
-#define DUMP(paca, name, format) \
-	printf(" %-*s = %#-*"format"\t(0x%lx)\n", 16, #name, 18, paca->name, \
-		offsetof(struct paca_struct, name));
+#define DUMP(paca, name, format) do { \
+		if (paged_vis()) \
+			printf(" %-*s = %#-*"format"\t(0x%lx)\n", 16, #name, 18, \
+			       paca->name, offsetof(struct paca_struct, name)); \
+} while (0)
 
 	DUMP(p, lock_token, "x");
 	DUMP(p, paca_index, "x");
@@ -2134,13 +2187,14 @@ static void dump_all_pacas(void)
 		return;
 	}
 
+	paged_start();
 	for_each_possible_cpu(cpu)
 		dump_one_paca(cpu);
+	paged_end("dpa\n");
 }
 
 static void dump_pacas(void)
 {
-	unsigned long num;
 	int c;
 
Quoted 8 lines

arch/powerpc/xmon/xmon.c static void dump_pacas(void) · line 2205

Quoted 6 lines
arch/powerpc/xmon/xmon.c +1 -0
 	c = inchar();
@@ -2148,13 +2202,15 @@ static void dump_pacas(void)
 		dump_all_pacas();
 		return;
 	}
+	if (c != '_') {

What's that about?

It was to do with re-running the command for the next page, but it's not needed in the next version.

Quoted 5 lines
Quoted 5 lines
arch/powerpc/xmon/xmon.c +4 -0
+		termch = c;
+		if (!scanhex(&paca_cpu))
+			paca_cpu = xmon_owner;
+	}
 
Quoted 13 lines

arch/powerpc/xmon/xmon.c static void dump_pacas(void) · line 2215

Quoted 11 lines
arch/powerpc/xmon/xmon.c +3 -6
-	termch = c;	/* Put c back, it wasn't 'a' */
-
-	if (scanhex(&num))
-		dump_one_paca(num);
-	else
-		dump_one_paca(xmon_owner);
+	paged_start();
+	dump_one_paca(paca_cpu);
+	paged_end("dp_\n");
 }
 #endif

cheers

Thanks for the review,
Sam.