pkg: ship usr/lib/security/amd64/*.so links
[unleashed.git] / include / sys / cpucaps_impl.h
blob95afd2182734fd9f1df26358324074a40f591118
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
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_CPUCAPS_IMPL_H
28 #define _SYS_CPUCAPS_IMPL_H
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
34 #ifdef _KERNEL
36 #include <sys/kstat.h>
37 #include <sys/cpucaps.h>
38 #include <sys/list.h>
39 #include <sys/time.h>
40 #include <sys/waitq.h>
43 * When resource control framework sets the cap to NOCAP value the cap
44 * is disabled.
46 #define NOCAP MAXCAP
49 * Maximum value for the cap usage. Should be the maximum value for hrtime_t
51 #if defined(_LP64)
52 #define MAX_USAGE LONG_MAX
53 #else
54 #define MAX_USAGE 9223372036854775807LL
55 #endif
59 * Most of the per-project or per-zone state related to CPU caps is kept in the
60 * cpucap_t structure.
62 typedef struct cpucap {
63 list_node_t cap_link; /* next/prev capped entity */
64 struct kproject *cap_project; /* project for the cap */
65 struct zone *cap_zone; /* zone for the cap */
66 waitq_t cap_waitq; /* waitq for capped threads */
67 kstat_t *cap_kstat; /* cpucaps specific kstat */
68 int64_t cap_gen; /* zone cap specific */
69 hrtime_t cap_value; /* scaled CPU usage cap */
70 hrtime_t cap_usage; /* current CPU usage */
71 disp_lock_t cap_usagelock; /* protects cap_usage above */
73 * Per cap statistics.
75 hrtime_t cap_maxusage; /* maximum cap usage */
76 u_longlong_t cap_below; /* # of ticks spend below the cap */
77 u_longlong_t cap_above; /* # of ticks spend above the cap */
78 } cpucap_t;
81 * Wrapper macros for checking cap state.
83 #define CAP_ENABLED(cap) ((cap)->cap_value != 0)
84 #define CAP_DISABLED(cap) (!CAP_ENABLED(cap))
86 #define PROJECT_IS_CAPPED(project) \
87 (((project)->kpj_cpucap != NULL) && \
88 CAP_ENABLED((project)->kpj_cpucap))
90 #define ZONE_IS_CAPPED(zone) \
91 (((zone)->zone_cpucap != NULL) && \
92 CAP_ENABLED((zone)->zone_cpucap))
94 #endif /* _KERNEL */
96 #ifdef __cplusplus
98 #endif
100 #endif /* _SYS_CPUCAPS_IMPL_H */