X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/316670eb35587141e969394ae8537d66b9211e80..04b8595b18b1b41ac7a206e4b3d51a635f8413d7:/bsd/sys/proc_internal.h diff --git a/bsd/sys/proc_internal.h b/bsd/sys/proc_internal.h index e4c7497bf..96c7c3392 100644 --- a/bsd/sys/proc_internal.h +++ b/bsd/sys/proc_internal.h @@ -154,6 +154,7 @@ struct session { */ #define S_DEFAULT 0x00000000 /* No flags set */ #define S_NOCTTY 0x00000001 /* Do not associate controlling tty */ +#define S_CTTYREF 0x00000010 /* vnode ref taken by cttyopen */ #define S_LIST_TERM 1 /* marked for termination */ @@ -217,7 +218,8 @@ struct proc { gid_t p_rgid; uid_t p_svuid; gid_t p_svgid; - uint64_t p_uniqueid; /* process uniqe ID */ + uint64_t p_uniqueid; /* process unique ID - incremented on fork/spawn/vfork, remains same across exec. */ + uint64_t p_puniqueid; /* parent's unique ID - set on fork/spawn/vfork, doesn't change if reparented. */ lck_mtx_t p_mlock; /* mutex lock for proc */ @@ -334,10 +336,12 @@ struct proc { uint32_t p_pcaction; /* action for process control on starvation */ uint8_t p_uuid[16]; /* from LC_UUID load command */ -#if !CONFIG_EMBEDDED -#define PROC_LEGACY_BEHAVIOR_IOTHROTTLE (0x00000001) - uint32_t p_legacy_behavior; -#endif + /* + * CPU type and subtype of binary slice executed in + * this process. Protected by proc lock. + */ + cpu_type_t p_cputype; + cpu_subtype_t p_cpusubtype; /* End area that is copied on creation. */ /* XXXXXXXXXXXXX End of BCOPY'ed on fork (AIOLOCK)XXXXXXXXXXXXXXXX */ @@ -349,20 +353,23 @@ struct proc { struct klist p_klist; /* knote list (PL ?)*/ - struct rusage *p_ru; /* Exit information. (PL) */ + struct rusage_superset *p_ru; /* Exit information. (PL) */ int p_sigwaitcnt; thread_t p_signalholder; thread_t p_transholder; /* DEPRECATE following field */ u_short p_acflag; /* Accounting flags. */ + volatile u_short p_vfs_iopolicy; /* VFS iopolicy flags. (atomic bit ops) */ struct lctx *p_lctx; /* Pointer to login context. */ LIST_ENTRY(proc) p_lclist; /* List of processes in lctx. */ user_addr_t p_threadstart; /* pthread start fn */ user_addr_t p_wqthread; /* pthread workqueue fn */ int p_pthsize; /* pthread size */ + uint32_t p_pth_tsd_offset; /* offset from pthread_t to TSD for new threads */ user_addr_t p_targconc; /* target concurrency ptr */ + user_addr_t p_stack_addr_hint; /* stack allocation hint for wq threads */ void * p_wqptr; /* workq ptr */ int p_wqsize; /* allocated size */ boolean_t p_wqiniting; /* semaphore to serialze wq_open */ @@ -372,6 +379,9 @@ struct proc { int p_ractive; int p_idversion; /* version of process identity */ void * p_pthhash; /* pthread waitqueue hash */ + volatile uint64_t was_throttled __attribute__((aligned(8))); /* Counter for number of throttled I/Os */ + volatile uint64_t did_throttle __attribute__((aligned(8))); /* Counter for number of I/Os this proc throttled */ + #if DIAGNOSTIC unsigned int p_fdlock_pc[4]; unsigned int p_fdunlock_pc[4]; @@ -381,10 +391,27 @@ struct proc { #endif /* SIGNAL_DEBUG */ #endif /* DIAGNOSTIC */ uint64_t p_dispatchqueue_offset; + uint64_t p_dispatchqueue_serialno_offset; #if VM_PRESSURE_EVENTS struct timeval vm_pressure_last_notify_tstamp; #endif - int p_dirty; /* dirty state */ + +#if CONFIG_MEMORYSTATUS + /* Fields protected by proc list lock */ + TAILQ_ENTRY(proc) p_memstat_list; /* priority bucket link */ + uint32_t p_memstat_state; /* state */ + int32_t p_memstat_effectivepriority; /* priority after transaction state accounted for */ + int32_t p_memstat_requestedpriority; /* active priority */ + uint32_t p_memstat_dirty; /* dirty state */ + uint64_t p_memstat_userdata; /* user state */ + uint64_t p_memstat_idledeadline; /* time at which process became clean */ +#if CONFIG_JETSAM + int32_t p_memstat_memlimit; /* cached memory limit */ +#endif +#if CONFIG_FREEZE + uint32_t p_memstat_suspendedfootprint; /* footprint at time of suspensions */ +#endif /* CONFIG_FREEZE */ +#endif /* CONFIG_MEMORYSTATUS */ }; #define PGRPID_DEAD 0xdeaddead @@ -420,8 +447,8 @@ struct proc { #define P_LTRANSCOMMIT 0x00000020 /* process is committed to trans */ #define P_LINTRANSIT 0x00000040 /* process in exec or in creation */ #define P_LTRANSWAIT 0x00000080 /* waiting for trans to complete */ -#define P_LVFORK 0x00000100 /* */ -#define P_LINVFORK 0x00000200 /* */ +#define P_LVFORK 0x00000100 /* parent proc of a vfork */ +#define P_LINVFORK 0x00000200 /* child proc of a vfork */ #define P_LTRACED 0x00000400 /* */ #define P_LSIGEXC 0x00000800 /* */ #define P_LNOATTACH 0x00001000 /* */ @@ -437,7 +464,17 @@ struct proc { #define P_LRAGE_VNODES 0x00400000 #define P_LREGISTER 0x00800000 /* thread start fns registered */ #define P_LVMRSRCOWNER 0x01000000 /* can handle the resource ownership of */ -#define P_LPTERMINATE 0x02000000 /* can handle the resource ownership of */ +/* old P_LPTERMINATE 0x02000000 */ +#define P_LTERM_DECRYPTFAIL 0x04000000 /* process terminating due to key failure to decrypt */ +#define P_LTERM_JETSAM 0x08000000 /* process is being jetsam'd */ +#define P_JETSAM_VMPAGESHORTAGE 0x00000000 /* jetsam: lowest jetsam priority proc, killed due to vm page shortage */ +#define P_JETSAM_VMTHRASHING 0x10000000 /* jetsam: lowest jetsam priority proc, killed due to vm thrashing */ +#define P_JETSAM_HIWAT 0x20000000 /* jetsam: high water mark */ +#define P_JETSAM_PID 0x30000000 /* jetsam: pid */ +#define P_JETSAM_IDLEEXIT 0x40000000 /* jetsam: idle exit */ +#define P_JETSAM_VNODE 0x50000000 /* jetsam: vnode kill */ +#define P_JETSAM_FCTHRASHING 0x60000000 /* jetsam: lowest jetsam priority proc, killed due to filecache thrashing */ +#define P_JETSAM_MASK 0x70000000 /* jetsam type mask */ /* Process control state for resource starvation */ #define P_PCTHROTTLE 1 @@ -455,6 +492,9 @@ struct proc { /* additional process flags */ #define P_LADVLOCK 0x01 +/* p_vfs_iopolicy flags */ +#define P_VFS_IOPOLICY_FORCE_HFS_CASE_SENSITIVITY 0x0001 + /* defns for proc_iterate */ #define PROC_ALLPROCLIST 1 /* walk the allproc list (procs not exited yet) */ #define PROC_ZOMBPROCLIST 2 /* walk the zombie list */ @@ -597,7 +637,7 @@ struct user64_extern_proc { */ extern int nprocs, maxproc; /* Current and max number of procs. */ extern int maxprocperuid; /* Current number of procs per uid */ -__private_extern__ int hard_maxproc; /* hard limit */ +extern int hard_maxproc; /* hard limit */ extern unsigned int proc_shutdown_exitcount; #define PID_MAX 99999 @@ -649,7 +689,7 @@ LIST_HEAD(proclist, proc); extern struct proclist allproc; /* List of all processes. */ extern struct proclist zombproc; /* List of zombie processes. */ extern struct proc *initproc; -extern void procinit(void) __attribute__((section("__TEXT, initcode"))); +extern void procinit(void); extern void proc_lock(struct proc *); extern void proc_unlock(struct proc *); extern void proc_spinlock(struct proc *); @@ -690,15 +730,15 @@ extern int tsleep1(void *chan, int pri, const char *wmesg, u_int64_t abstime, in extern int msleep0(void *chan, lck_mtx_t *mtx, int pri, const char *wmesg, int timo, int (*continuation)(int)); extern void vfork_return(struct proc *child, int32_t *retval, int rval); extern int exit1(struct proc *, int, int *); -extern int exit1_internal(struct proc *, int, int *, boolean_t, boolean_t); -extern int fork1(proc_t, thread_t *, int); +extern int exit1_internal(struct proc *, int, int *, boolean_t, boolean_t, int); +extern int fork1(proc_t, thread_t *, int, coalition_t); extern void vfork_exit_internal(struct proc *p, int rv, int forced); extern void proc_reparentlocked(struct proc *child, struct proc * newparent, int cansignal, int locked); extern int pgrp_iterate(struct pgrp * pgrp, int flags, int (*callout)(proc_t , void *), void *arg, int (*filterfn)(proc_t , void *), void *filterarg); extern int proc_iterate(int flags, int (*callout)(proc_t , void *), void *arg, int (*filterfn)(proc_t , void *), void *filterarg); extern int proc_rebootscan(int (*callout)(proc_t , void *), void *arg, int (*filterfn)(proc_t , void *), void *filterarg); extern int proc_childrenwalk(proc_t p, int (*callout)(proc_t , void *), void *arg); -extern proc_t proc_findinternal(int pid, int funneled); +extern proc_t proc_findinternal(int pid, int locked); extern proc_t proc_findthread(thread_t thread); extern void proc_refdrain(proc_t); extern void proc_childdrainlocked(proc_t); @@ -727,7 +767,7 @@ int itimerfix(struct timeval *tv); int itimerdecr(struct proc * p, struct itimerval *itp, int usec); void proc_signalstart(struct proc *, int locked); void proc_signalend(struct proc *, int locked); -int proc_transstart(struct proc *, int locked); +int proc_transstart(struct proc *, int locked, int non_blocking); void proc_transcommit(struct proc *, int locked); void proc_transend(struct proc *, int locked); int proc_transwait(struct proc *, int locked); @@ -743,9 +783,8 @@ void proc_resetregister(proc_t p); thread_t proc_thread(proc_t); extern int proc_pendingsignals(proc_t, sigset_t); int proc_getpcontrol(int pid, int * pcontrolp); -int proc_dopcontrol(proc_t p, void *unused_arg); +int proc_dopcontrol(proc_t p); int proc_resetpcontrol(int pid); -extern void proc_removethrottle(proc_t); #if PSYNCH void pth_proc_hashinit(proc_t); void pth_proc_hashdelete(proc_t); @@ -755,4 +794,11 @@ void psynch_wq_cleanup(__unused void * param, __unused void * param1); extern lck_mtx_t * pthread_list_mlock; #endif /* PSYNCH */ struct uthread * current_uthread(void); + +/* return 1 if process is forcing case-sensitive HFS+ access, 0 for default */ +extern int proc_is_forcing_hfs_case_sensitivity(proc_t); + +pid_t dtrace_proc_selfpid(void); +pid_t dtrace_proc_selfppid(void); +uid_t dtrace_proc_selfruid(void); #endif /* !_SYS_PROC_INTERNAL_H_ */