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