1 /* $NetBSD: sched.d,v 1.2 2010/02/21 01:46:35 darran Exp $ */ 2 3 /* 4 * CDDL HEADER START 5 * 6 * The contents of this file are subject to the terms of the 7 * Common Development and Distribution License (the "License"). 8 * You may not use this file except in compliance with the License. 9 * 10 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11 * or http://www.opensolaris.org/os/licensing. 12 * See the License for the specific language governing permissions 13 * and limitations under the License. 14 * 15 * When distributing Covered Code, include this CDDL HEADER in each 16 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17 * If applicable, add the following below this CDDL HEADER, with the 18 * fields enclosed by brackets "[]" replaced with your own identifying 19 * information: Portions Copyright [yyyy] [name of copyright owner] 20 * 21 * CDDL HEADER END 22 * 23 * Portions Copyright 2006-2008 John Birrell jb@freebsd.org 24 * 25 * $FreeBSD: src/cddl/lib/libdtrace/sched.d,v 1.1.4.1 2009/08/03 08:13:06 kensmith Exp $ 26 */ 27 /* 28 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 29 * Use is subject to license terms. 30 */ 31 32 #pragma ident "%Z%%M% %I% %E% SMI" 33 34 #pragma D depends_on module unix 35 #pragma D depends_on provider sched 36 37 struct cpuinfo { 38 processorid_t cpu_id; /* CPU identifier */ 39 psetid_t cpu_pset; /* processor set identifier */ 40 chipid_t cpu_chip; /* chip identifier */ 41 lgrp_id_t cpu_lgrp; /* locality group identifer */ 42 processor_info_t cpu_info; /* CPU information */ 43 }; 44 45 typedef struct cpuinfo cpuinfo_t; 46 47 translator cpuinfo_t < cpu_t *C > { 48 cpu_id = C->cpu_id; 49 cpu_pset = C->cpu_part->cp_id; 50 cpu_chip = C->cpu_physid->cpu_chipid; 51 cpu_lgrp = C->cpu_lpl->lpl_lgrpid; 52 cpu_info = (processor_info_t)C->cpu_type_info; 53 }; 54 55 translator cpuinfo_t < disp_t *D > { 56 cpu_id = D->disp_cpu == NULL ? -1 : 57 xlate <cpuinfo_t> (D->disp_cpu).cpu_id; 58 cpu_pset = D->disp_cpu == NULL ? -1 : 59 xlate <cpuinfo_t> (D->disp_cpu).cpu_pset; 60 cpu_chip = D->disp_cpu == NULL ? -1 : 61 xlate <cpuinfo_t> (D->disp_cpu).cpu_chip; 62 cpu_lgrp = D->disp_cpu == NULL ? -1 : 63 xlate <cpuinfo_t> (D->disp_cpu).cpu_lgrp; 64 cpu_info = D->disp_cpu == NULL ? 65 *((processor_info_t *)dtrace`dtrace_zero) : 66 (processor_info_t)xlate <cpuinfo_t> (D->disp_cpu).cpu_info; 67 }; 68 69 inline cpuinfo_t *curcpu = xlate <cpuinfo_t *> (curthread->t_cpu); 70 #pragma D attributes Stable/Stable/Common curcpu 71 #pragma D binding "1.0" curcpu 72 73 inline processorid_t cpu = curcpu->cpu_id; 74 #pragma D attributes Stable/Stable/Common cpu 75 #pragma D binding "1.0" cpu 76 77 inline psetid_t pset = curcpu->cpu_pset; 78 #pragma D attributes Stable/Stable/Common pset 79 #pragma D binding "1.0" pset 80 81 inline chipid_t chip = curcpu->cpu_chip; 82 #pragma D attributes Stable/Stable/Common chip 83 #pragma D binding "1.0" chip 84 85 inline lgrp_id_t lgrp = curcpu->cpu_lgrp; 86 #pragma D attributes Stable/Stable/Common lgrp 87 #pragma D binding "1.0" lgrp 88 89