heads-up: New ::stacks dcmd


Date: Fri, 6 Feb 2009 16:24:42 -0800
From: Jonathan Adams <jonathan.adams at sun dot com>
To: on-all at eng dot sun dot com, onnv-gate at onnv dot eng dot sun dot com
Subject: heads-up: New ::stacks dcmd

With my putback of:

6799290 need to uniquify stacks in kmdb

There is a new dcmd, ::stacks, in the genunix dmod.  If (like me) you find
yourself doing:

	> ::walk thread | ::findstack !/home/dep/bin/munges
	205     ##################################  tp: ffffff0003e11c60
	        swtch+0x200()
	        cv_wait+0x75()
	        taskq_thread+0x11c()
	        thread_start+8()
	...

reflexively, you'll be happy to know that that's now much shorter (and
faster, especially if dep's home-directory is offline):

	> ::stacks
	THREAD           STATE    SOBJ                COUNT
	ffffff0003e11c60 SLEEP    CV                    205
	                 swtch+0x200
	                 cv_wait+0x75
	                 taskq_thread+0x11c
	                 thread_start+8

	ffffff0154567aa0 SLEEP    CV                     62
	                 swtch+0x200
	                 cv_wait_sig_swap_core+0x170
	                 cv_wait_sig_swap+0x18
	                 cv_waituntil_sig+0x135
	                 poll_common+0x4b5
	                 pollsys+0xe4
	                 sys_syscall32+0x1fc
	[ ... elided ... ]
	fffffffffbc3ae20 STOPPED  <NONE>                  1
	                 swtch+0x200
	                 sched+0x44f
	                 main+0x486

	ffffff016bf7de20 STOPPED  <NONE>                  1
	                 swtch+0x200
	                 stop+0x84c
	                 isjobstop+0xc4
	                 issig_forreal+0x4dc
	                 issig+0x24
	                 cv_wait_sig_swap_core+0x206
	                 cv_wait_sig_swap+0x18
	                 waitid+0x2a0
	                 waitsys32+0x30
	                 sys_syscall32+0x1fc
	>

It also has the advantage of working in KMDB.  I hope you find it
useful; the help text follows.

Cheers,
- jonathan

> ::help stacks

NAME
  stacks - print unique kernel thread stacks

SYNOPSIS
  [ addr ] ::stacks [-afilv] [-c func] [-C func] [-s sobj | -S sobj] [-t tstate
| -T tstate]

DESCRIPTION
  ::stacks processes all of the thread stacks on the system, grouping
  together threads which have the same:

    * Thread state,
    * Sync object type, and
    * PCs in their stack trace.

  The default output (no address or options) is just a dump of the thread
  groups in the system.  For a view of active threads, use "::stacks -i",
  which filters out FREE threads (interrupt threads which are currently
  inactive) and threads sleeping on a CV. (Note that those threads may still
  be of note; this is just for a first glance.)  More general filtering
  options are described below, in the "FILTERS" section.

  ::stacks can be used in a pipeline.  The input to ::stacks is one or more
  thread pointers.  For example, to get a summary of threads in a process,
  you can do:

    procp::walk thread | ::stacks

  When output into a pipe, ::stacks prints all of the threads input,
  filtered by the given filtering options.  This means that multiple
  ::stacks invocations can be piped together to achieve more complicated
  filters.  For example, to get threads which have both 'fop_read' and
  'cv_wait_sig_swap' in their stack trace, you could do:

    ::stacks -c fop_read | ::stacks -c cv_wait_sig_swap_core

  To get the full list of threads in each group, use the '-a' flag:

    ::stacks -a

OPTIONS
    -a    Print all of the grouped threads, instead of just a count.
    -f    Force a re-run of the thread stack gathering
    -v    Be verbose about thread stack gathering.

FILTERS
    -i    Show active threads; equivalent to '-S CV -T FREE'.
    -c func[+offset]
          Only print threads whose stacks contain func/func+offset.
    -C func[+offset]
          Only print threads whose stacks do not contain func/func+offset.
    -s {type | ALL}
          Only print threads which are on a 'type' synchronization object
          (SOBJ).
    -S {type | ALL}
          Only print threads which are not on a 'type' SOBJ.
    -t tstate
          Only print threads which are in thread state 'tstate'.
    -T tstate
          Only print threads which are not in thread state 'tstate'.

     SOBJ types: mutex rwlock cv sema user user_pi shuttle
  Thread states: free sleep run onproc zomb stopped wait panic

ATTRIBUTES

  Target: kvm
  Module: genunix
  Interface Stability: Unstable

last modified by alanbur on 2009/11/20 23:48
Collectives
Project


© Sun Microsystems Inc. 2009
XWiki Enterprise 1.8.2.19075 - Documentation
Terms Of Use | Privacy | Trademarks | Copyright Policy | Site Guidelines | Site map | Help
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Use.