File lsslot-fix-and-unify-formatting-of-cpu-slots.patch of Package powerpc-utils.32342

From a63f08289611e3c76814a3b9fbb7ef7c56d13ff5 Mon Sep 17 00:00:00 2001
From: Tyrel Datwyler <tyreld@linux.ibm.com>
Date: Thu, 1 Feb 2024 07:19:58 +0530
Subject: [PATCH 2/3] lsslot: fix and unify formatting of cpu slots

When listing cpu slots with and without the -b option the formatting is
inconsistent and some column headers and associated data are not aligned.

Adjusted format strings accordingly.

Without patch:
localhost:~/powerpc-utils # ./src/drmgr/lsslot -c cpu
drc-name   OFDT-node           drc_index    thread id(s)
CPU 41     PowerPC,POWER10@28  10000028     28 29 2a 2b 2c 2d 2e 2f
CPU 33     PowerPC,POWER10@20  10000020     20 21 22 23 24 25 26 27
CPU 25     PowerPC,POWER10@18  10000018     18 19 1a 1b 1c 1d 1e 1f
CPU 17     PowerPC,POWER10@10  10000010     10 11 12 13 14 15 16 17
CPU 9      PowerPC,POWER10@8   10000008     8 9 a b c d e f
CPU 1      PowerPC,POWER10@0   10000000     0 1 2 3 4 5 6 7

localhost:~/powerpc-utils # ./src/drmgr/lsslot -c cpu -b
drc-name  OFDT-node         drc_index  thread id(s)     l2-cache       l3-cache
CPU 41    PowerPC,POWER10@28  10000028   28 29 2a 2b 2c 2d 2e 2f  N/A            N/A
CPU 33    PowerPC,POWER10@20  10000020   20 21 22 23 24 25 26 27  N/A            N/A
CPU 25    PowerPC,POWER10@18  10000018   18 19 1a 1b 1c 1d 1e 1f  N/A            N/A
CPU 17    PowerPC,POWER10@10  10000010   10 11 12 13 14 15 16 17  N/A            N/A
CPU 9     PowerPC,POWER10@8   10000008   8 9 a b c d e f  N/A            N/A
CPU 1     PowerPC,POWER10@0   10000000   0 1 2 3 4 5 6 7  N/A            N/A

With patch:
localhost:~/powerpc-utils # ./src/drmgr/lsslot -c cpu
drc-name  OFDT-node           drc_index  thread id(s)
CPU 41    PowerPC,POWER10@28  10000028   28 29 2a 2b 2c 2d 2e 2f
CPU 33    PowerPC,POWER10@20  10000020   20 21 22 23 24 25 26 27
CPU 25    PowerPC,POWER10@18  10000018   18 19 1a 1b 1c 1d 1e 1f
CPU 17    PowerPC,POWER10@10  10000010   10 11 12 13 14 15 16 17
CPU 9     PowerPC,POWER10@8   10000008   8  9  a  b  c  d  e  f
CPU 1     PowerPC,POWER10@0   10000000   0  1  2  3  4  5  6  7

localhost:~/powerpc-utils # ./src/drmgr/lsslot -c cpu -b
drc-name  OFDT-node           drc_index  thread id(s)             l2-cache       l3-cache
CPU 41    PowerPC,POWER10@28  10000028   28 29 2a 2b 2c 2d 2e 2f  N/A            N/A
CPU 33    PowerPC,POWER10@20  10000020   20 21 22 23 24 25 26 27  N/A            N/A
CPU 25    PowerPC,POWER10@18  10000018   18 19 1a 1b 1c 1d 1e 1f  N/A            N/A
CPU 17    PowerPC,POWER10@10  10000010   10 11 12 13 14 15 16 17  N/A            N/A
CPU 9     PowerPC,POWER10@8   10000008   8  9  a  b  c  d  e  f   N/A            N/A
CPU 1     PowerPC,POWER10@0   10000000   0  1  2  3  4  5  6  7   N/A            N/A

Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com>
---
 src/drmgr/lsslot_chrp_cpu.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/drmgr/lsslot_chrp_cpu.c b/src/drmgr/lsslot_chrp_cpu.c
index af87e4e..a4c9851 100644
--- a/src/drmgr/lsslot_chrp_cpu.c
+++ b/src/drmgr/lsslot_chrp_cpu.c
@@ -38,8 +38,8 @@ list_cpus(struct dr_info *dr_info)
 {
 	struct dr_node *cpu;
 	struct thread *t;
-	char *fmt_s = "%-11s%-20s%-13s%-13s\n";
-	char *fmt = "%-11s%-20s%-12x";
+	char *fmt_s = "%-10s%-20s%-11s%-13s\n";
+	char *fmt = "%-10s%-20s%-11x";
 
 	printf(fmt_s, "drc-name", "OFDT-node", "drc_index", "thread id(s)");
 
@@ -48,7 +48,7 @@ list_cpus(struct dr_info *dr_info)
 			printf(fmt, cpu->drc_name, cpu->name ? cpu->name : "--",
 			       cpu->drc_index);
 			for (t = cpu->cpu_threads; t; t = t->sibling)
-				printf(" %x", t->id);
+				printf("%-2x ", t->id);
 			printf("\n");
 		}
 	}
@@ -84,8 +84,8 @@ list_cpus_and_caches(struct dr_info *dr_info)
 {
 	struct dr_node *cpu = NULL;
 	struct thread *t;
-	int thread_id_field_sz = 17;
-	char *fmt_s = "%-10s%-18s%-11s%-17s%-15s%-15s\n";
+	int thread_id_field_sz = 25;
+	char *fmt_s = "%-10s%-20s%-11s%-25s%-15s%-15s\n";
 	char *fmt = "%-10s%-20s%-11x";
 	char *fmt_caches = "%-15s%-15s\n";
 
@@ -101,8 +101,8 @@ list_cpus_and_caches(struct dr_info *dr_info)
 		       cpu->drc_index);
 
 		for (t = cpu->cpu_threads; t; t = t->sibling) {
-			printf("%x ", t->id);
-			count += 2;
+			printf("%-2x ", t->id);
+			count += 3;
 		}
 
 		/* pad out the thread ids field */
-- 
2.43.0

openSUSE Build Service is sponsored by