1 // Copyright 2021 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This file defines data types used to retrieve coalition metrics from the OS.
7 #ifndef COMPONENTS_POWER_METRICS_RESOURCE_COALITION_INTERNAL_TYPES_MAC_H_
8 #define COMPONENTS_POWER_METRICS_RESOURCE_COALITION_INTERNAL_TYPES_MAC_H_
12 // Comes from osfmk/mach/coalition.h
13 #define COALITION_TYPE_RESOURCE (0)
14 #define COALITION_TYPE_JETSAM (1)
15 #define COALITION_TYPE_MAX (1)
17 #define COALITION_NUM_TYPES (COALITION_TYPE_MAX + 1)
19 #define COALITION_NUM_THREAD_QOS_TYPES 7
21 // Comes from osfmk/mach/thread_policy.h
22 #define THREAD_QOS_UNSPECIFIED 0
23 #define THREAD_QOS_DEFAULT THREAD_QOS_UNSPECIFIED /* Temporary rename */
24 #define THREAD_QOS_MAINTENANCE 1
25 #define THREAD_QOS_BACKGROUND 2
26 #define THREAD_QOS_UTILITY 3
27 #define THREAD_QOS_LEGACY 4 /* i.e. default workq threads */
28 #define THREAD_QOS_USER_INITIATED 5
29 #define THREAD_QOS_USER_INTERACTIVE 6
31 #define THREAD_QOS_LAST 7
33 static_assert(COALITION_NUM_THREAD_QOS_TYPES == THREAD_QOS_LAST,
34 "Unexpected number of QoS levels.");
36 // Comes from bsd/sys/coalition.h
37 struct coalition_resource_usage {
38 uint64_t tasks_started;
39 uint64_t tasks_exited;
40 uint64_t time_nonempty;
42 uint64_t interrupt_wakeups;
43 uint64_t platform_idle_wakeups;
45 uint64_t byteswritten;
47 uint64_t cpu_time_billed_to_me;
48 uint64_t cpu_time_billed_to_others;
50 uint64_t logical_immediate_writes;
51 uint64_t logical_deferred_writes;
52 uint64_t logical_invalidated_writes;
53 uint64_t logical_metadata_writes;
54 uint64_t logical_immediate_writes_to_external;
55 uint64_t logical_deferred_writes_to_external;
56 uint64_t logical_invalidated_writes_to_external;
57 uint64_t logical_metadata_writes_to_external;
58 uint64_t energy_billed_to_me;
59 uint64_t energy_billed_to_others;
61 uint64_t cpu_time_eqos_len; /* Stores the number of thread QoS types */
62 uint64_t cpu_time_eqos[COALITION_NUM_THREAD_QOS_TYPES];
63 uint64_t cpu_instructions;
65 uint64_t fs_metadata_writes;
69 struct proc_pidcoalitioninfo {
70 uint64_t coalition_id[COALITION_NUM_TYPES];
76 // Comes from bsd/sys/proc_info.h
77 #define PROC_PIDCOALITIONINFO 20
79 #endif // COMPONENTS_POWER_METRICS_RESOURCE_COALITION_INTERNAL_TYPES_MAC_H_