]> git.saurik.com Git - apple/xnu.git/blame_incremental - osfmk/mach/sfi_class.h
xnu-4570.71.2.tar.gz
[apple/xnu.git] / osfmk / mach / sfi_class.h
... / ...
CommitLineData
1/*
2 * Copyright (c) 2013 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29#ifndef _MACH_SFI_CLASS_H_
30#define _MACH_SFI_CLASS_H_
31
32#include <stdint.h>
33#include <mach/mach_types.h>
34
35#define SFI_CLASS_DEFINITIONS 20140526
36
37/*
38 * SFI Classes are used to categorized threads, and map
39 * them to "off-time" windows.
40 *
41 * Threads classified approximately in this order, so
42 * there's an implicit requirement that lowest duty cycle
43 * (largest off-time) are a lower class, and increasing
44 * SFI classes increase the duty cycle (if SFI is enabled
45 * at all).
46 */
47typedef uint32_t sfi_class_id_t;
48
49#ifdef XNU_KERNEL_PRIVATE
50
51/*
52 * Total number of classes supported including SFI_CLASS_UNSPECIFIED.
53 * If new class is defined increase this number.
54 */
55#define MAX_SFI_CLASS_ID 0x00000011
56
57/*
58 * Threads may initially start out unspecified
59 */
60#define SFI_CLASS_UNSPECIFIED 0x00000000
61
62#endif /* XNU_KERNEL_PRIVATE */
63
64/*
65 * Threads are placed in this class as a result of placing threads or
66 * processes in a background state using APIs such as setpriority(2),
67 * specifying PRIO_DARWIN_THREAD or PRIO_DARWIN_PROCESS.
68 */
69#define SFI_CLASS_DARWIN_BG 0x00000001
70
71/*
72 * Threads are placed in this class as a result of an application
73 * entering "Nap mode".
74 */
75#define SFI_CLASS_APP_NAP 0x00000002
76
77/*
78 * Threads are placed in this class by making per coalition (by
79 * calling coalition_set_sfi_class(cid, SFI_CLASS_MANAGED)) or per
80 * process selection (by calling process_set_sfi_class(pid,
81 * SFI_CLASS_MANAGED)). FOCAL/NONFOCAL is a function of a task's
82 * role.
83 */
84#define SFI_CLASS_MANAGED_FOCAL 0x00000003
85
86#define SFI_CLASS_MANAGED_NONFOCAL 0x00000004
87
88#define SFI_CLASS_MANAGED SFI_CLASS_MANAGED_FOCAL
89
90/*
91 * Coalitions/processes that have not been explicitly tagged
92 * and are not opted into one of the special classes below
93 * fall into the default categories. FOCAL/NONFOCAL is a function
94 * of a task's role.
95 */
96#define SFI_CLASS_DEFAULT_FOCAL 0x00000005
97
98#define SFI_CLASS_DEFAULT_NONFOCAL 0x00000006
99
100#define SFI_CLASS_DEFAULT SFI_CLASS_DEFAULT_FOCAL
101
102/*
103 * Threads that are part of the kernel task should be duty-cycled
104 * only as an extreme last resort, since they must be preempted
105 * while locks may be held in kernel mode.
106 */
107#define SFI_CLASS_KERNEL 0x00000007
108
109/*
110 * Threads that must not be part of "Selective Forced Idle" are
111 * placed in this class. Real time threads, threads of
112 * processes such as WindowServer that are critical to good user
113 * experience, should be placed in this class.
114 */
115#define SFI_CLASS_OPTED_OUT 0x00000008
116
117/*
118 * Threads running in various QOS classes
119 */
120#define SFI_CLASS_UTILITY 0x00000009
121#define SFI_CLASS_LEGACY_FOCAL 0x0000000A
122#define SFI_CLASS_LEGACY_NONFOCAL 0x0000000B
123#define SFI_CLASS_USER_INITIATED_FOCAL 0x0000000C
124#define SFI_CLASS_USER_INITIATED_NONFOCAL 0x0000000D
125#define SFI_CLASS_USER_INTERACTIVE_FOCAL 0x0000000E
126#define SFI_CLASS_USER_INTERACTIVE_NONFOCAL 0x0000000F
127#define SFI_CLASS_MAINTENANCE 0x00000010
128
129/*
130 * Windows that are specified smaller than MIN_SFI_WINDOW_USEC
131 * will be automatically rounded up.
132 */
133#define MIN_SFI_WINDOW_USEC 500
134
135#endif /* _MACH_SFI_CLASS_H_ */