xref: /titanic_51/usr/src/uts/common/sys/cmt.h (revision 6890d023cce317bfcb74d7e43a813d060ebd2e47)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_CMT_H
27 #define	_CMT_H
28 
29 /*
30  * CMT PG class
31  */
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 #if (defined(_KERNEL) || defined(_KMEMUSER))
38 #include <sys/group.h>
39 #include <sys/pghw.h>
40 #include <sys/types.h>
41 
42 /*
43  * CMT pg structure
44  */
45 typedef struct pg_cmt {
46 	struct pghw	cmt_pg;			/* physical grouping */
47 	struct group	*cmt_siblings;		/* CMT PGs to balance with */
48 	struct pg_cmt	*cmt_parent;		/* Parent CMT PG */
49 	struct group	*cmt_children;		/* Active children CMT PGs */
50 	int		cmt_nchildren;		/* # of children CMT PGs */
51 	uint32_t	cmt_nrunning;		/* # of running threads */
52 	struct group	cmt_cpus_actv;
53 	struct bitset	cmt_cpus_actv_set;	/* bitset of active CPUs */
54 } pg_cmt_t;
55 
56 /*
57  * Change the number of running threads on the pg
58  */
59 #define	PG_NRUN_UPDATE(cp, n)	(pg_cmt_load((cp), (n)))
60 
61 void		pg_cmt_load(cpu_t *, int);
62 void		pg_cmt_cpu_startup(cpu_t *);
63 int		pg_cmt_can_migrate(cpu_t *, cpu_t *);
64 
65 int		pg_plat_cmt_load_bal_hw(pghw_type_t);
66 int		pg_plat_cmt_affinity_hw(pghw_type_t);
67 
68 cpu_t		*cmt_balance(kthread_t *, cpu_t *);
69 
70 #endif	/* !_KERNEL && !_KMEMUSER */
71 
72 #ifdef	__cplusplus
73 }
74 #endif
75 
76 #endif /* _CMT_H */
77