X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/fe8ab488e9161c46dd9885d58fc52996dc0249ff..7e41aa883dd258f888d0470250eead40a53ef1f5:/osfmk/kern/coalition.h?ds=sidebyside diff --git a/osfmk/kern/coalition.h b/osfmk/kern/coalition.h index 38bdefd58..0bd9d2d88 100644 --- a/osfmk/kern/coalition.h +++ b/osfmk/kern/coalition.h @@ -29,24 +29,46 @@ #ifndef _KERN_COALITION_H_ #define _KERN_COALITION_H_ +/* only kernel-private interfaces */ #ifdef XNU_KERNEL_PRIVATE +#include -void coalition_init(void); +#if CONFIG_COALITIONS + +void coalitions_init(void); /* These may return: * KERN_ALREADY_IN_SET task is already in a coalition (maybe this one, maybe a different one) * KERN_TERMINATED coalition is already terminated (so it may not adopt any more tasks) */ -kern_return_t coalition_adopt_task(coalition_t coal, task_t task); -kern_return_t coalition_default_adopt_task(task_t task); +kern_return_t coalitions_adopt_task(coalition_t *coaltions, task_t task); +kern_return_t coalitions_adopt_init_task(task_t task); /* Currently, no error conditions. If task is not already in a coalition, * KERN_SUCCESS is returned because removing it did not fail. */ -kern_return_t coalition_remove_task(task_t task); +kern_return_t coalitions_remove_task(task_t task); +void task_release_coalitions(task_t task); + +/* + * + */ +kern_return_t coalitions_set_roles(coalition_t coalitions[COALITION_NUM_TYPES], + task_t task, int roles[COALITION_NUM_TYPES]); uint64_t coalition_id(coalition_t coal); -uint64_t task_coalition_id(task_t task); +void task_coalition_ids(task_t task, uint64_t ids[COALITION_NUM_TYPES]); +void task_coalition_roles(task_t task, int roles[COALITION_NUM_TYPES]); +int coalition_type(coalition_t coal); + +void task_coalition_update_gpu_stats(task_t task, uint64_t gpu_ns_delta); +uint32_t task_coalition_adjust_focal_count(task_t task, int count); +uint32_t task_coalition_focal_count(task_t task); +uint32_t task_coalition_adjust_nonfocal_count(task_t task, int count); +uint32_t task_coalition_nonfocal_count(task_t task); + +void coalition_for_each_task(coalition_t coal, void *ctx, + void (*callback)(coalition_t, void *, task_t)); /* Returns with a reference, or COALITION_NULL. * There is no coalition with id 0. @@ -58,13 +80,6 @@ coalition_t coalition_find_by_id(uint64_t coal_id); */ coalition_t coalition_find_and_activate_by_id(uint64_t coal_id); -/* This may return: - * KERN_TERMINATED coalition is terminated - * This will panic if the coalition is already reaped, which implies - * that it wasn't active. - */ -kern_return_t coalition_extend_active(coalition_t coal); - void coalition_remove_active(coalition_t coal); void coalition_release(coalition_t coal); @@ -94,28 +109,53 @@ kern_return_t coalition_request_terminate_internal(coalition_t coal); * KERN_RESOURCE_SHORTAGE Unable to allocate kernel resources for a * new coalition. */ -kern_return_t coalition_create_internal(coalition_t *out, boolean_t privileged); +kern_return_t coalition_create_internal(int type, boolean_t privileged, coalition_t *out); boolean_t coalition_is_privileged(coalition_t coal); -boolean_t task_is_in_privileged_coalition(task_t task); - -/* This struct is also defined in bsd/sys/coalition.h. Keep in sync. */ -struct coalition_resource_usage { - uint64_t tasks_started; - uint64_t tasks_exited; - uint64_t time_nonempty; - uint64_t cpu_time; - uint64_t interrupt_wakeups; - uint64_t platform_idle_wakeups; - uint64_t bytesread; - uint64_t byteswritten; - uint64_t gpu_time; -}; +boolean_t task_is_in_privileged_coalition(task_t task, int type); kern_return_t coalition_resource_usage_internal(coalition_t coal, struct coalition_resource_usage *cru_out); -ledger_t coalition_get_ledger(coalition_t coal); - +/* + * development/debug interfaces + */ +#if defined(DEVELOPMENT) || defined(DEBUG) +int coalition_should_notify(coalition_t coal); +void coalition_set_notify(coalition_t coal, int notify); +#endif + +#else /* !CONFIG_COALITIONS */ + +static inline void task_coalition_update_gpu_stats(__unused task_t task, + __unused uint64_t gpu_ns_delta) +{ + return; +} + +static inline uint32_t task_coalition_adjust_focal_count(__unused task_t task, + __unused int count) +{ + return 0; +} + +static inline uint32_t task_coalition_adjust_nonfocal_count(__unused task_t task, + __unused int count) +{ + return 0; +} + +static inline uint32_t task_coalition_focal_count(__unused task_t task) +{ + return 0; +} + +static inline void coalition_for_each_task(__unused coalition_t coal, + __unused void *ctx, + __unused void (*callback)(coalition_t, void *, task_t)) +{ + return; +} + +#endif /* CONFIG_COALITIONS */ #endif /* XNU_KERNEL_PRIVATE */ - #endif /* _KERN_COALITION_H */