RFC: Sorting in top -m io

Dan Nelson dnelson at allantgroup.com
Thu Jul 8 10:49:12 PDT 2004


In the last episode (Jul 08), Giorgos Keramidas said:
> On 2004-07-08 12:07, Dan Nelson <dnelson at allantgroup.com> wrote:
> > In the last episode (Jul 08), Alfred Perlstein said:
> > > * Giorgos Keramidas <keramida at freebsd.org> [040708 05:45] wrote:
> > > >
> > > > The new -m io option of top is cool, but sorting ...
> > >
> > > I think it's awesome.  Go for it.
> >
> > docs are still missing: manpage, top Usage string, and "?" help all
> > need to describe the -m flag and 'm' key.
> 
> Err, yeah.  I should have waited.  I have a few changes to the manpage
> at home.  In a couple of hours they should be ready and into shape for
> commiting.
> 
> > Since there's room, context-switch info would also be neat to display.
> 
> I'm not sure I can tackle this.  I have close to nil experience with
> the stuff top uses to extract the useful information from the kernel.
> Copy-pasting and tinkering a bit with a few OO-like sort methods
> wasn't very hard but for anything else I'll have to read a lot of
> stuff :-)

It's just extracting stuff out of the rusage struct for each process. 
Take a look around line 661 of machine.c; you can see it's getting the
deltas between two rusage structs for certain members.  Just add lines
for ru.ru_nvcsw and ru_nivcsw, and fix up the printf on line 674 and
the definitions of io_header and io_Proc_format around line 96 to
display the fields.

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-current mailing list