1 # -*- tab-width: 4 -*- ;; Emacs
2 # vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM
3 ############################################################ IDENT(1)
5 # $Title: dwatch(8) module for dtrace_sched(4) $
6 # $Copyright: 2014-2018 Devin Teske. All rights reserved. $
9 ############################################################ DESCRIPTION
11 # Display CPU scheduling activity
13 ############################################################ PROBE
17 : ${PROBE:=sched:::} ;;
19 : ${PROBE:=sched:::off-cpu, sched:::on-cpu, sched:::remain-cpu} ;;
21 : ${PROBE:=sched:::sleep, sched:::wakeup} ;;
23 : ${PROBE:=sched:::change-pri, sched:::lend-pri} ;;
25 : ${PROBE:=sched:::dequeue, sched:::enqueue, sched:::load-change} ;;
27 : ${PROBE:=sched:::${PROFILE#sched-}}
30 ############################################################ ACTIONS
38 $PROBE /* probe ID $ID */
41 this->args = this->args0;
43 this->pid = this->pid0;
46 sched:::change-pri, sched:::dequeue, sched:::enqueue,
47 sched:::lend-pri, sched:::off-cpu, sched:::surrender,
48 sched:::tick, sched:::wakeup /* probe ID $(( $ID + 1 )) */
50 printf("<$(( $ID + 1 ))>");}
51 this->curprio = (u_char)((struct thread *)args[0])->td_priority;
53 $( pproc -P _sched "(struct proc *)args[1]" )
55 this->args = this->args_sched;
56 this->pid = this->pid_sched;
59 sched:::enqueue /* probe ID $(( $ID + 2 )) */
61 printf("<$(( $ID + 2 ))>");}
62 /* details = "head" or "tail" */
63 this->details = (int)arg3 == 0 ? "tail" : "head";
66 sched:::change-pri, sched:::lend-pri /* probe ID $(( $ID + 3 )) */
68 printf("<$(( $ID + 3 ))>");}
69 /* details = "<curprio> -> <arg2>" */
70 this->details = strjoin(lltostr(this->curprio),
71 strjoin("->", lltostr((uint8_t)arg2)));
74 sched:::load-change /* probe ID $(( $ID + 4 )) */
76 printf("<$(( $ID + 4 ))>");}
77 /* details = "CPU<arg0> queue <arg1>" */
78 this->details = strjoin(strjoin("CPU", lltostr((int)arg0)),
79 strjoin(" queue ", lltostr((int)arg1)));
82 $PROBE /* probe ID $(( $ID + 5 )) */
84 printf("<$(( $ID + 5 ))>");}
85 /* details += " pid <pid> -- <proc args of pid>" */
86 this->details = strjoin(this->details, this->details == "" ? "" : " ");
87 this->details = strjoin(this->details, strjoin(
88 strjoin("pid ", lltostr(this->pid)),
89 strjoin(" -- ", this->args)));
95 ############################################################ EVENT DETAILS
97 if [ ! "$CUSTOM_DETAILS" ]; then
100 * Print scheduling details
102 printf("%s %s", probename, this->details);
104 EVENT_DETAILS=$( cat <&9 )
107 ################################################################################
109 ################################################################################