Blame SOURCES/0013-irqbalance-ui-print-cpulist-in-SETUP-IRQS.patch

7bf5db
From 577796abe7337c8df446c082688816ec22804876 Mon Sep 17 00:00:00 2001
7bf5db
From: Liu Chao <liuchao173@huawei.com>
7bf5db
Date: Mon, 11 Jul 2022 11:12:06 +0800
7bf5db
Subject: [PATCH 13/14] irqbalance-ui: print cpulist in SETUP IRQS
7bf5db
7bf5db
save space for printing interrupt names
7bf5db
7bf5db
Signed-off-by: Liu Chao <liuchao173@huawei.com>
7bf5db
---
7bf5db
 ui/ui.c | 30 +++++++++++++++++++++++++++---
7bf5db
 1 file changed, 27 insertions(+), 3 deletions(-)
7bf5db
7bf5db
diff --git a/ui/ui.c b/ui/ui.c
7bf5db
index 2dad442..f1490d5 100644
7bf5db
--- a/ui/ui.c
7bf5db
+++ b/ui/ui.c
7bf5db
@@ -352,9 +352,32 @@ void handle_cpu_banning()
7bf5db
 	}
7bf5db
 }
7bf5db
 
7bf5db
+static int rbot, rtop;
7bf5db
+
7bf5db
+static inline void bsnl_emit(char *buf, int buflen)
7bf5db
+{
7bf5db
+	int len = strlen(buf);
7bf5db
+	if (len > 0) {
7bf5db
+		snprintf(buf + len, buflen - len, ",");
7bf5db
+		len++;
7bf5db
+	}
7bf5db
+	if (rbot == rtop)
7bf5db
+		snprintf(buf + len, buflen - len, "%d", rbot);
7bf5db
+	else
7bf5db
+		snprintf(buf + len, buflen - len, "%d-%d", rbot, rtop);
7bf5db
+}
7bf5db
+
7bf5db
 void copy_assigned_obj(int *number, void *data)
7bf5db
 {
7bf5db
-	snprintf(data + strlen(data), 128 - strlen(data), "%d, ", *number);
7bf5db
+	if (rtop == -1) {
7bf5db
+		rbot = rtop = *number;
7bf5db
+		return;
7bf5db
+	}
7bf5db
+	if (*number > rtop + 1) {
7bf5db
+		bsnl_emit(data, 128);
7bf5db
+		rbot = *number;
7bf5db
+	}
7bf5db
+	rtop = *number;
7bf5db
 }
7bf5db
 
7bf5db
 void print_assigned_objects_string(irq_t *irq, int *line_offset)
7bf5db
@@ -363,9 +386,10 @@ void print_assigned_objects_string(irq_t *irq, int *line_offset)
7bf5db
 		return;
7bf5db
 	}
7bf5db
 	char assigned_to[128] = "\0";
7bf5db
+	rtop = -1;
7bf5db
 	for_each_int(irq->assigned_to, copy_assigned_obj, assigned_to);
7bf5db
-	assigned_to[strlen(assigned_to) - 2] = '\0';
7bf5db
-	mvprintw(*line_offset, 68, "%s", assigned_to);
7bf5db
+	bsnl_emit(assigned_to, 128);
7bf5db
+	mvprintw(*line_offset, 68, "%s             ", assigned_to);
7bf5db
 }
7bf5db
 
7bf5db
 void print_tmp_irq_line(irq_t *irq, void *data __attribute__((unused)))
7bf5db
-- 
7bf5db
2.33.1
7bf5db