docs/how-to-build.md: use proper markup for directory names
[unleashed/tickless.git] / include / sys / cmt.h
blobafdb6730a6b1ead84a20bd6cd122bca49bf9c51d
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _CMT_H
27 #define _CMT_H
30 * CMT PG class
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
37 #if (defined(_KERNEL) || defined(_KMEMUSER))
38 #include <sys/group.h>
39 #include <sys/pghw.h>
40 #include <sys/lgrp.h>
41 #include <sys/types.h>
44 * CMT related dispatcher policies
46 #define CMT_NO_POLICY 0x0
47 #define CMT_BALANCE 0x1
48 #define CMT_COALESCE 0x2
49 #define CMT_AFFINITY 0x4
51 typedef uint_t pg_cmt_policy_t;
54 * CMT pg structure
56 typedef struct pg_cmt {
57 struct pghw cmt_pg; /* physical grouping */
58 struct group *cmt_siblings; /* CMT PGs to balance with */
59 struct pg_cmt *cmt_parent; /* Parent CMT PG */
60 struct group *cmt_children; /* Active children CMT PGs */
61 pg_cmt_policy_t cmt_policy; /* Dispatcher policies to use */
62 uint32_t cmt_utilization; /* Group's utilization */
63 int cmt_nchildren; /* # of children CMT PGs */
64 struct group cmt_cpus_actv;
65 struct bitset cmt_cpus_actv_set; /* bitset of active CPUs */
66 kstat_t *cmt_kstat; /* cmt kstats exported */
67 } pg_cmt_t;
70 * CMT lgroup structure
72 typedef struct cmt_lgrp {
73 group_t cl_pgs; /* Top level group of active CMT PGs */
74 int cl_npgs; /* # of top level PGs in the lgroup */
75 lgrp_handle_t cl_hand; /* lgroup's platform handle */
76 struct cmt_lgrp *cl_next; /* next cmt_lgrp */
77 } cmt_lgrp_t;
80 * Change the number of running threads on the pg
82 #define PG_NRUN_UPDATE(cp, n) (pg_cmt_load((cp), (n)))
85 * Indicate that the given logical CPU is (or isn't) currently utilized
87 #define CMT_CPU_UTILIZED(cp) (pg_cmt_load((cp), 1))
88 #define CMT_CPU_NOT_UTILIZED(cp) (pg_cmt_load((cp), -1))
91 * CMT PG's capacity
93 * Currently, this is defined to be the number of active
94 * logical CPUs in the group.
96 * This will be used in conjunction with the utilization, which is defined
97 * to be the number of threads actively running on CPUs in the group.
99 #define CMT_CAPACITY(pg) (GROUP_SIZE(&((pg_cmt_t *)pg)->cmt_cpus_actv))
101 void pg_cmt_load(cpu_t *, int);
102 void pg_cmt_cpu_startup(cpu_t *);
103 int pg_cmt_can_migrate(cpu_t *, cpu_t *);
106 * CMT platform interfaces
108 pg_cmt_policy_t pg_plat_cmt_policy(pghw_type_t);
109 int pg_plat_cmt_rank(pg_cmt_t *, pg_cmt_t *);
112 * CMT dispatcher policy
114 cpu_t *cmt_balance(kthread_t *, cpu_t *);
117 * Power Aware Dispatcher Interfaces
119 int cmt_pad_enable(pghw_type_t);
120 int cmt_pad_disable(pghw_type_t);
122 #endif /* !_KERNEL && !_KMEMUSER */
124 #ifdef __cplusplus
126 #endif
128 #endif /* _CMT_H */