1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma D option quiet 28 #pragma D option nspec=4 29 #pragma D option specsize=100k 30 31 int maxlen; 32 int spec[int]; 33 34 sched:::enqueue 35 { 36 this->len = ++qlen[this->cpu = args[2]->cpu_id]; 37 in[args[0]->pr_addr] = timestamp; 38 } 39 40 sched:::enqueue 41 /this->len > maxlen && spec[this->cpu]/ 42 { 43 /* 44 * There is already a speculation for this CPU. We just set a new 45 * record, so we'll discard the old one. 46 */ 47 discard(spec[this->cpu]); 48 } 49 50 sched:::enqueue 51 /this->len > maxlen/ 52 { 53 /* 54 * We have a winner. Set the new maximum length and set the timestamp 55 * of the longest length. 56 */ 57 maxlen = this->len; 58 longtime[this->cpu] = timestamp; 59 60 /* 61 * Now start a new speculation, and speculatively trace the length. 62 */ 63 this->spec = spec[this->cpu] = speculation(); 64 speculate(this->spec); 65 printf("Run queue of length %d:\n", this->len); 66 } 67 68 sched:::dequeue 69 /(this->in = in[args[0]->pr_addr]) && 70 this->in <= longtime[this->cpu = args[2]->cpu_id]/ 71 { 72 speculate(spec[this->cpu]); 73 printf(" %d/%d (%s)\n", 74 args[1]->pr_pid, args[0]->pr_lwpid, 75 stringof(args[1]->pr_fname)); 76 } 77 78 sched:::dequeue 79 /qlen[args[2]->cpu_id]/ 80 { 81 in[args[0]->pr_addr] = 0; 82 this->len = --qlen[args[2]->cpu_id]; 83 } 84 85 sched:::dequeue 86 /this->len == 0 && spec[this->cpu]/ 87 { 88 /* 89 * We just processed the last thread that was enqueued at the time 90 * of longest length; commit the speculation, which by now contains 91 * each thread that was enqueued when the queue was longest. 92 */ 93 commit(spec[this->cpu]); 94 spec[this->cpu] = 0; 95 } 96