[PATCH 1/2] powerpc/xmon: Specify the full format in DUMP() macro

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE3028d

5 messages, 3 authors, 2018-05-25 · open the first message on its own page

[PATCH 1/2] powerpc/xmon: Specify the full format in DUMP() macro

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2018-05-23 11:48:48

In dump_one_paca() the DUMP macro unconditionally prepends '#' to the
printf format specifier. In most cases we're using either 'x' or 'lx'
etc. and that is OK. But for 'p' and other formats using '#' is
actually undefined, and once we enable printf() checking for
xmon_printf() we will get warnings from the compiler.

So just have each usage specify the full format, that way we can omit
'#' when it's inappropriate.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/xmon/xmon.c | 102 +++++++++++++++++++++++------------------------
 1 file changed, 51 insertions(+), 51 deletions(-)
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 064e70a59b47..a81aa3afd87e 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -2349,27 +2349,27 @@ static void dump_one_paca(int cpu)
 	printf(" %-*s = %s\n", 20, "present", cpu_present(cpu) ? "yes" : "no");
 	printf(" %-*s = %s\n", 20, "online", cpu_online(cpu) ? "yes" : "no");
 
-#define DUMP(paca, name, format) \
-	printf(" %-*s = %#-*"format"\t(0x%lx)\n", 20, #name, 18, paca->name, \
+#define DUMP(paca, name, format)				\
+	printf(" %-*s = "format"\t(0x%lx)\n", 20, #name, 18, paca->name, \
 		offsetof(struct paca_struct, name));
 
-	DUMP(p, lock_token, "x");
-	DUMP(p, paca_index, "x");
-	DUMP(p, kernel_toc, "llx");
-	DUMP(p, kernelbase, "llx");
-	DUMP(p, kernel_msr, "llx");
-	DUMP(p, emergency_sp, "px");
+	DUMP(p, lock_token, "%#-*x");
+	DUMP(p, paca_index, "%#-*x");
+	DUMP(p, kernel_toc, "%#-*llx");
+	DUMP(p, kernelbase, "%#-*llx");
+	DUMP(p, kernel_msr, "%#-*llx");
+	DUMP(p, emergency_sp, "%-*px");
 #ifdef CONFIG_PPC_BOOK3S_64
-	DUMP(p, nmi_emergency_sp, "px");
-	DUMP(p, mc_emergency_sp, "px");
-	DUMP(p, in_nmi, "x");
-	DUMP(p, in_mce, "x");
-	DUMP(p, hmi_event_available, "x");
+	DUMP(p, nmi_emergency_sp, "%-*px");
+	DUMP(p, mc_emergency_sp, "%-*px");
+	DUMP(p, in_nmi, "%#-*x");
+	DUMP(p, in_mce, "%#-*x");
+	DUMP(p, hmi_event_available, "%#-*x");
 #endif
-	DUMP(p, data_offset, "llx");
-	DUMP(p, hw_cpu_id, "x");
-	DUMP(p, cpu_start, "x");
-	DUMP(p, kexec_state, "x");
+	DUMP(p, data_offset, "%#-*llx");
+	DUMP(p, hw_cpu_id, "%#-*x");
+	DUMP(p, cpu_start, "%#-*x");
+	DUMP(p, kexec_state, "%#-*x");
 #ifdef CONFIG_PPC_BOOK3S_64
 	for (i = 0; i < SLB_NUM_BOLTED; i++) {
 		u64 esid, vsid;
@@ -2385,54 +2385,54 @@ static void dump_one_paca(int cpu)
 				i, esid, vsid);
 		}
 	}
-	DUMP(p, vmalloc_sllp, "x");
-	DUMP(p, slb_cache_ptr, "x");
+	DUMP(p, vmalloc_sllp, "%#-*x");
+	DUMP(p, slb_cache_ptr, "%#-*x");
 	for (i = 0; i < SLB_CACHE_ENTRIES; i++)
 		printf(" slb_cache[%d]:        = 0x%016x\n", i, p->slb_cache[i]);
 
-	DUMP(p, rfi_flush_fallback_area, "px");
+	DUMP(p, rfi_flush_fallback_area, "%-*px");
 #endif
-	DUMP(p, dscr_default, "llx");
+	DUMP(p, dscr_default, "%#-*llx");
 #ifdef CONFIG_PPC_BOOK3E
-	DUMP(p, pgd, "px");
-	DUMP(p, kernel_pgd, "px");
-	DUMP(p, tcd_ptr, "px");
-	DUMP(p, mc_kstack, "px");
-	DUMP(p, crit_kstack, "px");
-	DUMP(p, dbg_kstack, "px");
+	DUMP(p, pgd, "%-*px");
+	DUMP(p, kernel_pgd, "%-*px");
+	DUMP(p, tcd_ptr, "%-*px");
+	DUMP(p, mc_kstack, "%-*px");
+	DUMP(p, crit_kstack, "%-*px");
+	DUMP(p, dbg_kstack, "%-*px");
 #endif
-	DUMP(p, __current, "px");
-	DUMP(p, kstack, "llx");
+	DUMP(p, __current, "%-*px");
+	DUMP(p, kstack, "%#-*llx");
 	printf(" kstack_base          = 0x%016llx\n", p->kstack & ~(THREAD_SIZE - 1));
-	DUMP(p, stab_rr, "llx");
-	DUMP(p, saved_r1, "llx");
-	DUMP(p, trap_save, "x");
-	DUMP(p, irq_soft_mask, "x");
-	DUMP(p, irq_happened, "x");
-	DUMP(p, io_sync, "x");
-	DUMP(p, irq_work_pending, "x");
-	DUMP(p, nap_state_lost, "x");
-	DUMP(p, sprg_vdso, "llx");
+	DUMP(p, stab_rr, "%#-*llx");
+	DUMP(p, saved_r1, "%#-*llx");
+	DUMP(p, trap_save, "%#-*x");
+	DUMP(p, irq_soft_mask, "%#-*x");
+	DUMP(p, irq_happened, "%#-*x");
+	DUMP(p, io_sync, "%#-*x");
+	DUMP(p, irq_work_pending, "%#-*x");
+	DUMP(p, nap_state_lost, "%#-*x");
+	DUMP(p, sprg_vdso, "%#-*llx");
 
 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
-	DUMP(p, tm_scratch, "llx");
+	DUMP(p, tm_scratch, "%#-*llx");
 #endif
 
 #ifdef CONFIG_PPC_POWERNV
-	DUMP(p, core_idle_state_ptr, "px");
-	DUMP(p, thread_idle_state, "x");
-	DUMP(p, thread_mask, "x");
-	DUMP(p, subcore_sibling_mask, "x");
+	DUMP(p, core_idle_state_ptr, "%-*px");
+	DUMP(p, thread_idle_state, "%#-*x");
+	DUMP(p, thread_mask, "%#-*x");
+	DUMP(p, subcore_sibling_mask, "%#-*x");
 #endif
 
-	DUMP(p, accounting.utime, "lx");
-	DUMP(p, accounting.stime, "lx");
-	DUMP(p, accounting.utime_scaled, "lx");
-	DUMP(p, accounting.starttime, "lx");
-	DUMP(p, accounting.starttime_user, "lx");
-	DUMP(p, accounting.startspurr, "lx");
-	DUMP(p, accounting.utime_sspurr, "lx");
-	DUMP(p, accounting.steal_time, "lx");
+	DUMP(p, accounting.utime, "%#-*lx");
+	DUMP(p, accounting.stime, "%#-*lx");
+	DUMP(p, accounting.utime_scaled, "%#-*lx");
+	DUMP(p, accounting.starttime, "%#-*lx");
+	DUMP(p, accounting.starttime_user, "%#-*lx");
+	DUMP(p, accounting.startspurr, "%#-*lx");
+	DUMP(p, accounting.utime_sspurr, "%#-*lx");
+	DUMP(p, accounting.steal_time, "%#-*lx");
 #undef DUMP
 
 	catch_memory_errors = 0;
-- 
2.14.1

[PATCH 2/2] powerpc/xmon: Realign paca dump fields

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2018-05-23 11:48:49

We've added some fields with longer names since we originally wrote
this, so the fields are no longer lined up. Adjust the widths to make
it all look nice again, eg:

  0:mon> dp
  paca for cpu 0x0 @ c000000001fa0000:
   possible                  = yes
   ...
   slb_shadow            [0] = 0xc000000008000000 0x400ea1b217000500
   slb_shadow            [1] = 0xd000000008000001 0x400d43642f000510
   ...
   rfi_flush_fallback_area   = c0000000fff80000   (0xcc8)
   ...
   accounting.starttime_user = 0x51582f07         (0xae8)

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/xmon/xmon.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index a81aa3afd87e..421c3a9aa734 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -2345,12 +2345,12 @@ static void dump_one_paca(int cpu)
 
 	printf("paca for cpu 0x%x @ %px:\n", cpu, p);
 
-	printf(" %-*s = %s\n", 20, "possible", cpu_possible(cpu) ? "yes" : "no");
-	printf(" %-*s = %s\n", 20, "present", cpu_present(cpu) ? "yes" : "no");
-	printf(" %-*s = %s\n", 20, "online", cpu_online(cpu) ? "yes" : "no");
+	printf(" %-*s = %s\n", 25, "possible", cpu_possible(cpu) ? "yes" : "no");
+	printf(" %-*s = %s\n", 25, "present", cpu_present(cpu) ? "yes" : "no");
+	printf(" %-*s = %s\n", 25, "online", cpu_online(cpu) ? "yes" : "no");
 
 #define DUMP(paca, name, format)				\
-	printf(" %-*s = "format"\t(0x%lx)\n", 20, #name, 18, paca->name, \
+	printf(" %-*s = "format"\t(0x%lx)\n", 25, #name, 18, paca->name, \
 		offsetof(struct paca_struct, name));
 
 	DUMP(p, lock_token, "%#-*x");
@@ -2381,14 +2381,15 @@ static void dump_one_paca(int cpu)
 		vsid = be64_to_cpu(p->slb_shadow_ptr->save_area[i].vsid);
 
 		if (esid || vsid) {
-			printf(" slb_shadow[%d]:       = 0x%016llx 0x%016llx\n",
-				i, esid, vsid);
+			printf(" %-*s[%d] = 0x%016llx 0x%016llx\n",
+			       22, "slb_shadow", i, esid, vsid);
 		}
 	}
 	DUMP(p, vmalloc_sllp, "%#-*x");
 	DUMP(p, slb_cache_ptr, "%#-*x");
 	for (i = 0; i < SLB_CACHE_ENTRIES; i++)
-		printf(" slb_cache[%d]:        = 0x%016x\n", i, p->slb_cache[i]);
+		printf(" %-*s[%d] = 0x%016x\n",
+		       22, "slb_cache", i, p->slb_cache[i]);
 
 	DUMP(p, rfi_flush_fallback_area, "%-*px");
 #endif
@@ -2403,7 +2404,7 @@ static void dump_one_paca(int cpu)
 #endif
 	DUMP(p, __current, "%-*px");
 	DUMP(p, kstack, "%#-*llx");
-	printf(" kstack_base          = 0x%016llx\n", p->kstack & ~(THREAD_SIZE - 1));
+	printf(" %-*s = 0x%016llx\n", 25, "kstack_base", p->kstack & ~(THREAD_SIZE - 1));
 	DUMP(p, stab_rr, "%#-*llx");
 	DUMP(p, saved_r1, "%#-*llx");
 	DUMP(p, trap_save, "%#-*x");
-- 
2.14.1

Re: [PATCH 1/2] powerpc/xmon: Specify the full format in DUMP() macro

From: Mathieu Malaterre <hidden>
Date: 2018-05-23 18:55:37

On Wed, May 23, 2018 at 1:48 PM, Michael Ellerman [off-list ref] wrote:
In dump_one_paca() the DUMP macro unconditionally prepends '#' to the
printf format specifier. In most cases we're using either 'x' or 'lx'
etc. and that is OK. But for 'p' and other formats using '#' is
actually undefined, and once we enable printf() checking for
xmon_printf() we will get warnings from the compiler.
Much more elegant, thanks.

All %#-* and %-* formatters are correct. The change to 22 is correct
since both SLB_NUM_BOLTED & SLB_CACHE_ENTRIES < 10.

For the series:

Reviewed-by: Mathieu Malaterre <redacted>
quoted hunk
So just have each usage specify the full format, that way we can omit
'#' when it's inappropriate.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/xmon/xmon.c | 102 +++++++++++++++++++++++------------------------
 1 file changed, 51 insertions(+), 51 deletions(-)
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 064e70a59b47..a81aa3afd87e 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -2349,27 +2349,27 @@ static void dump_one_paca(int cpu)
        printf(" %-*s = %s\n", 20, "present", cpu_present(cpu) ? "yes" : "no");
        printf(" %-*s = %s\n", 20, "online", cpu_online(cpu) ? "yes" : "no");

-#define DUMP(paca, name, format) \
-       printf(" %-*s = %#-*"format"\t(0x%lx)\n", 20, #name, 18, paca->name, \
+#define DUMP(paca, name, format)                               \
+       printf(" %-*s = "format"\t(0x%lx)\n", 20, #name, 18, paca->name, \
                offsetof(struct paca_struct, name));

-       DUMP(p, lock_token, "x");
-       DUMP(p, paca_index, "x");
-       DUMP(p, kernel_toc, "llx");
-       DUMP(p, kernelbase, "llx");
-       DUMP(p, kernel_msr, "llx");
-       DUMP(p, emergency_sp, "px");
+       DUMP(p, lock_token, "%#-*x");
+       DUMP(p, paca_index, "%#-*x");
+       DUMP(p, kernel_toc, "%#-*llx");
+       DUMP(p, kernelbase, "%#-*llx");
+       DUMP(p, kernel_msr, "%#-*llx");
+       DUMP(p, emergency_sp, "%-*px");
 #ifdef CONFIG_PPC_BOOK3S_64
-       DUMP(p, nmi_emergency_sp, "px");
-       DUMP(p, mc_emergency_sp, "px");
-       DUMP(p, in_nmi, "x");
-       DUMP(p, in_mce, "x");
-       DUMP(p, hmi_event_available, "x");
+       DUMP(p, nmi_emergency_sp, "%-*px");
+       DUMP(p, mc_emergency_sp, "%-*px");
+       DUMP(p, in_nmi, "%#-*x");
+       DUMP(p, in_mce, "%#-*x");
+       DUMP(p, hmi_event_available, "%#-*x");
 #endif
-       DUMP(p, data_offset, "llx");
-       DUMP(p, hw_cpu_id, "x");
-       DUMP(p, cpu_start, "x");
-       DUMP(p, kexec_state, "x");
+       DUMP(p, data_offset, "%#-*llx");
+       DUMP(p, hw_cpu_id, "%#-*x");
+       DUMP(p, cpu_start, "%#-*x");
+       DUMP(p, kexec_state, "%#-*x");
 #ifdef CONFIG_PPC_BOOK3S_64
        for (i = 0; i < SLB_NUM_BOLTED; i++) {
                u64 esid, vsid;
@@ -2385,54 +2385,54 @@ static void dump_one_paca(int cpu)
                                i, esid, vsid);
                }
        }
-       DUMP(p, vmalloc_sllp, "x");
-       DUMP(p, slb_cache_ptr, "x");
+       DUMP(p, vmalloc_sllp, "%#-*x");
+       DUMP(p, slb_cache_ptr, "%#-*x");
        for (i = 0; i < SLB_CACHE_ENTRIES; i++)
                printf(" slb_cache[%d]:        = 0x%016x\n", i, p->slb_cache[i]);

-       DUMP(p, rfi_flush_fallback_area, "px");
+       DUMP(p, rfi_flush_fallback_area, "%-*px");
 #endif
-       DUMP(p, dscr_default, "llx");
+       DUMP(p, dscr_default, "%#-*llx");
 #ifdef CONFIG_PPC_BOOK3E
-       DUMP(p, pgd, "px");
-       DUMP(p, kernel_pgd, "px");
-       DUMP(p, tcd_ptr, "px");
-       DUMP(p, mc_kstack, "px");
-       DUMP(p, crit_kstack, "px");
-       DUMP(p, dbg_kstack, "px");
+       DUMP(p, pgd, "%-*px");
+       DUMP(p, kernel_pgd, "%-*px");
+       DUMP(p, tcd_ptr, "%-*px");
+       DUMP(p, mc_kstack, "%-*px");
+       DUMP(p, crit_kstack, "%-*px");
+       DUMP(p, dbg_kstack, "%-*px");
 #endif
-       DUMP(p, __current, "px");
-       DUMP(p, kstack, "llx");
+       DUMP(p, __current, "%-*px");
+       DUMP(p, kstack, "%#-*llx");
        printf(" kstack_base          = 0x%016llx\n", p->kstack & ~(THREAD_SIZE - 1));
-       DUMP(p, stab_rr, "llx");
-       DUMP(p, saved_r1, "llx");
-       DUMP(p, trap_save, "x");
-       DUMP(p, irq_soft_mask, "x");
-       DUMP(p, irq_happened, "x");
-       DUMP(p, io_sync, "x");
-       DUMP(p, irq_work_pending, "x");
-       DUMP(p, nap_state_lost, "x");
-       DUMP(p, sprg_vdso, "llx");
+       DUMP(p, stab_rr, "%#-*llx");
+       DUMP(p, saved_r1, "%#-*llx");
+       DUMP(p, trap_save, "%#-*x");
+       DUMP(p, irq_soft_mask, "%#-*x");
+       DUMP(p, irq_happened, "%#-*x");
+       DUMP(p, io_sync, "%#-*x");
+       DUMP(p, irq_work_pending, "%#-*x");
+       DUMP(p, nap_state_lost, "%#-*x");
+       DUMP(p, sprg_vdso, "%#-*llx");

 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
-       DUMP(p, tm_scratch, "llx");
+       DUMP(p, tm_scratch, "%#-*llx");
 #endif

 #ifdef CONFIG_PPC_POWERNV
-       DUMP(p, core_idle_state_ptr, "px");
-       DUMP(p, thread_idle_state, "x");
-       DUMP(p, thread_mask, "x");
-       DUMP(p, subcore_sibling_mask, "x");
+       DUMP(p, core_idle_state_ptr, "%-*px");
+       DUMP(p, thread_idle_state, "%#-*x");
+       DUMP(p, thread_mask, "%#-*x");
+       DUMP(p, subcore_sibling_mask, "%#-*x");
 #endif

-       DUMP(p, accounting.utime, "lx");
-       DUMP(p, accounting.stime, "lx");
-       DUMP(p, accounting.utime_scaled, "lx");
-       DUMP(p, accounting.starttime, "lx");
-       DUMP(p, accounting.starttime_user, "lx");
-       DUMP(p, accounting.startspurr, "lx");
-       DUMP(p, accounting.utime_sspurr, "lx");
-       DUMP(p, accounting.steal_time, "lx");
+       DUMP(p, accounting.utime, "%#-*lx");
+       DUMP(p, accounting.stime, "%#-*lx");
+       DUMP(p, accounting.utime_scaled, "%#-*lx");
+       DUMP(p, accounting.starttime, "%#-*lx");
+       DUMP(p, accounting.starttime_user, "%#-*lx");
+       DUMP(p, accounting.startspurr, "%#-*lx");
+       DUMP(p, accounting.utime_sspurr, "%#-*lx");
+       DUMP(p, accounting.steal_time, "%#-*lx");
 #undef DUMP

        catch_memory_errors = 0;
--
2.14.1

Re: [1/2] powerpc/xmon: Specify the full format in DUMP() macro

From: Michael Ellerman <hidden>
Date: 2018-05-25 11:41:52

On Wed, 2018-05-23 at 11:48:36 UTC, Michael Ellerman wrote:
In dump_one_paca() the DUMP macro unconditionally prepends '#' to the
printf format specifier. In most cases we're using either 'x' or 'lx'
etc. and that is OK. But for 'p' and other formats using '#' is
actually undefined, and once we enable printf() checking for
xmon_printf() we will get warnings from the compiler.

So just have each usage specify the full format, that way we can omit
'#' when it's inappropriate.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Mathieu Malaterre <redacted>
Applied to powerpc next.

https://git.kernel.org/powerpc/c/6671683db8540e5766f44a1089549c

cheers

Re: [2/2] powerpc/xmon: Realign paca dump fields

From: Michael Ellerman <hidden>
Date: 2018-05-25 11:41:54

On Wed, 2018-05-23 at 11:48:37 UTC, Michael Ellerman wrote:
We've added some fields with longer names since we originally wrote
this, so the fields are no longer lined up. Adjust the widths to make
it all look nice again, eg:

  0:mon> dp
  paca for cpu 0x0 @ c000000001fa0000:
   possible                  = yes
   ...
   slb_shadow            [0] = 0xc000000008000000 0x400ea1b217000500
   slb_shadow            [1] = 0xd000000008000001 0x400d43642f000510
   ...
   rfi_flush_fallback_area   = c0000000fff80000   (0xcc8)
   ...
   accounting.starttime_user = 0x51582f07         (0xae8)

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Applied to powerpc next.

https://git.kernel.org/powerpc/c/9ce53e27265e7bab728774fac785f6

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help