Blame SOURCES/0012-irqbalance-ui-support-scroll-under-tui-mode-of-irqba.patch

9425f0
From db7dc03388a20ba2d873a81c3e14b933e2b09551 Mon Sep 17 00:00:00 2001
9425f0
From: Liu Chao <liuchao173@huawei.com>
9425f0
Date: Mon, 4 Jul 2022 16:25:14 +0800
9425f0
Subject: [PATCH 12/14] irqbalance-ui: support scroll under tui mode of
9425f0
 irqbalance-ui
9425f0
9425f0
support using Up, Down, PageUp, PageDown to scroll in view mode
9425f0
support using Up and Down in edit mode
9425f0
9425f0
Signed-off-by: Liu Chao <liuchao173@huawei.com>
9425f0
---
9425f0
 ui/helpers.c       |   2 +
9425f0
 ui/irqbalance-ui.c | 138 ++++++++++++++++++++++++---------
9425f0
 ui/irqbalance-ui.h |   2 +
9425f0
 ui/ui.c            | 187 ++++++++++++++++++++++++++++++++++++---------
9425f0
 ui/ui.h            |   3 +
9425f0
 5 files changed, 262 insertions(+), 70 deletions(-)
9425f0
9425f0
diff --git a/ui/helpers.c b/ui/helpers.c
9425f0
index 5d71275..0e9f76c 100644
9425f0
--- a/ui/helpers.c
9425f0
+++ b/ui/helpers.c
9425f0
@@ -89,6 +89,7 @@ gpointer copy_cpu_ban(gconstpointer src, gpointer data __attribute__((unused)))
9425f0
 	cpu_ban_t *new = malloc(sizeof(cpu_ban_t));
9425f0
 	new->number = old->number;
9425f0
 	new->is_banned = old->is_banned;
9425f0
+	new->is_changed = 0;
9425f0
 	return new;
9425f0
 }
9425f0
 
9425f0
@@ -100,6 +101,7 @@ gpointer copy_irq(gconstpointer src, gpointer data __attribute__((unused)))
9425f0
 	new->load = old->load;
9425f0
 	new->diff = old->diff;
9425f0
 	new->is_banned = old->is_banned;
9425f0
+	new->is_changed = 0;
9425f0
 	new->class = old->class;
9425f0
 	new->assigned_to = g_list_copy(old->assigned_to);
9425f0
 	return new;
9425f0
diff --git a/ui/irqbalance-ui.c b/ui/irqbalance-ui.c
9425f0
index 89ed94a..47b6c88 100644
9425f0
--- a/ui/irqbalance-ui.c
9425f0
+++ b/ui/irqbalance-ui.c
9425f0
@@ -371,48 +371,116 @@ gboolean rescan_tree(gpointer data __attribute__((unused)))
9425f0
 	free(irqbalance_data);
9425f0
 	return TRUE;
9425f0
 }
9425f0
-
9425f0
-gboolean key_loop(gpointer data __attribute__((unused)))
9425f0
-{
9425f0
-	int c = getch();
9425f0
-	switch(c) {
9425f0
-	case 'q':
9425f0
-		close_window(0);
9425f0
-		break;
9425f0
-	case KEY_F(3):
9425f0
-		if (state == STATE_SETTINGS || state == STATE_SETUP_IRQS) {
9425f0
-			state = STATE_TREE;
9425f0
-			display_tree();
9425f0
-		}
9425f0
+void scroll_window() {
9425f0
+	switch(state) {
9425f0
+	case STATE_TREE:
9425f0
+		display_tree();
9425f0
 		break;
9425f0
-	case KEY_F(4):
9425f0
-		if (state == STATE_TREE || state == STATE_SETUP_IRQS) {
9425f0
-			state = STATE_SETTINGS;
9425f0
-			settings();
9425f0
-		}
9425f0
+	case STATE_SETTINGS:
9425f0
 		settings();
9425f0
 		break;
9425f0
-	case KEY_F(5):
9425f0
-		if (state == STATE_TREE || state == STATE_SETTINGS) {
9425f0
-			state = STATE_SETUP_IRQS;
9425f0
-			setup_irqs();
9425f0
-		}
9425f0
-		break;
9425f0
-	case 'c':
9425f0
-		if (state == STATE_SETTINGS)
9425f0
-			handle_cpu_banning();
9425f0
-		break;
9425f0
-	case 'i':
9425f0
-		if (state == STATE_SETUP_IRQS)
9425f0
-			handle_irq_banning();
9425f0
-		break;
9425f0
-	case 's':
9425f0
-		if (state == STATE_SETTINGS)
9425f0
-			handle_sleep_setting();
9425f0
+	case STATE_SETUP_IRQS:
9425f0
+		setup_irqs();
9425f0
 		break;
9425f0
 	default:
9425f0
 		break;
9425f0
 	}
9425f0
+}
9425f0
+
9425f0
+gboolean key_loop(gpointer data __attribute__((unused)))
9425f0
+{
9425f0
+	while(1) {
9425f0
+		int c = getch();
9425f0
+		switch(c) {
9425f0
+		case 'q':
9425f0
+			close_window(0);
9425f0
+			break;
9425f0
+		case KEY_UP:
9425f0
+			if (offset > 0) {
9425f0
+				offset--;
9425f0
+				scroll_window();
9425f0
+			}
9425f0
+			break;
9425f0
+		case KEY_DOWN:
9425f0
+			if (offset < max_offset) {
9425f0
+				offset++;
9425f0
+				scroll_window();
9425f0
+			}
9425f0
+			break;
9425f0
+		case KEY_NPAGE:
9425f0
+			switch (state) {
9425f0
+			case STATE_TREE:
9425f0
+				offset += LINES - 5;
9425f0
+				break;
9425f0
+			case STATE_SETTINGS:
9425f0
+				offset += LINES - 8;
9425f0
+				break;
9425f0
+			case STATE_SETUP_IRQS:
9425f0
+				offset += LINES - 6;
9425f0
+				break;
9425f0
+			default:
9425f0
+				break;
9425f0
+			}
9425f0
+			if (offset > max_offset)
9425f0
+				offset = max_offset;
9425f0
+			scroll_window();
9425f0
+			break;
9425f0
+		case KEY_PPAGE:
9425f0
+			switch (state) {
9425f0
+			case STATE_TREE:
9425f0
+				offset -= LINES - 5;
9425f0
+				break;
9425f0
+			case STATE_SETTINGS:
9425f0
+				offset -= LINES - 8;
9425f0
+				break;
9425f0
+			case STATE_SETUP_IRQS:
9425f0
+				offset -= LINES - 6;
9425f0
+				break;
9425f0
+			default:
9425f0
+				break;
9425f0
+			}
9425f0
+			if (offset < 0)
9425f0
+				offset = 0;
9425f0
+			scroll_window();
9425f0
+			break;
9425f0
+		case KEY_F(3):
9425f0
+			if (state == STATE_SETTINGS || state == STATE_SETUP_IRQS) {
9425f0
+				state = STATE_TREE;
9425f0
+				offset = 0;
9425f0
+				display_tree();
9425f0
+			}
9425f0
+			break;
9425f0
+		case KEY_F(4):
9425f0
+			if (state == STATE_TREE || state == STATE_SETUP_IRQS) {
9425f0
+				state = STATE_SETTINGS;
9425f0
+				offset = 0;
9425f0
+				settings();
9425f0
+			}
9425f0
+			settings();
9425f0
+			break;
9425f0
+		case KEY_F(5):
9425f0
+			if (state == STATE_TREE || state == STATE_SETTINGS) {
9425f0
+				state = STATE_SETUP_IRQS;
9425f0
+				offset = 0;
9425f0
+				setup_irqs();
9425f0
+			}
9425f0
+			break;
9425f0
+		case 'c':
9425f0
+			if (state == STATE_SETTINGS)
9425f0
+				handle_cpu_banning();
9425f0
+			break;
9425f0
+		case 'i':
9425f0
+			if (state == STATE_SETUP_IRQS)
9425f0
+				handle_irq_banning();
9425f0
+			break;
9425f0
+		case 's':
9425f0
+			if (state == STATE_SETTINGS)
9425f0
+				handle_sleep_setting();
9425f0
+			break;
9425f0
+		default:
9425f0
+			break;
9425f0
+		}
9425f0
+	}
9425f0
 	return TRUE;
9425f0
 }
9425f0
 
9425f0
diff --git a/ui/irqbalance-ui.h b/ui/irqbalance-ui.h
9425f0
index fba7e7c..dc24083 100644
9425f0
--- a/ui/irqbalance-ui.h
9425f0
+++ b/ui/irqbalance-ui.h
9425f0
@@ -41,6 +41,7 @@ typedef struct irq {
9425f0
 	uint64_t load;
9425f0
 	uint64_t diff;
9425f0
 	char is_banned;
9425f0
+	char is_changed;
9425f0
 	GList *assigned_to;
9425f0
 	int class;
9425f0
 } irq_t;
9425f0
@@ -60,6 +61,7 @@ typedef struct cpu_node {
9425f0
 typedef struct cpu_ban {
9425f0
 	int number;
9425f0
 	char is_banned;
9425f0
+	char is_changed;
9425f0
 } cpu_ban_t;
9425f0
 
9425f0
 typedef struct setup {
9425f0
diff --git a/ui/ui.c b/ui/ui.c
9425f0
index 6b1c689..2dad442 100644
9425f0
--- a/ui/ui.c
9425f0
+++ b/ui/ui.c
9425f0
@@ -3,6 +3,8 @@
9425f0
 #include <string.h>
9425f0
 #include "ui.h"
9425f0
 
9425f0
+int offset;
9425f0
+int max_offset;
9425f0
 
9425f0
 GList *all_cpus = NULL;
9425f0
 GList *all_irqs = NULL;
9425f0
@@ -134,32 +136,54 @@ void get_banned_cpu(int *cpu, void *data __attribute__((unused)))
9425f0
 	all_cpus = g_list_append(all_cpus, new);
9425f0
 }
9425f0
 
9425f0
-void print_cpu_line(cpu_ban_t *cpu, void *data)
9425f0
+void print_tmp_cpu_line(cpu_ban_t *cpu, void *data __attribute__((unused)))
9425f0
 {
9425f0
-	int *line_offset = data;
9425f0
-	if(cpu->is_banned) {
9425f0
-		attrset(COLOR_PAIR(10));
9425f0
-	} else {
9425f0
-		attrset(COLOR_PAIR(9));
9425f0
+	int line = max_offset - offset + 6;
9425f0
+	if (max_offset >= offset && line < LINES - 3) {
9425f0
+		if (cpu->is_changed)
9425f0
+			attrset(COLOR_PAIR(3));
9425f0
+		else if(cpu->is_banned)
9425f0
+			attrset(COLOR_PAIR(10));
9425f0
+		else
9425f0
+			attrset(COLOR_PAIR(9));
9425f0
+		mvprintw(line, 3, "CPU %d     ", cpu->number);
9425f0
+		mvprintw(line, 19, "%s", cpu->is_banned ?
9425f0
+				"YES	" :
9425f0
+				"NO	 ");
9425f0
 	}
9425f0
-	mvprintw(*line_offset, 3, "CPU %d", cpu->number);
9425f0
-	mvprintw(*line_offset, 19, "%s", cpu->is_banned ?
9425f0
-			"YES	" :
9425f0
-			"NO	 ");
9425f0
-	(*line_offset)++;
9425f0
+	max_offset++;
9425f0
+}
9425f0
+
9425f0
+void print_cpu_line(cpu_ban_t *cpu, void *data __attribute__((unused)))
9425f0
+{
9425f0
+	int line = max_offset - offset + 6;
9425f0
+	if (max_offset >= offset && line < LINES - 2) {
9425f0
+		if(cpu->is_banned)
9425f0
+			attrset(COLOR_PAIR(10));
9425f0
+		else
9425f0
+			attrset(COLOR_PAIR(9));
9425f0
+		mvprintw(line, 3, "CPU %d     ", cpu->number);
9425f0
+		mvprintw(line, 19, "%s", cpu->is_banned ?
9425f0
+				"YES	" :
9425f0
+				"NO	 ");
9425f0
+	}
9425f0
+	max_offset++;
9425f0
 }
9425f0
 
9425f0
 void print_all_cpus()
9425f0
 {
9425f0
+	max_offset = 0;
9425f0
 	if(all_cpus == NULL) {
9425f0
 		for_each_node(tree, get_cpu, NULL);
9425f0
 		for_each_int(setup.banned_cpus, get_banned_cpu, NULL);
9425f0
 		all_cpus = g_list_sort(all_cpus, sort_all_cpus);
9425f0
 	}
9425f0
-	int line = 6;
9425f0
 	attrset(COLOR_PAIR(2));
9425f0
 	mvprintw(4, 3, "NUMBER          IS BANNED");
9425f0
-	for_each_cpu(all_cpus, print_cpu_line, &line);
9425f0
+	for_each_cpu(all_cpus, print_cpu_line, NULL);
9425f0
+	max_offset -= LINES - 8;
9425f0
+	if (max_offset < 0)
9425f0
+		max_offset = 0;
9425f0
 }
9425f0
 
9425f0
 void add_banned_cpu(int *banned_cpu, void *data)
9425f0
@@ -195,6 +219,7 @@ int toggle_cpu(GList *cpu_list, int cpu_number)
9425f0
 	} else {
9425f0
 		((cpu_ban_t *)(entry->data))->is_banned = 1;
9425f0
 	}
9425f0
+	((cpu_ban_t *)(entry->data))->is_changed = 1;
9425f0
 	return ((cpu_ban_t *)(entry->data))->is_banned;
9425f0
 }
9425f0
 
9425f0
@@ -239,18 +264,37 @@ void handle_cpu_banning()
9425f0
 			if(position > 6) {
9425f0
 				position--;
9425f0
 				move(position, 19);
9425f0
+			} else if (offset > 0) {
9425f0
+				offset--;
9425f0
+				max_offset = 0;
9425f0
+				for_each_cpu(tmp, print_tmp_cpu_line, NULL);
9425f0
+				max_offset -= LINES - 9;
9425f0
+				if (max_offset < 0)
9425f0
+					max_offset = 0;
9425f0
+				move(position, 19);
9425f0
 			}
9425f0
 			break;
9425f0
 		case KEY_DOWN:
9425f0
-			if(position <= g_list_length(all_cpus) + 4) {
9425f0
-				position++;
9425f0
+			if(position < (size_t)(LINES - 4)) {
9425f0
+				if (position <= g_list_length(all_cpus) + 4 - offset) {
9425f0
+					position++;
9425f0
+					move(position, 19);
9425f0
+				}
9425f0
+			} else if (offset < max_offset) {
9425f0
+				offset++;
9425f0
+				max_offset = 0;
9425f0
+				for_each_cpu(tmp, print_tmp_cpu_line, NULL);
9425f0
+				max_offset -= LINES - 9;
9425f0
+				if (max_offset < 0)
9425f0
+					max_offset = 0;
9425f0
 				move(position, 19);
9425f0
 			}
9425f0
 			break;
9425f0
 		case '\n':
9425f0
 		case '\r': {
9425f0
 			attrset(COLOR_PAIR(3));
9425f0
-			int banned = toggle_cpu(tmp, position - 6);
9425f0
+			int banned = toggle_cpu(tmp, position + offset - 6);
9425f0
+			mvprintw(position, 3, "CPU %d     ", position + offset - 6);
9425f0
 			if(banned) {
9425f0
 				mvprintw(position, 19, "YES");
9425f0
 			} else {
9425f0
@@ -263,8 +307,7 @@ void handle_cpu_banning()
9425f0
 		case 27:
9425f0
 			processing = 0;
9425f0
 			curs_set(0);
9425f0
-			/* Forget the changes */
9425f0
-			tmp = g_list_copy_deep(all_cpus, copy_cpu_ban, NULL);
9425f0
+			g_list_free(tmp);
9425f0
 			print_all_cpus();
9425f0
 			attrset(COLOR_PAIR(0));
9425f0
 			mvprintw(LINES - 3, 1, "			\
9425f0
@@ -278,6 +321,7 @@ void handle_cpu_banning()
9425f0
 			break;
9425f0
 		case 's':
9425f0
 			processing = 0;
9425f0
+			g_list_free(all_cpus);
9425f0
 			all_cpus = tmp;
9425f0
 			curs_set(0);
9425f0
 			print_all_cpus();
9425f0
@@ -324,9 +368,12 @@ void print_assigned_objects_string(irq_t *irq, int *line_offset)
9425f0
 	mvprintw(*line_offset, 68, "%s", assigned_to);
9425f0
 }
9425f0
 
9425f0
-void print_irq_line(irq_t *irq, void *data)
9425f0
+void print_tmp_irq_line(irq_t *irq, void *data __attribute__((unused)))
9425f0
 {
9425f0
-	int *line_offset = data;
9425f0
+	int line = max_offset - offset + 4;
9425f0
+	max_offset++;
9425f0
+	if (line < 4 || line >= LINES - 3)
9425f0
+		return;
9425f0
 	switch(irq->class) {
9425f0
 	case(IRQ_OTHER):
9425f0
 		attrset(COLOR_PAIR(1));
9425f0
@@ -352,23 +399,62 @@ void print_irq_line(irq_t *irq, void *data)
9425f0
 		attrset(COLOR_PAIR(0));
9425f0
 		break;
9425f0
 	}
9425f0
-	mvprintw(*line_offset, 3, "IRQ %d", irq->vector);
9425f0
-	mvprintw(*line_offset, 19, "%s", irq->is_banned ? "YES" : "NO ");
9425f0
-	mvprintw(*line_offset, 36, "%s",
9425f0
+	mvprintw(line, 3, "IRQ %d      ", irq->vector);
9425f0
+	mvprintw(line, 19, "%s", irq->is_banned ? "YES" : "NO ");
9425f0
+	mvprintw(line, 36, "%s               ",
9425f0
 			 irq->class < 0 ? "Unknown" : IRQ_CLASS_TO_STR[irq->class]);
9425f0
-	print_assigned_objects_string(irq, line_offset);
9425f0
-	(*line_offset)++;
9425f0
+	print_assigned_objects_string(irq, &line);
9425f0
+}
9425f0
 
9425f0
+void print_irq_line(irq_t *irq, void *data __attribute__((unused)))
9425f0
+{
9425f0
+	int line = max_offset - offset + 4;
9425f0
+	max_offset++;
9425f0
+	if (line < 4 || line >= LINES - 2)
9425f0
+		return;
9425f0
+	switch(irq->class) {
9425f0
+	case(IRQ_OTHER):
9425f0
+		attrset(COLOR_PAIR(1));
9425f0
+		break;
9425f0
+	case(IRQ_LEGACY):
9425f0
+		attrset(COLOR_PAIR(2));
9425f0
+		break;
9425f0
+	case(IRQ_SCSI):
9425f0
+		attrset(COLOR_PAIR(3));
9425f0
+		break;
9425f0
+	case(IRQ_VIDEO):
9425f0
+		attrset(COLOR_PAIR(8));
9425f0
+		break;
9425f0
+	case(IRQ_ETH):
9425f0
+	case(IRQ_GBETH):
9425f0
+	case(IRQ_10GBETH):
9425f0
+		attrset(COLOR_PAIR(9));
9425f0
+		break;
9425f0
+	case(IRQ_VIRT_EVENT):
9425f0
+		attrset(COLOR_PAIR(10));
9425f0
+		break;
9425f0
+	default:
9425f0
+		attrset(COLOR_PAIR(0));
9425f0
+		break;
9425f0
+	}
9425f0
+	mvprintw(line, 3, "IRQ %d", irq->vector);
9425f0
+	mvprintw(line, 19, "%s", irq->is_banned ? "YES" : "NO ");
9425f0
+	mvprintw(line, 36, "%s               ",
9425f0
+			 irq->class < 0 ? "Unknown" : IRQ_CLASS_TO_STR[irq->class]);
9425f0
+	print_assigned_objects_string(irq, &line);
9425f0
 }
9425f0
 
9425f0
 void print_all_irqs()
9425f0
 {
9425f0
-	int line = 4;
9425f0
+	max_offset = 0;
9425f0
 	attrset(COLOR_PAIR(0));
9425f0
 	mvprintw(2, 3,
9425f0
 			"NUMBER          IS BANNED        CLASS      \
9425f0
 			    ASSIGNED TO CPUS");
9425f0
-	for_each_irq(all_irqs, print_irq_line, &line);
9425f0
+	for_each_irq(all_irqs, print_irq_line, NULL);
9425f0
+	max_offset -= LINES - 6;
9425f0
+	if (max_offset < 0)
9425f0
+		max_offset = 0;
9425f0
 }
9425f0
 
9425f0
 int toggle_irq(GList *irq_list, int position)
9425f0
@@ -384,6 +470,7 @@ int toggle_irq(GList *irq_list, int position)
9425f0
 	} else {
9425f0
 		((irq_t *)(entry->data))->is_banned = 1;
9425f0
 	}
9425f0
+	((irq_t *)(entry->data))->is_changed = 1;
9425f0
 	return ((irq_t *)(entry->data))->is_banned;
9425f0
 }
9425f0
 
9425f0
@@ -431,18 +518,36 @@ void handle_irq_banning()
9425f0
 			if(position > 4) {
9425f0
 				position--;
9425f0
 				move(position, 19);
9425f0
+			} else if (offset > 0) {
9425f0
+				offset--;
9425f0
+				max_offset = 0;
9425f0
+				for_each_irq(tmp, print_tmp_irq_line, NULL);
9425f0
+				max_offset -= LINES - 7;
9425f0
+				if (max_offset < 0)
9425f0
+					max_offset = 0;
9425f0
+				move(position, 19);
9425f0
 			}
9425f0
 			break;
9425f0
 		case KEY_DOWN:
9425f0
-			if(position < g_list_length(all_irqs) + 3) {
9425f0
-				position++;
9425f0
+			if (position < (size_t)(LINES  - 4)) {
9425f0
+				if(position < g_list_length(all_irqs) + 3) {
9425f0
+					position++;
9425f0
+					move(position, 19);
9425f0
+				}
9425f0
+			} else if (offset < max_offset) {
9425f0
+				offset++;
9425f0
+				max_offset = 0;
9425f0
+				for_each_irq(tmp, print_tmp_irq_line, NULL);
9425f0
+				max_offset -= LINES - 7;
9425f0
+				if (max_offset < 0)
9425f0
+					max_offset = 0;
9425f0
 				move(position, 19);
9425f0
 			}
9425f0
 			break;
9425f0
 		case '\n':
9425f0
 		case '\r': {
9425f0
 			attrset(COLOR_PAIR(3));
9425f0
-			int banned = toggle_irq(tmp, position - 4);
9425f0
+			int banned = toggle_irq(tmp, position + offset - 4);
9425f0
 			if(banned) {
9425f0
 				mvprintw(position, 19, "YES");
9425f0
 			} else {
9425f0
@@ -456,7 +561,7 @@ void handle_irq_banning()
9425f0
 			processing = 0;
9425f0
 			curs_set(0);
9425f0
 			/* Forget the changes */
9425f0
-			tmp = g_list_copy_deep(all_irqs, copy_irq, NULL);
9425f0
+			g_list_free(tmp);
9425f0
 			print_all_irqs();
9425f0
 			attrset(COLOR_PAIR(0));
9425f0
 			mvprintw(LINES - 3, 1, "			\
9425f0
@@ -470,6 +575,7 @@ void handle_irq_banning()
9425f0
 			break;
9425f0
 		case 's':
9425f0
 			processing = 0;
9425f0
+			g_list_free(all_irqs);
9425f0
 			all_irqs = tmp;
9425f0
 			curs_set(0);
9425f0
 			print_all_irqs();
9425f0
@@ -548,11 +654,13 @@ void init()
9425f0
 		init_pair(10, COLOR_MAGENTA, COLOR_BLACK);
9425f0
 	}
9425f0
 
9425f0
+	offset = 0;
9425f0
 	display_tree();
9425f0
 }
9425f0
 
9425f0
 void close_window(int sig __attribute__((unused)))
9425f0
 {
9425f0
+	g_list_free(all_cpus);
9425f0
 	g_list_free(setup.banned_irqs);
9425f0
 	g_list_free(setup.banned_cpus);
9425f0
 	g_list_free_full(tree, free);
9425f0
@@ -595,10 +703,13 @@ void setup_irqs()
9425f0
 void display_tree_node_irqs(irq_t *irq, void *data)
9425f0
 {
9425f0
 	char indent[32] = "	   \0";
9425f0
-	snprintf(indent + strlen(indent), 32 - strlen(indent), "%s", (char *)data);
9425f0
-	attrset(COLOR_PAIR(3));
9425f0
-	printw("%sIRQ %u, IRQs since last rebalance %lu\n",
9425f0
+	if (max_offset >= offset && max_offset - offset < LINES - 5) {
9425f0
+		snprintf(indent + strlen(indent), 32 - strlen(indent), "%s", (char *)data);
9425f0
+		attrset(COLOR_PAIR(3));
9425f0
+		printw("%sIRQ %u, IRQs since last rebalance %lu\n",
9425f0
 			indent, irq->vector, irq->diff);
9425f0
+	}
9425f0
+	max_offset++;
9425f0
 }
9425f0
 
9425f0
 void display_tree_node(cpu_node_t *node, void *data)
9425f0
@@ -644,7 +755,9 @@ void display_tree_node(cpu_node_t *node, void *data)
9425f0
 	default:
9425f0
 		break;
9425f0
 	}
9425f0
-	printw("%s", copy_to);
9425f0
+	if (max_offset >= offset)
9425f0
+		printw("%s", copy_to);
9425f0
+	max_offset++;
9425f0
 	if(g_list_length(node->irqs) > 0) {
9425f0
 		for_each_irq(node->irqs, display_tree_node_irqs, indent);
9425f0
 	}
9425f0
@@ -661,7 +774,11 @@ void display_tree()
9425f0
 	char *irqbalance_data = get_data(STATS);
9425f0
 	parse_into_tree(irqbalance_data);
9425f0
 	display_banned_cpus();
9425f0
+	max_offset = 0;
9425f0
 	for_each_node(tree, display_tree_node, NULL);
9425f0
+	max_offset -= LINES - 5;
9425f0
+	if (max_offset < 0)
9425f0
+		max_offset = 0;
9425f0
 	show_frame();
9425f0
 	show_footer();
9425f0
 	refresh();
9425f0
diff --git a/ui/ui.h b/ui/ui.h
9425f0
index ca2a3a6..da5b4b9 100644
9425f0
--- a/ui/ui.h
9425f0
+++ b/ui/ui.h
9425f0
@@ -14,6 +14,9 @@
9425f0
 extern GList *tree;
9425f0
 extern setup_t setup;
9425f0
 
9425f0
+extern int offset;
9425f0
+extern int max_offset;
9425f0
+
9425f0
 void show_frame();
9425f0
 void show_footer();
9425f0
 
9425f0
-- 
9425f0
2.33.1
9425f0