* Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
- *
+ *
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
- *
+ *
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
- *
+ *
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
- *
+ *
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
* and the default ones are being returned instead.
*/
-typedef natural_t task_policy_flavor_t;
-typedef integer_t *task_policy_t;
+typedef natural_t task_policy_flavor_t;
+typedef integer_t *task_policy_t;
/*
-kern_return_t task_policy_set(
- task_t task,
- task_policy_flavor_t flavor,
- task_policy_t policy_info,
- mach_msg_type_number_t count);
-
-kern_return_t task_policy_get(
- task_t task,
- task_policy_flavor_t flavor,
- task_policy_t policy_info,
- mach_msg_type_number_t *count,
- boolean_t *get_default);
-*/
+ * kern_return_t task_policy_set(
+ * task_t task,
+ * task_policy_flavor_t flavor,
+ * task_policy_t policy_info,
+ * mach_msg_type_number_t count);
+ *
+ * kern_return_t task_policy_get(
+ * task_t task,
+ * task_policy_flavor_t flavor,
+ * task_policy_t policy_info,
+ * mach_msg_type_number_t *count,
+ * boolean_t *get_default);
+ */
/*
* Defined flavors.
* a time with this designation, which is assigned FCFS.
*/
-#define TASK_CATEGORY_POLICY 1
+#define TASK_CATEGORY_POLICY 1
-#define TASK_SUPPRESSION_POLICY 3
-#define TASK_POLICY_STATE 4
-#define TASK_BASE_QOS_POLICY 8
-#define TASK_OVERRIDE_QOS_POLICY 9
-#define TASK_BASE_LATENCY_QOS_POLICY 10
-#define TASK_BASE_THROUGHPUT_QOS_POLICY 11
+#define TASK_SUPPRESSION_POLICY 3
+#define TASK_POLICY_STATE 4
+#define TASK_BASE_QOS_POLICY 8
+#define TASK_OVERRIDE_QOS_POLICY 9
+#define TASK_BASE_LATENCY_QOS_POLICY 10
+#define TASK_BASE_THROUGHPUT_QOS_POLICY 11
enum task_role {
- TASK_RENICED = -1,
- TASK_UNSPECIFIED = 0,
- TASK_FOREGROUND_APPLICATION,
- TASK_BACKGROUND_APPLICATION,
- TASK_CONTROL_APPLICATION,
- TASK_GRAPHICS_SERVER,
- TASK_THROTTLE_APPLICATION,
- TASK_NONUI_APPLICATION,
- TASK_DEFAULT_APPLICATION
+ TASK_RENICED = -1,
+ TASK_UNSPECIFIED = 0,
+ TASK_FOREGROUND_APPLICATION = 1,
+ TASK_BACKGROUND_APPLICATION = 2,
+ TASK_CONTROL_APPLICATION = 3,
+ TASK_GRAPHICS_SERVER = 4,
+ TASK_THROTTLE_APPLICATION = 5,
+ TASK_NONUI_APPLICATION = 6,
+ TASK_DEFAULT_APPLICATION = 7,
+ TASK_DARWINBG_APPLICATION = 8,
};
-typedef integer_t task_role_t;
+typedef integer_t task_role_t;
struct task_category_policy {
- task_role_t role;
+ task_role_t role;
};
-typedef struct task_category_policy task_category_policy_data_t;
-typedef struct task_category_policy *task_category_policy_t;
+typedef struct task_category_policy task_category_policy_data_t;
+typedef struct task_category_policy *task_category_policy_t;
-#define TASK_CATEGORY_POLICY_COUNT ((mach_msg_type_number_t) \
+#define TASK_CATEGORY_POLICY_COUNT ((mach_msg_type_number_t) \
(sizeof (task_category_policy_data_t) / sizeof (integer_t)))
enum task_latency_qos {
LATENCY_QOS_TIER_UNSPECIFIED = 0x0,
- LATENCY_QOS_TIER_0 = ((0xFF<<16) | 1),
- LATENCY_QOS_TIER_1 = ((0xFF<<16) | 2),
- LATENCY_QOS_TIER_2 = ((0xFF<<16) | 3),
- LATENCY_QOS_TIER_3 = ((0xFF<<16) | 4),
- LATENCY_QOS_TIER_4 = ((0xFF<<16) | 5),
- LATENCY_QOS_TIER_5 = ((0xFF<<16) | 6)
-
+ LATENCY_QOS_TIER_0 = ((0xFF << 16) | 1),
+ LATENCY_QOS_TIER_1 = ((0xFF << 16) | 2),
+ LATENCY_QOS_TIER_2 = ((0xFF << 16) | 3),
+ LATENCY_QOS_TIER_3 = ((0xFF << 16) | 4),
+ LATENCY_QOS_TIER_4 = ((0xFF << 16) | 5),
+ LATENCY_QOS_TIER_5 = ((0xFF << 16) | 6)
};
-typedef integer_t task_latency_qos_t;
+typedef integer_t task_latency_qos_t;
enum task_throughput_qos {
THROUGHPUT_QOS_TIER_UNSPECIFIED = 0x0,
- THROUGHPUT_QOS_TIER_0 = ((0xFE<<16) | 1),
- THROUGHPUT_QOS_TIER_1 = ((0xFE<<16) | 2),
- THROUGHPUT_QOS_TIER_2 = ((0xFE<<16) | 3),
- THROUGHPUT_QOS_TIER_3 = ((0xFE<<16) | 4),
- THROUGHPUT_QOS_TIER_4 = ((0xFE<<16) | 5),
- THROUGHPUT_QOS_TIER_5 = ((0xFE<<16) | 6),
+ THROUGHPUT_QOS_TIER_0 = ((0xFE << 16) | 1),
+ THROUGHPUT_QOS_TIER_1 = ((0xFE << 16) | 2),
+ THROUGHPUT_QOS_TIER_2 = ((0xFE << 16) | 3),
+ THROUGHPUT_QOS_TIER_3 = ((0xFE << 16) | 4),
+ THROUGHPUT_QOS_TIER_4 = ((0xFE << 16) | 5),
+ THROUGHPUT_QOS_TIER_5 = ((0xFE << 16) | 6),
};
#define LATENCY_QOS_LAUNCH_DEFAULT_TIER LATENCY_QOS_TIER_3
#define THROUGHPUT_QOS_LAUNCH_DEFAULT_TIER THROUGHPUT_QOS_TIER_3
-typedef integer_t task_throughput_qos_t;
+typedef integer_t task_throughput_qos_t;
struct task_qos_policy {
task_latency_qos_t task_latency_qos_tier;
};
typedef struct task_qos_policy *task_qos_policy_t;
-#define TASK_QOS_POLICY_COUNT ((mach_msg_type_number_t) \
+#define TASK_QOS_POLICY_COUNT ((mach_msg_type_number_t) \
(sizeof (struct task_qos_policy) / sizeof (integer_t)))
/* These should be removed - they belong in proc_info.h */
#define PROC_FLAG_DARWINBG 0x8000 /* process in darwin background */
-#define PROC_FLAG_EXT_DARWINBG 0x10000 /* process in darwin background - external enforcement */
+#define PROC_FLAG_EXT_DARWINBG 0x10000 /* process in darwin background - external enforcement */
#define PROC_FLAG_IOS_APPLEDAEMON 0x20000 /* process is apple ios daemon */
#define PROC_FLAG_IOS_IMPPROMOTION 0x80000 /* process is apple ios daemon */
#define PROC_FLAG_ADAPTIVE 0x100000 /* Process is adaptive */
#ifdef PRIVATE
+/*
+ * Internal bitfields are privately exported for *revlocked*
+ * tools like msa to decode tracepoints and taskinfo to dump state
+ *
+ * These struct definitions *will* change in the future.
+ * When they do, we will update TASK_POLICY_INTERNAL_STRUCT_VERSION.
+ */
+
+#define TASK_POLICY_INTERNAL_STRUCT_VERSION 2
+
struct task_requested_policy {
- /* Task and thread policy (inherited) */
- uint64_t int_darwinbg :1, /* marked as darwinbg via setpriority */
- ext_darwinbg :1,
- int_iotier :2, /* IO throttle tier */
- ext_iotier :2,
- int_iopassive :1, /* should IOs cause lower tiers to be throttled */
- ext_iopassive :1,
- bg_iotier :2, /* what IO throttle tier should apply to me when I'm darwinbg? (pushed to threads) */
- terminated :1, /* all throttles should be removed for quick exit or SIGTERM handling */
-
- /* Thread only policy */
- th_pidbind_bg :1, /* thread only: task i'm bound to is marked 'watchbg' */
- th_workq_bg :1, /* thread only: currently running a background priority workqueue */
- thrp_qos :3, /* thread only: thread qos class */
- thrp_qos_relprio :4, /* thread only: thread qos relative priority (store as inverse, -10 -> 0xA) */
- thrp_qos_override :3, /* thread only: thread qos class override */
-
- /* Task only policy */
- t_apptype :3, /* What apptype did launchd tell us this was (inherited) */
- t_boosted :1, /* Has a non-zero importance assertion count */
- t_int_gpu_deny :1, /* don't allow access to GPU */
- t_ext_gpu_deny :1,
- t_role :3, /* task's system role */
- t_tal_enabled :1, /* TAL mode is enabled */
- t_base_latency_qos :3, /* Timer latency QoS */
- t_over_latency_qos :3, /* Timer latency QoS override */
- t_base_through_qos :3, /* Computation throughput QoS */
- t_over_through_qos :3, /* Computation throughput QoS override */
- t_sfi_managed :1, /* SFI Managed task */
- t_qos_clamp :3, /* task qos clamp */
-
- /* Task only: suppression policies (non-embedded only) */
- t_sup_active :1, /* Suppression is on */
- t_sup_lowpri_cpu :1, /* Wants low priority CPU (MAXPRI_THROTTLE) */
- t_sup_timer :3, /* Wanted timer throttling QoS tier */
- t_sup_disk :1, /* Wants disk throttling */
- t_sup_cpu_limit :1, /* Wants CPU limit (not hooked up yet)*/
- t_sup_suspend :1, /* Wants to be suspended */
- t_sup_throughput :3, /* Wants throughput QoS tier */
- t_sup_cpu :1, /* Wants suppressed CPU priority (MAXPRI_SUPPRESSED) */
- t_sup_bg_sockets :1, /* Wants background sockets */
-
- reserved :2;
+ uint64_t trp_int_darwinbg :1, /* marked as darwinbg via setpriority */
+ trp_ext_darwinbg :1,
+ trp_int_iotier :2, /* IO throttle tier */
+ trp_ext_iotier :2,
+ trp_int_iopassive :1, /* should IOs cause lower tiers to be throttled */
+ trp_ext_iopassive :1,
+ trp_bg_iotier :2, /* what IO throttle tier should apply to me when I'm darwinbg? (pushed to threads) */
+ trp_terminated :1, /* all throttles should be removed for quick exit or SIGTERM handling */
+ trp_base_latency_qos :3, /* Timer latency QoS */
+ trp_base_through_qos :3, /* Computation throughput QoS */
+
+ trp_apptype :3, /* What apptype did launchd tell us this was (inherited) */
+ trp_boosted :1, /* Has a non-zero importance assertion count */
+ trp_role :4, /* task's system role */
+ trp_tal_enabled :1, /* TAL mode is enabled */
+ trp_over_latency_qos :3, /* Timer latency QoS override */
+ trp_over_through_qos :3, /* Computation throughput QoS override */
+ trp_sfi_managed :1, /* SFI Managed task */
+ trp_qos_clamp :3, /* task qos clamp */
+
+ /* suppression policies (non-embedded only) */
+ trp_sup_active :1, /* Suppression is on */
+ trp_sup_lowpri_cpu :1, /* Wants low priority CPU (MAXPRI_THROTTLE) */
+ trp_sup_timer :3, /* Wanted timer throttling QoS tier */
+ trp_sup_disk :1, /* Wants disk throttling */
+ trp_sup_throughput :3, /* Wants throughput QoS tier */
+ trp_sup_cpu :1, /* Wants suppressed CPU priority (MAXPRI_SUPPRESSED) */
+ trp_sup_bg_sockets :1, /* Wants background sockets */
+
+ trp_reserved :17;
};
struct task_effective_policy {
- /* Task and thread policy */
- uint64_t darwinbg :1, /* marked as 'background', and sockets are marked bg when created */
- lowpri_cpu :1, /* cpu priority == MAXPRI_THROTTLE */
- io_tier :2, /* effective throttle tier */
- io_passive :1, /* should IOs cause lower tiers to be throttled */
- all_sockets_bg :1, /* All existing sockets in process are marked as bg (thread: all created by thread) */
- new_sockets_bg :1, /* Newly created sockets should be marked as bg */
- bg_iotier :2, /* What throttle tier should I be in when darwinbg is set? */
- terminated :1, /* all throttles have been removed for quick exit or SIGTERM handling */
- qos_ui_is_urgent :1, /* bump UI-Interactive QoS up to the urgent preemption band */
-
- /* Thread only policy */
- thep_qos :3, /* thread only: thread qos class */
- thep_qos_relprio :4, /* thread only: thread qos relative priority (store as inverse, -10 -> 0xA) */
-
- /* Task only policy */
- t_gpu_deny :1, /* not allowed to access GPU */
- t_tal_engaged :1, /* TAL mode is in effect */
- t_suspended :1, /* task_suspend-ed due to suppression */
- t_watchers_bg :1, /* watchers are BG-ed */
- t_latency_qos :3, /* Timer latency QoS level */
- t_through_qos :3, /* Computation throughput QoS level */
- t_sup_active :1, /* suppression behaviors are in effect */
- t_role :3, /* task's system role */
- t_suppressed_cpu :1, /* cpu priority == MAXPRI_SUPPRESSED (trumped by lowpri_cpu) */
- t_sfi_managed :1, /* SFI Managed task */
- t_live_donor :1, /* task is a live importance boost donor */
- t_qos_clamp :3, /* task qos clamp (applies to qos-disabled threads too) */
- t_qos_ceiling :3, /* task qos ceiling (applies to only qos-participating threads) */
-
- reserved :23;
+ uint64_t tep_darwinbg :1, /* marked as 'background', and sockets are marked bg when created */
+ tep_lowpri_cpu :1, /* cpu priority == MAXPRI_THROTTLE */
+ tep_io_tier :2, /* effective throttle tier */
+ tep_io_passive :1, /* should IOs cause lower tiers to be throttled */
+ tep_all_sockets_bg :1, /* All existing sockets in process are marked as bg (thread: all created by thread) */
+ tep_new_sockets_bg :1, /* Newly created sockets should be marked as bg */
+ tep_bg_iotier :2, /* What throttle tier should I be in when darwinbg is set? */
+ tep_terminated :1, /* all throttles have been removed for quick exit or SIGTERM handling */
+ tep_qos_ui_is_urgent :1, /* bump UI-Interactive QoS up to the urgent preemption band */
+ tep_latency_qos :3, /* Timer latency QoS level */
+ tep_through_qos :3, /* Computation throughput QoS level */
+
+ tep_tal_engaged :1, /* TAL mode is in effect */
+ tep_watchers_bg :1, /* watchers are BG-ed */
+ tep_sup_active :1, /* suppression behaviors are in effect */
+ tep_role :4, /* task's system role */
+ tep_suppressed_cpu :1, /* cpu priority == MAXPRI_SUPPRESSED (trumped by lowpri_cpu) */
+ tep_sfi_managed :1, /* SFI Managed task */
+ tep_live_donor :1, /* task is a live importance boost donor */
+ tep_qos_clamp :3, /* task qos clamp (applies to qos-disabled threads too) */
+ tep_qos_ceiling :3, /* task qos ceiling (applies to only qos-participating threads) */
+
+ tep_reserved :31;
};
-struct task_pended_policy {
- uint64_t t_updating_policy :1, /* Busy bit for task to prevent concurrent 'complete' operations */
-
- /* Task and thread policy */
- update_sockets :1,
-
- /* Task only policy */
- t_update_timers :1,
- t_update_watchers :1,
-
- reserved :60;
-};
-
-#endif
+#endif /* PRIVATE */
#ifdef MACH_KERNEL_PRIVATE
extern const struct task_requested_policy default_task_requested_policy;
extern const struct task_effective_policy default_task_effective_policy;
-extern const struct task_pended_policy default_task_pended_policy;
extern kern_return_t
-qos_latency_policy_validate(task_latency_qos_t);
+ qos_latency_policy_validate(task_latency_qos_t);
extern kern_return_t
-qos_throughput_policy_validate(task_throughput_qos_t);
+ qos_throughput_policy_validate(task_throughput_qos_t);
extern uint32_t
-qos_extract(uint32_t);
+ qos_extract(uint32_t);
extern uint32_t
-qos_latency_policy_package(uint32_t);
+ qos_latency_policy_package(uint32_t);
extern uint32_t
-qos_throughput_policy_package(uint32_t);
+ qos_throughput_policy_package(uint32_t);
#endif /* MACH_KERNEL_PRIVATE */
typedef struct task_suppression_policy *task_suppression_policy_t;
-#define TASK_SUPPRESSION_POLICY_COUNT ((mach_msg_type_number_t) \
+#define TASK_SUPPRESSION_POLICY_COUNT ((mach_msg_type_number_t) \
(sizeof (struct task_suppression_policy) / sizeof (integer_t)))
struct task_policy_state {
uint32_t imp_externcnt;
uint64_t flags;
uint64_t imp_transitions;
- uint64_t reserved[2];
+ uint64_t tps_requested_policy;
+ uint64_t tps_effective_policy;
};
typedef struct task_policy_state *task_policy_state_t;
-#define TASK_POLICY_STATE_COUNT ((mach_msg_type_number_t) \
+#define TASK_POLICY_STATE_COUNT ((mach_msg_type_number_t) \
(sizeof (struct task_policy_state) / sizeof (integer_t)))
#define TASK_APPTYPE_DAEMON_BACKGROUND 4
#define TASK_APPTYPE_APP_DEFAULT 5
#define TASK_APPTYPE_APP_TAL 6
+#define TASK_APPTYPE_DRIVER 7
/* task policy state flags */
#define TASK_IMP_RECEIVER 0x00000001
#define TASK_IMP_DONOR 0x00000002
-#define TASK_IMP_LIVE_DONOR 0x00000004
-#define TASK_DENAP_RECEIVER 0x00000008
+#define TASK_IMP_LIVE_DONOR 0x00000004
+#define TASK_DENAP_RECEIVER 0x00000008
/* requested_policy */
#define POLICY_REQ_INT_DARWIN_BG 0x00000001
/* thread requested policy */
#define POLICY_REQ_PIDBIND_BG 0x00000400
-#define POLICY_REQ_WORKQ_BG 0x00000800
+#define POLICY_REQ_WORKQ_BG 0x00000800 /* deprecated */
#define POLICY_REQ_TH_QOS_MASK 0x07000000 /* 3 bits (overlaps with ROLE) */
#define POLICY_REQ_TH_QOS_SHIFT 24
#define POLICY_REQ_TH_QOS_OVER_MASK 0x70000000 /* 3 bits (overlaps with TAL and SFI) */
#endif /* PRIVATE */
-#endif /* _MACH_TASK_POLICY_H_ */
+#endif /* _MACH_TASK_POLICY_H_ */