On Thu, May 04, 2006 at 02:57:03PM -0700, Alexander Kolbasov wrote:
> > Alexander Kolbasov <akolb at eng.sun.com> writes:
> > 
> > > There are numerous cases in the kernel code where bitmaps are used to 
> > > represent sets of non-negative integers (e.g. sets of CPU IDs). I suggest 
> > > an 
> > > RFE for a new command that will print such sets as a list of integers 
> > > (possibly collapsing consecutive ranges to x-y).
> > >
> > > For example, it can be something like
> > >
> > > cpu_ready_set ::print_set
> > > 0-32
> > >
> > > Do you think it is worth while and generic enough?
> > >
> > 
> > This seems like it would be:
> > CR 6265065 Add ::bitset dcmd to print bitsets
> > 
> > Or at least closely related to it.
> 
> Uff, I filed 6265065 a year ago and forgot about it by now :-). Seems that it 
> didn't get any comments from MDB experts at the time. BTW, here is the full 
> implementation from the bug report (missing the command inclusion in 
> recognizable command list):
> 
> /* ARGSUSED */
> int
> bitset(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
> {
>         uint64_t set = (uint64_t)addr;
>         uint64_t mask = 1;
>         int i = 0;
> 
>         if (!(flags & DCMD_ADDRSPEC)) {
>                 mdb_warn("usage: set ::bitset");
>                 return (DCMD_ERR);
>         }
> 
>         if (set == 0)
>                 return (DCMD_OK);
> 
>         for (; set != (uint64_t)0; i++, mask <<= 1) {
>                 if (set & mask) {
>                         mdb_printf("%d ", i);
>                         set &= ~mask;
>                 }
>         }
>         mdb_printf("\n");
>         return (DCMD_OK);
> }
> 
> This doesn't collapse ranges, though.

You'd really want it to handle arrays of uint_ts or ulong_ts.  Which makes you
really want a ::cpuset dcmd, which knows how to print out CPU sets, no matter
what the size.

Looking in mdb, one already exists:

> cpu_ready_set::cpuset
0-1
> cpu_ready_set::cpuset -l
0
1

It's implemented in sun4u/modules/unix/unix.c.  So it clearly needs to be
genericized for use on x86/amd64.

Cheers,
- jonathan

-- 
Jonathan Adams, Solaris Kernel Development

Reply via email to