]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/mach/coalition.h
xnu-6153.121.1.tar.gz
[apple/xnu.git] / osfmk / mach / coalition.h
index 6b2038de4585600501fd409e8ad2c9c8ce20dab6..82be1cf5a252048332c14ac577b0f5c4fd291742 100644 (file)
@@ -31,7 +31,7 @@
 
 /* code shared by userspace and xnu */
 
-#define COALITION_CREATE_FLAGS_MASK       ((uint32_t)0xF1)
+#define COALITION_CREATE_FLAGS_MASK       ((uint32_t)0xFF1)
 #define COALITION_CREATE_FLAGS_PRIVILEGED ((uint32_t)0x01)
 
 #define COALITION_CREATE_FLAGS_TYPE_MASK  ((uint32_t)0xF0)
 
 #define COALITION_CREATE_FLAGS_SET_TYPE(flags, type) \
        do { \
-               flags &= ~COALITION_CREATE_FLAGS_TYPE_MASK; \
-               flags |= (((type) << COALITION_CREATE_FLAGS_TYPE_SHIFT) \
-                          & COALITION_CREATE_FLAGS_TYPE_MASK); \
+               flags &= ~COALITION_CREATE_FLAGS_TYPE_MASK; \
+               flags |= (((type) << COALITION_CREATE_FLAGS_TYPE_SHIFT) \
+                          & COALITION_CREATE_FLAGS_TYPE_MASK); \
        } while (0)
 
+#define COALITION_CREATE_FLAGS_ROLE_MASK  ((uint32_t)0xF00)
+#define COALITION_CREATE_FLAGS_ROLE_SHIFT (8)
+
+#define COALITION_CREATE_FLAGS_GET_ROLE(flags) \
+    (((flags) & COALITION_CREATE_FLAGS_ROLE_MASK) >> COALITION_CREATE_FLAGS_ROLE_SHIFT)
+
+#define COALITION_CREATE_FLAGS_SET_ROLE(flags, role) \
+    do { \
+       flags &= ~COALITION_CREATE_FLAGS_ROLE_MASK; \
+       flags |= (((role) << COALITION_CREATE_FLAGS_ROLE_SHIFT) \
+              & COALITION_CREATE_FLAGS_ROLE_MASK); \
+    } while (0)
+
+/*
+ * Default scheduling policy of the lead/parent task in a coalition
+ */
+#define COALITION_ROLE_UNDEF       (0)
+#define COALITION_ROLE_SYSTEM      (1)
+#define COALITION_ROLE_BACKGROUND  (2)
+#define COALITION_ROLE_ADAPTIVE    (3)
+#define COALITION_ROLE_INTERACTIVE (4)
+#define COALITION_NUM_ROLES        (5)
 
 #define COALITION_TYPE_RESOURCE  (0)
 #define COALITION_TYPE_JETSAM    (1)
@@ -54,6 +76,7 @@
 
 #define COALITION_NUM_TYPES      (COALITION_TYPE_MAX + 1)
 
+#define COALITION_TASKROLE_NONE   (-1) /* task plays no role in the given coalition */
 #define COALITION_TASKROLE_UNDEF  (0)
 #define COALITION_TASKROLE_LEADER (1)
 #define COALITION_TASKROLE_XPC    (2)
 
 #define COALITION_NUM_SORT        (6)
 
+#define COALITION_NUM_THREAD_QOS_TYPES   7
+
+/* Coalition Efficiency Interface Support */
+
+/* Flags for coalition efficiency */
+#define COALITION_FLAGS_EFFICIENT       (0x1)
+
+/*
+ * Mapping of launchd plist values to coalition efficiency flags.
+ * Launchd uses this mapping to pass the correct flags to
+ * coalition_info_set_efficiency(cid, flags);
+ *
+ * Current supported values mapping:
+ * { "Efficient" : COALITION_FLAGS_EFFICIENT, }
+ */
+static const char *coalition_efficiency_names[] = {
+       "Efficient",
+};
+static const uint64_t coalition_efficiency_flags[] = {
+       COALITION_FLAGS_EFFICIENT,
+};
+
 struct coalition_resource_usage {
        uint64_t tasks_started;
        uint64_t tasks_exited;
@@ -88,10 +133,22 @@ struct coalition_resource_usage {
        uint64_t gpu_time;
        uint64_t cpu_time_billed_to_me;
        uint64_t cpu_time_billed_to_others;
+       uint64_t energy;
        uint64_t logical_immediate_writes;
        uint64_t logical_deferred_writes;
        uint64_t logical_invalidated_writes;
        uint64_t logical_metadata_writes;
+       uint64_t logical_immediate_writes_to_external;
+       uint64_t logical_deferred_writes_to_external;
+       uint64_t logical_invalidated_writes_to_external;
+       uint64_t logical_metadata_writes_to_external;
+       uint64_t energy_billed_to_me;
+       uint64_t energy_billed_to_others;
+       uint64_t cpu_ptime;
+       uint64_t cpu_time_eqos_len;     /* Stores the number of thread QoS types */
+       uint64_t cpu_time_eqos[COALITION_NUM_THREAD_QOS_TYPES];
+       uint64_t cpu_instructions;
+       uint64_t cpu_cycles;
 };
 
 #ifdef PRIVATE
@@ -104,6 +161,13 @@ struct coalition_resource_usage {
 
 /* coalition_info flavors */
 #define COALITION_INFO_RESOURCE_USAGE 1
+#define COALITION_INFO_SET_NAME 2
+#define COALITION_INFO_SET_EFFICIENCY 3
+
+/* coalition_ledger_set operations */
+#define COALITION_LEDGER_SET_LOGICAL_WRITES_LIMIT 1
+
+#define COALITION_EFFICIENCY_VALID_FLAGS    (COALITION_FLAGS_EFFICIENT)
 
 /* structure returned from libproc coalition listing interface */
 struct procinfo_coalinfo {