=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/top/display.c,v retrieving revision 1.54 retrieving revision 1.55 diff -c -r1.54 -r1.55 *** src/usr.bin/top/display.c 2018/01/04 17:44:20 1.54 --- src/usr.bin/top/display.c 2018/09/26 17:23:13 1.55 *************** *** 1,4 **** ! /* $OpenBSD: display.c,v 1.54 2018/01/04 17:44:20 deraadt Exp $ */ /* * Top users/processes display for Unix --- 1,4 ---- ! /* $OpenBSD: display.c,v 1.55 2018/09/26 17:23:13 cheloha Exp $ */ /* * Top users/processes display for Unix *************** *** 125,133 **** int display_resize(void) { ! int display_lines; ! int cpu_lines = (combine_cpus ? 1 : ncpu); y_mem = 2 + cpu_lines; y_header = 4 + cpu_lines; y_procs = 5 + cpu_lines; --- 125,135 ---- int display_resize(void) { ! int cpu_lines, display_lines, ncpuonline; + ncpuonline = getncpuonline(); + cpu_lines = (combine_cpus ? 1 : ncpuonline); + y_mem = 2 + cpu_lines; y_header = 4 + cpu_lines; y_procs = 5 + cpu_lines; *************** *** 136,142 **** /* if operating in "dumb" mode, we only need one line */ display_lines = smart_terminal ? screen_length - y_procs : 1; ! y_idlecursor = y_message = 3 + (combine_cpus ? 1 : ncpu); if (screen_length <= y_message) y_idlecursor = y_message = screen_length - 1; --- 138,144 ---- /* if operating in "dumb" mode, we only need one line */ display_lines = smart_terminal ? screen_length - y_procs : 1; ! y_idlecursor = y_message = 3 + cpu_lines; if (screen_length <= y_message) y_idlecursor = y_message = screen_length - 1; *************** *** 377,389 **** } void ! i_cpustates(int64_t *ostates) { ! int i, first, cpu; double value; int64_t *states; char **names, *thisname; if (combine_cpus) { static double *values; if (!values) { --- 379,397 ---- } void ! i_cpustates(int64_t *ostates, int *online) { ! int i, first, cpu, ncpuonline; double value; int64_t *states; char **names, *thisname; + ncpuonline = 0; + for (i = 0; i < ncpu; i++) { + if (online[i]) + ncpuonline++; + } + if (combine_cpus) { static double *values; if (!values) { *************** *** 393,398 **** --- 401,408 ---- } memset(values, 0, num_cpustates * sizeof(*values)); for (cpu = 0; cpu < ncpu; cpu++) { + if (!online[cpu]) + continue; names = cpustate_names; states = ostates + (CPUSTATES * cpu); i = 0; *************** *** 409,419 **** first = 0; move(2, 0); clrtoeol(); ! printwp("%-3d CPUs: ", ncpu); while ((thisname = *names++) != NULL) { if (*thisname != '\0') { ! value = values[i++] / ncpu; /* if percentage is >= 1000, print it as 100% */ printwp((value >= 1000 ? "%s%4.0f%% %s" : "%s%4.1f%% %s"), first++ == 0 ? "" : ", ", --- 419,429 ---- first = 0; move(2, 0); clrtoeol(); ! printwp("%-3d CPUs: ", ncpuonline); while ((thisname = *names++) != NULL) { if (*thisname != '\0') { ! value = values[i++] / ncpuonline; /* if percentage is >= 1000, print it as 100% */ printwp((value >= 1000 ? "%s%4.0f%% %s" : "%s%4.1f%% %s"), first++ == 0 ? "" : ", ", *************** *** 430,442 **** first = 0; states = ostates + (CPUSTATES * cpu); ! if (screen_length > 2 + cpu || !smart_terminal) { move(2 + cpu, 0); clrtoeol(); addstrp(cpustates_tag(cpu)); while ((thisname = *names++) != NULL) { if (*thisname != '\0') { /* retrieve the value and remember it */ value = *states++; --- 440,459 ---- first = 0; states = ostates + (CPUSTATES * cpu); ! if ((screen_length > 2 + cpu && 2 + cpu < y_mem) || ! !smart_terminal) { move(2 + cpu, 0); clrtoeol(); addstrp(cpustates_tag(cpu)); while ((thisname = *names++) != NULL) { if (*thisname != '\0') { + if (!online[cpu]) { + printwp("%s%5s %s", + first++ == 0 ? "" : ", ", + "-", thisname); + continue; + } /* retrieve the value and remember it */ value = *states++;