Other macros

Other macros that may be of interest are the cdevsw and fmodsw macros. They can be used to view all the character device switch tables and the module switch tables. They both contain pointers to the streamtab structure which are d_str and f_str respectively. Every module and driver must be identified by either cdevsw[] or fmodsw[]. To view all of the entries in the fmodsw table, use:

S> fmodsw+ fmodsw
f_name ldterm /* name of module */
f_str D019D688 /* pointer to streamtab struct */
f_flag D019D698 /* same as device flag */
f_cpu 000C0000 /* MP cpu binding */
S> nx
f_name ansi
f_str D019D738
f_flag D019D748
f_cpu 000C0000
S> nx
...

Use 'cdevsw+ cdevsw' to see all of the character device switch table entries. The linkblk structure defines the number of strinfo structures that will be allocated. The structure is passed in a message and is part of the multiplexor driver. A macro called linkblk is provided so that the entries can be analyzed. Please obtain the stream.k file from Appendix C2 before using linkblk.

Figure 11 (struct linkblk)

  S>linkblk
LINKBLK TABLE SIZE = 22
LBLKADDR QTOP QBOT FILEADDR MUXID
D159C680 00000000 D158F64C D139235C 022
D159CC80 00000000 D158F74C D1392404 021
D158FC40 00000000 D158E54C D1391498 020
D158EA00 00000000 D155DF4C D1392458 019
D155D840 00000000 D155CE4C D1392944 018
D155C580 00000000 D157154C D13927F4 017
D1571840 00000000 D157164C D13928F0 016
D14A4B80 00000000 D14A4A4C D1393370 015
D14A34C0 00000000 D14A354C D13933C4 014
D14A3DC0 00000000 D14A3E4C D1393418 013
D1498D00 00000000 D14A684C D139346C 012
D14A2700 00000000 D14A234C D13934C0 011
D14A2D40 00000000 D14A2C4C D1393514 010
D149D900 00000000 D149D74C D1393568 009
D149C2C0 00000000 D149C34C D13935BC 008
D149CBC0 00000000 D149CC4C D1393610 007
D149BA00 00000000 D149B64C D1393664 006
D149A500 00000000 D149BF4C D13936B8 005
D149AE00 00000000 D149AA4C D139370C 004
D1499640 00000000 D149954C D1393760 003
D1498340 00000000 D149824C D13937B4 002
D1497C80 00000000 D149794C D1393808 001

In this case, 22 strinfo structures have been allocated. The LBLKADDR field is a pointer to the linkblk structure. QTOP is a pointer to the lowest level write queue of the upper stream, but is always NULL. QBOT is a pointer to the highest level write queue of the lower stream. In our implementation, it is the same as the 'bsrv' field of streams so it is a pointer to the back service queue for backenable. The FILEADDR field contains a file pointer for the lower stream. It is actually obtained from the linkinfo structure (see /usr/include/sys/strsubr.h). The MUXID is a unique id for each connection which is used for routing and is the return value of the I_LINK ioctl.


S> strmsg D1A69A20
msgb type rf size psize next
D1A69A20 01 PROTO 01 00000100 0000003C D1649FA0
D170C9C0 00 DATA 01 00000100 00000028 00000000
D15224C0 00 DATA 02 00000100 00000001 00000000
D15224C0 00 DATA 02 00000100 00000001 00000000
D1649FA0 01 PROTO 01 00000100 0000003C D1AEBFE0
D1A6D980 00 DATA 01 00000100 00000028 00000000
... D1D82FC0 01 PROTO 01 00000100 00000018 00000000
D1D6B4E0 00 DATA 01 00000100 00000028 00000000
D1D82FE0 00 DATA 02 00000100 00000001 00000000
D1D82FE0 00 DATA 02 00000100 00000001 00000000

Another way to view all the queues that have data is to use the cqueue macro which requires no arguments.


S> cqueue
queue bsrv idname ptr count cpu plumbing:sched:flag
D158754C D1AEDE4C tcp D1942300 189 UBND PROCSON WANTR USE
D1AA3C4C D17F944C tcp D1A63480 1204 UBND PROCSON WANTR USE
D191244C D1932A4C tcp D1A43E00 1538 UBND PROCSON WANTR USE
D174264C D166EF4C tcp D1A4FF80 2021 UBND PROCSON WANTR USE
D16F9E4C D1A87D4C tcp D17AA400 2220 UBND PROCSON WANTR USE
D159A54C D1ADA54C tcp D1AED780 4719 UBND PROCSON WANTR USE
D180134C D14D3E4C tcp D1A76B80 4142 UBND PROCSON WANTR USE
D1AC474C D17E7B4C tcp D178A500 96 UBND PROCSON WANTR USE
D18E034C D170974C tcp D1848880 1139 UBND PROCSON WANTR USE
D16E524C D1A9FD4C tcp D1864C00 3114 UBND PROCSON WANTR USE
D1AEAD4C D17B2F4C tcp D1ADC780 1270 UBND PROCSON WANTR USE
D1AC044C D1AA6F4C tcp D14A5F00 7240 UBND PROCSON WANTR USE
D158FA4C D158FD4C strm 00000000 32808 0000 PROCSON WANTW FULL USE
D158FB4C D158FA4C ethernet D15094EC 32903 0000 PROCSON WANTW FULL USE
D158FD4C D158E54C strc D158FC80 12411 UBND PROCSON WANTW FULL USE
1172. queues, Strinfo.cnt = 1172.

Then one could use the queue macro above to examine these queues as well.

To view the stream statistics, use the strstat macro:


S> strstat
[D0241370] [D0264830]
inuse (Strinfo) total max fail
stream 000000AF(000000AF) 000004B8 000000CB 00000000
queue 00000494(00000494) 00001618 0000054C 00000000
msgblock 00003739(000040EE) 0197AC88 000040EE 00000000
mdbblock 0000359F(00003A83) 0162F9FB 00003A79 00000007
linkblk 00000016(00000016) 00000016 00000016 00000000
strevent 00000008(00000008) 00000008 00000008 00000000
Total byte count = 00459BBF
strthresh = 00000000

In this case, we see that there are 7 failures in mdbblock. We would then run something like kmeminfo to check if there are kernel memory failures as well as look for full streams. strfollow - give address of a stream queue


S> strfollow D158FD00
Upstream from queue D158FD00:
queue    bsrv     idname   ptr   count cpu plumbing:sched:flag
D158FD00 D158FA00 strc     D158FC80 00 UBND PROCSON WANTR READR USE
D158E500 D158FA00 ip       D021A28C 00 UBND PROCSON MUXLOW WANTR READR USE
dstrcalls- The dstrcalls macro is given the arguments *strbcalls and 0 (zero). It is mainly used by the whatswrong macro. It displays stream events that could not be processed. This macro only generates information if strbcalls is non-zero.

First, check that strbcalls is greater than zero:


S> dl strbcalls
strbcalls:  D1791300 D1791300 00000000 00000000  ..y...y.........  .
If the first field is non-zero, then use:


S> do dstrcalls *strbcalls 0
0  D1791300  setrun D1295A00 0804B65C 0
1  D1791330  20202025 20202020 6E69682F 20202076
2  D1791360  D195CD40 D1932D20 D1791360 1
3  D1791390  04018280 0000061A 00000000 0
/*note Ron C. thinks that this macro is not completely correct. He will let me know */ msgques The msgques macro displays the active message queue. It is like running 'ipcs -q' on a live system.


  S> msgques
  Id    Addr     first    last   uid gid qbytes cbytes q_num spid rpid mode
  000 D0219C98 00000000 00000000 000 068  6000   0000   000  2200 0EB0 83B6
  001 D0219D08 D0259E80 D0259E60 000 068  8000   0138   006  0EB0 2364 81B6
queowner - give address of a queue to find the owner /* Note, for queowner to work, please pick up the modified file.k macro in Appendix C2 */


S> queowner D1AA3C4C
Proc D1530200 Name: in.rlogind
 #  File      Vnode     Stream
[24] D1ADB200  D1703804  D1A78380
[23] D1ADB200  D1703804  D1A78380
[22] D1ADB200  D1703804  D1A78380
queuerun-Disply streams and queue information for queues waiting to be run


S> queuerun
D14DEC00
stream D14DEF80  iocwwait 0000  rerr 00000000   werr 00000000  pushcnt 00000000
flag   00000040: STPLEX     sigflg 00000000:
evflag 00000000:     pollevents 0000:
sd_vnode     D14B1304:
dev             30/00:
sd_sidp      00000000:
sd_pgidp     00000000:
sd_eventlist 00000000:

stream_lckp D14B0500
queues D14B1200, D14B124C
Downstream from queue D14B124C:
queue    bsrv     idname   ptr   count cpu plumbing:sched:flag
D14B124C D14DEC4C strc     D14DEF80 00 0000 PROCSON WANTR USE
D14DEB4C D14B124C strm     00000000 00 UBND PROCSON WANTR USE
D14DED4C D14DEB4C strm     00000000 00 0000 PROCSON WANTR USE
D14DEE4C D14DED4C kd       D015281C 00 0000 PROCSON WANTR USE
Upstream from queue D14DEE00:
queue    bsrv     idname   ptr   count cpu plumbing:sched:flag
D14DEE00 00000000 kd       D015281C 00 0000 PROCSON WANTR READR USE
D14DED00 00000000 strm     00000000 00 UBND PROCSON WANTR READR USE
D14DEB00 D14DED00 strm     00000000 00 0000 PROCSON WANTR READR USE
D14B1200 D14DEB00 strc     D14DEF80 00 0000 PROCSON WANTR READR USE
D14DEC00 D14DEB00 cmux     D139BE30 22 0000 PROCSON ENABLED MUXLOW WANTR READR U
SE
queues_flag - Display the queues summary information.


S> queues_flag
queue    bsrv     idname   ptr   count cpu plumbing:sched:flag
1172. queues, Strinfo.cnt = 1172.

semques Print information about active semaphore queues


  S> semques
  Id    Addr     first    last   uid gid qbytes cbytes q_num spid rpid mode
  001 D0219D08 D0259E80 D0259E60 000 068  8000   0138   006  0EB0 2364 81B6
sockets - Display the active sockets.


   S> sockets
   000 D0266B44
   001 D0266C44
   002 D0266D44
   003 D0266E44
   004 D0266F44
   005 D0267044
   006 D0267144
   007 D0267244
...
   554 D02BBF44
   557 D02BC244
   55A D02BC544
   #### D02BF044: page table entry not valid (1AFC:0)

/* no new file found on fishface:/usr/local/macros/1.3/new/
   Ron C. is working on a fix */
strowner - The strowner macro is given one argument, the address of a stream. Given a stream, it will scan the process list and display all processes which have the stream open, along with the file and vnode pointers associated with the open stream.


S> strowner D1A92C80
Proc D1B16400 Name: /u/lotus/123.v10/sysV386/dvr/l13pgc.dvr
 #  File      Vnode     Stream
[22] D1AE0680  D1A7D204  D1A92C80
Proc D1B26C00 Name: /u/lotus/123.v10/sysV386/bin/123_exe
 #  File      Vnode     Stream
[24] D1AE0680  D1A7D204  D1A92C80
[23] D1AE0680  D1A7D204  D1A92C80
[22] D1AE0680  D1A7D204  D1A92C80
Proc D16C1000 Name: -sh
 #  File      Vnode     Stream
[24] D1AE0680  D1A7D204  D1A92C80
[23] D1AE0680  D1A7D204  D1A92C80
[22] D1AE0680  D1A7D204  D1A92C80
Proc D15C3000 Name: login -r ats2
 #  File      Vnode     Stream
[24] D1AE0680  D1A7D204  D1A92C80
[23] D1AE0680  D1A7D204  D1A92C80
[22] D1AE0680  D1A7D204  D1A92C80
strqueue - given the address of a queue, strqueue displays the queue information


S> strqueue D1AA3C4C
queue    bsrv     idname   ptr   count cpu plumbing:sched:flag
D1AA3C4C D17F944C tcp      D1A63480 1204 UBND PROCSON WANTR USE
    msgb     type       rf size    psize    next
    D1A99C00 00 DATA    05 00000400 00000200 D1A6CB40

    D1A6CB40 00 DATA    05 00000200 000001A9 D176CCE0

    D176CCE0 00 DATA    05 00000200 0000010B 00000000
strfiles - given the address of a process, this macro displays all the streams associated with the process. So, we could use the address of Proc displayed by 'strowner above':


S> strfiles D1B16400
stream D1A92C80  iocwwait 0000  rerr 00000000   werr 00000000  pushcnt 00000003
flag   04018082: RSLEEP STRISTTY SNDMREAD OLDNDELAY STRHOLD
sigflg 00000000:
evflag 00000000:     pollevents 0000:
sd_vnode     D1A36704:
dev             12/14:
sd_sidp      D1A78B60:
sd_pgidp     D1A78B60:
sd_eventlist 00000000:

queues D1A57500, D1A5754C
Downstream from queue D1A5754C:
queue    bsrv     idname   ptr   count cpu plumbing:sched:flag
D1A5754C 00000000 strwhead D1A92C80 00 UBND PROCSON USE
D1A5754C 00000000 strwhead D1A92C80 00 UBND PROCSON USE
D16FBF4C D1A5754C ttcompat D150D924 00 UBND PROCSON WANTR USE
D1A40D4C D1A5754C ldterm   D1692B24 00 UBND PROCSON WANTR USE
D166E54C D1A5754C ptem     D029E318 00 UBND PROCSON WANTR USE
D152464C D1A5754C pts      D0242F20 00 UBND PROCSON WANTR USE
Upstream from queue D1524600:
queue    bsrv     idname   ptr   count cpu plumbing:sched:flag
D1524600 00000000 pts      D0242F20 00 UBND PROCSON WANTR READR USE
D166E500 D1524600 ptem     D029E318 00 UBND PROCSON WANTR READR USE
D1A40D00 D1524600 ldterm   D1692B24 00 UBND PROCSON WANTR READR USE
D16FBF00 D1A40D00 ttcompat D150D924 00 UBND PROCSON WANTR READR USE
D1A57500 D1A40D00 strrhead D1A92C80 00 UBND PROCSON WANTR READR USE
and this shows that only one stream is owned by the process.