#! /usr/sbin/dtrace -qs /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at * http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* * Trace how many times all the threads of the given process and its children * are run in each lgroup */ BEGIN { } /* * Trace any processes that are forked ancestors of given process */ syscall::fork1:return /progenyof($1) && pid != $1/ { printf("Trace child of PID %d (PID %d LWPID %d)\n", curpsinfo->pr_ppid, pid, tid); trace_pids[pid] = 1; } syscall::forkall:return /progenyof($1) && pid != $1/ { printf("Trace child of PID %d (PID %d LWPID %d)\n", curpsinfo->pr_ppid, pid, tid); trace_pids[pid] = 1; } syscall::vfork:return /progenyof($1) && pid != $1/ { printf("Trace child of PID %d (PID %d LWPID %d)\n", curpsinfo->pr_ppid, pid, tid); trace_pids[pid] = 1; } /* * Count how many times each thread of any traced process runs in each lgroup, * aggregating on PID, TID, home lgroup, and lgroup run on */ sched:::on-cpu /pid == $1 || trace_pids[pid]/ { printf("PID %d TID %d with home lgroup %d ran on CPU %d in lgroup %d\n", pid, tid, curthread->t_lpl->lpl_lgrpid, cpu, lgrp); @lgrp_count[pid, tid, curthread->t_lpl->lpl_lgrpid, lgrp] = count(); } END { /* * Print PID, TID, its home lgroup, which lgroup that it ran in, and * how many times */ printa("\nPID %d TID %d with home lgroup %d ran in lgroup %d:\t%@d times\n", @lgrp_count); }