1*5e3eaea3SApple OSS Distributions#!/usr/local/bin/luatrace -s 2*5e3eaea3SApple OSS Distributions 3*5e3eaea3SApple OSS Distributionstrace_codename = function(codename, callback) 4*5e3eaea3SApple OSS Distributions local debugid = trace.debugid(codename) 5*5e3eaea3SApple OSS Distributions if debugid ~= 0 then 6*5e3eaea3SApple OSS Distributions trace.single(debugid,callback) 7*5e3eaea3SApple OSS Distributions else 8*5e3eaea3SApple OSS Distributions printf("WARNING: Cannot locate debugid for '%s'\n", codename) 9*5e3eaea3SApple OSS Distributions end 10*5e3eaea3SApple OSS Distributionsend 11*5e3eaea3SApple OSS Distributions 12*5e3eaea3SApple OSS Distributionsinitial_timestamp = 0 13*5e3eaea3SApple OSS Distributionspid_map = {}; 14*5e3eaea3SApple OSS Distributionsget_prefix = function(buf) 15*5e3eaea3SApple OSS Distributions if initial_timestamp == 0 then 16*5e3eaea3SApple OSS Distributions initial_timestamp = buf.timestamp 17*5e3eaea3SApple OSS Distributions end 18*5e3eaea3SApple OSS Distributions local secs = trace.convert_timestamp_to_nanoseconds(buf.timestamp - initial_timestamp) / 1000000000 19*5e3eaea3SApple OSS Distributions 20*5e3eaea3SApple OSS Distributions local prefix 21*5e3eaea3SApple OSS Distributions if trace.debugid_is_start(buf.debugid) then 22*5e3eaea3SApple OSS Distributions prefix = "→" 23*5e3eaea3SApple OSS Distributions elseif trace.debugid_is_end(buf.debugid) then 24*5e3eaea3SApple OSS Distributions prefix = "←" 25*5e3eaea3SApple OSS Distributions else 26*5e3eaea3SApple OSS Distributions prefix = "↔" 27*5e3eaea3SApple OSS Distributions end 28*5e3eaea3SApple OSS Distributions 29*5e3eaea3SApple OSS Distributions local proc 30*5e3eaea3SApple OSS Distributions if buf.pid == buf[1] then 31*5e3eaea3SApple OSS Distributions proc = buf.command 32*5e3eaea3SApple OSS Distributions if pid_map[buf[1]] == nil then 33*5e3eaea3SApple OSS Distributions pid_map[buf[1]] = buf.command 34*5e3eaea3SApple OSS Distributions end 35*5e3eaea3SApple OSS Distributions elseif pid_map[buf[1]] ~= nil then 36*5e3eaea3SApple OSS Distributions proc = pid_map[buf[1]] 37*5e3eaea3SApple OSS Distributions else 38*5e3eaea3SApple OSS Distributions proc = "UNKNOWN" 39*5e3eaea3SApple OSS Distributions end 40*5e3eaea3SApple OSS Distributions 41*5e3eaea3SApple OSS Distributions return string.format("%s %6.9f %-17s [%05d.%06x] %-24s", 42*5e3eaea3SApple OSS Distributions prefix, secs, proc, buf.pid, buf.threadid, buf.debugname) 43*5e3eaea3SApple OSS Distributionsend 44*5e3eaea3SApple OSS Distributions 45*5e3eaea3SApple OSS Distributionsparse_pthread_priority = function(pri) 46*5e3eaea3SApple OSS Distributions pri = pri & 0xffffffff 47*5e3eaea3SApple OSS Distributions if (pri & 0x02000000) == 0x02000000 then 48*5e3eaea3SApple OSS Distributions return "Manager" 49*5e3eaea3SApple OSS Distributions end 50*5e3eaea3SApple OSS Distributions local qos = (pri & 0x00ffff00) >> 8 51*5e3eaea3SApple OSS Distributions if qos == 0x20 then 52*5e3eaea3SApple OSS Distributions return string.format("UI[%x]", pri); 53*5e3eaea3SApple OSS Distributions elseif qos == 0x10 then 54*5e3eaea3SApple OSS Distributions return string.format("IN[%x]", pri); 55*5e3eaea3SApple OSS Distributions elseif qos == 0x08 then 56*5e3eaea3SApple OSS Distributions return string.format("DF[%x]", pri); 57*5e3eaea3SApple OSS Distributions elseif qos == 0x04 then 58*5e3eaea3SApple OSS Distributions return string.format("UT[%x]", pri); 59*5e3eaea3SApple OSS Distributions elseif qos == 0x02 then 60*5e3eaea3SApple OSS Distributions return string.format("BG[%x]", pri); 61*5e3eaea3SApple OSS Distributions elseif qos == 0x01 then 62*5e3eaea3SApple OSS Distributions return string.format("MT[%x]", pri); 63*5e3eaea3SApple OSS Distributions elseif qos == 0x00 then 64*5e3eaea3SApple OSS Distributions return string.format("--[%x]", pri); 65*5e3eaea3SApple OSS Distributions else 66*5e3eaea3SApple OSS Distributions return string.format("??[%x]", pri); 67*5e3eaea3SApple OSS Distributions end 68*5e3eaea3SApple OSS Distributionsend 69*5e3eaea3SApple OSS Distributions 70*5e3eaea3SApple OSS Distributionsparse_thread_qos = function(pri) 71*5e3eaea3SApple OSS Distributions if pri == 7 then 72*5e3eaea3SApple OSS Distributions return string.format("MG", pri); 73*5e3eaea3SApple OSS Distributions elseif pri == 6 then 74*5e3eaea3SApple OSS Distributions return string.format("UI", pri); 75*5e3eaea3SApple OSS Distributions elseif pri == 5 then 76*5e3eaea3SApple OSS Distributions return string.format("IN", pri); 77*5e3eaea3SApple OSS Distributions elseif pri == 4 then 78*5e3eaea3SApple OSS Distributions return string.format("DF", pri); 79*5e3eaea3SApple OSS Distributions elseif pri == 3 then 80*5e3eaea3SApple OSS Distributions return string.format("UT", pri); 81*5e3eaea3SApple OSS Distributions elseif pri == 2 then 82*5e3eaea3SApple OSS Distributions return string.format("BG", pri); 83*5e3eaea3SApple OSS Distributions elseif pri == 1 then 84*5e3eaea3SApple OSS Distributions return string.format("MT", pri); 85*5e3eaea3SApple OSS Distributions elseif pri == 0 then 86*5e3eaea3SApple OSS Distributions return string.format("--", pri); 87*5e3eaea3SApple OSS Distributions else 88*5e3eaea3SApple OSS Distributions return string.format("??[%x]", pri); 89*5e3eaea3SApple OSS Distributions end 90*5e3eaea3SApple OSS Distributionsend 91*5e3eaea3SApple OSS Distributions 92*5e3eaea3SApple OSS Distributionsparse_thactive_req_qos = function(pri) 93*5e3eaea3SApple OSS Distributions if pri ~= 0 then 94*5e3eaea3SApple OSS Distributions return parse_thread_qos(pri) 95*5e3eaea3SApple OSS Distributions end 96*5e3eaea3SApple OSS Distributions return "None" 97*5e3eaea3SApple OSS Distributionsend 98*5e3eaea3SApple OSS Distributions 99*5e3eaea3SApple OSS Distributionsget_thactive = function(low, high) 100*5e3eaea3SApple OSS Distributions return string.format("req: %s, MG: %d, UI: %d, IN: %d, DE: %d, UT: %d, BG: %d, MT: %d", 101*5e3eaea3SApple OSS Distributions parse_thactive_req_qos(high >> (16 * 3)), (high >> (2 * 16)) & 0xffff, 102*5e3eaea3SApple OSS Distributions (high >> (1 * 16)) & 0xffff, (high >> (0 * 16)) & 0xffff, 103*5e3eaea3SApple OSS Distributions (low >> (3 * 16)) & 0xffff, (low >> (2 * 16)) & 0xffff, 104*5e3eaea3SApple OSS Distributions (low >> (1 * 16)) & 0xffff, (low >> (0 * 16)) & 0xffff) 105*5e3eaea3SApple OSS Distributionsend 106*5e3eaea3SApple OSS Distributions 107*5e3eaea3SApple OSS Distributions-- workqueue lifecycle 108*5e3eaea3SApple OSS Distributions 109*5e3eaea3SApple OSS Distributionstrace_codename("wq_pthread_exit", function(buf) 110*5e3eaea3SApple OSS Distributions local prefix = get_prefix(buf) 111*5e3eaea3SApple OSS Distributions if trace.debugid_is_start(buf.debugid) then 112*5e3eaea3SApple OSS Distributions printf("%s\tprocess is exiting\n",prefix) 113*5e3eaea3SApple OSS Distributions else 114*5e3eaea3SApple OSS Distributions printf("%s\tworkqueue marked as exiting and timer is complete\n",prefix) 115*5e3eaea3SApple OSS Distributions end 116*5e3eaea3SApple OSS Distributionsend) 117*5e3eaea3SApple OSS Distributions 118*5e3eaea3SApple OSS Distributionstrace_codename("wq_workqueue_exit", function(buf) 119*5e3eaea3SApple OSS Distributions local prefix = get_prefix(buf) 120*5e3eaea3SApple OSS Distributions if trace.debugid_is_start(buf.debugid) then 121*5e3eaea3SApple OSS Distributions printf("%s\tall threads have exited, cleaning up\n",prefix) 122*5e3eaea3SApple OSS Distributions else 123*5e3eaea3SApple OSS Distributions printf("%s\tclean up complete\n",prefix) 124*5e3eaea3SApple OSS Distributions end 125*5e3eaea3SApple OSS Distributionsend) 126*5e3eaea3SApple OSS Distributions 127*5e3eaea3SApple OSS Distributionstrace_codename("wq_start_add_timer", function(buf) 128*5e3eaea3SApple OSS Distributions local prefix = get_prefix(buf) 129*5e3eaea3SApple OSS Distributions printf("%s\tarming timer to fire in %d us (flags: %x, reqcount: %d)\n", 130*5e3eaea3SApple OSS Distributions prefix, buf.arg4, buf.arg3, buf.arg2) 131*5e3eaea3SApple OSS Distributionsend) 132*5e3eaea3SApple OSS Distributions 133*5e3eaea3SApple OSS Distributionstrace_codename("wq_add_timer", function(buf) 134*5e3eaea3SApple OSS Distributions local prefix = get_prefix(buf) 135*5e3eaea3SApple OSS Distributions if trace.debugid_is_start(buf.debugid) then 136*5e3eaea3SApple OSS Distributions printf("%s\tadd_timer fired (flags: %x, nthreads: %d, thidlecount: %d)\n", 137*5e3eaea3SApple OSS Distributions prefix, buf.arg2, buf.arg3, buf.arg4) 138*5e3eaea3SApple OSS Distributions elseif trace.debugid_is_end(buf.debugid) then 139*5e3eaea3SApple OSS Distributions printf("%s\tadd_timer completed (start_timer: %x, nthreads: %d, thidlecount: %d)\n", 140*5e3eaea3SApple OSS Distributions prefix, buf.arg2, buf.arg3, buf.arg4) 141*5e3eaea3SApple OSS Distributions end 142*5e3eaea3SApple OSS Distributionsend) 143*5e3eaea3SApple OSS Distributions 144*5e3eaea3SApple OSS Distributionstrace_codename("wq_select_threadreq", function(buf) 145*5e3eaea3SApple OSS Distributions local prefix = get_prefix(buf) 146*5e3eaea3SApple OSS Distributions if buf[2] == 0 then 147*5e3eaea3SApple OSS Distributions printf("%s\tSelection failed: process exiting\n", prefix) 148*5e3eaea3SApple OSS Distributions elseif buf[2] == 1 then 149*5e3eaea3SApple OSS Distributions printf("%s\tSelection failed: no request\n", prefix) 150*5e3eaea3SApple OSS Distributions elseif buf[2] == 2 then 151*5e3eaea3SApple OSS Distributions printf("%s\tSelection failed: throttled\n", prefix) 152*5e3eaea3SApple OSS Distributions elseif buf[2] == 3 then 153*5e3eaea3SApple OSS Distributions printf("%s\tSelection failed: scheduler would preempt\n", prefix) 154*5e3eaea3SApple OSS Distributions end 155*5e3eaea3SApple OSS Distributionsend) 156*5e3eaea3SApple OSS Distributions 157*5e3eaea3SApple OSS Distributionstrace_codename("wq_creator_select", function(buf) 158*5e3eaea3SApple OSS Distributions local prefix = get_prefix(buf) 159*5e3eaea3SApple OSS Distributions if buf[2] == 1 then 160*5e3eaea3SApple OSS Distributions printf("%s\t\tcreator %x overridden at %s\n", prefix, buf[3], 161*5e3eaea3SApple OSS Distributions parse_thread_qos(buf[4])) 162*5e3eaea3SApple OSS Distributions elseif buf[2] == 2 then 163*5e3eaea3SApple OSS Distributions printf("%s\t\tcreator %x selected at %s\n", prefix, buf[3], 164*5e3eaea3SApple OSS Distributions parse_thread_qos(buf[4])) 165*5e3eaea3SApple OSS Distributions elseif buf[2] == 3 then 166*5e3eaea3SApple OSS Distributions printf("%s\t\tcreator idled (%d yields)\n", prefix, buf[4]) 167*5e3eaea3SApple OSS Distributions elseif buf[2] == 4 then 168*5e3eaea3SApple OSS Distributions printf("%s\t\tcreator removed (%d yields)\n", prefix, buf[4]) 169*5e3eaea3SApple OSS Distributions end 170*5e3eaea3SApple OSS Distributionsend) 171*5e3eaea3SApple OSS Distributions 172*5e3eaea3SApple OSS Distributionstrace_codename("wq_creator_yield", function(buf) 173*5e3eaea3SApple OSS Distributions local prefix = get_prefix(buf) 174*5e3eaea3SApple OSS Distributions local reason = "unknown" 175*5e3eaea3SApple OSS Distributions if buf[2] == 1 then 176*5e3eaea3SApple OSS Distributions reason = "fast steal rate" 177*5e3eaea3SApple OSS Distributions elseif buf[2] == 2 then 178*5e3eaea3SApple OSS Distributions reason = "above ncpu scheduled" 179*5e3eaea3SApple OSS Distributions end 180*5e3eaea3SApple OSS Distributions printf("%s\t\tcreator yielded (%s, current:%d snapshot:%d)\n", 181*5e3eaea3SApple OSS Distributions prefix, reason, buf[3], buf[4]) 182*5e3eaea3SApple OSS Distributionsend) 183*5e3eaea3SApple OSS Distributions 184*5e3eaea3SApple OSS Distributionstrace_codename("wq_thread_logical_run", function(buf) 185*5e3eaea3SApple OSS Distributions local prefix = get_prefix(buf) 186*5e3eaea3SApple OSS Distributions if trace.debugid_is_start(buf.debugid) then 187*5e3eaea3SApple OSS Distributions printf("%s\tthread unparking (request %x)\n", prefix, buf[2]) 188*5e3eaea3SApple OSS Distributions else 189*5e3eaea3SApple OSS Distributions printf("%s\tthread parking\n", prefix) 190*5e3eaea3SApple OSS Distributions end 191*5e3eaea3SApple OSS Distributionsend) 192*5e3eaea3SApple OSS Distributions 193*5e3eaea3SApple OSS Distributionstrace.enable_thread_cputime() 194*5e3eaea3SApple OSS Distributionsrunthread_time_map = {} 195*5e3eaea3SApple OSS Distributionsrunthread_cputime_map = {} 196*5e3eaea3SApple OSS Distributionstrace_codename("wq_runthread", function(buf) 197*5e3eaea3SApple OSS Distributions local prefix = get_prefix(buf) 198*5e3eaea3SApple OSS Distributions if trace.debugid_is_start(buf.debugid) then 199*5e3eaea3SApple OSS Distributions printf("%s\tSTART running thread\n", prefix) 200*5e3eaea3SApple OSS Distributions runthread_time_map[buf.threadid] = buf.timestamp; 201*5e3eaea3SApple OSS Distributions runthread_cputime_map[buf.threadid] = trace.cputime_for_thread(buf.threadid); 202*5e3eaea3SApple OSS Distributions elseif runthread_time_map[buf.threadid] then 203*5e3eaea3SApple OSS Distributions local time = buf.timestamp - runthread_time_map[buf.threadid] 204*5e3eaea3SApple OSS Distributions local cputime = trace.cputime_for_thread(buf.threadid) - runthread_cputime_map[buf.threadid] 205*5e3eaea3SApple OSS Distributions 206*5e3eaea3SApple OSS Distributions local time_ms = trace.convert_timestamp_to_nanoseconds(time) / 1000000 207*5e3eaea3SApple OSS Distributions local cputime_ms = trace.convert_timestamp_to_nanoseconds(cputime) / 1000000 208*5e3eaea3SApple OSS Distributions 209*5e3eaea3SApple OSS Distributions printf("%s\tDONE running thread: time = %6.6f ms, cputime = %6.6f ms\n", 210*5e3eaea3SApple OSS Distributions prefix, time_ms, cputime_ms) 211*5e3eaea3SApple OSS Distributions 212*5e3eaea3SApple OSS Distributions runthread_time_map[buf.threadid] = 0 213*5e3eaea3SApple OSS Distributions runthread_cputime_map[buf.threadid] = 0 214*5e3eaea3SApple OSS Distributions elseif trace.debugid_is_end(buf.debugid) then 215*5e3eaea3SApple OSS Distributions printf("%s\tDONE running thread\n", prefix) 216*5e3eaea3SApple OSS Distributions end 217*5e3eaea3SApple OSS Distributionsend) 218*5e3eaea3SApple OSS Distributions 219*5e3eaea3SApple OSS Distributionstrace_codename("wq_thactive_update", function(buf) 220*5e3eaea3SApple OSS Distributions local prefix = get_prefix(buf) 221*5e3eaea3SApple OSS Distributions local thactive = get_thactive(buf[2], buf[3]) 222*5e3eaea3SApple OSS Distributions printf("%s\tthactive updated (%s)\n", prefix, thactive) 223*5e3eaea3SApple OSS Distributionsend) 224*5e3eaea3SApple OSS Distributions 225*5e3eaea3SApple OSS Distributionstrace_codename("wq_thread_block", function(buf) 226*5e3eaea3SApple OSS Distributions local prefix = get_prefix(buf) 227*5e3eaea3SApple OSS Distributions local req_pri = parse_thread_qos(buf[3] >> 8) 228*5e3eaea3SApple OSS Distributions if trace.debugid_is_start(buf.debugid) then 229*5e3eaea3SApple OSS Distributions printf("%s\tthread blocked (activecount: %d, priority: %s, req_pri: %s, reqcount: %d, start_timer: %d)\n", 230*5e3eaea3SApple OSS Distributions prefix, buf[2], parse_thread_qos(buf[3] & 0xff), req_pri, buf[4] >> 1, buf[4] & 0x1) 231*5e3eaea3SApple OSS Distributions else 232*5e3eaea3SApple OSS Distributions printf("%s\tthread unblocked (activecount: %d, priority: %s, req_pri: %s, threads_scheduled: %d)\n", 233*5e3eaea3SApple OSS Distributions prefix, buf[2], parse_thread_qos(buf[3] & 0xff), req_pri, buf[4]) 234*5e3eaea3SApple OSS Distributions end 235*5e3eaea3SApple OSS Distributionsend) 236*5e3eaea3SApple OSS Distributions 237*5e3eaea3SApple OSS Distributionstrace_codename("wq_thread_create_failed", function(buf) 238*5e3eaea3SApple OSS Distributions local prefix = get_prefix(buf) 239*5e3eaea3SApple OSS Distributions if buf[3] == 0 then 240*5e3eaea3SApple OSS Distributions printf("%s\tfailed to create new workqueue thread, kern_return: 0x%x\n", 241*5e3eaea3SApple OSS Distributions prefix, buf[2]) 242*5e3eaea3SApple OSS Distributions elseif buf[3] == 1 then 243*5e3eaea3SApple OSS Distributions printf("%s\tfailed to vm_map workq thread stack: 0x%x\n", prefix, buf[2]) 244*5e3eaea3SApple OSS Distributions elseif buf[3] == 2 then 245*5e3eaea3SApple OSS Distributions printf("%s\tfailed to vm_protect workq thread guardsize: 0x%x\n", prefix, buf[2]) 246*5e3eaea3SApple OSS Distributions end 247*5e3eaea3SApple OSS Distributionsend) 248*5e3eaea3SApple OSS Distributions 249*5e3eaea3SApple OSS Distributionstrace_codename("wq_thread_create", function(buf) 250*5e3eaea3SApple OSS Distributions printf("%s\tcreated new workqueue thread\n", get_prefix(buf)) 251*5e3eaea3SApple OSS Distributionsend) 252*5e3eaea3SApple OSS Distributions 253*5e3eaea3SApple OSS Distributionstrace_codename("wq_thread_terminate", function(buf) 254*5e3eaea3SApple OSS Distributions local prefix = get_prefix(buf) 255*5e3eaea3SApple OSS Distributions local what 256*5e3eaea3SApple OSS Distributions if trace.debugid_is_start(buf.debugid) then 257*5e3eaea3SApple OSS Distributions what = "try to terminate thread" 258*5e3eaea3SApple OSS Distributions else 259*5e3eaea3SApple OSS Distributions what = "terminated thread" 260*5e3eaea3SApple OSS Distributions end 261*5e3eaea3SApple OSS Distributions printf("%s\t%s: currently idle %d\n", prefix, what, buf[2]) 262*5e3eaea3SApple OSS Distributionsend) 263*5e3eaea3SApple OSS Distributions 264*5e3eaea3SApple OSS Distributionstrace_codename("wq_wqops_reqthreads", function(buf) 265*5e3eaea3SApple OSS Distributions local prefix = get_prefix(buf) 266*5e3eaea3SApple OSS Distributions printf("%s\tlegacy thread request made for %d threads at %s\n", prefix, buf[2], parse_pthread_priority(buf[3])); 267*5e3eaea3SApple OSS Distributionsend) 268*5e3eaea3SApple OSS Distributions 269*5e3eaea3SApple OSS Distributionstrace_codename("wq_thread_request_initiate", function(buf) 270*5e3eaea3SApple OSS Distributions local prefix = get_prefix(buf) 271*5e3eaea3SApple OSS Distributions printf("%s\tthread request %x made at %s (count:%d)\n", prefix, buf[2], parse_thread_qos(buf[3]), buf[4]); 272*5e3eaea3SApple OSS Distributionsend) 273*5e3eaea3SApple OSS Distributions 274*5e3eaea3SApple OSS Distributionstrace_codename("wq_thread_request_modify", function(buf) 275*5e3eaea3SApple OSS Distributions local prefix = get_prefix(buf) 276*5e3eaea3SApple OSS Distributions printf("%s\tthread request %x priorty updated to %s\n", prefix, buf[2], parse_thread_qos(buf[3])); 277*5e3eaea3SApple OSS Distributionsend) 278*5e3eaea3SApple OSS Distributions 279*5e3eaea3SApple OSS Distributionstrace_codename("wq_thread_request_cancel", function(buf) 280*5e3eaea3SApple OSS Distributions local prefix = get_prefix(buf) 281*5e3eaea3SApple OSS Distributions printf("%s\tthread request %x canceled\n", prefix, buf[2], parse_thread_qos(buf[3])); 282*5e3eaea3SApple OSS Distributionsend) 283*5e3eaea3SApple OSS Distributions 284*5e3eaea3SApple OSS Distributionstrace_codename("wq_constrained_admission", function(buf) 285*5e3eaea3SApple OSS Distributions local prefix = get_prefix(buf) 286*5e3eaea3SApple OSS Distributions if buf[2] == 1 then 287*5e3eaea3SApple OSS Distributions printf("fail: %s\twq_constrained_threads_scheduled=%d >= wq_max_constrained_threads=%d\n", 288*5e3eaea3SApple OSS Distributions prefix, buf[3], buf[4]) 289*5e3eaea3SApple OSS Distributions elseif (buf[2] == 2) or (buf[2] == 3) then 290*5e3eaea3SApple OSS Distributions local success = nil; 291*5e3eaea3SApple OSS Distributions if buf[2] == 2 then success = "success" 292*5e3eaea3SApple OSS Distributions else success = "fail" end 293*5e3eaea3SApple OSS Distributions printf("%s\t%s\tthactive_count=%d + busycount=%d >= wq->wq_max_concurrency\n", 294*5e3eaea3SApple OSS Distributions prefix, success, buf[3], buf[4]) 295*5e3eaea3SApple OSS Distributions end 296*5e3eaea3SApple OSS Distributionsend) 297*5e3eaea3SApple OSS Distributions 298*5e3eaea3SApple OSS Distributionstrace_codename("wq_cooperative_admission", function(buf) 299*5e3eaea3SApple OSS Distributions local prefix = get_prefix(buf) 300*5e3eaea3SApple OSS Distributions if (buf[4] == 1) then 301*5e3eaea3SApple OSS Distributions printf("%s\tsuccess at qos %s\t wq_cooperative_threads_scheduled=%d >= wq_max_cooperative_threads\n", 302*5e3eaea3SApple OSS Distributions prefix, parse_thread_qos(buf[2]), buf[1]) 303*5e3eaea3SApple OSS Distributions elseif (buf[4] == 2) then 304*5e3eaea3SApple OSS Distributions printf("%s\tsuccess at qos %s\t due to empty bucket, wq_cooperative_threads_scheduled=%d\n", 305*5e3eaea3SApple OSS Distributions prefix, parse_thread_qos(buf[2]), buf[1]) 306*5e3eaea3SApple OSS Distributions elseif (buf[4] == 3) then 307*5e3eaea3SApple OSS Distributions success = "success" 308*5e3eaea3SApple OSS Distributions if (buf[3] == 0) then 309*5e3eaea3SApple OSS Distributions success = "fail" 310*5e3eaea3SApple OSS Distributions end 311*5e3eaea3SApple OSS Distributions printf("%s\t%s at qos %s\twq_cooperative_threads_scheduled_up_to_qos=%d\n", 312*5e3eaea3SApple OSS Distributions prefix, success, parse_thread_qos(buf[2]), buf[1]) 313*5e3eaea3SApple OSS Distributions end 314*5e3eaea3SApple OSS Distributionsend) 315*5e3eaea3SApple OSS Distributions 316*5e3eaea3SApple OSS Distributionstrace_codename("wq_death_call", function(buf) 317*5e3eaea3SApple OSS Distributions local prefix = get_prefix(buf) 318*5e3eaea3SApple OSS Distributions if trace.debugid_is_start(buf.debugid) then 319*5e3eaea3SApple OSS Distributions printf("%s\tentering death call\n", prefix); 320*5e3eaea3SApple OSS Distributions elseif trace.debugid_is_end(buf.debugid) then 321*5e3eaea3SApple OSS Distributions printf("%s\tleaving death call\n", prefix); 322*5e3eaea3SApple OSS Distributions else 323*5e3eaea3SApple OSS Distributions printf("%s\tscheduling death call\n", prefix); 324*5e3eaea3SApple OSS Distributions end 325*5e3eaea3SApple OSS Distributionsend) 326*5e3eaea3SApple OSS Distributions-- 327*5e3eaea3SApple OSS Distributions-- vim:ts=4:sw=4:noet: 328