X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/a1c7dba18ef36983396c282fe85292db066e39db..c7d2c2c6ee645e10cbccdd01c6191873ec77239d:/osfmk/kern/task.h diff --git a/osfmk/kern/task.h b/osfmk/kern/task.h index b82c53bb4..5ddff0c75 100644 --- a/osfmk/kern/task.h +++ b/osfmk/kern/task.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2010 Apple Inc. All rights reserved. + * Copyright (c) 2000-2010, 2015 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -117,6 +117,7 @@ #ifdef XNU_KERNEL_PRIVATE +#include #include /* defns for task->rsu_controldata */ @@ -147,6 +148,7 @@ #include +#include #ifdef CONFIG_ATM #include @@ -258,6 +260,7 @@ struct task { #ifdef MACH_BSD void *bsd_info; #endif + kcdata_descriptor_t corpse_info; struct vm_shared_region *shared_region; volatile uint32_t t_flags; /* general-purpose task flags protected by task_lock (TL) */ #define TF_64B_ADDR 0x00000001 /* task has 64-bit addressing */ @@ -266,6 +269,8 @@ struct task { #define TF_WAKEMON_WARNING 0x00000008 /* task is in wakeups monitor warning zone */ #define TF_TELEMETRY (TF_CPUMON_WARNING | TF_WAKEMON_WARNING) /* task is a telemetry participant */ #define TF_GPU_DENIED 0x00000010 /* task is not allowed to access the GPU */ +#define TF_CORPSE 0x00000020 /* task is a corpse */ +#define TF_PENDING_CORPSE 0x00000040 /* task corpse has not been reported yet */ #define task_has_64BitAddr(task) \ (((task)->t_flags & TF_64B_ADDR) != 0) @@ -276,10 +281,25 @@ struct task { #define task_has_64BitData(task) \ (((task)->t_flags & TF_64B_DATA) != 0) +#define task_is_a_corpse(task) \ + (((task)->t_flags & TF_CORPSE) != 0) + +#define task_set_corpse(task) \ + ((task)->t_flags |= TF_CORPSE) + +#define task_corpse_pending_report(task) \ + (((task)->t_flags & TF_PENDING_CORPSE) != 0) + +#define task_set_corpse_pending_report(task) \ + ((task)->t_flags |= TF_PENDING_CORPSE) + +#define task_clear_corpse_pending_report(task) \ + ((task)->t_flags &= ~TF_PENDING_CORPSE) + mach_vm_address_t all_image_info_addr; /* dyld __all_image_info */ mach_vm_size_t all_image_info_size; /* section location and size */ -#if CONFIG_COUNTERS || KPERF +#if KPERF #define TASK_PMC_FLAG 0x1 /* Bit in "t_chud" signifying PMC interest */ #define TASK_KPC_FORCED_ALL_CTRS 0x2 /* Bit in "t_chud" signifying KPC forced all counters */ @@ -325,14 +345,19 @@ struct task { /* * Can be merged with imp_donor bits, once the IMPORTANCE_INHERITANCE macro goes away. */ - uint32_t low_mem_notified_warn :1, /* warning low memory notification is sent to the task */ - low_mem_notified_critical :1, /* critical low memory notification is sent to the task */ - purged_memory_warn :1, /* purgeable memory of the task is purged for warning level pressure */ - purged_memory_critical :1, /* purgeable memory of the task is purged for critical level pressure */ - mem_notify_reserved :28; /* reserved for future use */ + uint32_t low_mem_notified_warn :1, /* warning low memory notification is sent to the task */ + low_mem_notified_critical :1, /* critical low memory notification is sent to the task */ + purged_memory_warn :1, /* purgeable memory of the task is purged for warning level pressure */ + purged_memory_critical :1, /* purgeable memory of the task is purged for critical level pressure */ + low_mem_privileged_listener :1, /* if set, task would like to know about pressure changes before other tasks on the system */ + mem_notify_reserved :27; /* reserved for future use */ + + io_stat_info_t task_io_stats; + uint64_t task_immediate_writes __attribute__((aligned(8))); + uint64_t task_deferred_writes __attribute__((aligned(8))); + uint64_t task_invalidated_writes __attribute__((aligned(8))); + uint64_t task_metadata_writes __attribute__((aligned(8))); - io_stat_info_t task_io_stats; - /* * The cpu_time_qos_stats fields are protected by the task lock */ @@ -350,10 +375,16 @@ struct task { boolean_t task_purgeable_disowning; boolean_t task_purgeable_disowned; - /* Coalition is set in task_create_internal and unset in task_deallocate_internal, so it can be referenced without the task lock. */ - coalition_t coalition; /* coalition this task belongs to */ - /* These fields are protected by coalition->lock, not the task lock. */ - queue_chain_t coalition_tasks; /* list of tasks in the coalition */ + /* + * A task's coalition set is "adopted" in task_create_internal + * and unset in task_deallocate_internal, so each array member + * can be referenced without the task lock. + * Note: these fields are protected by coalition->lock, + * not the task lock. + */ + coalition_t coalition[COALITION_NUM_TYPES]; + queue_chain_t task_coalition[COALITION_NUM_TYPES]; + uint64_t dispatchqueue_offset; #if HYPERVISOR void *hv_task_target; /* hypervisor virtual machine object associated with this task */ @@ -444,6 +475,10 @@ extern kern_return_t task_wait( extern kern_return_t task_release( task_t task); +/* Suspend/resume a task where the kernel owns the suspend count */ +extern kern_return_t task_suspend_internal( task_t task); +extern kern_return_t task_resume_internal( task_t task); + /* Suspends a task by placing a hold on its threads */ extern kern_return_t task_pidsuspend( task_t task); @@ -459,6 +494,8 @@ extern kern_return_t task_send_trace_memory( uint32_t pid, uint64_t uniqueid); +extern void tasks_system_suspend(boolean_t suspend); + #if CONFIG_FREEZE /* Freeze a task's resident pages */ @@ -491,7 +528,7 @@ extern kern_return_t task_terminate_internal( extern kern_return_t task_create_internal( task_t parent_task, - coalition_t parent_coalition, + coalition_t *parent_coalitions, boolean_t inherit_memory, boolean_t is_64bit, task_t *child_task); /* OUT */ @@ -542,6 +579,7 @@ extern int get_task_numacts( task_t task); extern int get_task_numactivethreads(task_t task); +extern kern_return_t task_collect_crash_info(task_t task); /* JMM - should just be temporary (implementation in bsd_kern still) */ extern void set_bsdtask_info(task_t,void *); @@ -555,7 +593,9 @@ extern uint64_t get_task_phys_footprint(task_t); extern uint64_t get_task_phys_footprint_max(task_t); extern uint64_t get_task_purgeable_size(task_t); extern uint64_t get_task_cpu_time(task_t); +extern uint64_t get_task_dispatchqueue_offset(task_t); +extern kern_return_t task_convert_phys_footprint_limit(int, int *); extern kern_return_t task_set_phys_footprint_limit_internal(task_t, int, int *, boolean_t); extern kern_return_t task_get_phys_footprint_limit(task_t task, int *limit_mb); @@ -586,6 +626,7 @@ struct _task_ledger_indices { int internal; int iokit_mapped; int alternate_accounting; + int alternate_accounting_compressed; int phys_footprint; int internal_compressed; int purgeable_volatile; @@ -594,7 +635,9 @@ struct _task_ledger_indices { int purgeable_nonvolatile_compressed; int platform_idle_wakeups; int interrupt_wakeups; - int sfi_wait_times[MAX_SFI_CLASS_ID]; +#if CONFIG_SCHED_SFI + int sfi_wait_times[MAX_SFI_CLASS_ID]; +#endif /* CONFIG_SCHED_SFI */ #ifdef CONFIG_BANK int cpu_time_billed_to_me; int cpu_time_billed_to_others; @@ -666,11 +709,15 @@ extern void proc_get_task_policy2(task_t task, thread_t thread, int category, in /* For use by kernel threads and others who don't hold a reference on the target thread */ extern void proc_set_task_policy_thread(task_t task, uint64_t tid, int category, int flavor, int value); -extern void proc_set_task_spawnpolicy(task_t task, int apptype, int qos_clamp, +extern void proc_set_task_spawnpolicy(task_t task, int apptype, int qos_clamp, int role, ipc_port_t * portwatch_ports, int portwatch_count); extern void task_set_main_thread_qos(task_t task, thread_t main_thread); +extern int proc_darwin_role_to_task_role(int darwin_role, int* task_role); +extern int proc_task_role_to_darwin_role(int task_role); + + /* IO Throttle tiers */ #define THROTTLE_LEVEL_NONE -1 #define THROTTLE_LEVEL_TIER0 0 /* IOPOL_NORMAL, IOPOL_DEFAULT, IOPOL_PASSIVE */ @@ -699,6 +746,7 @@ extern int proc_restore_workq_bgthreadpolicy(thread_t thread); extern int proc_get_darwinbgstate(task_t task, uint32_t *flagsp); extern boolean_t proc_task_is_tal(task_t task); +extern int task_get_apptype(task_t); extern integer_t task_grab_latency_qos(task_t task); extern void task_policy_create(task_t task, int parent_boosted); extern void thread_policy_create(thread_t thread); @@ -791,6 +839,7 @@ extern int task_importance_drop_legacy_external_assertion(task_t target_task, ui #endif /* IMPORTANCE_INHERITANCE */ +extern int task_low_mem_privileged_listener(task_t task, boolean_t new_value, boolean_t *old_value); extern boolean_t task_has_been_notified(task_t task, int pressurelevel); extern boolean_t task_used_for_purging(task_t task, int pressurelevel); extern void task_mark_has_been_notified(task_t task, int pressurelevel); @@ -799,11 +848,7 @@ extern void task_clear_has_been_notified(task_t task, int pressurelevel); extern void task_clear_used_for_purging(task_t task); extern int task_importance_estimate(task_t task); -/* - * This should only be used for debugging. - * pid is stored in audit_token by set_security_token(). - */ -#define audit_token_pid_from_task(task) ((task)->audit_token.val[5]) +extern int task_pid(task_t task); /* End task_policy */ @@ -812,12 +857,19 @@ extern kern_return_t task_purge_volatile_memory(task_t task); extern void task_set_gpu_denied(task_t task, boolean_t denied); extern boolean_t task_is_gpu_denied(task_t task); +#define TASK_WRITE_IMMEDIATE 0x1 +#define TASK_WRITE_DEFERRED 0x2 +#define TASK_WRITE_INVALIDATED 0x4 +#define TASK_WRITE_METADATA 0x8 +extern void task_update_logical_writes(task_t task, uint32_t io_size, int flags); + #endif /* XNU_KERNEL_PRIVATE */ #ifdef KERNEL_PRIVATE extern void *get_bsdtask_info(task_t); extern void *get_bsdthreadtask_info(thread_t); +extern void task_bsdtask_kill(task_t); extern vm_map_t get_task_map(task_t); extern ledger_t get_task_ledger(task_t);