bin/101975: [PATCH] Adding percents in /usr/src/usr.bin/systat/pigs.c

Bruce Evans bde at
Wed Aug 16 13:06:55 UTC 2006

[Private reply]

Hi Giorgos,

> On 2006-08-14 14:54, bsd at wrote:
> > Sorry, but i'm only based in 'systat -swaps', where shows it:
> > Disk 1K-blocks     Used  /0%  /10% /20% /30% /40% /50% /60% /70% /80% /90% /100%
> > ad0s1  8388480     1076  X
> There is no % after 100 in "systat -swap".  Precisely because all those
> % characters push the line length up to almost 80 characters and this
> would overflow 80x25 terminal lines.

The truncation seems to depend on whether swap is configured.  With
no swap configured, the display is a mess and looks like "...10\n0<garbage>.
It looks like it started with 100% and truncated to 100 but was still
too long so the line wrapped.  I suspect that it truncates at 80 columns
and wraps at 79 columns.  With 1 swap device configured, this display
is less of a mess and looks like "...10\n<non-garbage>.  I suspect
that it still mistruncates and wraps, but the line for the first swap
device starts at column 1 and overwrites the garbage.

It seems unlikely that the scale is correct with the %'s expanding things.
It's hard to tell -- I never use swap on systems with more than 64MB of
memory, and most systems have lots of swap and use epsilon% of it.

> I'm not sure it's worth repeating the same 'hack' in other screens, but
> I'd certainly prefer any of:
> Disk 1K-blocks     Used  /0  /10 /20 /30 /40 /50 /60 /70 /80 /90 /100%
> Disk 1K-blocks     Used  /0% /10 /20 /30 /40 /50 /60 /70 /80 /90 /100

% at the end looks good.  Some other displays use "%foo N1...Nk" instead of
foo "N1%...Nk%" to save space.

Looking at the pigs display reminded me that it shows bogus idle
percentages.  On an idle machine with N CPUs, after warming up it shows
<idle> taking about 100/(N+1)% and N idle threads also taking 100/(N+1)%.
top -S shows the idle threads correctly as taking almost 100%.  I think
the problem is that it doesn't understand the per-cpu idle thread.  It
might also not understand idle priority threads.


More information about the freebsd-bugs mailing list