hyptop: Add physical information row

Introduce a new row to represent the underlying physical machine
and the physical information hyptop gathers from diag.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This commit is contained in:
Mete Durlu
2025-12-03 12:48:29 +01:00
committed by Steffen Eiden
parent c403208332
commit 1771e7f2f3
7 changed files with 58 additions and 6 deletions

View File

@@ -383,6 +383,6 @@ int dg_debugfs_lpar_init(void)
return fh;
else
close(fh);
sd_dg_register(&l_sd_dg, 1);
sd_dg_register(&l_sd_dg, 1, 1);
return 0;
}

View File

@@ -358,6 +358,6 @@ int dg_debugfs_vm_init(void)
close(fh);
l_2fc_buf_size = sizeof(struct l_debugfs_d2fc_hdr);
l_guest_name_init();
sd_dg_register(&dg_debugfs_vm_dg, 0);
sd_dg_register(&dg_debugfs_vm_dg, 0, 0);
return 0;
}

View File

@@ -19,6 +19,7 @@
#define SD_DG_INIT_INTERVAL_SEC 1
#define SD_SYS_ID_SIZE 9
#define SD_SYS_DEFAULT_ID "PHYSICAL"
/*
* CPU info
@@ -449,7 +450,8 @@ struct sd_dg {
struct sd_cpu_item **cpu_item_enable_vec;
};
void sd_dg_register(struct sd_dg *, int);
void sd_dg_register(struct sd_dg *, int, int);
int sd_dg_has_phys_data(void);
int sd_dg_has_core_data(void);
/*

View File

@@ -26,6 +26,7 @@ static int l_cpu_type_cnt;
static int l_sys_item_cnt;
static int l_cpu_item_cnt;
static int l_has_core_data;
static int l_has_phys_data;
static struct sd_sys *l_root_sys;
/*
@@ -148,7 +149,7 @@ void sd_update(void)
/*
* Register a data gatherer
*/
void sd_dg_register(struct sd_dg *dg, int has_core_data)
void sd_dg_register(struct sd_dg *dg, int has_core_data, int has_phys_data)
{
struct timespec ts = {SD_DG_INIT_INTERVAL_SEC, 0};
struct sd_sys_item *sys_item;
@@ -156,6 +157,7 @@ void sd_dg_register(struct sd_dg *dg, int has_core_data)
unsigned int i;
l_has_core_data = has_core_data;
l_has_phys_data = has_phys_data;
sd.dg = dg;
for (i = 0; dg->cpu_type_vec[i]; i++)
dg->cpu_type_vec[i]->idx = (1UL << i);
@@ -172,6 +174,14 @@ void sd_dg_register(struct sd_dg *dg, int has_core_data)
l_cpu_types_init();
}
/*
* Does backend has physical CPUs data?
*/
int sd_dg_has_phys_data(void)
{
return l_has_phys_data;
}
/*
* Does backend has core data?
*/
@@ -419,7 +429,7 @@ int sd_cpu_item_cnt(void)
*/
void sd_init(void)
{
l_root_sys = sd_sys_new(NULL, "root");
l_root_sys = sd_sys_new(NULL, SD_SYS_DEFAULT_ID);
}
/*

View File

@@ -260,6 +260,10 @@ void table_row_del_all(struct table *t)
util_list_remove(&t->row_list, row);
table_row_free(row);
}
if (t->row_physical) {
table_row_free(t->row_physical);
t->row_physical = NULL;
}
l_row_last_init(t);
t->row_cnt_marked = 0;
t->ready = 0;
@@ -418,6 +422,8 @@ static void l_row_last_calc(struct table *t)
*/
void table_finish(struct table *t)
{
if (t->row_physical)
l_row_format(t, t->row_physical);
l_row_last_calc(t);
t->ready = 1;
}
@@ -463,6 +469,8 @@ void table_rebuild(struct table *t)
l_col_max_width_init(t, col);
util_list_iterate(&t->row_list, row)
l_row_format(t, row);
if (t->row_physical)
l_row_format(t, t->row_physical);
l_row_format(t, t->row_last);
}
@@ -921,6 +929,10 @@ static void l_table_print_curses(struct table *t)
}
ht_reverse_on();
l_row_print(t, t->row_last);
if (t->row_physical) {
hyptop_print_nl();
l_row_print(t, t->row_physical);
}
hyptop_print_seek_back(0);
ht_reverse_off();
#ifdef WITH_SCROLL_BAR
@@ -952,6 +964,10 @@ static void l_table_print_all(struct table *t)
}
l_row_print(t, t->row_last);
hyptop_print_nl();
if (t->row_physical) {
l_row_print(t, t->row_physical);
hyptop_print_nl();
}
hyptop_printf("------------------------------------------------------"
"-------------------------\n");
}
@@ -991,6 +1007,11 @@ static void l_table_print_all_formatted(struct table *t)
util_fmt_pair(FMT_PERSIST, "iteration", "%u", g.o.iterations_act);
ht_fmt_time();
ht_fmt_cpu_types();
if (t->row_physical) {
util_fmt_obj_start(FMT_ROW, "physical_information");
l_row_print_formatted(t, t->row_physical);
util_fmt_obj_end(); /* physical_information{} */
}
if (strcmp(g.o.cur_win->id, "sys_list") == 0)
util_fmt_obj_start(FMT_LIST, "systems");
else

View File

@@ -324,6 +324,7 @@ struct table {
struct table_col **col_vec;
struct table_col *col_selected;
struct table_row *row_last;
struct table_row *row_physical;
int row_cnt;
int row_cnt_marked;
int row_cnt_extra;

View File

@@ -162,6 +162,22 @@ static void l_sys_item_add(struct table_row *table_row, struct sd_sys *sys,
}
}
static void l_row_add_physical(struct table *t, struct sd_sys *sys)
{
struct sd_sys_item *item;
struct table_row *row;
unsigned int i;
row = table_row_alloc(t);
table_row_entry_str_add(row, &l_col_sys, sd_sys_id(sys));
sd_sys_item_iterate(item, i) {
if (!sd_sys_item_set(sys, item))
continue;
l_sys_item_add(row, sys, item);
}
t->row_physical = row;
}
/*
* Add system to table
*/
@@ -196,6 +212,8 @@ static void l_table_create(void)
continue;
l_sys_add(guest);
}
if (sd_dg_has_phys_data())
l_row_add_physical(l_t, parent);
table_finish(l_t);
}
@@ -337,7 +355,7 @@ void win_sys_list_init(void)
int item_cnt;
/* Alloc table and add columns */
l_t = table_new(1, 1, 1, 1);
l_t = table_new(2, 1, 1, 1);
table_col_add(l_t, &l_col_sys);
item_cnt = sd_sys_item_cnt() + 1;