top(1): Don't show the swap line when there are no swap devices
Submitted by: antranigv@freebsd.am Reviewed by: bapt MFC after: 1 month Sponsored by: Klara Systems Differential Revision: https://reviews.freebsd.org/D18928
This commit is contained in:
parent
8bd416a216
commit
2984a71677
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=349235
@ -675,6 +675,9 @@ i_swap(int *stats)
|
||||
{
|
||||
swap_buffer = setup_buffer(swap_buffer, 0);
|
||||
|
||||
if (swap_names == NULL)
|
||||
return;
|
||||
|
||||
fputs("\nSwap: ", stdout);
|
||||
lastline++;
|
||||
|
||||
@ -690,6 +693,9 @@ u_swap(int *stats)
|
||||
|
||||
new = setup_buffer(new, 0);
|
||||
|
||||
if (swap_names == NULL)
|
||||
return;
|
||||
|
||||
/* format the new line */
|
||||
summary_format(new, stats, swap_names);
|
||||
line_update(swap_buffer, new, x_swap, y_swap);
|
||||
|
@ -150,6 +150,7 @@ static const char *swapnames[] = {
|
||||
};
|
||||
static int swap_stats[nitems(swapnames)];
|
||||
|
||||
static int has_swap;
|
||||
|
||||
/* these are for keeping track of the proc array */
|
||||
|
||||
@ -248,12 +249,12 @@ update_layout(void)
|
||||
y_mem = 3;
|
||||
y_arc = 4;
|
||||
y_carc = 5;
|
||||
y_swap = 4 + arc_enabled + carc_enabled;
|
||||
y_idlecursor = 5 + arc_enabled + carc_enabled;
|
||||
y_message = 5 + arc_enabled + carc_enabled;
|
||||
y_header = 6 + arc_enabled + carc_enabled;
|
||||
y_procs = 7 + arc_enabled + carc_enabled;
|
||||
Header_lines = 7 + arc_enabled + carc_enabled;
|
||||
y_swap = 3 + arc_enabled + carc_enabled + has_swap;
|
||||
y_idlecursor = 4 + arc_enabled + carc_enabled + has_swap;
|
||||
y_message = 4 + arc_enabled + carc_enabled + has_swap;
|
||||
y_header = 5 + arc_enabled + carc_enabled + has_swap;
|
||||
y_procs = 6 + arc_enabled + carc_enabled + has_swap;
|
||||
Header_lines = 6 + arc_enabled + carc_enabled + has_swap;
|
||||
|
||||
if (pcpu_stats) {
|
||||
y_mem += ncpus - 1;
|
||||
@ -273,7 +274,7 @@ machine_init(struct statics *statics)
|
||||
{
|
||||
int i, j, empty, pagesize;
|
||||
uint64_t arc_size;
|
||||
int carc_en;
|
||||
int carc_en, nswapdev;
|
||||
size_t size;
|
||||
|
||||
size = sizeof(smpmode);
|
||||
@ -298,6 +299,11 @@ machine_init(struct statics *statics)
|
||||
if (kd == NULL)
|
||||
return (-1);
|
||||
|
||||
size = sizeof(nswapdev);
|
||||
if (sysctlbyname("vm.nswapdev", &nswapdev, &size, NULL,
|
||||
0) == 0 && nswapdev != 0)
|
||||
has_swap = 1;
|
||||
|
||||
GETSYSCTL("kern.ccpu", ccpu);
|
||||
|
||||
/* this is used in calculating WCPU -- calculate it ahead of time */
|
||||
@ -332,7 +338,10 @@ machine_init(struct statics *statics)
|
||||
statics->carc_names = carcnames;
|
||||
else
|
||||
statics->carc_names = NULL;
|
||||
statics->swap_names = swapnames;
|
||||
if (has_swap)
|
||||
statics->swap_names = swapnames;
|
||||
else
|
||||
statics->swap_names = NULL;
|
||||
statics->order_names = ordernames;
|
||||
|
||||
/* Allocate state for per-CPU stats. */
|
||||
|
Loading…
Reference in New Issue
Block a user