11da177e4SLinus Torvalds #ifndef _LINUX_SCHED_H 21da177e4SLinus Torvalds #define _LINUX_SCHED_H 31da177e4SLinus Torvalds 4b7b3c76aSDavid Woodhouse /* 5b7b3c76aSDavid Woodhouse * cloning flags: 6b7b3c76aSDavid Woodhouse */ 7b7b3c76aSDavid Woodhouse #define CSIGNAL 0x000000ff /* signal mask to be sent at exit */ 8b7b3c76aSDavid Woodhouse #define CLONE_VM 0x00000100 /* set if VM shared between processes */ 9b7b3c76aSDavid Woodhouse #define CLONE_FS 0x00000200 /* set if fs info shared between processes */ 10b7b3c76aSDavid Woodhouse #define CLONE_FILES 0x00000400 /* set if open files shared between processes */ 11b7b3c76aSDavid Woodhouse #define CLONE_SIGHAND 0x00000800 /* set if signal handlers and blocked signals shared */ 12b7b3c76aSDavid Woodhouse #define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */ 13b7b3c76aSDavid Woodhouse #define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */ 14b7b3c76aSDavid Woodhouse #define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */ 15b7b3c76aSDavid Woodhouse #define CLONE_THREAD 0x00010000 /* Same thread group? */ 16b7b3c76aSDavid Woodhouse #define CLONE_NEWNS 0x00020000 /* New namespace group? */ 17b7b3c76aSDavid Woodhouse #define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */ 18b7b3c76aSDavid Woodhouse #define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */ 19b7b3c76aSDavid Woodhouse #define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */ 20b7b3c76aSDavid Woodhouse #define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */ 21b7b3c76aSDavid Woodhouse #define CLONE_DETACHED 0x00400000 /* Unused, ignored */ 22b7b3c76aSDavid Woodhouse #define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */ 23b7b3c76aSDavid Woodhouse #define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */ 24b7b3c76aSDavid Woodhouse #define CLONE_STOPPED 0x02000000 /* Start in stopped state */ 25071df104SSerge E. Hallyn #define CLONE_NEWUTS 0x04000000 /* New utsname group? */ 2625b21cb2SKirill Korotaev #define CLONE_NEWIPC 0x08000000 /* New ipcs */ 2777ec739dSSerge E. Hallyn #define CLONE_NEWUSER 0x10000000 /* New user namespace */ 2830e49c26SPavel Emelyanov #define CLONE_NEWPID 0x20000000 /* New pid namespace */ 29169e3674SEric W. Biederman #define CLONE_NEWNET 0x40000000 /* New network namespace */ 30fadad878SJens Axboe #define CLONE_IO 0x80000000 /* Clone io context */ 31b7b3c76aSDavid Woodhouse 32b7b3c76aSDavid Woodhouse /* 33b7b3c76aSDavid Woodhouse * Scheduling policies 34b7b3c76aSDavid Woodhouse */ 35b7b3c76aSDavid Woodhouse #define SCHED_NORMAL 0 36b7b3c76aSDavid Woodhouse #define SCHED_FIFO 1 37b7b3c76aSDavid Woodhouse #define SCHED_RR 2 38b7b3c76aSDavid Woodhouse #define SCHED_BATCH 3 390e6aca43SIngo Molnar /* SCHED_ISO: reserved but not implemented yet */ 400e6aca43SIngo Molnar #define SCHED_IDLE 5 41b7b3c76aSDavid Woodhouse 42a3b6714eSDavid Woodhouse #ifdef __KERNEL__ 43b7b3c76aSDavid Woodhouse 44b7b3c76aSDavid Woodhouse struct sched_param { 45b7b3c76aSDavid Woodhouse int sched_priority; 46b7b3c76aSDavid Woodhouse }; 47b7b3c76aSDavid Woodhouse 481da177e4SLinus Torvalds #include <asm/param.h> /* for HZ */ 491da177e4SLinus Torvalds 501da177e4SLinus Torvalds #include <linux/capability.h> 511da177e4SLinus Torvalds #include <linux/threads.h> 521da177e4SLinus Torvalds #include <linux/kernel.h> 531da177e4SLinus Torvalds #include <linux/types.h> 541da177e4SLinus Torvalds #include <linux/timex.h> 551da177e4SLinus Torvalds #include <linux/jiffies.h> 561da177e4SLinus Torvalds #include <linux/rbtree.h> 571da177e4SLinus Torvalds #include <linux/thread_info.h> 581da177e4SLinus Torvalds #include <linux/cpumask.h> 591da177e4SLinus Torvalds #include <linux/errno.h> 601da177e4SLinus Torvalds #include <linux/nodemask.h> 61c92ff1bdSMartin Schwidefsky #include <linux/mm_types.h> 621da177e4SLinus Torvalds 631da177e4SLinus Torvalds #include <asm/system.h> 641da177e4SLinus Torvalds #include <asm/page.h> 651da177e4SLinus Torvalds #include <asm/ptrace.h> 661da177e4SLinus Torvalds #include <asm/cputime.h> 671da177e4SLinus Torvalds 681da177e4SLinus Torvalds #include <linux/smp.h> 691da177e4SLinus Torvalds #include <linux/sem.h> 701da177e4SLinus Torvalds #include <linux/signal.h> 711da177e4SLinus Torvalds #include <linux/fs_struct.h> 721da177e4SLinus Torvalds #include <linux/compiler.h> 731da177e4SLinus Torvalds #include <linux/completion.h> 741da177e4SLinus Torvalds #include <linux/pid.h> 751da177e4SLinus Torvalds #include <linux/percpu.h> 761da177e4SLinus Torvalds #include <linux/topology.h> 773e26c149SPeter Zijlstra #include <linux/proportions.h> 781da177e4SLinus Torvalds #include <linux/seccomp.h> 79e56d0903SIngo Molnar #include <linux/rcupdate.h> 8023f78d4aSIngo Molnar #include <linux/rtmutex.h> 811da177e4SLinus Torvalds 82a3b6714eSDavid Woodhouse #include <linux/time.h> 83a3b6714eSDavid Woodhouse #include <linux/param.h> 84a3b6714eSDavid Woodhouse #include <linux/resource.h> 85a3b6714eSDavid Woodhouse #include <linux/timer.h> 86a3b6714eSDavid Woodhouse #include <linux/hrtimer.h> 877c3ab738SAndrew Morton #include <linux/task_io_accounting.h> 885cb350baSDhaval Giani #include <linux/kobject.h> 899745512cSArjan van de Ven #include <linux/latencytop.h> 909e2b2dc4SDavid Howells #include <linux/cred.h> 91a3b6714eSDavid Woodhouse 92a3b6714eSDavid Woodhouse #include <asm/processor.h> 9336d57ac4SH. J. Lu 9478fb7466SPavel Emelianov struct mem_cgroup; 951da177e4SLinus Torvalds struct exec_domain; 96c87e2837SIngo Molnar struct futex_pi_state; 97286100a6SAlexey Dobriyan struct robust_list_head; 98d89d8796SNeil Brown struct bio; 991da177e4SLinus Torvalds 1001da177e4SLinus Torvalds /* 1011da177e4SLinus Torvalds * List of flags we want to share for kernel threads, 1021da177e4SLinus Torvalds * if only because they are not used by them anyway. 1031da177e4SLinus Torvalds */ 1041da177e4SLinus Torvalds #define CLONE_KERNEL (CLONE_FS | CLONE_FILES | CLONE_SIGHAND) 1051da177e4SLinus Torvalds 1061da177e4SLinus Torvalds /* 1071da177e4SLinus Torvalds * These are the constant used to fake the fixed-point load-average 1081da177e4SLinus Torvalds * counting. Some notes: 1091da177e4SLinus Torvalds * - 11 bit fractions expand to 22 bits by the multiplies: this gives 1101da177e4SLinus Torvalds * a load-average precision of 10 bits integer + 11 bits fractional 1111da177e4SLinus Torvalds * - if you want to count load-averages more often, you need more 1121da177e4SLinus Torvalds * precision, or rounding will get you. With 2-second counting freq, 1131da177e4SLinus Torvalds * the EXP_n values would be 1981, 2034 and 2043 if still using only 1141da177e4SLinus Torvalds * 11 bit fractions. 1151da177e4SLinus Torvalds */ 1161da177e4SLinus Torvalds extern unsigned long avenrun[]; /* Load averages */ 1171da177e4SLinus Torvalds 1181da177e4SLinus Torvalds #define FSHIFT 11 /* nr of bits of precision */ 1191da177e4SLinus Torvalds #define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */ 1200c2043abSLinus Torvalds #define LOAD_FREQ (5*HZ+1) /* 5 sec intervals */ 1211da177e4SLinus Torvalds #define EXP_1 1884 /* 1/exp(5sec/1min) as fixed-point */ 1221da177e4SLinus Torvalds #define EXP_5 2014 /* 1/exp(5sec/5min) */ 1231da177e4SLinus Torvalds #define EXP_15 2037 /* 1/exp(5sec/15min) */ 1241da177e4SLinus Torvalds 1251da177e4SLinus Torvalds #define CALC_LOAD(load,exp,n) \ 1261da177e4SLinus Torvalds load *= exp; \ 1271da177e4SLinus Torvalds load += n*(FIXED_1-exp); \ 1281da177e4SLinus Torvalds load >>= FSHIFT; 1291da177e4SLinus Torvalds 1301da177e4SLinus Torvalds extern unsigned long total_forks; 1311da177e4SLinus Torvalds extern int nr_threads; 1321da177e4SLinus Torvalds DECLARE_PER_CPU(unsigned long, process_counts); 1331da177e4SLinus Torvalds extern int nr_processes(void); 1341da177e4SLinus Torvalds extern unsigned long nr_running(void); 1351da177e4SLinus Torvalds extern unsigned long nr_uninterruptible(void); 136db1b1fefSJack Steiner extern unsigned long nr_active(void); 1371da177e4SLinus Torvalds extern unsigned long nr_iowait(void); 1381da177e4SLinus Torvalds 13943ae34cbSIngo Molnar struct seq_file; 14043ae34cbSIngo Molnar struct cfs_rq; 1414cf86d77SIngo Molnar struct task_group; 14243ae34cbSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 14343ae34cbSIngo Molnar extern void proc_sched_show_task(struct task_struct *p, struct seq_file *m); 14443ae34cbSIngo Molnar extern void proc_sched_set_task(struct task_struct *p); 14543ae34cbSIngo Molnar extern void 1465cef9ecaSIngo Molnar print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq); 14743ae34cbSIngo Molnar #else 14843ae34cbSIngo Molnar static inline void 14943ae34cbSIngo Molnar proc_sched_show_task(struct task_struct *p, struct seq_file *m) 15043ae34cbSIngo Molnar { 15143ae34cbSIngo Molnar } 15243ae34cbSIngo Molnar static inline void proc_sched_set_task(struct task_struct *p) 15343ae34cbSIngo Molnar { 15443ae34cbSIngo Molnar } 15543ae34cbSIngo Molnar static inline void 1565cef9ecaSIngo Molnar print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq) 15743ae34cbSIngo Molnar { 15843ae34cbSIngo Molnar } 15943ae34cbSIngo Molnar #endif 1601da177e4SLinus Torvalds 161690229a0SIngo Molnar extern unsigned long long time_sync_thresh; 162690229a0SIngo Molnar 1634a8342d2SLinus Torvalds /* 1644a8342d2SLinus Torvalds * Task state bitmask. NOTE! These bits are also 1654a8342d2SLinus Torvalds * encoded in fs/proc/array.c: get_task_state(). 1664a8342d2SLinus Torvalds * 1674a8342d2SLinus Torvalds * We have two separate sets of flags: task->state 1684a8342d2SLinus Torvalds * is about runnability, while task->exit_state are 1694a8342d2SLinus Torvalds * about the task exiting. Confusing, but this way 1704a8342d2SLinus Torvalds * modifying one set can't modify the other one by 1714a8342d2SLinus Torvalds * mistake. 1724a8342d2SLinus Torvalds */ 1731da177e4SLinus Torvalds #define TASK_RUNNING 0 1741da177e4SLinus Torvalds #define TASK_INTERRUPTIBLE 1 1751da177e4SLinus Torvalds #define TASK_UNINTERRUPTIBLE 2 176f021a3c2SMatthew Wilcox #define __TASK_STOPPED 4 177f021a3c2SMatthew Wilcox #define __TASK_TRACED 8 1784a8342d2SLinus Torvalds /* in tsk->exit_state */ 1794a8342d2SLinus Torvalds #define EXIT_ZOMBIE 16 1804a8342d2SLinus Torvalds #define EXIT_DEAD 32 1814a8342d2SLinus Torvalds /* in tsk->state again */ 182af927232SMike Galbraith #define TASK_DEAD 64 183f021a3c2SMatthew Wilcox #define TASK_WAKEKILL 128 184f021a3c2SMatthew Wilcox 185f021a3c2SMatthew Wilcox /* Convenience macros for the sake of set_task_state */ 186f021a3c2SMatthew Wilcox #define TASK_KILLABLE (TASK_WAKEKILL | TASK_UNINTERRUPTIBLE) 187f021a3c2SMatthew Wilcox #define TASK_STOPPED (TASK_WAKEKILL | __TASK_STOPPED) 188f021a3c2SMatthew Wilcox #define TASK_TRACED (TASK_WAKEKILL | __TASK_TRACED) 1891da177e4SLinus Torvalds 19092a1f4bcSMatthew Wilcox /* Convenience macros for the sake of wake_up */ 19192a1f4bcSMatthew Wilcox #define TASK_NORMAL (TASK_INTERRUPTIBLE | TASK_UNINTERRUPTIBLE) 192f021a3c2SMatthew Wilcox #define TASK_ALL (TASK_NORMAL | __TASK_STOPPED | __TASK_TRACED) 19392a1f4bcSMatthew Wilcox 19492a1f4bcSMatthew Wilcox /* get_task_state() */ 19592a1f4bcSMatthew Wilcox #define TASK_REPORT (TASK_RUNNING | TASK_INTERRUPTIBLE | \ 196f021a3c2SMatthew Wilcox TASK_UNINTERRUPTIBLE | __TASK_STOPPED | \ 197f021a3c2SMatthew Wilcox __TASK_TRACED) 19892a1f4bcSMatthew Wilcox 199f021a3c2SMatthew Wilcox #define task_is_traced(task) ((task->state & __TASK_TRACED) != 0) 200f021a3c2SMatthew Wilcox #define task_is_stopped(task) ((task->state & __TASK_STOPPED) != 0) 20192a1f4bcSMatthew Wilcox #define task_is_stopped_or_traced(task) \ 202f021a3c2SMatthew Wilcox ((task->state & (__TASK_STOPPED | __TASK_TRACED)) != 0) 20392a1f4bcSMatthew Wilcox #define task_contributes_to_load(task) \ 20492a1f4bcSMatthew Wilcox ((task->state & TASK_UNINTERRUPTIBLE) != 0) 2051da177e4SLinus Torvalds 2061da177e4SLinus Torvalds #define __set_task_state(tsk, state_value) \ 2071da177e4SLinus Torvalds do { (tsk)->state = (state_value); } while (0) 2081da177e4SLinus Torvalds #define set_task_state(tsk, state_value) \ 2091da177e4SLinus Torvalds set_mb((tsk)->state, (state_value)) 2101da177e4SLinus Torvalds 211498d0c57SAndrew Morton /* 212498d0c57SAndrew Morton * set_current_state() includes a barrier so that the write of current->state 213498d0c57SAndrew Morton * is correctly serialised wrt the caller's subsequent test of whether to 214498d0c57SAndrew Morton * actually sleep: 215498d0c57SAndrew Morton * 216498d0c57SAndrew Morton * set_current_state(TASK_UNINTERRUPTIBLE); 217498d0c57SAndrew Morton * if (do_i_need_to_sleep()) 218498d0c57SAndrew Morton * schedule(); 219498d0c57SAndrew Morton * 220498d0c57SAndrew Morton * If the caller does not need such serialisation then use __set_current_state() 221498d0c57SAndrew Morton */ 2221da177e4SLinus Torvalds #define __set_current_state(state_value) \ 2231da177e4SLinus Torvalds do { current->state = (state_value); } while (0) 2241da177e4SLinus Torvalds #define set_current_state(state_value) \ 2251da177e4SLinus Torvalds set_mb(current->state, (state_value)) 2261da177e4SLinus Torvalds 2271da177e4SLinus Torvalds /* Task command name length */ 2281da177e4SLinus Torvalds #define TASK_COMM_LEN 16 2291da177e4SLinus Torvalds 2301da177e4SLinus Torvalds #include <linux/spinlock.h> 2311da177e4SLinus Torvalds 2321da177e4SLinus Torvalds /* 2331da177e4SLinus Torvalds * This serializes "schedule()" and also protects 2341da177e4SLinus Torvalds * the run-queue from deletions/modifications (but 2351da177e4SLinus Torvalds * _adding_ to the beginning of the run-queue has 2361da177e4SLinus Torvalds * a separate lock). 2371da177e4SLinus Torvalds */ 2381da177e4SLinus Torvalds extern rwlock_t tasklist_lock; 2391da177e4SLinus Torvalds extern spinlock_t mmlist_lock; 2401da177e4SLinus Torvalds 24136c8b586SIngo Molnar struct task_struct; 2421da177e4SLinus Torvalds 2431da177e4SLinus Torvalds extern void sched_init(void); 2441da177e4SLinus Torvalds extern void sched_init_smp(void); 2452d07b255SHarvey Harrison extern asmlinkage void schedule_tail(struct task_struct *prev); 24636c8b586SIngo Molnar extern void init_idle(struct task_struct *idle, int cpu); 2471df21055SIngo Molnar extern void init_idle_bootup_task(struct task_struct *idle); 2481da177e4SLinus Torvalds 249017730c1SIngo Molnar extern int runqueue_is_locked(void); 250017730c1SIngo Molnar 2511da177e4SLinus Torvalds extern cpumask_t nohz_cpu_mask; 25246cb4b7cSSiddha, Suresh B #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ) 25346cb4b7cSSiddha, Suresh B extern int select_nohz_load_balancer(int cpu); 25446cb4b7cSSiddha, Suresh B #else 25546cb4b7cSSiddha, Suresh B static inline int select_nohz_load_balancer(int cpu) 25646cb4b7cSSiddha, Suresh B { 25746cb4b7cSSiddha, Suresh B return 0; 25846cb4b7cSSiddha, Suresh B } 25946cb4b7cSSiddha, Suresh B #endif 2601da177e4SLinus Torvalds 26148d5e258SPeter Zijlstra extern unsigned long rt_needs_cpu(int cpu); 26248d5e258SPeter Zijlstra 263e59e2ae2SIngo Molnar /* 26439bc89fdSIngo Molnar * Only dump TASK_* tasks. (0 for all tasks) 265e59e2ae2SIngo Molnar */ 266e59e2ae2SIngo Molnar extern void show_state_filter(unsigned long state_filter); 267e59e2ae2SIngo Molnar 268e59e2ae2SIngo Molnar static inline void show_state(void) 269e59e2ae2SIngo Molnar { 27039bc89fdSIngo Molnar show_state_filter(0); 271e59e2ae2SIngo Molnar } 272e59e2ae2SIngo Molnar 2731da177e4SLinus Torvalds extern void show_regs(struct pt_regs *); 2741da177e4SLinus Torvalds 2751da177e4SLinus Torvalds /* 2761da177e4SLinus Torvalds * TASK is a pointer to the task whose backtrace we want to see (or NULL for current 2771da177e4SLinus Torvalds * task), SP is the stack pointer of the first frame that should be shown in the back 2781da177e4SLinus Torvalds * trace (or NULL if the entire call-chain of the task should be shown). 2791da177e4SLinus Torvalds */ 2801da177e4SLinus Torvalds extern void show_stack(struct task_struct *task, unsigned long *sp); 2811da177e4SLinus Torvalds 2821da177e4SLinus Torvalds void io_schedule(void); 2831da177e4SLinus Torvalds long io_schedule_timeout(long timeout); 2841da177e4SLinus Torvalds 2851da177e4SLinus Torvalds extern void cpu_init (void); 2861da177e4SLinus Torvalds extern void trap_init(void); 287fa13a5a1SPaul Mackerras extern void account_process_tick(struct task_struct *task, int user); 2881da177e4SLinus Torvalds extern void update_process_times(int user); 2891da177e4SLinus Torvalds extern void scheduler_tick(void); 2908f4d37ecSPeter Zijlstra extern void hrtick_resched(void); 2911da177e4SLinus Torvalds 29282a1fcb9SIngo Molnar extern void sched_show_task(struct task_struct *p); 29382a1fcb9SIngo Molnar 2948446f1d3SIngo Molnar #ifdef CONFIG_DETECT_SOFTLOCKUP 2956687a97dSIngo Molnar extern void softlockup_tick(void); 2968446f1d3SIngo Molnar extern void touch_softlockup_watchdog(void); 29704c9167fSJeremy Fitzhardinge extern void touch_all_softlockup_watchdogs(void); 2989c44bc03SIngo Molnar extern unsigned int softlockup_panic; 29982a1fcb9SIngo Molnar extern unsigned long sysctl_hung_task_check_count; 30082a1fcb9SIngo Molnar extern unsigned long sysctl_hung_task_timeout_secs; 30190739081SIngo Molnar extern unsigned long sysctl_hung_task_warnings; 3029383d967SDimitri Sivanich extern int softlockup_thresh; 3038446f1d3SIngo Molnar #else 3046687a97dSIngo Molnar static inline void softlockup_tick(void) 3058446f1d3SIngo Molnar { 3068446f1d3SIngo Molnar } 3078446f1d3SIngo Molnar static inline void spawn_softlockup_task(void) 3088446f1d3SIngo Molnar { 3098446f1d3SIngo Molnar } 3108446f1d3SIngo Molnar static inline void touch_softlockup_watchdog(void) 3118446f1d3SIngo Molnar { 3128446f1d3SIngo Molnar } 31304c9167fSJeremy Fitzhardinge static inline void touch_all_softlockup_watchdogs(void) 31404c9167fSJeremy Fitzhardinge { 31504c9167fSJeremy Fitzhardinge } 3168446f1d3SIngo Molnar #endif 3178446f1d3SIngo Molnar 3188446f1d3SIngo Molnar 3191da177e4SLinus Torvalds /* Attach to any functions which should be ignored in wchan output. */ 3201da177e4SLinus Torvalds #define __sched __attribute__((__section__(".sched.text"))) 321deaf2227SIngo Molnar 322deaf2227SIngo Molnar /* Linker adds these: start and end of __sched functions */ 323deaf2227SIngo Molnar extern char __sched_text_start[], __sched_text_end[]; 324deaf2227SIngo Molnar 3251da177e4SLinus Torvalds /* Is this address in the __sched functions? */ 3261da177e4SLinus Torvalds extern int in_sched_functions(unsigned long addr); 3271da177e4SLinus Torvalds 3281da177e4SLinus Torvalds #define MAX_SCHEDULE_TIMEOUT LONG_MAX 329b3c97528SHarvey Harrison extern signed long schedule_timeout(signed long timeout); 33064ed93a2SNishanth Aravamudan extern signed long schedule_timeout_interruptible(signed long timeout); 331294d5cc2SMatthew Wilcox extern signed long schedule_timeout_killable(signed long timeout); 33264ed93a2SNishanth Aravamudan extern signed long schedule_timeout_uninterruptible(signed long timeout); 3331da177e4SLinus Torvalds asmlinkage void schedule(void); 3341da177e4SLinus Torvalds 335ab516013SSerge E. Hallyn struct nsproxy; 336acce292cSCedric Le Goater struct user_namespace; 3371da177e4SLinus Torvalds 3381da177e4SLinus Torvalds /* Maximum number of active map areas.. This is a random (large) number */ 3391da177e4SLinus Torvalds #define DEFAULT_MAX_MAP_COUNT 65536 3401da177e4SLinus Torvalds 3411da177e4SLinus Torvalds extern int sysctl_max_map_count; 3421da177e4SLinus Torvalds 3431da177e4SLinus Torvalds #include <linux/aio.h> 3441da177e4SLinus Torvalds 3451da177e4SLinus Torvalds extern unsigned long 3461da177e4SLinus Torvalds arch_get_unmapped_area(struct file *, unsigned long, unsigned long, 3471da177e4SLinus Torvalds unsigned long, unsigned long); 3481da177e4SLinus Torvalds extern unsigned long 3491da177e4SLinus Torvalds arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr, 3501da177e4SLinus Torvalds unsigned long len, unsigned long pgoff, 3511da177e4SLinus Torvalds unsigned long flags); 3521363c3cdSWolfgang Wander extern void arch_unmap_area(struct mm_struct *, unsigned long); 3531363c3cdSWolfgang Wander extern void arch_unmap_area_topdown(struct mm_struct *, unsigned long); 3541da177e4SLinus Torvalds 355f412ac08SHugh Dickins #if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS 356f412ac08SHugh Dickins /* 357f412ac08SHugh Dickins * The mm counters are not protected by its page_table_lock, 358f412ac08SHugh Dickins * so must be incremented atomically. 359f412ac08SHugh Dickins */ 360d3cb4871SChristoph Lameter #define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value) 361d3cb4871SChristoph Lameter #define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member)) 362d3cb4871SChristoph Lameter #define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member) 363d3cb4871SChristoph Lameter #define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member) 364d3cb4871SChristoph Lameter #define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member) 365f412ac08SHugh Dickins 366f412ac08SHugh Dickins #else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */ 367f412ac08SHugh Dickins /* 368f412ac08SHugh Dickins * The mm counters are protected by its page_table_lock, 369f412ac08SHugh Dickins * so can be incremented directly. 370f412ac08SHugh Dickins */ 3711da177e4SLinus Torvalds #define set_mm_counter(mm, member, value) (mm)->_##member = (value) 3721da177e4SLinus Torvalds #define get_mm_counter(mm, member) ((mm)->_##member) 3731da177e4SLinus Torvalds #define add_mm_counter(mm, member, value) (mm)->_##member += (value) 3741da177e4SLinus Torvalds #define inc_mm_counter(mm, member) (mm)->_##member++ 3751da177e4SLinus Torvalds #define dec_mm_counter(mm, member) (mm)->_##member-- 3764294621fSHugh Dickins 377f412ac08SHugh Dickins #endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */ 378f412ac08SHugh Dickins 379f412ac08SHugh Dickins #define get_mm_rss(mm) \ 380f412ac08SHugh Dickins (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss)) 381365e9c87SHugh Dickins #define update_hiwater_rss(mm) do { \ 382365e9c87SHugh Dickins unsigned long _rss = get_mm_rss(mm); \ 383365e9c87SHugh Dickins if ((mm)->hiwater_rss < _rss) \ 384365e9c87SHugh Dickins (mm)->hiwater_rss = _rss; \ 385365e9c87SHugh Dickins } while (0) 386365e9c87SHugh Dickins #define update_hiwater_vm(mm) do { \ 387365e9c87SHugh Dickins if ((mm)->hiwater_vm < (mm)->total_vm) \ 388365e9c87SHugh Dickins (mm)->hiwater_vm = (mm)->total_vm; \ 389365e9c87SHugh Dickins } while (0) 390365e9c87SHugh Dickins 3916c5d5238SKawai, Hidehiro extern void set_dumpable(struct mm_struct *mm, int value); 3926c5d5238SKawai, Hidehiro extern int get_dumpable(struct mm_struct *mm); 3936c5d5238SKawai, Hidehiro 3946c5d5238SKawai, Hidehiro /* mm flags */ 3953cb4a0bbSKawai, Hidehiro /* dumpable bits */ 3966c5d5238SKawai, Hidehiro #define MMF_DUMPABLE 0 /* core dump is permitted */ 3976c5d5238SKawai, Hidehiro #define MMF_DUMP_SECURELY 1 /* core file is readable only by root */ 3983cb4a0bbSKawai, Hidehiro #define MMF_DUMPABLE_BITS 2 3993cb4a0bbSKawai, Hidehiro 4003cb4a0bbSKawai, Hidehiro /* coredump filter bits */ 4013cb4a0bbSKawai, Hidehiro #define MMF_DUMP_ANON_PRIVATE 2 4023cb4a0bbSKawai, Hidehiro #define MMF_DUMP_ANON_SHARED 3 4033cb4a0bbSKawai, Hidehiro #define MMF_DUMP_MAPPED_PRIVATE 4 4043cb4a0bbSKawai, Hidehiro #define MMF_DUMP_MAPPED_SHARED 5 40582df3973SRoland McGrath #define MMF_DUMP_ELF_HEADERS 6 4063cb4a0bbSKawai, Hidehiro #define MMF_DUMP_FILTER_SHIFT MMF_DUMPABLE_BITS 40782df3973SRoland McGrath #define MMF_DUMP_FILTER_BITS 5 4083cb4a0bbSKawai, Hidehiro #define MMF_DUMP_FILTER_MASK \ 4093cb4a0bbSKawai, Hidehiro (((1 << MMF_DUMP_FILTER_BITS) - 1) << MMF_DUMP_FILTER_SHIFT) 4103cb4a0bbSKawai, Hidehiro #define MMF_DUMP_FILTER_DEFAULT \ 4113cb4a0bbSKawai, Hidehiro ((1 << MMF_DUMP_ANON_PRIVATE) | (1 << MMF_DUMP_ANON_SHARED)) 4126c5d5238SKawai, Hidehiro 4131da177e4SLinus Torvalds struct sighand_struct { 4141da177e4SLinus Torvalds atomic_t count; 4151da177e4SLinus Torvalds struct k_sigaction action[_NSIG]; 4161da177e4SLinus Torvalds spinlock_t siglock; 417b8fceee1SDavide Libenzi wait_queue_head_t signalfd_wqh; 4181da177e4SLinus Torvalds }; 4191da177e4SLinus Torvalds 4200e464814SKaiGai Kohei struct pacct_struct { 421f6ec29a4SKaiGai Kohei int ac_flag; 422f6ec29a4SKaiGai Kohei long ac_exitcode; 4230e464814SKaiGai Kohei unsigned long ac_mem; 42477787bfbSKaiGai Kohei cputime_t ac_utime, ac_stime; 42577787bfbSKaiGai Kohei unsigned long ac_minflt, ac_majflt; 4260e464814SKaiGai Kohei }; 4270e464814SKaiGai Kohei 428*f06febc9SFrank Mayhar /** 429*f06febc9SFrank Mayhar * struct task_cputime - collected CPU time counts 430*f06febc9SFrank Mayhar * @utime: time spent in user mode, in &cputime_t units 431*f06febc9SFrank Mayhar * @stime: time spent in kernel mode, in &cputime_t units 432*f06febc9SFrank Mayhar * @sum_exec_runtime: total time spent on the CPU, in nanoseconds 433*f06febc9SFrank Mayhar * 434*f06febc9SFrank Mayhar * This structure groups together three kinds of CPU time that are 435*f06febc9SFrank Mayhar * tracked for threads and thread groups. Most things considering 436*f06febc9SFrank Mayhar * CPU time want to group these counts together and treat all three 437*f06febc9SFrank Mayhar * of them in parallel. 438*f06febc9SFrank Mayhar */ 439*f06febc9SFrank Mayhar struct task_cputime { 440*f06febc9SFrank Mayhar cputime_t utime; 441*f06febc9SFrank Mayhar cputime_t stime; 442*f06febc9SFrank Mayhar unsigned long long sum_exec_runtime; 443*f06febc9SFrank Mayhar }; 444*f06febc9SFrank Mayhar /* Alternate field names when used to cache expirations. */ 445*f06febc9SFrank Mayhar #define prof_exp stime 446*f06febc9SFrank Mayhar #define virt_exp utime 447*f06febc9SFrank Mayhar #define sched_exp sum_exec_runtime 448*f06febc9SFrank Mayhar 449*f06febc9SFrank Mayhar /** 450*f06febc9SFrank Mayhar * struct thread_group_cputime - thread group interval timer counts 451*f06febc9SFrank Mayhar * @totals: thread group interval timers; substructure for 452*f06febc9SFrank Mayhar * uniprocessor kernel, per-cpu for SMP kernel. 453*f06febc9SFrank Mayhar * 454*f06febc9SFrank Mayhar * This structure contains the version of task_cputime, above, that is 455*f06febc9SFrank Mayhar * used for thread group CPU clock calculations. 456*f06febc9SFrank Mayhar */ 457*f06febc9SFrank Mayhar #ifdef CONFIG_SMP 458*f06febc9SFrank Mayhar struct thread_group_cputime { 459*f06febc9SFrank Mayhar struct task_cputime *totals; 460*f06febc9SFrank Mayhar }; 461*f06febc9SFrank Mayhar #else 462*f06febc9SFrank Mayhar struct thread_group_cputime { 463*f06febc9SFrank Mayhar struct task_cputime totals; 464*f06febc9SFrank Mayhar }; 465*f06febc9SFrank Mayhar #endif 466*f06febc9SFrank Mayhar 4671da177e4SLinus Torvalds /* 4681da177e4SLinus Torvalds * NOTE! "signal_struct" does not have it's own 4691da177e4SLinus Torvalds * locking, because a shared signal_struct always 4701da177e4SLinus Torvalds * implies a shared sighand_struct, so locking 4711da177e4SLinus Torvalds * sighand_struct is always a proper superset of 4721da177e4SLinus Torvalds * the locking of signal_struct. 4731da177e4SLinus Torvalds */ 4741da177e4SLinus Torvalds struct signal_struct { 4751da177e4SLinus Torvalds atomic_t count; 4761da177e4SLinus Torvalds atomic_t live; 4771da177e4SLinus Torvalds 4781da177e4SLinus Torvalds wait_queue_head_t wait_chldexit; /* for wait4() */ 4791da177e4SLinus Torvalds 4801da177e4SLinus Torvalds /* current thread group signal load-balancing target: */ 48136c8b586SIngo Molnar struct task_struct *curr_target; 4821da177e4SLinus Torvalds 4831da177e4SLinus Torvalds /* shared signal handling: */ 4841da177e4SLinus Torvalds struct sigpending shared_pending; 4851da177e4SLinus Torvalds 4861da177e4SLinus Torvalds /* thread group exit support */ 4871da177e4SLinus Torvalds int group_exit_code; 4881da177e4SLinus Torvalds /* overloaded: 4891da177e4SLinus Torvalds * - notify group_exit_task when ->count is equal to notify_count 4901da177e4SLinus Torvalds * - everyone except group_exit_task is stopped during signal delivery 4911da177e4SLinus Torvalds * of fatal signals, group_exit_task processes the signal. 4921da177e4SLinus Torvalds */ 4931da177e4SLinus Torvalds struct task_struct *group_exit_task; 4941da177e4SLinus Torvalds int notify_count; 4951da177e4SLinus Torvalds 4961da177e4SLinus Torvalds /* thread group stop support, overloads group_exit_code too */ 4971da177e4SLinus Torvalds int group_stop_count; 4981da177e4SLinus Torvalds unsigned int flags; /* see SIGNAL_* flags below */ 4991da177e4SLinus Torvalds 5001da177e4SLinus Torvalds /* POSIX.1b Interval Timers */ 5011da177e4SLinus Torvalds struct list_head posix_timers; 5021da177e4SLinus Torvalds 5031da177e4SLinus Torvalds /* ITIMER_REAL timer for the process */ 5042ff678b8SThomas Gleixner struct hrtimer real_timer; 505fea9d175SOleg Nesterov struct pid *leader_pid; 5062ff678b8SThomas Gleixner ktime_t it_real_incr; 5071da177e4SLinus Torvalds 5081da177e4SLinus Torvalds /* ITIMER_PROF and ITIMER_VIRTUAL timers for the process */ 5091da177e4SLinus Torvalds cputime_t it_prof_expires, it_virt_expires; 5101da177e4SLinus Torvalds cputime_t it_prof_incr, it_virt_incr; 5111da177e4SLinus Torvalds 512*f06febc9SFrank Mayhar /* 513*f06febc9SFrank Mayhar * Thread group totals for process CPU clocks. 514*f06febc9SFrank Mayhar * See thread_group_cputime(), et al, for details. 515*f06febc9SFrank Mayhar */ 516*f06febc9SFrank Mayhar struct thread_group_cputime cputime; 517*f06febc9SFrank Mayhar 518*f06febc9SFrank Mayhar /* Earliest-expiration cache. */ 519*f06febc9SFrank Mayhar struct task_cputime cputime_expires; 520*f06febc9SFrank Mayhar 521*f06febc9SFrank Mayhar struct list_head cpu_timers[3]; 522*f06febc9SFrank Mayhar 5231da177e4SLinus Torvalds /* job control IDs */ 5249a2e7057SPavel Emelyanov 5259a2e7057SPavel Emelyanov /* 5269a2e7057SPavel Emelyanov * pgrp and session fields are deprecated. 5279a2e7057SPavel Emelyanov * use the task_session_Xnr and task_pgrp_Xnr routines below 5289a2e7057SPavel Emelyanov */ 5299a2e7057SPavel Emelyanov 5309a2e7057SPavel Emelyanov union { 5319a2e7057SPavel Emelyanov pid_t pgrp __deprecated; 5329a2e7057SPavel Emelyanov pid_t __pgrp; 5339a2e7057SPavel Emelyanov }; 5349a2e7057SPavel Emelyanov 535ab521dc0SEric W. Biederman struct pid *tty_old_pgrp; 5361ec320afSCedric Le Goater 5371ec320afSCedric Le Goater union { 5381ec320afSCedric Le Goater pid_t session __deprecated; 5391ec320afSCedric Le Goater pid_t __session; 5401ec320afSCedric Le Goater }; 5411ec320afSCedric Le Goater 5421da177e4SLinus Torvalds /* boolean value for session group leader */ 5431da177e4SLinus Torvalds int leader; 5441da177e4SLinus Torvalds 5451da177e4SLinus Torvalds struct tty_struct *tty; /* NULL if no tty */ 5461da177e4SLinus Torvalds 5471da177e4SLinus Torvalds /* 5481da177e4SLinus Torvalds * Cumulative resource counters for dead threads in the group, 5491da177e4SLinus Torvalds * and for reaped dead child processes forked by this group. 5501da177e4SLinus Torvalds * Live threads maintain their own counters and add to these 5511da177e4SLinus Torvalds * in __exit_signal, except for the group leader. 5521da177e4SLinus Torvalds */ 553*f06febc9SFrank Mayhar cputime_t cutime, cstime; 5549ac52315SLaurent Vivier cputime_t gtime; 5559ac52315SLaurent Vivier cputime_t cgtime; 5561da177e4SLinus Torvalds unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw; 5571da177e4SLinus Torvalds unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt; 5586eaeeabaSEric Dumazet unsigned long inblock, oublock, cinblock, coublock; 559940389b8SAndrea Righi struct task_io_accounting ioac; 5601da177e4SLinus Torvalds 5611da177e4SLinus Torvalds /* 5621da177e4SLinus Torvalds * We don't bother to synchronize most readers of this at all, 5631da177e4SLinus Torvalds * because there is no reader checking a limit that actually needs 5641da177e4SLinus Torvalds * to get both rlim_cur and rlim_max atomically, and either one 5651da177e4SLinus Torvalds * alone is a single word that can safely be read normally. 5661da177e4SLinus Torvalds * getrlimit/setrlimit use task_lock(current->group_leader) to 5671da177e4SLinus Torvalds * protect this instead of the siglock, because they really 5681da177e4SLinus Torvalds * have no need to disable irqs. 5691da177e4SLinus Torvalds */ 5701da177e4SLinus Torvalds struct rlimit rlim[RLIM_NLIMITS]; 5711da177e4SLinus Torvalds 5721da177e4SLinus Torvalds /* keep the process-shared keyrings here so that they do the right 5731da177e4SLinus Torvalds * thing in threads created with CLONE_THREAD */ 5741da177e4SLinus Torvalds #ifdef CONFIG_KEYS 5751da177e4SLinus Torvalds struct key *session_keyring; /* keyring inherited over fork */ 5761da177e4SLinus Torvalds struct key *process_keyring; /* keyring private to this process */ 5771da177e4SLinus Torvalds #endif 5780e464814SKaiGai Kohei #ifdef CONFIG_BSD_PROCESS_ACCT 5790e464814SKaiGai Kohei struct pacct_struct pacct; /* per-process accounting information */ 5800e464814SKaiGai Kohei #endif 581ad4ecbcbSShailabh Nagar #ifdef CONFIG_TASKSTATS 582ad4ecbcbSShailabh Nagar struct taskstats *stats; 583ad4ecbcbSShailabh Nagar #endif 584522ed776SMiloslav Trmac #ifdef CONFIG_AUDIT 585522ed776SMiloslav Trmac unsigned audit_tty; 586522ed776SMiloslav Trmac struct tty_audit_buf *tty_audit_buf; 587522ed776SMiloslav Trmac #endif 5881da177e4SLinus Torvalds }; 5891da177e4SLinus Torvalds 5904866cde0SNick Piggin /* Context switch must be unlocked if interrupts are to be enabled */ 5914866cde0SNick Piggin #ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW 5924866cde0SNick Piggin # define __ARCH_WANT_UNLOCKED_CTXSW 5934866cde0SNick Piggin #endif 5944866cde0SNick Piggin 5951da177e4SLinus Torvalds /* 5961da177e4SLinus Torvalds * Bits in flags field of signal_struct. 5971da177e4SLinus Torvalds */ 5981da177e4SLinus Torvalds #define SIGNAL_STOP_STOPPED 0x00000001 /* job control stop in effect */ 5991da177e4SLinus Torvalds #define SIGNAL_STOP_DEQUEUED 0x00000002 /* stop signal dequeued */ 6001da177e4SLinus Torvalds #define SIGNAL_STOP_CONTINUED 0x00000004 /* SIGCONT since WCONTINUED reap */ 6011da177e4SLinus Torvalds #define SIGNAL_GROUP_EXIT 0x00000008 /* group exit in progress */ 602e4420551SOleg Nesterov /* 603e4420551SOleg Nesterov * Pending notifications to parent. 604e4420551SOleg Nesterov */ 605e4420551SOleg Nesterov #define SIGNAL_CLD_STOPPED 0x00000010 606e4420551SOleg Nesterov #define SIGNAL_CLD_CONTINUED 0x00000020 607e4420551SOleg Nesterov #define SIGNAL_CLD_MASK (SIGNAL_CLD_STOPPED|SIGNAL_CLD_CONTINUED) 6081da177e4SLinus Torvalds 609fae5fa44SOleg Nesterov #define SIGNAL_UNKILLABLE 0x00000040 /* for init: ignore fatal signals */ 610fae5fa44SOleg Nesterov 611ed5d2cacSOleg Nesterov /* If true, all threads except ->group_exit_task have pending SIGKILL */ 612ed5d2cacSOleg Nesterov static inline int signal_group_exit(const struct signal_struct *sig) 613ed5d2cacSOleg Nesterov { 614ed5d2cacSOleg Nesterov return (sig->flags & SIGNAL_GROUP_EXIT) || 615ed5d2cacSOleg Nesterov (sig->group_exit_task != NULL); 616ed5d2cacSOleg Nesterov } 617ed5d2cacSOleg Nesterov 6181da177e4SLinus Torvalds /* 6191da177e4SLinus Torvalds * Some day this will be a full-fledged user tracking system.. 6201da177e4SLinus Torvalds */ 6211da177e4SLinus Torvalds struct user_struct { 6221da177e4SLinus Torvalds atomic_t __count; /* reference count */ 6231da177e4SLinus Torvalds atomic_t processes; /* How many processes does this user have? */ 6241da177e4SLinus Torvalds atomic_t files; /* How many open files does this user have? */ 6251da177e4SLinus Torvalds atomic_t sigpending; /* How many pending signals does this user have? */ 6262d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 6270eeca283SRobert Love atomic_t inotify_watches; /* How many inotify watches does this user have? */ 6280eeca283SRobert Love atomic_t inotify_devs; /* How many inotify devs does this user have opened? */ 6290eeca283SRobert Love #endif 630970a8645SAlexey Dobriyan #ifdef CONFIG_POSIX_MQUEUE 6311da177e4SLinus Torvalds /* protected by mq_lock */ 6321da177e4SLinus Torvalds unsigned long mq_bytes; /* How many bytes can be allocated to mqueue? */ 633970a8645SAlexey Dobriyan #endif 6341da177e4SLinus Torvalds unsigned long locked_shm; /* How many pages of mlocked shm ? */ 6351da177e4SLinus Torvalds 6361da177e4SLinus Torvalds #ifdef CONFIG_KEYS 6371da177e4SLinus Torvalds struct key *uid_keyring; /* UID specific keyring */ 6381da177e4SLinus Torvalds struct key *session_keyring; /* UID's default session keyring */ 6391da177e4SLinus Torvalds #endif 6401da177e4SLinus Torvalds 6411da177e4SLinus Torvalds /* Hash table maintenance information */ 642735de223SPavel Emelyanov struct hlist_node uidhash_node; 6431da177e4SLinus Torvalds uid_t uid; 64424e377a8SSrivatsa Vaddagiri 645052f1dc7SPeter Zijlstra #ifdef CONFIG_USER_SCHED 6464cf86d77SIngo Molnar struct task_group *tg; 647b1a8c172SDhaval Giani #ifdef CONFIG_SYSFS 648eb41d946SKay Sievers struct kobject kobj; 6495cb350baSDhaval Giani struct work_struct work; 65024e377a8SSrivatsa Vaddagiri #endif 651b1a8c172SDhaval Giani #endif 6521da177e4SLinus Torvalds }; 6531da177e4SLinus Torvalds 654eb41d946SKay Sievers extern int uids_sysfs_init(void); 6555cb350baSDhaval Giani 6561da177e4SLinus Torvalds extern struct user_struct *find_user(uid_t); 6571da177e4SLinus Torvalds 6581da177e4SLinus Torvalds extern struct user_struct root_user; 6591da177e4SLinus Torvalds #define INIT_USER (&root_user) 6601da177e4SLinus Torvalds 6611da177e4SLinus Torvalds struct backing_dev_info; 6621da177e4SLinus Torvalds struct reclaim_state; 6631da177e4SLinus Torvalds 66452f17b6cSChandra Seetharaman #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) 6651da177e4SLinus Torvalds struct sched_info { 6661da177e4SLinus Torvalds /* cumulative counters */ 6672d72376bSIngo Molnar unsigned long pcount; /* # of times run on this cpu */ 668172ba844SBalbir Singh unsigned long long cpu_time, /* time spent on the cpu */ 669172ba844SBalbir Singh run_delay; /* time spent waiting on a runqueue */ 6701da177e4SLinus Torvalds 6711da177e4SLinus Torvalds /* timestamps */ 672172ba844SBalbir Singh unsigned long long last_arrival,/* when we last ran on a cpu */ 6731da177e4SLinus Torvalds last_queued; /* when we were last queued to run */ 674b8efb561SIngo Molnar #ifdef CONFIG_SCHEDSTATS 675b8efb561SIngo Molnar /* BKL stats */ 676480b9434SKen Chen unsigned int bkl_count; 677b8efb561SIngo Molnar #endif 6781da177e4SLinus Torvalds }; 67952f17b6cSChandra Seetharaman #endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */ 6801da177e4SLinus Torvalds 68152f17b6cSChandra Seetharaman #ifdef CONFIG_SCHEDSTATS 68215ad7cdcSHelge Deller extern const struct file_operations proc_schedstat_operations; 68352f17b6cSChandra Seetharaman #endif /* CONFIG_SCHEDSTATS */ 6841da177e4SLinus Torvalds 685ca74e92bSShailabh Nagar #ifdef CONFIG_TASK_DELAY_ACCT 686ca74e92bSShailabh Nagar struct task_delay_info { 687ca74e92bSShailabh Nagar spinlock_t lock; 688ca74e92bSShailabh Nagar unsigned int flags; /* Private per-task flags */ 689ca74e92bSShailabh Nagar 690ca74e92bSShailabh Nagar /* For each stat XXX, add following, aligned appropriately 691ca74e92bSShailabh Nagar * 692ca74e92bSShailabh Nagar * struct timespec XXX_start, XXX_end; 693ca74e92bSShailabh Nagar * u64 XXX_delay; 694ca74e92bSShailabh Nagar * u32 XXX_count; 695ca74e92bSShailabh Nagar * 696ca74e92bSShailabh Nagar * Atomicity of updates to XXX_delay, XXX_count protected by 697ca74e92bSShailabh Nagar * single lock above (split into XXX_lock if contention is an issue). 698ca74e92bSShailabh Nagar */ 6990ff92245SShailabh Nagar 7000ff92245SShailabh Nagar /* 7010ff92245SShailabh Nagar * XXX_count is incremented on every XXX operation, the delay 7020ff92245SShailabh Nagar * associated with the operation is added to XXX_delay. 7030ff92245SShailabh Nagar * XXX_delay contains the accumulated delay time in nanoseconds. 7040ff92245SShailabh Nagar */ 7050ff92245SShailabh Nagar struct timespec blkio_start, blkio_end; /* Shared by blkio, swapin */ 7060ff92245SShailabh Nagar u64 blkio_delay; /* wait for sync block io completion */ 7070ff92245SShailabh Nagar u64 swapin_delay; /* wait for swapin block io completion */ 7080ff92245SShailabh Nagar u32 blkio_count; /* total count of the number of sync block */ 7090ff92245SShailabh Nagar /* io operations performed */ 7100ff92245SShailabh Nagar u32 swapin_count; /* total count of the number of swapin block */ 7110ff92245SShailabh Nagar /* io operations performed */ 712873b4771SKeika Kobayashi 713873b4771SKeika Kobayashi struct timespec freepages_start, freepages_end; 714873b4771SKeika Kobayashi u64 freepages_delay; /* wait for memory reclaim */ 715873b4771SKeika Kobayashi u32 freepages_count; /* total count of memory reclaim */ 716ca74e92bSShailabh Nagar }; 71752f17b6cSChandra Seetharaman #endif /* CONFIG_TASK_DELAY_ACCT */ 71852f17b6cSChandra Seetharaman 71952f17b6cSChandra Seetharaman static inline int sched_info_on(void) 72052f17b6cSChandra Seetharaman { 72152f17b6cSChandra Seetharaman #ifdef CONFIG_SCHEDSTATS 72252f17b6cSChandra Seetharaman return 1; 72352f17b6cSChandra Seetharaman #elif defined(CONFIG_TASK_DELAY_ACCT) 72452f17b6cSChandra Seetharaman extern int delayacct_on; 72552f17b6cSChandra Seetharaman return delayacct_on; 72652f17b6cSChandra Seetharaman #else 72752f17b6cSChandra Seetharaman return 0; 728ca74e92bSShailabh Nagar #endif 72952f17b6cSChandra Seetharaman } 730ca74e92bSShailabh Nagar 731d15bcfdbSIngo Molnar enum cpu_idle_type { 732d15bcfdbSIngo Molnar CPU_IDLE, 733d15bcfdbSIngo Molnar CPU_NOT_IDLE, 734d15bcfdbSIngo Molnar CPU_NEWLY_IDLE, 735d15bcfdbSIngo Molnar CPU_MAX_IDLE_TYPES 7361da177e4SLinus Torvalds }; 7371da177e4SLinus Torvalds 7381da177e4SLinus Torvalds /* 7391da177e4SLinus Torvalds * sched-domains (multiprocessor balancing) declarations: 7401da177e4SLinus Torvalds */ 7419aa7b369SIngo Molnar 7429aa7b369SIngo Molnar /* 7439aa7b369SIngo Molnar * Increase resolution of nice-level calculations: 7449aa7b369SIngo Molnar */ 7459aa7b369SIngo Molnar #define SCHED_LOAD_SHIFT 10 7469aa7b369SIngo Molnar #define SCHED_LOAD_SCALE (1L << SCHED_LOAD_SHIFT) 7479aa7b369SIngo Molnar 748f8700df7SSuresh Siddha #define SCHED_LOAD_SCALE_FUZZ SCHED_LOAD_SCALE 7491da177e4SLinus Torvalds 7502dd73a4fSPeter Williams #ifdef CONFIG_SMP 7511da177e4SLinus Torvalds #define SD_LOAD_BALANCE 1 /* Do load balancing on this domain. */ 7521da177e4SLinus Torvalds #define SD_BALANCE_NEWIDLE 2 /* Balance when about to become idle */ 7531da177e4SLinus Torvalds #define SD_BALANCE_EXEC 4 /* Balance on exec */ 754147cbb4bSNick Piggin #define SD_BALANCE_FORK 8 /* Balance on fork, clone */ 755147cbb4bSNick Piggin #define SD_WAKE_IDLE 16 /* Wake to idle CPU on task wakeup */ 756147cbb4bSNick Piggin #define SD_WAKE_AFFINE 32 /* Wake task to waking CPU */ 757147cbb4bSNick Piggin #define SD_WAKE_BALANCE 64 /* Perform balancing at task wakeup */ 758147cbb4bSNick Piggin #define SD_SHARE_CPUPOWER 128 /* Domain members share cpu power */ 7595c45bf27SSiddha, Suresh B #define SD_POWERSAVINGS_BALANCE 256 /* Balance for power savings */ 76089c4710eSSiddha, Suresh B #define SD_SHARE_PKG_RESOURCES 512 /* Domain members share cpu pkg resources */ 76108c183f3SChristoph Lameter #define SD_SERIALIZE 1024 /* Only a single load balancing instance */ 7621d3504fcSHidetoshi Seto #define SD_WAKE_IDLE_FAR 2048 /* Gain latency sacrificing cache hit */ 7635c45bf27SSiddha, Suresh B 76489c4710eSSiddha, Suresh B #define BALANCE_FOR_MC_POWER \ 76589c4710eSSiddha, Suresh B (sched_smt_power_savings ? SD_POWERSAVINGS_BALANCE : 0) 76689c4710eSSiddha, Suresh B 76789c4710eSSiddha, Suresh B #define BALANCE_FOR_PKG_POWER \ 76889c4710eSSiddha, Suresh B ((sched_mc_power_savings || sched_smt_power_savings) ? \ 76989c4710eSSiddha, Suresh B SD_POWERSAVINGS_BALANCE : 0) 77089c4710eSSiddha, Suresh B 77189c4710eSSiddha, Suresh B #define test_sd_parent(sd, flag) ((sd->parent && \ 77289c4710eSSiddha, Suresh B (sd->parent->flags & flag)) ? 1 : 0) 7735c45bf27SSiddha, Suresh B 7741da177e4SLinus Torvalds 7751da177e4SLinus Torvalds struct sched_group { 7761da177e4SLinus Torvalds struct sched_group *next; /* Must be a circular list */ 7771da177e4SLinus Torvalds cpumask_t cpumask; 7781da177e4SLinus Torvalds 7791da177e4SLinus Torvalds /* 7801da177e4SLinus Torvalds * CPU power of this group, SCHED_LOAD_SCALE being max power for a 7811da177e4SLinus Torvalds * single CPU. This is read only (except for setup, hotplug CPU). 7825517d86bSEric Dumazet * Note : Never change cpu_power without recompute its reciprocal 7831da177e4SLinus Torvalds */ 7845517d86bSEric Dumazet unsigned int __cpu_power; 7855517d86bSEric Dumazet /* 7865517d86bSEric Dumazet * reciprocal value of cpu_power to avoid expensive divides 7875517d86bSEric Dumazet * (see include/linux/reciprocal_div.h) 7885517d86bSEric Dumazet */ 7895517d86bSEric Dumazet u32 reciprocal_cpu_power; 7901da177e4SLinus Torvalds }; 7911da177e4SLinus Torvalds 7921d3504fcSHidetoshi Seto enum sched_domain_level { 7931d3504fcSHidetoshi Seto SD_LV_NONE = 0, 7941d3504fcSHidetoshi Seto SD_LV_SIBLING, 7951d3504fcSHidetoshi Seto SD_LV_MC, 7961d3504fcSHidetoshi Seto SD_LV_CPU, 7971d3504fcSHidetoshi Seto SD_LV_NODE, 7981d3504fcSHidetoshi Seto SD_LV_ALLNODES, 7991d3504fcSHidetoshi Seto SD_LV_MAX 8001d3504fcSHidetoshi Seto }; 8011d3504fcSHidetoshi Seto 8021d3504fcSHidetoshi Seto struct sched_domain_attr { 8031d3504fcSHidetoshi Seto int relax_domain_level; 8041d3504fcSHidetoshi Seto }; 8051d3504fcSHidetoshi Seto 8061d3504fcSHidetoshi Seto #define SD_ATTR_INIT (struct sched_domain_attr) { \ 8071d3504fcSHidetoshi Seto .relax_domain_level = -1, \ 8081d3504fcSHidetoshi Seto } 8091d3504fcSHidetoshi Seto 8101da177e4SLinus Torvalds struct sched_domain { 8111da177e4SLinus Torvalds /* These fields must be setup */ 8121da177e4SLinus Torvalds struct sched_domain *parent; /* top domain must be null terminated */ 8131a848870SSiddha, Suresh B struct sched_domain *child; /* bottom domain must be null terminated */ 8141da177e4SLinus Torvalds struct sched_group *groups; /* the balancing groups of the domain */ 8151da177e4SLinus Torvalds cpumask_t span; /* span of all CPUs in this domain */ 8161da177e4SLinus Torvalds unsigned long min_interval; /* Minimum balance interval ms */ 8171da177e4SLinus Torvalds unsigned long max_interval; /* Maximum balance interval ms */ 8181da177e4SLinus Torvalds unsigned int busy_factor; /* less balancing by factor if busy */ 8191da177e4SLinus Torvalds unsigned int imbalance_pct; /* No balance until over watermark */ 8201da177e4SLinus Torvalds unsigned int cache_nice_tries; /* Leave cache hot tasks for # tries */ 8217897986bSNick Piggin unsigned int busy_idx; 8227897986bSNick Piggin unsigned int idle_idx; 8237897986bSNick Piggin unsigned int newidle_idx; 8247897986bSNick Piggin unsigned int wake_idx; 825147cbb4bSNick Piggin unsigned int forkexec_idx; 8261da177e4SLinus Torvalds int flags; /* See SD_* */ 8271d3504fcSHidetoshi Seto enum sched_domain_level level; 8281da177e4SLinus Torvalds 8291da177e4SLinus Torvalds /* Runtime fields. */ 8301da177e4SLinus Torvalds unsigned long last_balance; /* init to jiffies. units in jiffies */ 8311da177e4SLinus Torvalds unsigned int balance_interval; /* initialise to 1. units in ms. */ 8321da177e4SLinus Torvalds unsigned int nr_balance_failed; /* initialise to 0 */ 8331da177e4SLinus Torvalds 8342398f2c6SPeter Zijlstra u64 last_update; 8352398f2c6SPeter Zijlstra 8361da177e4SLinus Torvalds #ifdef CONFIG_SCHEDSTATS 8371da177e4SLinus Torvalds /* load_balance() stats */ 838480b9434SKen Chen unsigned int lb_count[CPU_MAX_IDLE_TYPES]; 839480b9434SKen Chen unsigned int lb_failed[CPU_MAX_IDLE_TYPES]; 840480b9434SKen Chen unsigned int lb_balanced[CPU_MAX_IDLE_TYPES]; 841480b9434SKen Chen unsigned int lb_imbalance[CPU_MAX_IDLE_TYPES]; 842480b9434SKen Chen unsigned int lb_gained[CPU_MAX_IDLE_TYPES]; 843480b9434SKen Chen unsigned int lb_hot_gained[CPU_MAX_IDLE_TYPES]; 844480b9434SKen Chen unsigned int lb_nobusyg[CPU_MAX_IDLE_TYPES]; 845480b9434SKen Chen unsigned int lb_nobusyq[CPU_MAX_IDLE_TYPES]; 8461da177e4SLinus Torvalds 8471da177e4SLinus Torvalds /* Active load balancing */ 848480b9434SKen Chen unsigned int alb_count; 849480b9434SKen Chen unsigned int alb_failed; 850480b9434SKen Chen unsigned int alb_pushed; 8511da177e4SLinus Torvalds 85268767a0aSNick Piggin /* SD_BALANCE_EXEC stats */ 853480b9434SKen Chen unsigned int sbe_count; 854480b9434SKen Chen unsigned int sbe_balanced; 855480b9434SKen Chen unsigned int sbe_pushed; 8561da177e4SLinus Torvalds 85768767a0aSNick Piggin /* SD_BALANCE_FORK stats */ 858480b9434SKen Chen unsigned int sbf_count; 859480b9434SKen Chen unsigned int sbf_balanced; 860480b9434SKen Chen unsigned int sbf_pushed; 86168767a0aSNick Piggin 8621da177e4SLinus Torvalds /* try_to_wake_up() stats */ 863480b9434SKen Chen unsigned int ttwu_wake_remote; 864480b9434SKen Chen unsigned int ttwu_move_affine; 865480b9434SKen Chen unsigned int ttwu_move_balance; 8661da177e4SLinus Torvalds #endif 8671da177e4SLinus Torvalds }; 8681da177e4SLinus Torvalds 8691d3504fcSHidetoshi Seto extern void partition_sched_domains(int ndoms_new, cpumask_t *doms_new, 8701d3504fcSHidetoshi Seto struct sched_domain_attr *dattr_new); 8719aefd0abSHeiko Carstens extern int arch_reinit_sched_domains(void); 872029190c5SPaul Jackson 8731b427c15SIngo Molnar #else /* CONFIG_SMP */ 8741b427c15SIngo Molnar 8751b427c15SIngo Molnar struct sched_domain_attr; 8761b427c15SIngo Molnar 8771b427c15SIngo Molnar static inline void 8781b427c15SIngo Molnar partition_sched_domains(int ndoms_new, cpumask_t *doms_new, 8791b427c15SIngo Molnar struct sched_domain_attr *dattr_new) 8801b427c15SIngo Molnar { 8811b427c15SIngo Molnar } 8821b427c15SIngo Molnar #endif /* !CONFIG_SMP */ 8831da177e4SLinus Torvalds 8841da177e4SLinus Torvalds struct io_context; /* See blkdev.h */ 8851da177e4SLinus Torvalds #define NGROUPS_SMALL 32 8861bf47346SEric Dumazet #define NGROUPS_PER_BLOCK ((unsigned int)(PAGE_SIZE / sizeof(gid_t))) 8871da177e4SLinus Torvalds struct group_info { 8881da177e4SLinus Torvalds int ngroups; 8891da177e4SLinus Torvalds atomic_t usage; 8901da177e4SLinus Torvalds gid_t small_block[NGROUPS_SMALL]; 8911da177e4SLinus Torvalds int nblocks; 8921da177e4SLinus Torvalds gid_t *blocks[0]; 8931da177e4SLinus Torvalds }; 8941da177e4SLinus Torvalds 8951da177e4SLinus Torvalds /* 8961da177e4SLinus Torvalds * get_group_info() must be called with the owning task locked (via task_lock()) 8971da177e4SLinus Torvalds * when task != current. The reason being that the vast majority of callers are 8981da177e4SLinus Torvalds * looking at current->group_info, which can not be changed except by the 8991da177e4SLinus Torvalds * current task. Changing current->group_info requires the task lock, too. 9001da177e4SLinus Torvalds */ 9011da177e4SLinus Torvalds #define get_group_info(group_info) do { \ 9021da177e4SLinus Torvalds atomic_inc(&(group_info)->usage); \ 9031da177e4SLinus Torvalds } while (0) 9041da177e4SLinus Torvalds 9051da177e4SLinus Torvalds #define put_group_info(group_info) do { \ 9061da177e4SLinus Torvalds if (atomic_dec_and_test(&(group_info)->usage)) \ 9071da177e4SLinus Torvalds groups_free(group_info); \ 9081da177e4SLinus Torvalds } while (0) 9091da177e4SLinus Torvalds 9103e30148cSDavid Howells extern struct group_info *groups_alloc(int gidsetsize); 9113e30148cSDavid Howells extern void groups_free(struct group_info *group_info); 9123e30148cSDavid Howells extern int set_current_groups(struct group_info *group_info); 9133e30148cSDavid Howells extern int groups_search(struct group_info *group_info, gid_t grp); 9141da177e4SLinus Torvalds /* access the groups "array" with this macro */ 9151da177e4SLinus Torvalds #define GROUP_AT(gi, i) \ 9161da177e4SLinus Torvalds ((gi)->blocks[(i)/NGROUPS_PER_BLOCK][(i)%NGROUPS_PER_BLOCK]) 9171da177e4SLinus Torvalds 918383f2835SChen, Kenneth W #ifdef ARCH_HAS_PREFETCH_SWITCH_STACK 91936c8b586SIngo Molnar extern void prefetch_stack(struct task_struct *t); 920383f2835SChen, Kenneth W #else 921383f2835SChen, Kenneth W static inline void prefetch_stack(struct task_struct *t) { } 922383f2835SChen, Kenneth W #endif 9231da177e4SLinus Torvalds 9241da177e4SLinus Torvalds struct audit_context; /* See audit.c */ 9251da177e4SLinus Torvalds struct mempolicy; 926b92ce558SJens Axboe struct pipe_inode_info; 9274865ecf1SSerge E. Hallyn struct uts_namespace; 9281da177e4SLinus Torvalds 92920b8a59fSIngo Molnar struct rq; 93020b8a59fSIngo Molnar struct sched_domain; 93120b8a59fSIngo Molnar 93220b8a59fSIngo Molnar struct sched_class { 9335522d5d5SIngo Molnar const struct sched_class *next; 93420b8a59fSIngo Molnar 935fd390f6aSIngo Molnar void (*enqueue_task) (struct rq *rq, struct task_struct *p, int wakeup); 936f02231e5SIngo Molnar void (*dequeue_task) (struct rq *rq, struct task_struct *p, int sleep); 9374530d7abSDmitry Adamushko void (*yield_task) (struct rq *rq); 938e7693a36SGregory Haskins int (*select_task_rq)(struct task_struct *p, int sync); 93920b8a59fSIngo Molnar 94020b8a59fSIngo Molnar void (*check_preempt_curr) (struct rq *rq, struct task_struct *p); 94120b8a59fSIngo Molnar 942fb8d4724SIngo Molnar struct task_struct * (*pick_next_task) (struct rq *rq); 94331ee529cSIngo Molnar void (*put_prev_task) (struct rq *rq, struct task_struct *p); 94420b8a59fSIngo Molnar 945681f3e68SPeter Williams #ifdef CONFIG_SMP 94643010659SPeter Williams unsigned long (*load_balance) (struct rq *this_rq, int this_cpu, 947e1d1484fSPeter Williams struct rq *busiest, unsigned long max_load_move, 94820b8a59fSIngo Molnar struct sched_domain *sd, enum cpu_idle_type idle, 949a4ac01c3SPeter Williams int *all_pinned, int *this_best_prio); 95020b8a59fSIngo Molnar 951e1d1484fSPeter Williams int (*move_one_task) (struct rq *this_rq, int this_cpu, 952e1d1484fSPeter Williams struct rq *busiest, struct sched_domain *sd, 953e1d1484fSPeter Williams enum cpu_idle_type idle); 9549a897c5aSSteven Rostedt void (*pre_schedule) (struct rq *this_rq, struct task_struct *task); 9559a897c5aSSteven Rostedt void (*post_schedule) (struct rq *this_rq); 9569a897c5aSSteven Rostedt void (*task_wake_up) (struct rq *this_rq, struct task_struct *task); 957681f3e68SPeter Williams #endif 958e1d1484fSPeter Williams 95983b699edSSrivatsa Vaddagiri void (*set_curr_task) (struct rq *rq); 9608f4d37ecSPeter Zijlstra void (*task_tick) (struct rq *rq, struct task_struct *p, int queued); 961ee0827d8SIngo Molnar void (*task_new) (struct rq *rq, struct task_struct *p); 962cd8ba7cdSMike Travis void (*set_cpus_allowed)(struct task_struct *p, 963cd8ba7cdSMike Travis const cpumask_t *newmask); 96457d885feSGregory Haskins 9651f11eb6aSGregory Haskins void (*rq_online)(struct rq *rq); 9661f11eb6aSGregory Haskins void (*rq_offline)(struct rq *rq); 967cb469845SSteven Rostedt 968cb469845SSteven Rostedt void (*switched_from) (struct rq *this_rq, struct task_struct *task, 969cb469845SSteven Rostedt int running); 970cb469845SSteven Rostedt void (*switched_to) (struct rq *this_rq, struct task_struct *task, 971cb469845SSteven Rostedt int running); 972cb469845SSteven Rostedt void (*prio_changed) (struct rq *this_rq, struct task_struct *task, 973cb469845SSteven Rostedt int oldprio, int running); 974810b3817SPeter Zijlstra 975810b3817SPeter Zijlstra #ifdef CONFIG_FAIR_GROUP_SCHED 976810b3817SPeter Zijlstra void (*moved_group) (struct task_struct *p); 977810b3817SPeter Zijlstra #endif 97820b8a59fSIngo Molnar }; 97920b8a59fSIngo Molnar 98020b8a59fSIngo Molnar struct load_weight { 98120b8a59fSIngo Molnar unsigned long weight, inv_weight; 98220b8a59fSIngo Molnar }; 98320b8a59fSIngo Molnar 98420b8a59fSIngo Molnar /* 98520b8a59fSIngo Molnar * CFS stats for a schedulable entity (task, task-group etc) 98620b8a59fSIngo Molnar * 98720b8a59fSIngo Molnar * Current field usage histogram: 98820b8a59fSIngo Molnar * 98920b8a59fSIngo Molnar * 4 se->block_start 99020b8a59fSIngo Molnar * 4 se->run_node 99120b8a59fSIngo Molnar * 4 se->sleep_start 99220b8a59fSIngo Molnar * 6 se->load.weight 99320b8a59fSIngo Molnar */ 99420b8a59fSIngo Molnar struct sched_entity { 99520b8a59fSIngo Molnar struct load_weight load; /* for load-balancing */ 99620b8a59fSIngo Molnar struct rb_node run_node; 9974a55bd5eSPeter Zijlstra struct list_head group_node; 99820b8a59fSIngo Molnar unsigned int on_rq; 99920b8a59fSIngo Molnar 100020b8a59fSIngo Molnar u64 exec_start; 100194c18227SIngo Molnar u64 sum_exec_runtime; 1002e9acbff6SIngo Molnar u64 vruntime; 1003f6cf891cSIngo Molnar u64 prev_sum_exec_runtime; 100494c18227SIngo Molnar 10054ae7d5ceSIngo Molnar u64 last_wakeup; 10064ae7d5ceSIngo Molnar u64 avg_overlap; 10074ae7d5ceSIngo Molnar 100894c18227SIngo Molnar #ifdef CONFIG_SCHEDSTATS 100994c18227SIngo Molnar u64 wait_start; 101094c18227SIngo Molnar u64 wait_max; 10116d082592SArjan van de Ven u64 wait_count; 10126d082592SArjan van de Ven u64 wait_sum; 101394c18227SIngo Molnar 101494c18227SIngo Molnar u64 sleep_start; 101520b8a59fSIngo Molnar u64 sleep_max; 101694c18227SIngo Molnar s64 sum_sleep_runtime; 101794c18227SIngo Molnar 101894c18227SIngo Molnar u64 block_start; 101920b8a59fSIngo Molnar u64 block_max; 102020b8a59fSIngo Molnar u64 exec_max; 1021eba1ed4bSIngo Molnar u64 slice_max; 1022cc367732SIngo Molnar 1023cc367732SIngo Molnar u64 nr_migrations; 1024cc367732SIngo Molnar u64 nr_migrations_cold; 1025cc367732SIngo Molnar u64 nr_failed_migrations_affine; 1026cc367732SIngo Molnar u64 nr_failed_migrations_running; 1027cc367732SIngo Molnar u64 nr_failed_migrations_hot; 1028cc367732SIngo Molnar u64 nr_forced_migrations; 1029cc367732SIngo Molnar u64 nr_forced2_migrations; 1030cc367732SIngo Molnar 1031cc367732SIngo Molnar u64 nr_wakeups; 1032cc367732SIngo Molnar u64 nr_wakeups_sync; 1033cc367732SIngo Molnar u64 nr_wakeups_migrate; 1034cc367732SIngo Molnar u64 nr_wakeups_local; 1035cc367732SIngo Molnar u64 nr_wakeups_remote; 1036cc367732SIngo Molnar u64 nr_wakeups_affine; 1037cc367732SIngo Molnar u64 nr_wakeups_affine_attempts; 1038cc367732SIngo Molnar u64 nr_wakeups_passive; 1039cc367732SIngo Molnar u64 nr_wakeups_idle; 104094c18227SIngo Molnar #endif 104194c18227SIngo Molnar 104220b8a59fSIngo Molnar #ifdef CONFIG_FAIR_GROUP_SCHED 104320b8a59fSIngo Molnar struct sched_entity *parent; 104420b8a59fSIngo Molnar /* rq on which this entity is (to be) queued: */ 104520b8a59fSIngo Molnar struct cfs_rq *cfs_rq; 104620b8a59fSIngo Molnar /* rq "owned" by this entity/group: */ 104720b8a59fSIngo Molnar struct cfs_rq *my_q; 104820b8a59fSIngo Molnar #endif 104920b8a59fSIngo Molnar }; 105070b97a7fSIngo Molnar 1051fa717060SPeter Zijlstra struct sched_rt_entity { 1052fa717060SPeter Zijlstra struct list_head run_list; 1053fa717060SPeter Zijlstra unsigned int time_slice; 105478f2c7dbSPeter Zijlstra unsigned long timeout; 10556f505b16SPeter Zijlstra int nr_cpus_allowed; 10566f505b16SPeter Zijlstra 105758d6c2d7SPeter Zijlstra struct sched_rt_entity *back; 1058052f1dc7SPeter Zijlstra #ifdef CONFIG_RT_GROUP_SCHED 10596f505b16SPeter Zijlstra struct sched_rt_entity *parent; 10606f505b16SPeter Zijlstra /* rq on which this entity is (to be) queued: */ 10616f505b16SPeter Zijlstra struct rt_rq *rt_rq; 10626f505b16SPeter Zijlstra /* rq "owned" by this entity/group: */ 10636f505b16SPeter Zijlstra struct rt_rq *my_q; 10646f505b16SPeter Zijlstra #endif 1065fa717060SPeter Zijlstra }; 1066fa717060SPeter Zijlstra 10671da177e4SLinus Torvalds struct task_struct { 10681da177e4SLinus Torvalds volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */ 1069f7e4217bSRoman Zippel void *stack; 10701da177e4SLinus Torvalds atomic_t usage; 107197dc32cdSWilliam Cohen unsigned int flags; /* per process flags, defined below */ 107297dc32cdSWilliam Cohen unsigned int ptrace; 10731da177e4SLinus Torvalds 107436772092SPaolo 'Blaisorblade' Giarrusso int lock_depth; /* BKL lock depth */ 10751da177e4SLinus Torvalds 10762dd73a4fSPeter Williams #ifdef CONFIG_SMP 10772dd73a4fSPeter Williams #ifdef __ARCH_WANT_UNLOCKED_CTXSW 10784866cde0SNick Piggin int oncpu; 10794866cde0SNick Piggin #endif 10802dd73a4fSPeter Williams #endif 108150e645a8SIngo Molnar 1082b29739f9SIngo Molnar int prio, static_prio, normal_prio; 1083c7aceabaSRichard Kennedy unsigned int rt_priority; 10845522d5d5SIngo Molnar const struct sched_class *sched_class; 108520b8a59fSIngo Molnar struct sched_entity se; 1086fa717060SPeter Zijlstra struct sched_rt_entity rt; 10871da177e4SLinus Torvalds 1088e107be36SAvi Kivity #ifdef CONFIG_PREEMPT_NOTIFIERS 1089e107be36SAvi Kivity /* list of struct preempt_notifier: */ 1090e107be36SAvi Kivity struct hlist_head preempt_notifiers; 1091e107be36SAvi Kivity #endif 1092e107be36SAvi Kivity 109318796aa0SAlexey Dobriyan /* 109418796aa0SAlexey Dobriyan * fpu_counter contains the number of consecutive context switches 109518796aa0SAlexey Dobriyan * that the FPU is used. If this is over a threshold, the lazy fpu 109618796aa0SAlexey Dobriyan * saving becomes unlazy to save the trap. This is an unsigned char 109718796aa0SAlexey Dobriyan * so that after 256 times the counter wraps and the behavior turns 109818796aa0SAlexey Dobriyan * lazy again; this to deal with bursty apps that only use FPU for 109918796aa0SAlexey Dobriyan * a short time 110018796aa0SAlexey Dobriyan */ 110118796aa0SAlexey Dobriyan unsigned char fpu_counter; 110218796aa0SAlexey Dobriyan s8 oomkilladj; /* OOM kill score adjustment (bit shift). */ 11036c5c9341SAlexey Dobriyan #ifdef CONFIG_BLK_DEV_IO_TRACE 11042056a782SJens Axboe unsigned int btrace_seq; 11056c5c9341SAlexey Dobriyan #endif 11061da177e4SLinus Torvalds 110797dc32cdSWilliam Cohen unsigned int policy; 11081da177e4SLinus Torvalds cpumask_t cpus_allowed; 11091da177e4SLinus Torvalds 1110e260be67SPaul E. McKenney #ifdef CONFIG_PREEMPT_RCU 1111e260be67SPaul E. McKenney int rcu_read_lock_nesting; 1112e260be67SPaul E. McKenney int rcu_flipctr_idx; 1113e260be67SPaul E. McKenney #endif /* #ifdef CONFIG_PREEMPT_RCU */ 1114e260be67SPaul E. McKenney 111552f17b6cSChandra Seetharaman #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) 11161da177e4SLinus Torvalds struct sched_info sched_info; 11171da177e4SLinus Torvalds #endif 11181da177e4SLinus Torvalds 11191da177e4SLinus Torvalds struct list_head tasks; 11201da177e4SLinus Torvalds 11211da177e4SLinus Torvalds struct mm_struct *mm, *active_mm; 11221da177e4SLinus Torvalds 11231da177e4SLinus Torvalds /* task state */ 11241da177e4SLinus Torvalds struct linux_binfmt *binfmt; 112597dc32cdSWilliam Cohen int exit_state; 11261da177e4SLinus Torvalds int exit_code, exit_signal; 11271da177e4SLinus Torvalds int pdeath_signal; /* The signal sent when the parent dies */ 11281da177e4SLinus Torvalds /* ??? */ 112997dc32cdSWilliam Cohen unsigned int personality; 11301da177e4SLinus Torvalds unsigned did_exec:1; 11311da177e4SLinus Torvalds pid_t pid; 11321da177e4SLinus Torvalds pid_t tgid; 11330a425405SArjan van de Ven 11340a425405SArjan van de Ven #ifdef CONFIG_CC_STACKPROTECTOR 11350a425405SArjan van de Ven /* Canary value for the -fstack-protector gcc feature */ 11360a425405SArjan van de Ven unsigned long stack_canary; 11370a425405SArjan van de Ven #endif 11381da177e4SLinus Torvalds /* 11391da177e4SLinus Torvalds * pointers to (original) parent process, youngest child, younger sibling, 11401da177e4SLinus Torvalds * older sibling, respectively. (p->father can be replaced with 1141f470021aSRoland McGrath * p->real_parent->pid) 11421da177e4SLinus Torvalds */ 1143f470021aSRoland McGrath struct task_struct *real_parent; /* real parent process */ 1144f470021aSRoland McGrath struct task_struct *parent; /* recipient of SIGCHLD, wait4() reports */ 11451da177e4SLinus Torvalds /* 1146f470021aSRoland McGrath * children/sibling forms the list of my natural children 11471da177e4SLinus Torvalds */ 11481da177e4SLinus Torvalds struct list_head children; /* list of my children */ 11491da177e4SLinus Torvalds struct list_head sibling; /* linkage in my parent's children list */ 11501da177e4SLinus Torvalds struct task_struct *group_leader; /* threadgroup leader */ 11511da177e4SLinus Torvalds 1152f470021aSRoland McGrath /* 1153f470021aSRoland McGrath * ptraced is the list of tasks this task is using ptrace on. 1154f470021aSRoland McGrath * This includes both natural children and PTRACE_ATTACH targets. 1155f470021aSRoland McGrath * p->ptrace_entry is p's link on the p->parent->ptraced list. 1156f470021aSRoland McGrath */ 1157f470021aSRoland McGrath struct list_head ptraced; 1158f470021aSRoland McGrath struct list_head ptrace_entry; 1159f470021aSRoland McGrath 11601da177e4SLinus Torvalds /* PID/PID hash table linkage. */ 116192476d7fSEric W. Biederman struct pid_link pids[PIDTYPE_MAX]; 116247e65328SOleg Nesterov struct list_head thread_group; 11631da177e4SLinus Torvalds 11641da177e4SLinus Torvalds struct completion *vfork_done; /* for vfork() */ 11651da177e4SLinus Torvalds int __user *set_child_tid; /* CLONE_CHILD_SETTID */ 11661da177e4SLinus Torvalds int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */ 11671da177e4SLinus Torvalds 1168c66f08beSMichael Neuling cputime_t utime, stime, utimescaled, stimescaled; 11699ac52315SLaurent Vivier cputime_t gtime; 11709301899bSBalbir Singh cputime_t prev_utime, prev_stime; 11711da177e4SLinus Torvalds unsigned long nvcsw, nivcsw; /* context switch counts */ 1172924b42d5STomas Janousek struct timespec start_time; /* monotonic time */ 1173924b42d5STomas Janousek struct timespec real_start_time; /* boot based time */ 11741da177e4SLinus Torvalds /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */ 11751da177e4SLinus Torvalds unsigned long min_flt, maj_flt; 11761da177e4SLinus Torvalds 1177*f06febc9SFrank Mayhar struct task_cputime cputime_expires; 11781da177e4SLinus Torvalds struct list_head cpu_timers[3]; 11791da177e4SLinus Torvalds 11801da177e4SLinus Torvalds /* process credentials */ 11811da177e4SLinus Torvalds uid_t uid,euid,suid,fsuid; 11821da177e4SLinus Torvalds gid_t gid,egid,sgid,fsgid; 11831da177e4SLinus Torvalds struct group_info *group_info; 11843b7391deSSerge E. Hallyn kernel_cap_t cap_effective, cap_inheritable, cap_permitted, cap_bset; 11851da177e4SLinus Torvalds struct user_struct *user; 1186c7aceabaSRichard Kennedy unsigned securebits; 11871da177e4SLinus Torvalds #ifdef CONFIG_KEYS 1188c7aceabaSRichard Kennedy unsigned char jit_keyring; /* default keyring to attach requested keys to */ 1189b5f545c8SDavid Howells struct key *request_key_auth; /* assumed request_key authority */ 11901da177e4SLinus Torvalds struct key *thread_keyring; /* keyring private to this thread */ 11911da177e4SLinus Torvalds #endif 119236772092SPaolo 'Blaisorblade' Giarrusso char comm[TASK_COMM_LEN]; /* executable name excluding path 119336772092SPaolo 'Blaisorblade' Giarrusso - access with [gs]et_task_comm (which lock 119436772092SPaolo 'Blaisorblade' Giarrusso it with task_lock()) 119536772092SPaolo 'Blaisorblade' Giarrusso - initialized normally by flush_old_exec */ 11961da177e4SLinus Torvalds /* file system info */ 11971da177e4SLinus Torvalds int link_count, total_link_count; 11983d5b6fccSAlexey Dobriyan #ifdef CONFIG_SYSVIPC 11991da177e4SLinus Torvalds /* ipc stuff */ 12001da177e4SLinus Torvalds struct sysv_sem sysvsem; 12013d5b6fccSAlexey Dobriyan #endif 120282a1fcb9SIngo Molnar #ifdef CONFIG_DETECT_SOFTLOCKUP 120382a1fcb9SIngo Molnar /* hung task detection */ 120482a1fcb9SIngo Molnar unsigned long last_switch_timestamp; 120582a1fcb9SIngo Molnar unsigned long last_switch_count; 120682a1fcb9SIngo Molnar #endif 12071da177e4SLinus Torvalds /* CPU-specific state of this task */ 12081da177e4SLinus Torvalds struct thread_struct thread; 12091da177e4SLinus Torvalds /* filesystem information */ 12101da177e4SLinus Torvalds struct fs_struct *fs; 12111da177e4SLinus Torvalds /* open file information */ 12121da177e4SLinus Torvalds struct files_struct *files; 12131651e14eSSerge E. Hallyn /* namespaces */ 1214ab516013SSerge E. Hallyn struct nsproxy *nsproxy; 12151da177e4SLinus Torvalds /* signal handlers */ 12161da177e4SLinus Torvalds struct signal_struct *signal; 12171da177e4SLinus Torvalds struct sighand_struct *sighand; 12181da177e4SLinus Torvalds 12191da177e4SLinus Torvalds sigset_t blocked, real_blocked; 1220f3de272bSRoland McGrath sigset_t saved_sigmask; /* restored if set_restore_sigmask() was used */ 12211da177e4SLinus Torvalds struct sigpending pending; 12221da177e4SLinus Torvalds 12231da177e4SLinus Torvalds unsigned long sas_ss_sp; 12241da177e4SLinus Torvalds size_t sas_ss_size; 12251da177e4SLinus Torvalds int (*notifier)(void *priv); 12261da177e4SLinus Torvalds void *notifier_data; 12271da177e4SLinus Torvalds sigset_t *notifier_mask; 122857c521ceSAlexey Dobriyan #ifdef CONFIG_SECURITY 12291da177e4SLinus Torvalds void *security; 123057c521ceSAlexey Dobriyan #endif 12311da177e4SLinus Torvalds struct audit_context *audit_context; 1232bfef93a5SAl Viro #ifdef CONFIG_AUDITSYSCALL 1233bfef93a5SAl Viro uid_t loginuid; 12344746ec5bSEric Paris unsigned int sessionid; 1235bfef93a5SAl Viro #endif 12361da177e4SLinus Torvalds seccomp_t seccomp; 12371da177e4SLinus Torvalds 12381da177e4SLinus Torvalds /* Thread group tracking */ 12391da177e4SLinus Torvalds u32 parent_exec_id; 12401da177e4SLinus Torvalds u32 self_exec_id; 12411da177e4SLinus Torvalds /* Protection of (de-)allocation: mm, files, fs, tty, keyrings */ 12421da177e4SLinus Torvalds spinlock_t alloc_lock; 12431da177e4SLinus Torvalds 1244b29739f9SIngo Molnar /* Protection of the PI data structures: */ 1245b29739f9SIngo Molnar spinlock_t pi_lock; 1246b29739f9SIngo Molnar 124723f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 124823f78d4aSIngo Molnar /* PI waiters blocked on a rt_mutex held by this task */ 124923f78d4aSIngo Molnar struct plist_head pi_waiters; 125023f78d4aSIngo Molnar /* Deadlock detection and priority inheritance handling */ 125123f78d4aSIngo Molnar struct rt_mutex_waiter *pi_blocked_on; 125223f78d4aSIngo Molnar #endif 125323f78d4aSIngo Molnar 1254408894eeSIngo Molnar #ifdef CONFIG_DEBUG_MUTEXES 1255408894eeSIngo Molnar /* mutex deadlock detection */ 1256408894eeSIngo Molnar struct mutex_waiter *blocked_on; 1257408894eeSIngo Molnar #endif 1258de30a2b3SIngo Molnar #ifdef CONFIG_TRACE_IRQFLAGS 1259de30a2b3SIngo Molnar unsigned int irq_events; 1260de30a2b3SIngo Molnar int hardirqs_enabled; 1261de30a2b3SIngo Molnar unsigned long hardirq_enable_ip; 1262de30a2b3SIngo Molnar unsigned int hardirq_enable_event; 1263de30a2b3SIngo Molnar unsigned long hardirq_disable_ip; 1264de30a2b3SIngo Molnar unsigned int hardirq_disable_event; 1265de30a2b3SIngo Molnar int softirqs_enabled; 1266de30a2b3SIngo Molnar unsigned long softirq_disable_ip; 1267de30a2b3SIngo Molnar unsigned int softirq_disable_event; 1268de30a2b3SIngo Molnar unsigned long softirq_enable_ip; 1269de30a2b3SIngo Molnar unsigned int softirq_enable_event; 1270de30a2b3SIngo Molnar int hardirq_context; 1271de30a2b3SIngo Molnar int softirq_context; 1272de30a2b3SIngo Molnar #endif 1273fbb9ce95SIngo Molnar #ifdef CONFIG_LOCKDEP 1274bdb9441eSPeter Zijlstra # define MAX_LOCK_DEPTH 48UL 1275fbb9ce95SIngo Molnar u64 curr_chain_key; 1276fbb9ce95SIngo Molnar int lockdep_depth; 1277fbb9ce95SIngo Molnar unsigned int lockdep_recursion; 1278c7aceabaSRichard Kennedy struct held_lock held_locks[MAX_LOCK_DEPTH]; 1279fbb9ce95SIngo Molnar #endif 1280408894eeSIngo Molnar 12811da177e4SLinus Torvalds /* journalling filesystem info */ 12821da177e4SLinus Torvalds void *journal_info; 12831da177e4SLinus Torvalds 1284d89d8796SNeil Brown /* stacked block device info */ 1285d89d8796SNeil Brown struct bio *bio_list, **bio_tail; 1286d89d8796SNeil Brown 12871da177e4SLinus Torvalds /* VM state */ 12881da177e4SLinus Torvalds struct reclaim_state *reclaim_state; 12891da177e4SLinus Torvalds 12901da177e4SLinus Torvalds struct backing_dev_info *backing_dev_info; 12911da177e4SLinus Torvalds 12921da177e4SLinus Torvalds struct io_context *io_context; 12931da177e4SLinus Torvalds 12941da177e4SLinus Torvalds unsigned long ptrace_message; 12951da177e4SLinus Torvalds siginfo_t *last_siginfo; /* For ptrace use. */ 1296940389b8SAndrea Righi struct task_io_accounting ioac; 12978f0ab514SJay Lan #if defined(CONFIG_TASK_XACCT) 12981da177e4SLinus Torvalds u64 acct_rss_mem1; /* accumulated rss usage */ 12991da177e4SLinus Torvalds u64 acct_vm_mem1; /* accumulated virtual memory usage */ 130049b5cf34SJonathan Lim cputime_t acct_timexpd; /* stime + utime since last update */ 13011da177e4SLinus Torvalds #endif 13021da177e4SLinus Torvalds #ifdef CONFIG_CPUSETS 13031da177e4SLinus Torvalds nodemask_t mems_allowed; 13041da177e4SLinus Torvalds int cpuset_mems_generation; 1305825a46afSPaul Jackson int cpuset_mem_spread_rotor; 13061da177e4SLinus Torvalds #endif 1307ddbcc7e8SPaul Menage #ifdef CONFIG_CGROUPS 1308817929ecSPaul Menage /* Control Group info protected by css_set_lock */ 1309817929ecSPaul Menage struct css_set *cgroups; 1310817929ecSPaul Menage /* cg_list protected by css_set_lock and tsk->alloc_lock */ 1311817929ecSPaul Menage struct list_head cg_list; 1312ddbcc7e8SPaul Menage #endif 131342b2dd0aSAlexey Dobriyan #ifdef CONFIG_FUTEX 13140771dfefSIngo Molnar struct robust_list_head __user *robust_list; 131534f192c6SIngo Molnar #ifdef CONFIG_COMPAT 131634f192c6SIngo Molnar struct compat_robust_list_head __user *compat_robust_list; 131734f192c6SIngo Molnar #endif 1318c87e2837SIngo Molnar struct list_head pi_state_list; 1319c87e2837SIngo Molnar struct futex_pi_state *pi_state_cache; 132042b2dd0aSAlexey Dobriyan #endif 1321c7aceabaSRichard Kennedy #ifdef CONFIG_NUMA 1322c7aceabaSRichard Kennedy struct mempolicy *mempolicy; 1323c7aceabaSRichard Kennedy short il_next; 1324c7aceabaSRichard Kennedy #endif 132522e2c507SJens Axboe atomic_t fs_excl; /* holding fs exclusive resources */ 1326e56d0903SIngo Molnar struct rcu_head rcu; 1327b92ce558SJens Axboe 1328b92ce558SJens Axboe /* 1329b92ce558SJens Axboe * cache last used pipe for splice 1330b92ce558SJens Axboe */ 1331b92ce558SJens Axboe struct pipe_inode_info *splice_pipe; 1332ca74e92bSShailabh Nagar #ifdef CONFIG_TASK_DELAY_ACCT 1333ca74e92bSShailabh Nagar struct task_delay_info *delays; 1334ca74e92bSShailabh Nagar #endif 1335f4f154fdSAkinobu Mita #ifdef CONFIG_FAULT_INJECTION 1336f4f154fdSAkinobu Mita int make_it_fail; 1337f4f154fdSAkinobu Mita #endif 13383e26c149SPeter Zijlstra struct prop_local_single dirties; 13399745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP 13409745512cSArjan van de Ven int latency_record_count; 13419745512cSArjan van de Ven struct latency_record latency_record[LT_SAVECOUNT]; 13429745512cSArjan van de Ven #endif 13431da177e4SLinus Torvalds }; 13441da177e4SLinus Torvalds 1345e05606d3SIngo Molnar /* 1346e05606d3SIngo Molnar * Priority of a process goes from 0..MAX_PRIO-1, valid RT 1347e05606d3SIngo Molnar * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH 1348e05606d3SIngo Molnar * tasks are in the range MAX_RT_PRIO..MAX_PRIO-1. Priority 1349e05606d3SIngo Molnar * values are inverted: lower p->prio value means higher priority. 1350e05606d3SIngo Molnar * 1351e05606d3SIngo Molnar * The MAX_USER_RT_PRIO value allows the actual maximum 1352e05606d3SIngo Molnar * RT priority to be separate from the value exported to 1353e05606d3SIngo Molnar * user-space. This allows kernel threads to set their 1354e05606d3SIngo Molnar * priority to a value higher than any user task. Note: 1355e05606d3SIngo Molnar * MAX_RT_PRIO must not be smaller than MAX_USER_RT_PRIO. 1356e05606d3SIngo Molnar */ 1357e05606d3SIngo Molnar 1358e05606d3SIngo Molnar #define MAX_USER_RT_PRIO 100 1359e05606d3SIngo Molnar #define MAX_RT_PRIO MAX_USER_RT_PRIO 1360e05606d3SIngo Molnar 1361e05606d3SIngo Molnar #define MAX_PRIO (MAX_RT_PRIO + 40) 1362e05606d3SIngo Molnar #define DEFAULT_PRIO (MAX_RT_PRIO + 20) 1363e05606d3SIngo Molnar 1364e05606d3SIngo Molnar static inline int rt_prio(int prio) 1365e05606d3SIngo Molnar { 1366e05606d3SIngo Molnar if (unlikely(prio < MAX_RT_PRIO)) 1367e05606d3SIngo Molnar return 1; 1368e05606d3SIngo Molnar return 0; 1369e05606d3SIngo Molnar } 1370e05606d3SIngo Molnar 1371e868171aSAlexey Dobriyan static inline int rt_task(struct task_struct *p) 1372e05606d3SIngo Molnar { 1373e05606d3SIngo Molnar return rt_prio(p->prio); 1374e05606d3SIngo Molnar } 1375e05606d3SIngo Molnar 1376a47afb0fSPavel Emelianov static inline void set_task_session(struct task_struct *tsk, pid_t session) 1377937949d9SCedric Le Goater { 1378a47afb0fSPavel Emelianov tsk->signal->__session = session; 1379937949d9SCedric Le Goater } 1380937949d9SCedric Le Goater 13819a2e7057SPavel Emelyanov static inline void set_task_pgrp(struct task_struct *tsk, pid_t pgrp) 13829a2e7057SPavel Emelyanov { 13839a2e7057SPavel Emelyanov tsk->signal->__pgrp = pgrp; 13849a2e7057SPavel Emelyanov } 13859a2e7057SPavel Emelyanov 1386e868171aSAlexey Dobriyan static inline struct pid *task_pid(struct task_struct *task) 138722c935f4SEric W. Biederman { 138822c935f4SEric W. Biederman return task->pids[PIDTYPE_PID].pid; 138922c935f4SEric W. Biederman } 139022c935f4SEric W. Biederman 1391e868171aSAlexey Dobriyan static inline struct pid *task_tgid(struct task_struct *task) 139222c935f4SEric W. Biederman { 139322c935f4SEric W. Biederman return task->group_leader->pids[PIDTYPE_PID].pid; 139422c935f4SEric W. Biederman } 139522c935f4SEric W. Biederman 1396e868171aSAlexey Dobriyan static inline struct pid *task_pgrp(struct task_struct *task) 139722c935f4SEric W. Biederman { 139822c935f4SEric W. Biederman return task->group_leader->pids[PIDTYPE_PGID].pid; 139922c935f4SEric W. Biederman } 140022c935f4SEric W. Biederman 1401e868171aSAlexey Dobriyan static inline struct pid *task_session(struct task_struct *task) 140222c935f4SEric W. Biederman { 140322c935f4SEric W. Biederman return task->group_leader->pids[PIDTYPE_SID].pid; 140422c935f4SEric W. Biederman } 140522c935f4SEric W. Biederman 14067af57294SPavel Emelyanov struct pid_namespace; 14077af57294SPavel Emelyanov 14087af57294SPavel Emelyanov /* 14097af57294SPavel Emelyanov * the helpers to get the task's different pids as they are seen 14107af57294SPavel Emelyanov * from various namespaces 14117af57294SPavel Emelyanov * 14127af57294SPavel Emelyanov * task_xid_nr() : global id, i.e. the id seen from the init namespace; 141344c4e1b2SEric W. Biederman * task_xid_vnr() : virtual id, i.e. the id seen from the pid namespace of 141444c4e1b2SEric W. Biederman * current. 14157af57294SPavel Emelyanov * task_xid_nr_ns() : id seen from the ns specified; 14167af57294SPavel Emelyanov * 14177af57294SPavel Emelyanov * set_task_vxid() : assigns a virtual id to a task; 14187af57294SPavel Emelyanov * 14197af57294SPavel Emelyanov * see also pid_nr() etc in include/linux/pid.h 14207af57294SPavel Emelyanov */ 14217af57294SPavel Emelyanov 1422e868171aSAlexey Dobriyan static inline pid_t task_pid_nr(struct task_struct *tsk) 14237af57294SPavel Emelyanov { 14247af57294SPavel Emelyanov return tsk->pid; 14257af57294SPavel Emelyanov } 14267af57294SPavel Emelyanov 14272f2a3a46SPavel Emelyanov pid_t task_pid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns); 14287af57294SPavel Emelyanov 14297af57294SPavel Emelyanov static inline pid_t task_pid_vnr(struct task_struct *tsk) 14307af57294SPavel Emelyanov { 14317af57294SPavel Emelyanov return pid_vnr(task_pid(tsk)); 14327af57294SPavel Emelyanov } 14337af57294SPavel Emelyanov 14347af57294SPavel Emelyanov 1435e868171aSAlexey Dobriyan static inline pid_t task_tgid_nr(struct task_struct *tsk) 14367af57294SPavel Emelyanov { 14377af57294SPavel Emelyanov return tsk->tgid; 14387af57294SPavel Emelyanov } 14397af57294SPavel Emelyanov 14402f2a3a46SPavel Emelyanov pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns); 14417af57294SPavel Emelyanov 14427af57294SPavel Emelyanov static inline pid_t task_tgid_vnr(struct task_struct *tsk) 14437af57294SPavel Emelyanov { 14447af57294SPavel Emelyanov return pid_vnr(task_tgid(tsk)); 14457af57294SPavel Emelyanov } 14467af57294SPavel Emelyanov 14477af57294SPavel Emelyanov 1448e868171aSAlexey Dobriyan static inline pid_t task_pgrp_nr(struct task_struct *tsk) 14497af57294SPavel Emelyanov { 14509a2e7057SPavel Emelyanov return tsk->signal->__pgrp; 14517af57294SPavel Emelyanov } 14527af57294SPavel Emelyanov 14532f2a3a46SPavel Emelyanov pid_t task_pgrp_nr_ns(struct task_struct *tsk, struct pid_namespace *ns); 14547af57294SPavel Emelyanov 14557af57294SPavel Emelyanov static inline pid_t task_pgrp_vnr(struct task_struct *tsk) 14567af57294SPavel Emelyanov { 14577af57294SPavel Emelyanov return pid_vnr(task_pgrp(tsk)); 14587af57294SPavel Emelyanov } 14597af57294SPavel Emelyanov 14607af57294SPavel Emelyanov 1461e868171aSAlexey Dobriyan static inline pid_t task_session_nr(struct task_struct *tsk) 14627af57294SPavel Emelyanov { 14637af57294SPavel Emelyanov return tsk->signal->__session; 14647af57294SPavel Emelyanov } 14657af57294SPavel Emelyanov 14662f2a3a46SPavel Emelyanov pid_t task_session_nr_ns(struct task_struct *tsk, struct pid_namespace *ns); 14677af57294SPavel Emelyanov 14687af57294SPavel Emelyanov static inline pid_t task_session_vnr(struct task_struct *tsk) 14697af57294SPavel Emelyanov { 14707af57294SPavel Emelyanov return pid_vnr(task_session(tsk)); 14717af57294SPavel Emelyanov } 14727af57294SPavel Emelyanov 14737af57294SPavel Emelyanov 14741da177e4SLinus Torvalds /** 14751da177e4SLinus Torvalds * pid_alive - check that a task structure is not stale 14761da177e4SLinus Torvalds * @p: Task structure to be checked. 14771da177e4SLinus Torvalds * 14781da177e4SLinus Torvalds * Test if a process is not yet dead (at most zombie state) 14791da177e4SLinus Torvalds * If pid_alive fails, then pointers within the task structure 14801da177e4SLinus Torvalds * can be stale and must not be dereferenced. 14811da177e4SLinus Torvalds */ 1482e868171aSAlexey Dobriyan static inline int pid_alive(struct task_struct *p) 14831da177e4SLinus Torvalds { 148492476d7fSEric W. Biederman return p->pids[PIDTYPE_PID].pid != NULL; 14851da177e4SLinus Torvalds } 14861da177e4SLinus Torvalds 1487f400e198SSukadev Bhattiprolu /** 1488b460cbc5SSerge E. Hallyn * is_global_init - check if a task structure is init 14893260259fSHenne * @tsk: Task structure to be checked. 14903260259fSHenne * 14913260259fSHenne * Check if a task structure is the first user space task the kernel created. 1492f400e198SSukadev Bhattiprolu */ 1493e868171aSAlexey Dobriyan static inline int is_global_init(struct task_struct *tsk) 1494b461cc03SPavel Emelyanov { 1495b461cc03SPavel Emelyanov return tsk->pid == 1; 1496b461cc03SPavel Emelyanov } 1497b460cbc5SSerge E. Hallyn 1498b460cbc5SSerge E. Hallyn /* 1499b460cbc5SSerge E. Hallyn * is_container_init: 1500b460cbc5SSerge E. Hallyn * check whether in the task is init in its own pid namespace. 1501b460cbc5SSerge E. Hallyn */ 1502b461cc03SPavel Emelyanov extern int is_container_init(struct task_struct *tsk); 1503f400e198SSukadev Bhattiprolu 15049ec52099SCedric Le Goater extern struct pid *cad_pid; 15059ec52099SCedric Le Goater 15061da177e4SLinus Torvalds extern void free_task(struct task_struct *tsk); 15071da177e4SLinus Torvalds #define get_task_struct(tsk) do { atomic_inc(&(tsk)->usage); } while(0) 1508e56d0903SIngo Molnar 1509158d9ebdSAndrew Morton extern void __put_task_struct(struct task_struct *t); 1510e56d0903SIngo Molnar 1511e56d0903SIngo Molnar static inline void put_task_struct(struct task_struct *t) 1512e56d0903SIngo Molnar { 1513e56d0903SIngo Molnar if (atomic_dec_and_test(&t->usage)) 15148c7904a0SEric W. Biederman __put_task_struct(t); 1515e56d0903SIngo Molnar } 15161da177e4SLinus Torvalds 151749048622SBalbir Singh extern cputime_t task_utime(struct task_struct *p); 151849048622SBalbir Singh extern cputime_t task_stime(struct task_struct *p); 151949048622SBalbir Singh extern cputime_t task_gtime(struct task_struct *p); 152049048622SBalbir Singh 15211da177e4SLinus Torvalds /* 15221da177e4SLinus Torvalds * Per process flags 15231da177e4SLinus Torvalds */ 15241da177e4SLinus Torvalds #define PF_ALIGNWARN 0x00000001 /* Print alignment warning msgs */ 15251da177e4SLinus Torvalds /* Not implemented yet, only for 486*/ 15261da177e4SLinus Torvalds #define PF_STARTING 0x00000002 /* being created */ 15271da177e4SLinus Torvalds #define PF_EXITING 0x00000004 /* getting shut down */ 1528778e9a9cSAlexey Kuznetsov #define PF_EXITPIDONE 0x00000008 /* pi exit done on shut down */ 152994886b84SLaurent Vivier #define PF_VCPU 0x00000010 /* I'm a virtual CPU */ 15301da177e4SLinus Torvalds #define PF_FORKNOEXEC 0x00000040 /* forked but didn't exec */ 15311da177e4SLinus Torvalds #define PF_SUPERPRIV 0x00000100 /* used super-user privileges */ 15321da177e4SLinus Torvalds #define PF_DUMPCORE 0x00000200 /* dumped core */ 15331da177e4SLinus Torvalds #define PF_SIGNALED 0x00000400 /* killed by a signal */ 15341da177e4SLinus Torvalds #define PF_MEMALLOC 0x00000800 /* Allocating memory */ 15351da177e4SLinus Torvalds #define PF_FLUSHER 0x00001000 /* responsible for disk writeback */ 15361da177e4SLinus Torvalds #define PF_USED_MATH 0x00002000 /* if unset the fpu must be initialized before use */ 15371da177e4SLinus Torvalds #define PF_NOFREEZE 0x00008000 /* this thread should not be frozen */ 15381da177e4SLinus Torvalds #define PF_FROZEN 0x00010000 /* frozen for system suspend */ 15391da177e4SLinus Torvalds #define PF_FSTRANS 0x00020000 /* inside a filesystem transaction */ 15401da177e4SLinus Torvalds #define PF_KSWAPD 0x00040000 /* I am kswapd */ 15411da177e4SLinus Torvalds #define PF_SWAPOFF 0x00080000 /* I am in swapoff */ 15421da177e4SLinus Torvalds #define PF_LESS_THROTTLE 0x00100000 /* Throttle me less: I clean memory */ 1543246bb0b1SOleg Nesterov #define PF_KTHREAD 0x00200000 /* I am a kernel thread */ 1544b31dc66aSJens Axboe #define PF_RANDOMIZE 0x00400000 /* randomize virtual address space */ 1545b31dc66aSJens Axboe #define PF_SWAPWRITE 0x00800000 /* Allowed to write to swap */ 1546b31dc66aSJens Axboe #define PF_SPREAD_PAGE 0x01000000 /* Spread page cache over cpuset */ 1547b31dc66aSJens Axboe #define PF_SPREAD_SLAB 0x02000000 /* Spread some slab caches over cpuset */ 15489985b0baSDavid Rientjes #define PF_THREAD_BOUND 0x04000000 /* Thread bound to specific cpu */ 1549c61afb18SPaul Jackson #define PF_MEMPOLICY 0x10000000 /* Non-default NUMA mempolicy */ 155061a87122SThomas Gleixner #define PF_MUTEX_TESTER 0x20000000 /* Thread belongs to the rt mutex tester */ 1551ba96a0c8SRafael J. Wysocki #define PF_FREEZER_SKIP 0x40000000 /* Freezer should not count it as freezeable */ 1552ebb12db5SRafael J. Wysocki #define PF_FREEZER_NOSIG 0x80000000 /* Freezer won't send signals to it */ 15531da177e4SLinus Torvalds 15541da177e4SLinus Torvalds /* 15551da177e4SLinus Torvalds * Only the _current_ task can read/write to tsk->flags, but other 15561da177e4SLinus Torvalds * tasks can access tsk->flags in readonly mode for example 15571da177e4SLinus Torvalds * with tsk_used_math (like during threaded core dumping). 15581da177e4SLinus Torvalds * There is however an exception to this rule during ptrace 15591da177e4SLinus Torvalds * or during fork: the ptracer task is allowed to write to the 15601da177e4SLinus Torvalds * child->flags of its traced child (same goes for fork, the parent 15611da177e4SLinus Torvalds * can write to the child->flags), because we're guaranteed the 15621da177e4SLinus Torvalds * child is not running and in turn not changing child->flags 15631da177e4SLinus Torvalds * at the same time the parent does it. 15641da177e4SLinus Torvalds */ 15651da177e4SLinus Torvalds #define clear_stopped_child_used_math(child) do { (child)->flags &= ~PF_USED_MATH; } while (0) 15661da177e4SLinus Torvalds #define set_stopped_child_used_math(child) do { (child)->flags |= PF_USED_MATH; } while (0) 15671da177e4SLinus Torvalds #define clear_used_math() clear_stopped_child_used_math(current) 15681da177e4SLinus Torvalds #define set_used_math() set_stopped_child_used_math(current) 15691da177e4SLinus Torvalds #define conditional_stopped_child_used_math(condition, child) \ 15701da177e4SLinus Torvalds do { (child)->flags &= ~PF_USED_MATH, (child)->flags |= (condition) ? PF_USED_MATH : 0; } while (0) 15711da177e4SLinus Torvalds #define conditional_used_math(condition) \ 15721da177e4SLinus Torvalds conditional_stopped_child_used_math(condition, current) 15731da177e4SLinus Torvalds #define copy_to_stopped_child_used_math(child) \ 15741da177e4SLinus Torvalds do { (child)->flags &= ~PF_USED_MATH, (child)->flags |= current->flags & PF_USED_MATH; } while (0) 15751da177e4SLinus Torvalds /* NOTE: this will return 0 or PF_USED_MATH, it will never return 1 */ 15761da177e4SLinus Torvalds #define tsk_used_math(p) ((p)->flags & PF_USED_MATH) 15771da177e4SLinus Torvalds #define used_math() tsk_used_math(current) 15781da177e4SLinus Torvalds 15791da177e4SLinus Torvalds #ifdef CONFIG_SMP 1580cd8ba7cdSMike Travis extern int set_cpus_allowed_ptr(struct task_struct *p, 1581cd8ba7cdSMike Travis const cpumask_t *new_mask); 15821da177e4SLinus Torvalds #else 1583cd8ba7cdSMike Travis static inline int set_cpus_allowed_ptr(struct task_struct *p, 1584cd8ba7cdSMike Travis const cpumask_t *new_mask) 15851da177e4SLinus Torvalds { 1586cd8ba7cdSMike Travis if (!cpu_isset(0, *new_mask)) 15871da177e4SLinus Torvalds return -EINVAL; 15881da177e4SLinus Torvalds return 0; 15891da177e4SLinus Torvalds } 15901da177e4SLinus Torvalds #endif 1591cd8ba7cdSMike Travis static inline int set_cpus_allowed(struct task_struct *p, cpumask_t new_mask) 1592cd8ba7cdSMike Travis { 1593cd8ba7cdSMike Travis return set_cpus_allowed_ptr(p, &new_mask); 1594cd8ba7cdSMike Travis } 15951da177e4SLinus Torvalds 15961da177e4SLinus Torvalds extern unsigned long long sched_clock(void); 1597e436d800SIngo Molnar 1598c1955a3dSPeter Zijlstra extern void sched_clock_init(void); 1599c1955a3dSPeter Zijlstra extern u64 sched_clock_cpu(int cpu); 1600c1955a3dSPeter Zijlstra 16013e51f33fSPeter Zijlstra #ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK 16023e51f33fSPeter Zijlstra static inline void sched_clock_tick(void) 16033e51f33fSPeter Zijlstra { 16043e51f33fSPeter Zijlstra } 16053e51f33fSPeter Zijlstra 16063e51f33fSPeter Zijlstra static inline void sched_clock_idle_sleep_event(void) 16073e51f33fSPeter Zijlstra { 16083e51f33fSPeter Zijlstra } 16093e51f33fSPeter Zijlstra 16103e51f33fSPeter Zijlstra static inline void sched_clock_idle_wakeup_event(u64 delta_ns) 16113e51f33fSPeter Zijlstra { 16123e51f33fSPeter Zijlstra } 1613e4e4e534SIngo Molnar #else 16143e51f33fSPeter Zijlstra extern void sched_clock_tick(void); 16153e51f33fSPeter Zijlstra extern void sched_clock_idle_sleep_event(void); 16163e51f33fSPeter Zijlstra extern void sched_clock_idle_wakeup_event(u64 delta_ns); 16173e51f33fSPeter Zijlstra #endif 16183e51f33fSPeter Zijlstra 1619e436d800SIngo Molnar /* 1620e436d800SIngo Molnar * For kernel-internal use: high-speed (but slightly incorrect) per-cpu 1621e436d800SIngo Molnar * clock constructed from sched_clock(): 1622e436d800SIngo Molnar */ 1623e436d800SIngo Molnar extern unsigned long long cpu_clock(int cpu); 1624e436d800SIngo Molnar 162536c8b586SIngo Molnar extern unsigned long long 162641b86e9cSIngo Molnar task_sched_runtime(struct task_struct *task); 1627*f06febc9SFrank Mayhar extern unsigned long long thread_group_sched_runtime(struct task_struct *task); 16281da177e4SLinus Torvalds 16291da177e4SLinus Torvalds /* sched_exec is called by processes performing an exec */ 16301da177e4SLinus Torvalds #ifdef CONFIG_SMP 16311da177e4SLinus Torvalds extern void sched_exec(void); 16321da177e4SLinus Torvalds #else 16331da177e4SLinus Torvalds #define sched_exec() {} 16341da177e4SLinus Torvalds #endif 16351da177e4SLinus Torvalds 16362aa44d05SIngo Molnar extern void sched_clock_idle_sleep_event(void); 16372aa44d05SIngo Molnar extern void sched_clock_idle_wakeup_event(u64 delta_ns); 1638bb29ab26SIngo Molnar 16391da177e4SLinus Torvalds #ifdef CONFIG_HOTPLUG_CPU 16401da177e4SLinus Torvalds extern void idle_task_exit(void); 16411da177e4SLinus Torvalds #else 16421da177e4SLinus Torvalds static inline void idle_task_exit(void) {} 16431da177e4SLinus Torvalds #endif 16441da177e4SLinus Torvalds 16451da177e4SLinus Torvalds extern void sched_idle_next(void); 1646b29739f9SIngo Molnar 164706d8308cSThomas Gleixner #if defined(CONFIG_NO_HZ) && defined(CONFIG_SMP) 164806d8308cSThomas Gleixner extern void wake_up_idle_cpu(int cpu); 164906d8308cSThomas Gleixner #else 165006d8308cSThomas Gleixner static inline void wake_up_idle_cpu(int cpu) { } 165106d8308cSThomas Gleixner #endif 165206d8308cSThomas Gleixner 16532bd8e6d4SIngo Molnar #ifdef CONFIG_SCHED_DEBUG 165421805085SPeter Zijlstra extern unsigned int sysctl_sched_latency; 1655b2be5e96SPeter Zijlstra extern unsigned int sysctl_sched_min_granularity; 1656bf0f6f24SIngo Molnar extern unsigned int sysctl_sched_wakeup_granularity; 1657bf0f6f24SIngo Molnar extern unsigned int sysctl_sched_child_runs_first; 1658bf0f6f24SIngo Molnar extern unsigned int sysctl_sched_features; 1659da84d961SIngo Molnar extern unsigned int sysctl_sched_migration_cost; 1660b82d9fddSPeter Zijlstra extern unsigned int sysctl_sched_nr_migrate; 16612398f2c6SPeter Zijlstra extern unsigned int sysctl_sched_shares_ratelimit; 1662b2be5e96SPeter Zijlstra 1663b2be5e96SPeter Zijlstra int sched_nr_latency_handler(struct ctl_table *table, int write, 1664b2be5e96SPeter Zijlstra struct file *file, void __user *buffer, size_t *length, 1665b2be5e96SPeter Zijlstra loff_t *ppos); 16662bd8e6d4SIngo Molnar #endif 16679f0c1e56SPeter Zijlstra extern unsigned int sysctl_sched_rt_period; 16689f0c1e56SPeter Zijlstra extern int sysctl_sched_rt_runtime; 16692bd8e6d4SIngo Molnar 1670d0b27fa7SPeter Zijlstra int sched_rt_handler(struct ctl_table *table, int write, 1671d0b27fa7SPeter Zijlstra struct file *filp, void __user *buffer, size_t *lenp, 1672d0b27fa7SPeter Zijlstra loff_t *ppos); 1673d0b27fa7SPeter Zijlstra 16742bd8e6d4SIngo Molnar extern unsigned int sysctl_sched_compat_yield; 1675bf0f6f24SIngo Molnar 1676b29739f9SIngo Molnar #ifdef CONFIG_RT_MUTEXES 167736c8b586SIngo Molnar extern int rt_mutex_getprio(struct task_struct *p); 167836c8b586SIngo Molnar extern void rt_mutex_setprio(struct task_struct *p, int prio); 167936c8b586SIngo Molnar extern void rt_mutex_adjust_pi(struct task_struct *p); 1680b29739f9SIngo Molnar #else 1681e868171aSAlexey Dobriyan static inline int rt_mutex_getprio(struct task_struct *p) 1682b29739f9SIngo Molnar { 1683b29739f9SIngo Molnar return p->normal_prio; 1684b29739f9SIngo Molnar } 168595e02ca9SThomas Gleixner # define rt_mutex_adjust_pi(p) do { } while (0) 1686b29739f9SIngo Molnar #endif 1687b29739f9SIngo Molnar 168836c8b586SIngo Molnar extern void set_user_nice(struct task_struct *p, long nice); 168936c8b586SIngo Molnar extern int task_prio(const struct task_struct *p); 169036c8b586SIngo Molnar extern int task_nice(const struct task_struct *p); 169136c8b586SIngo Molnar extern int can_nice(const struct task_struct *p, const int nice); 169236c8b586SIngo Molnar extern int task_curr(const struct task_struct *p); 16931da177e4SLinus Torvalds extern int idle_cpu(int cpu); 16941da177e4SLinus Torvalds extern int sched_setscheduler(struct task_struct *, int, struct sched_param *); 1695961ccdddSRusty Russell extern int sched_setscheduler_nocheck(struct task_struct *, int, 1696961ccdddSRusty Russell struct sched_param *); 169736c8b586SIngo Molnar extern struct task_struct *idle_task(int cpu); 169836c8b586SIngo Molnar extern struct task_struct *curr_task(int cpu); 169936c8b586SIngo Molnar extern void set_curr_task(int cpu, struct task_struct *p); 17001da177e4SLinus Torvalds 17011da177e4SLinus Torvalds void yield(void); 17021da177e4SLinus Torvalds 17031da177e4SLinus Torvalds /* 17041da177e4SLinus Torvalds * The default (Linux) execution domain. 17051da177e4SLinus Torvalds */ 17061da177e4SLinus Torvalds extern struct exec_domain default_exec_domain; 17071da177e4SLinus Torvalds 17081da177e4SLinus Torvalds union thread_union { 17091da177e4SLinus Torvalds struct thread_info thread_info; 17101da177e4SLinus Torvalds unsigned long stack[THREAD_SIZE/sizeof(long)]; 17111da177e4SLinus Torvalds }; 17121da177e4SLinus Torvalds 17131da177e4SLinus Torvalds #ifndef __HAVE_ARCH_KSTACK_END 17141da177e4SLinus Torvalds static inline int kstack_end(void *addr) 17151da177e4SLinus Torvalds { 17161da177e4SLinus Torvalds /* Reliable end of stack detection: 17171da177e4SLinus Torvalds * Some APM bios versions misalign the stack 17181da177e4SLinus Torvalds */ 17191da177e4SLinus Torvalds return !(((unsigned long)addr+sizeof(void*)-1) & (THREAD_SIZE-sizeof(void*))); 17201da177e4SLinus Torvalds } 17211da177e4SLinus Torvalds #endif 17221da177e4SLinus Torvalds 17231da177e4SLinus Torvalds extern union thread_union init_thread_union; 17241da177e4SLinus Torvalds extern struct task_struct init_task; 17251da177e4SLinus Torvalds 17261da177e4SLinus Torvalds extern struct mm_struct init_mm; 17271da177e4SLinus Torvalds 1728198fe21bSPavel Emelyanov extern struct pid_namespace init_pid_ns; 1729198fe21bSPavel Emelyanov 1730198fe21bSPavel Emelyanov /* 1731198fe21bSPavel Emelyanov * find a task by one of its numerical ids 1732198fe21bSPavel Emelyanov * 1733198fe21bSPavel Emelyanov * find_task_by_pid_type_ns(): 1734198fe21bSPavel Emelyanov * it is the most generic call - it finds a task by all id, 1735198fe21bSPavel Emelyanov * type and namespace specified 1736198fe21bSPavel Emelyanov * find_task_by_pid_ns(): 1737198fe21bSPavel Emelyanov * finds a task by its pid in the specified namespace 1738228ebcbeSPavel Emelyanov * find_task_by_vpid(): 1739228ebcbeSPavel Emelyanov * finds a task by its virtual pid 1740198fe21bSPavel Emelyanov * 1741e49859e7SPavel Emelyanov * see also find_vpid() etc in include/linux/pid.h 1742198fe21bSPavel Emelyanov */ 1743198fe21bSPavel Emelyanov 1744198fe21bSPavel Emelyanov extern struct task_struct *find_task_by_pid_type_ns(int type, int pid, 1745198fe21bSPavel Emelyanov struct pid_namespace *ns); 1746198fe21bSPavel Emelyanov 1747228ebcbeSPavel Emelyanov extern struct task_struct *find_task_by_vpid(pid_t nr); 1748228ebcbeSPavel Emelyanov extern struct task_struct *find_task_by_pid_ns(pid_t nr, 1749228ebcbeSPavel Emelyanov struct pid_namespace *ns); 1750198fe21bSPavel Emelyanov 17518520d7c7SOleg Nesterov extern void __set_special_pids(struct pid *pid); 17521da177e4SLinus Torvalds 17531da177e4SLinus Torvalds /* per-UID process charging. */ 1754acce292cSCedric Le Goater extern struct user_struct * alloc_uid(struct user_namespace *, uid_t); 17551da177e4SLinus Torvalds static inline struct user_struct *get_uid(struct user_struct *u) 17561da177e4SLinus Torvalds { 17571da177e4SLinus Torvalds atomic_inc(&u->__count); 17581da177e4SLinus Torvalds return u; 17591da177e4SLinus Torvalds } 17601da177e4SLinus Torvalds extern void free_uid(struct user_struct *); 17611da177e4SLinus Torvalds extern void switch_uid(struct user_struct *); 176228f300d2SPavel Emelyanov extern void release_uids(struct user_namespace *ns); 17631da177e4SLinus Torvalds 17641da177e4SLinus Torvalds #include <asm/current.h> 17651da177e4SLinus Torvalds 17663171a030SAtsushi Nemoto extern void do_timer(unsigned long ticks); 17671da177e4SLinus Torvalds 1768b3c97528SHarvey Harrison extern int wake_up_state(struct task_struct *tsk, unsigned int state); 1769b3c97528SHarvey Harrison extern int wake_up_process(struct task_struct *tsk); 1770b3c97528SHarvey Harrison extern void wake_up_new_task(struct task_struct *tsk, 1771b3c97528SHarvey Harrison unsigned long clone_flags); 17721da177e4SLinus Torvalds #ifdef CONFIG_SMP 17731da177e4SLinus Torvalds extern void kick_process(struct task_struct *tsk); 17741da177e4SLinus Torvalds #else 17751da177e4SLinus Torvalds static inline void kick_process(struct task_struct *tsk) { } 17761da177e4SLinus Torvalds #endif 1777ad46c2c4SIngo Molnar extern void sched_fork(struct task_struct *p, int clone_flags); 1778ad46c2c4SIngo Molnar extern void sched_dead(struct task_struct *p); 17791da177e4SLinus Torvalds 17801da177e4SLinus Torvalds extern int in_group_p(gid_t); 17811da177e4SLinus Torvalds extern int in_egroup_p(gid_t); 17821da177e4SLinus Torvalds 17831da177e4SLinus Torvalds extern void proc_caches_init(void); 17841da177e4SLinus Torvalds extern void flush_signals(struct task_struct *); 178510ab825bSOleg Nesterov extern void ignore_signals(struct task_struct *); 17861da177e4SLinus Torvalds extern void flush_signal_handlers(struct task_struct *, int force_default); 17871da177e4SLinus Torvalds extern int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info); 17881da177e4SLinus Torvalds 17891da177e4SLinus Torvalds static inline int dequeue_signal_lock(struct task_struct *tsk, sigset_t *mask, siginfo_t *info) 17901da177e4SLinus Torvalds { 17911da177e4SLinus Torvalds unsigned long flags; 17921da177e4SLinus Torvalds int ret; 17931da177e4SLinus Torvalds 17941da177e4SLinus Torvalds spin_lock_irqsave(&tsk->sighand->siglock, flags); 17951da177e4SLinus Torvalds ret = dequeue_signal(tsk, mask, info); 17961da177e4SLinus Torvalds spin_unlock_irqrestore(&tsk->sighand->siglock, flags); 17971da177e4SLinus Torvalds 17981da177e4SLinus Torvalds return ret; 17991da177e4SLinus Torvalds } 18001da177e4SLinus Torvalds 18011da177e4SLinus Torvalds extern void block_all_signals(int (*notifier)(void *priv), void *priv, 18021da177e4SLinus Torvalds sigset_t *mask); 18031da177e4SLinus Torvalds extern void unblock_all_signals(void); 18041da177e4SLinus Torvalds extern void release_task(struct task_struct * p); 18051da177e4SLinus Torvalds extern int send_sig_info(int, struct siginfo *, struct task_struct *); 18061da177e4SLinus Torvalds extern int force_sigsegv(int, struct task_struct *); 18071da177e4SLinus Torvalds extern int force_sig_info(int, struct siginfo *, struct task_struct *); 1808c4b92fc1SEric W. Biederman extern int __kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp); 1809c4b92fc1SEric W. Biederman extern int kill_pid_info(int sig, struct siginfo *info, struct pid *pid); 18102425c08bSEric W. Biederman extern int kill_pid_info_as_uid(int, struct siginfo *, struct pid *, uid_t, uid_t, u32); 1811c4b92fc1SEric W. Biederman extern int kill_pgrp(struct pid *pid, int sig, int priv); 1812c4b92fc1SEric W. Biederman extern int kill_pid(struct pid *pid, int sig, int priv); 1813c3de4b38SMatthew Wilcox extern int kill_proc_info(int, struct siginfo *, pid_t); 18142b2a1ff6SRoland McGrath extern int do_notify_parent(struct task_struct *, int); 18151da177e4SLinus Torvalds extern void force_sig(int, struct task_struct *); 18161da177e4SLinus Torvalds extern void force_sig_specific(int, struct task_struct *); 18171da177e4SLinus Torvalds extern int send_sig(int, struct task_struct *, int); 18181da177e4SLinus Torvalds extern void zap_other_threads(struct task_struct *p); 18191da177e4SLinus Torvalds extern struct sigqueue *sigqueue_alloc(void); 18201da177e4SLinus Torvalds extern void sigqueue_free(struct sigqueue *); 1821ac5c2153SOleg Nesterov extern int send_sigqueue(struct sigqueue *, struct task_struct *, int group); 18229ac95f2fSOleg Nesterov extern int do_sigaction(int, struct k_sigaction *, struct k_sigaction *); 18231da177e4SLinus Torvalds extern int do_sigaltstack(const stack_t __user *, stack_t __user *, unsigned long); 18241da177e4SLinus Torvalds 18259ec52099SCedric Le Goater static inline int kill_cad_pid(int sig, int priv) 18269ec52099SCedric Le Goater { 18279ec52099SCedric Le Goater return kill_pid(cad_pid, sig, priv); 18289ec52099SCedric Le Goater } 18299ec52099SCedric Le Goater 18301da177e4SLinus Torvalds /* These can be the second arg to send_sig_info/send_group_sig_info. */ 18311da177e4SLinus Torvalds #define SEND_SIG_NOINFO ((struct siginfo *) 0) 18321da177e4SLinus Torvalds #define SEND_SIG_PRIV ((struct siginfo *) 1) 18331da177e4SLinus Torvalds #define SEND_SIG_FORCED ((struct siginfo *) 2) 18341da177e4SLinus Torvalds 1835621d3121SOleg Nesterov static inline int is_si_special(const struct siginfo *info) 1836621d3121SOleg Nesterov { 1837621d3121SOleg Nesterov return info <= SEND_SIG_FORCED; 1838621d3121SOleg Nesterov } 1839621d3121SOleg Nesterov 18401da177e4SLinus Torvalds /* True if we are on the alternate signal stack. */ 18411da177e4SLinus Torvalds 18421da177e4SLinus Torvalds static inline int on_sig_stack(unsigned long sp) 18431da177e4SLinus Torvalds { 18441da177e4SLinus Torvalds return (sp - current->sas_ss_sp < current->sas_ss_size); 18451da177e4SLinus Torvalds } 18461da177e4SLinus Torvalds 18471da177e4SLinus Torvalds static inline int sas_ss_flags(unsigned long sp) 18481da177e4SLinus Torvalds { 18491da177e4SLinus Torvalds return (current->sas_ss_size == 0 ? SS_DISABLE 18501da177e4SLinus Torvalds : on_sig_stack(sp) ? SS_ONSTACK : 0); 18511da177e4SLinus Torvalds } 18521da177e4SLinus Torvalds 18531da177e4SLinus Torvalds /* 18541da177e4SLinus Torvalds * Routines for handling mm_structs 18551da177e4SLinus Torvalds */ 18561da177e4SLinus Torvalds extern struct mm_struct * mm_alloc(void); 18571da177e4SLinus Torvalds 18581da177e4SLinus Torvalds /* mmdrop drops the mm and the page tables */ 1859b3c97528SHarvey Harrison extern void __mmdrop(struct mm_struct *); 18601da177e4SLinus Torvalds static inline void mmdrop(struct mm_struct * mm) 18611da177e4SLinus Torvalds { 18626fb43d7bSIngo Molnar if (unlikely(atomic_dec_and_test(&mm->mm_count))) 18631da177e4SLinus Torvalds __mmdrop(mm); 18641da177e4SLinus Torvalds } 18651da177e4SLinus Torvalds 18661da177e4SLinus Torvalds /* mmput gets rid of the mappings and all user-space */ 18671da177e4SLinus Torvalds extern void mmput(struct mm_struct *); 18681da177e4SLinus Torvalds /* Grab a reference to a task's mm, if it is not already going away */ 18691da177e4SLinus Torvalds extern struct mm_struct *get_task_mm(struct task_struct *task); 18701da177e4SLinus Torvalds /* Remove the current tasks stale references to the old mm_struct */ 18711da177e4SLinus Torvalds extern void mm_release(struct task_struct *, struct mm_struct *); 1872402b0862SCarsten Otte /* Allocate a new mm structure and copy contents from tsk->mm */ 1873402b0862SCarsten Otte extern struct mm_struct *dup_mm(struct task_struct *tsk); 18741da177e4SLinus Torvalds 18751da177e4SLinus Torvalds extern int copy_thread(int, unsigned long, unsigned long, unsigned long, struct task_struct *, struct pt_regs *); 18761da177e4SLinus Torvalds extern void flush_thread(void); 18771da177e4SLinus Torvalds extern void exit_thread(void); 18781da177e4SLinus Torvalds 18791da177e4SLinus Torvalds extern void exit_files(struct task_struct *); 18806b3934efSOleg Nesterov extern void __cleanup_signal(struct signal_struct *); 1881a7e5328aSOleg Nesterov extern void __cleanup_sighand(struct sighand_struct *); 1882cbaffba1SOleg Nesterov 18831da177e4SLinus Torvalds extern void exit_itimers(struct signal_struct *); 1884cbaffba1SOleg Nesterov extern void flush_itimer_signals(void); 18851da177e4SLinus Torvalds 18861da177e4SLinus Torvalds extern NORET_TYPE void do_group_exit(int); 18871da177e4SLinus Torvalds 18881da177e4SLinus Torvalds extern void daemonize(const char *, ...); 18891da177e4SLinus Torvalds extern int allow_signal(int); 18901da177e4SLinus Torvalds extern int disallow_signal(int); 18911da177e4SLinus Torvalds 18921da177e4SLinus Torvalds extern int do_execve(char *, char __user * __user *, char __user * __user *, struct pt_regs *); 18931da177e4SLinus Torvalds extern long do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *); 189436c8b586SIngo Molnar struct task_struct *fork_idle(int); 18951da177e4SLinus Torvalds 18961da177e4SLinus Torvalds extern void set_task_comm(struct task_struct *tsk, char *from); 189759714d65SAndrew Morton extern char *get_task_comm(char *to, struct task_struct *tsk); 18981da177e4SLinus Torvalds 18991da177e4SLinus Torvalds #ifdef CONFIG_SMP 190085ba2d86SRoland McGrath extern unsigned long wait_task_inactive(struct task_struct *, long match_state); 19011da177e4SLinus Torvalds #else 190285ba2d86SRoland McGrath static inline unsigned long wait_task_inactive(struct task_struct *p, 190385ba2d86SRoland McGrath long match_state) 190485ba2d86SRoland McGrath { 190585ba2d86SRoland McGrath return 1; 190685ba2d86SRoland McGrath } 19071da177e4SLinus Torvalds #endif 19081da177e4SLinus Torvalds 19095e85d4abSEric W. Biederman #define next_task(p) list_entry(rcu_dereference((p)->tasks.next), struct task_struct, tasks) 19101da177e4SLinus Torvalds 19111da177e4SLinus Torvalds #define for_each_process(p) \ 19121da177e4SLinus Torvalds for (p = &init_task ; (p = next_task(p)) != &init_task ; ) 19131da177e4SLinus Torvalds 19141da177e4SLinus Torvalds /* 19151da177e4SLinus Torvalds * Careful: do_each_thread/while_each_thread is a double loop so 19161da177e4SLinus Torvalds * 'break' will not work as expected - use goto instead. 19171da177e4SLinus Torvalds */ 19181da177e4SLinus Torvalds #define do_each_thread(g, t) \ 19191da177e4SLinus Torvalds for (g = t = &init_task ; (g = t = next_task(g)) != &init_task ; ) do 19201da177e4SLinus Torvalds 19211da177e4SLinus Torvalds #define while_each_thread(g, t) \ 19221da177e4SLinus Torvalds while ((t = next_thread(t)) != g) 19231da177e4SLinus Torvalds 1924de12a787SEric W. Biederman /* de_thread depends on thread_group_leader not being a pid based check */ 1925de12a787SEric W. Biederman #define thread_group_leader(p) (p == p->group_leader) 19261da177e4SLinus Torvalds 19270804ef4bSEric W. Biederman /* Do to the insanities of de_thread it is possible for a process 19280804ef4bSEric W. Biederman * to have the pid of the thread group leader without actually being 19290804ef4bSEric W. Biederman * the thread group leader. For iteration through the pids in proc 19300804ef4bSEric W. Biederman * all we care about is that we have a task with the appropriate 19310804ef4bSEric W. Biederman * pid, we don't actually care if we have the right task. 19320804ef4bSEric W. Biederman */ 1933e868171aSAlexey Dobriyan static inline int has_group_leader_pid(struct task_struct *p) 19340804ef4bSEric W. Biederman { 19350804ef4bSEric W. Biederman return p->pid == p->tgid; 19360804ef4bSEric W. Biederman } 19370804ef4bSEric W. Biederman 1938bac0abd6SPavel Emelyanov static inline 1939bac0abd6SPavel Emelyanov int same_thread_group(struct task_struct *p1, struct task_struct *p2) 1940bac0abd6SPavel Emelyanov { 1941bac0abd6SPavel Emelyanov return p1->tgid == p2->tgid; 1942bac0abd6SPavel Emelyanov } 1943bac0abd6SPavel Emelyanov 194436c8b586SIngo Molnar static inline struct task_struct *next_thread(const struct task_struct *p) 194547e65328SOleg Nesterov { 194647e65328SOleg Nesterov return list_entry(rcu_dereference(p->thread_group.next), 194736c8b586SIngo Molnar struct task_struct, thread_group); 194847e65328SOleg Nesterov } 194947e65328SOleg Nesterov 1950e868171aSAlexey Dobriyan static inline int thread_group_empty(struct task_struct *p) 19511da177e4SLinus Torvalds { 195247e65328SOleg Nesterov return list_empty(&p->thread_group); 19531da177e4SLinus Torvalds } 19541da177e4SLinus Torvalds 19551da177e4SLinus Torvalds #define delay_group_leader(p) \ 19561da177e4SLinus Torvalds (thread_group_leader(p) && !thread_group_empty(p)) 19571da177e4SLinus Torvalds 19581da177e4SLinus Torvalds /* 1959260ea101SEric W. Biederman * Protects ->fs, ->files, ->mm, ->group_info, ->comm, keyring 196022e2c507SJens Axboe * subscriptions and synchronises with wait4(). Also used in procfs. Also 1961ddbcc7e8SPaul Menage * pins the final release of task.io_context. Also protects ->cpuset and 1962ddbcc7e8SPaul Menage * ->cgroup.subsys[]. 19631da177e4SLinus Torvalds * 19641da177e4SLinus Torvalds * Nests both inside and outside of read_lock(&tasklist_lock). 19651da177e4SLinus Torvalds * It must not be nested with write_lock_irq(&tasklist_lock), 19661da177e4SLinus Torvalds * neither inside nor outside. 19671da177e4SLinus Torvalds */ 19681da177e4SLinus Torvalds static inline void task_lock(struct task_struct *p) 19691da177e4SLinus Torvalds { 19701da177e4SLinus Torvalds spin_lock(&p->alloc_lock); 19711da177e4SLinus Torvalds } 19721da177e4SLinus Torvalds 19731da177e4SLinus Torvalds static inline void task_unlock(struct task_struct *p) 19741da177e4SLinus Torvalds { 19751da177e4SLinus Torvalds spin_unlock(&p->alloc_lock); 19761da177e4SLinus Torvalds } 19771da177e4SLinus Torvalds 1978f63ee72eSOleg Nesterov extern struct sighand_struct *lock_task_sighand(struct task_struct *tsk, 1979f63ee72eSOleg Nesterov unsigned long *flags); 1980f63ee72eSOleg Nesterov 1981f63ee72eSOleg Nesterov static inline void unlock_task_sighand(struct task_struct *tsk, 1982f63ee72eSOleg Nesterov unsigned long *flags) 1983f63ee72eSOleg Nesterov { 1984f63ee72eSOleg Nesterov spin_unlock_irqrestore(&tsk->sighand->siglock, *flags); 1985f63ee72eSOleg Nesterov } 1986f63ee72eSOleg Nesterov 1987f037360fSAl Viro #ifndef __HAVE_THREAD_FUNCTIONS 1988f037360fSAl Viro 1989f7e4217bSRoman Zippel #define task_thread_info(task) ((struct thread_info *)(task)->stack) 1990f7e4217bSRoman Zippel #define task_stack_page(task) ((task)->stack) 1991a1261f54SAl Viro 199210ebffdeSAl Viro static inline void setup_thread_stack(struct task_struct *p, struct task_struct *org) 199310ebffdeSAl Viro { 199410ebffdeSAl Viro *task_thread_info(p) = *task_thread_info(org); 199510ebffdeSAl Viro task_thread_info(p)->task = p; 199610ebffdeSAl Viro } 199710ebffdeSAl Viro 199810ebffdeSAl Viro static inline unsigned long *end_of_stack(struct task_struct *p) 199910ebffdeSAl Viro { 2000f7e4217bSRoman Zippel return (unsigned long *)(task_thread_info(p) + 1); 200110ebffdeSAl Viro } 200210ebffdeSAl Viro 2003f037360fSAl Viro #endif 2004f037360fSAl Viro 20058b05c7e6SFUJITA Tomonori static inline int object_is_on_stack(void *obj) 20068b05c7e6SFUJITA Tomonori { 20078b05c7e6SFUJITA Tomonori void *stack = task_stack_page(current); 20088b05c7e6SFUJITA Tomonori 20098b05c7e6SFUJITA Tomonori return (obj >= stack) && (obj < (stack + THREAD_SIZE)); 20108b05c7e6SFUJITA Tomonori } 20118b05c7e6SFUJITA Tomonori 20128c9843e5SBenjamin Herrenschmidt extern void thread_info_cache_init(void); 20138c9843e5SBenjamin Herrenschmidt 20141da177e4SLinus Torvalds /* set thread flags in other task's structures 20151da177e4SLinus Torvalds * - see asm/thread_info.h for TIF_xxxx flags available 20161da177e4SLinus Torvalds */ 20171da177e4SLinus Torvalds static inline void set_tsk_thread_flag(struct task_struct *tsk, int flag) 20181da177e4SLinus Torvalds { 2019a1261f54SAl Viro set_ti_thread_flag(task_thread_info(tsk), flag); 20201da177e4SLinus Torvalds } 20211da177e4SLinus Torvalds 20221da177e4SLinus Torvalds static inline void clear_tsk_thread_flag(struct task_struct *tsk, int flag) 20231da177e4SLinus Torvalds { 2024a1261f54SAl Viro clear_ti_thread_flag(task_thread_info(tsk), flag); 20251da177e4SLinus Torvalds } 20261da177e4SLinus Torvalds 20271da177e4SLinus Torvalds static inline int test_and_set_tsk_thread_flag(struct task_struct *tsk, int flag) 20281da177e4SLinus Torvalds { 2029a1261f54SAl Viro return test_and_set_ti_thread_flag(task_thread_info(tsk), flag); 20301da177e4SLinus Torvalds } 20311da177e4SLinus Torvalds 20321da177e4SLinus Torvalds static inline int test_and_clear_tsk_thread_flag(struct task_struct *tsk, int flag) 20331da177e4SLinus Torvalds { 2034a1261f54SAl Viro return test_and_clear_ti_thread_flag(task_thread_info(tsk), flag); 20351da177e4SLinus Torvalds } 20361da177e4SLinus Torvalds 20371da177e4SLinus Torvalds static inline int test_tsk_thread_flag(struct task_struct *tsk, int flag) 20381da177e4SLinus Torvalds { 2039a1261f54SAl Viro return test_ti_thread_flag(task_thread_info(tsk), flag); 20401da177e4SLinus Torvalds } 20411da177e4SLinus Torvalds 20421da177e4SLinus Torvalds static inline void set_tsk_need_resched(struct task_struct *tsk) 20431da177e4SLinus Torvalds { 20441da177e4SLinus Torvalds set_tsk_thread_flag(tsk,TIF_NEED_RESCHED); 20451da177e4SLinus Torvalds } 20461da177e4SLinus Torvalds 20471da177e4SLinus Torvalds static inline void clear_tsk_need_resched(struct task_struct *tsk) 20481da177e4SLinus Torvalds { 20491da177e4SLinus Torvalds clear_tsk_thread_flag(tsk,TIF_NEED_RESCHED); 20501da177e4SLinus Torvalds } 20511da177e4SLinus Torvalds 20528ae121acSGregory Haskins static inline int test_tsk_need_resched(struct task_struct *tsk) 20538ae121acSGregory Haskins { 20548ae121acSGregory Haskins return unlikely(test_tsk_thread_flag(tsk,TIF_NEED_RESCHED)); 20558ae121acSGregory Haskins } 20568ae121acSGregory Haskins 20571da177e4SLinus Torvalds static inline int signal_pending(struct task_struct *p) 20581da177e4SLinus Torvalds { 20591da177e4SLinus Torvalds return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING)); 20601da177e4SLinus Torvalds } 20611da177e4SLinus Torvalds 2062b3c97528SHarvey Harrison extern int __fatal_signal_pending(struct task_struct *p); 2063f776d12dSMatthew Wilcox 2064f776d12dSMatthew Wilcox static inline int fatal_signal_pending(struct task_struct *p) 2065f776d12dSMatthew Wilcox { 2066f776d12dSMatthew Wilcox return signal_pending(p) && __fatal_signal_pending(p); 2067f776d12dSMatthew Wilcox } 2068f776d12dSMatthew Wilcox 206916882c1eSOleg Nesterov static inline int signal_pending_state(long state, struct task_struct *p) 207016882c1eSOleg Nesterov { 207116882c1eSOleg Nesterov if (!(state & (TASK_INTERRUPTIBLE | TASK_WAKEKILL))) 207216882c1eSOleg Nesterov return 0; 207316882c1eSOleg Nesterov if (!signal_pending(p)) 207416882c1eSOleg Nesterov return 0; 207516882c1eSOleg Nesterov 207616882c1eSOleg Nesterov return (state & TASK_INTERRUPTIBLE) || __fatal_signal_pending(p); 207716882c1eSOleg Nesterov } 207816882c1eSOleg Nesterov 20791da177e4SLinus Torvalds static inline int need_resched(void) 20801da177e4SLinus Torvalds { 20819404ef02SLinus Torvalds return unlikely(test_thread_flag(TIF_NEED_RESCHED)); 20821da177e4SLinus Torvalds } 20831da177e4SLinus Torvalds 20841da177e4SLinus Torvalds /* 20851da177e4SLinus Torvalds * cond_resched() and cond_resched_lock(): latency reduction via 20861da177e4SLinus Torvalds * explicit rescheduling in places that are safe. The return 20871da177e4SLinus Torvalds * value indicates whether a reschedule was done in fact. 20881da177e4SLinus Torvalds * cond_resched_lock() will drop the spinlock before scheduling, 20891da177e4SLinus Torvalds * cond_resched_softirq() will enable bhs before scheduling. 20901da177e4SLinus Torvalds */ 2091c3921ab7SLinus Torvalds extern int _cond_resched(void); 2092c714a534SLinus Torvalds #ifdef CONFIG_PREEMPT_BKL 209302b67cc3SHerbert Xu static inline int cond_resched(void) 209402b67cc3SHerbert Xu { 209502b67cc3SHerbert Xu return 0; 209602b67cc3SHerbert Xu } 209702b67cc3SHerbert Xu #else 209802b67cc3SHerbert Xu static inline int cond_resched(void) 209902b67cc3SHerbert Xu { 210002b67cc3SHerbert Xu return _cond_resched(); 210102b67cc3SHerbert Xu } 210202b67cc3SHerbert Xu #endif 21031da177e4SLinus Torvalds extern int cond_resched_lock(spinlock_t * lock); 21041da177e4SLinus Torvalds extern int cond_resched_softirq(void); 2105c3921ab7SLinus Torvalds static inline int cond_resched_bkl(void) 2106c3921ab7SLinus Torvalds { 2107c3921ab7SLinus Torvalds return _cond_resched(); 2108c3921ab7SLinus Torvalds } 21091da177e4SLinus Torvalds 21101da177e4SLinus Torvalds /* 21111da177e4SLinus Torvalds * Does a critical section need to be broken due to another 211295c354feSNick Piggin * task waiting?: (technically does not depend on CONFIG_PREEMPT, 211395c354feSNick Piggin * but a general need for low latency) 21141da177e4SLinus Torvalds */ 211595c354feSNick Piggin static inline int spin_needbreak(spinlock_t *lock) 21161da177e4SLinus Torvalds { 211795c354feSNick Piggin #ifdef CONFIG_PREEMPT 211895c354feSNick Piggin return spin_is_contended(lock); 211995c354feSNick Piggin #else 21201da177e4SLinus Torvalds return 0; 212195c354feSNick Piggin #endif 21221da177e4SLinus Torvalds } 21231da177e4SLinus Torvalds 21247bb44adeSRoland McGrath /* 2125*f06febc9SFrank Mayhar * Thread group CPU time accounting. 2126*f06febc9SFrank Mayhar */ 2127*f06febc9SFrank Mayhar #ifdef CONFIG_SMP 2128*f06febc9SFrank Mayhar 2129*f06febc9SFrank Mayhar extern int thread_group_cputime_alloc_smp(struct task_struct *); 2130*f06febc9SFrank Mayhar extern void thread_group_cputime_smp(struct task_struct *, struct task_cputime *); 2131*f06febc9SFrank Mayhar 2132*f06febc9SFrank Mayhar static inline void thread_group_cputime_init(struct signal_struct *sig) 2133*f06febc9SFrank Mayhar { 2134*f06febc9SFrank Mayhar sig->cputime.totals = NULL; 2135*f06febc9SFrank Mayhar } 2136*f06febc9SFrank Mayhar 2137*f06febc9SFrank Mayhar static inline int thread_group_cputime_clone_thread(struct task_struct *curr, 2138*f06febc9SFrank Mayhar struct task_struct *new) 2139*f06febc9SFrank Mayhar { 2140*f06febc9SFrank Mayhar if (curr->signal->cputime.totals) 2141*f06febc9SFrank Mayhar return 0; 2142*f06febc9SFrank Mayhar return thread_group_cputime_alloc_smp(curr); 2143*f06febc9SFrank Mayhar } 2144*f06febc9SFrank Mayhar 2145*f06febc9SFrank Mayhar static inline void thread_group_cputime_free(struct signal_struct *sig) 2146*f06febc9SFrank Mayhar { 2147*f06febc9SFrank Mayhar free_percpu(sig->cputime.totals); 2148*f06febc9SFrank Mayhar } 2149*f06febc9SFrank Mayhar 2150*f06febc9SFrank Mayhar /** 2151*f06febc9SFrank Mayhar * thread_group_cputime - Sum the thread group time fields across all CPUs. 2152*f06febc9SFrank Mayhar * 2153*f06febc9SFrank Mayhar * This is a wrapper for the real routine, thread_group_cputime_smp(). See 2154*f06febc9SFrank Mayhar * that routine for details. 2155*f06febc9SFrank Mayhar */ 2156*f06febc9SFrank Mayhar static inline void thread_group_cputime( 2157*f06febc9SFrank Mayhar struct task_struct *tsk, 2158*f06febc9SFrank Mayhar struct task_cputime *times) 2159*f06febc9SFrank Mayhar { 2160*f06febc9SFrank Mayhar thread_group_cputime_smp(tsk, times); 2161*f06febc9SFrank Mayhar } 2162*f06febc9SFrank Mayhar 2163*f06febc9SFrank Mayhar /** 2164*f06febc9SFrank Mayhar * thread_group_cputime_account_user - Maintain utime for a thread group. 2165*f06febc9SFrank Mayhar * 2166*f06febc9SFrank Mayhar * @tgtimes: Pointer to thread_group_cputime structure. 2167*f06febc9SFrank Mayhar * @cputime: Time value by which to increment the utime field of that 2168*f06febc9SFrank Mayhar * structure. 2169*f06febc9SFrank Mayhar * 2170*f06febc9SFrank Mayhar * If thread group time is being maintained, get the structure for the 2171*f06febc9SFrank Mayhar * running CPU and update the utime field there. 2172*f06febc9SFrank Mayhar */ 2173*f06febc9SFrank Mayhar static inline void thread_group_cputime_account_user( 2174*f06febc9SFrank Mayhar struct thread_group_cputime *tgtimes, 2175*f06febc9SFrank Mayhar cputime_t cputime) 2176*f06febc9SFrank Mayhar { 2177*f06febc9SFrank Mayhar if (tgtimes->totals) { 2178*f06febc9SFrank Mayhar struct task_cputime *times; 2179*f06febc9SFrank Mayhar 2180*f06febc9SFrank Mayhar times = per_cpu_ptr(tgtimes->totals, get_cpu()); 2181*f06febc9SFrank Mayhar times->utime = cputime_add(times->utime, cputime); 2182*f06febc9SFrank Mayhar put_cpu_no_resched(); 2183*f06febc9SFrank Mayhar } 2184*f06febc9SFrank Mayhar } 2185*f06febc9SFrank Mayhar 2186*f06febc9SFrank Mayhar /** 2187*f06febc9SFrank Mayhar * thread_group_cputime_account_system - Maintain stime for a thread group. 2188*f06febc9SFrank Mayhar * 2189*f06febc9SFrank Mayhar * @tgtimes: Pointer to thread_group_cputime structure. 2190*f06febc9SFrank Mayhar * @cputime: Time value by which to increment the stime field of that 2191*f06febc9SFrank Mayhar * structure. 2192*f06febc9SFrank Mayhar * 2193*f06febc9SFrank Mayhar * If thread group time is being maintained, get the structure for the 2194*f06febc9SFrank Mayhar * running CPU and update the stime field there. 2195*f06febc9SFrank Mayhar */ 2196*f06febc9SFrank Mayhar static inline void thread_group_cputime_account_system( 2197*f06febc9SFrank Mayhar struct thread_group_cputime *tgtimes, 2198*f06febc9SFrank Mayhar cputime_t cputime) 2199*f06febc9SFrank Mayhar { 2200*f06febc9SFrank Mayhar if (tgtimes->totals) { 2201*f06febc9SFrank Mayhar struct task_cputime *times; 2202*f06febc9SFrank Mayhar 2203*f06febc9SFrank Mayhar times = per_cpu_ptr(tgtimes->totals, get_cpu()); 2204*f06febc9SFrank Mayhar times->stime = cputime_add(times->stime, cputime); 2205*f06febc9SFrank Mayhar put_cpu_no_resched(); 2206*f06febc9SFrank Mayhar } 2207*f06febc9SFrank Mayhar } 2208*f06febc9SFrank Mayhar 2209*f06febc9SFrank Mayhar /** 2210*f06febc9SFrank Mayhar * thread_group_cputime_account_exec_runtime - Maintain exec runtime for a 2211*f06febc9SFrank Mayhar * thread group. 2212*f06febc9SFrank Mayhar * 2213*f06febc9SFrank Mayhar * @tgtimes: Pointer to thread_group_cputime structure. 2214*f06febc9SFrank Mayhar * @ns: Time value by which to increment the sum_exec_runtime field 2215*f06febc9SFrank Mayhar * of that structure. 2216*f06febc9SFrank Mayhar * 2217*f06febc9SFrank Mayhar * If thread group time is being maintained, get the structure for the 2218*f06febc9SFrank Mayhar * running CPU and update the sum_exec_runtime field there. 2219*f06febc9SFrank Mayhar */ 2220*f06febc9SFrank Mayhar static inline void thread_group_cputime_account_exec_runtime( 2221*f06febc9SFrank Mayhar struct thread_group_cputime *tgtimes, 2222*f06febc9SFrank Mayhar unsigned long long ns) 2223*f06febc9SFrank Mayhar { 2224*f06febc9SFrank Mayhar if (tgtimes->totals) { 2225*f06febc9SFrank Mayhar struct task_cputime *times; 2226*f06febc9SFrank Mayhar 2227*f06febc9SFrank Mayhar times = per_cpu_ptr(tgtimes->totals, get_cpu()); 2228*f06febc9SFrank Mayhar times->sum_exec_runtime += ns; 2229*f06febc9SFrank Mayhar put_cpu_no_resched(); 2230*f06febc9SFrank Mayhar } 2231*f06febc9SFrank Mayhar } 2232*f06febc9SFrank Mayhar 2233*f06febc9SFrank Mayhar #else /* CONFIG_SMP */ 2234*f06febc9SFrank Mayhar 2235*f06febc9SFrank Mayhar static inline void thread_group_cputime_init(struct signal_struct *sig) 2236*f06febc9SFrank Mayhar { 2237*f06febc9SFrank Mayhar sig->cputime.totals.utime = cputime_zero; 2238*f06febc9SFrank Mayhar sig->cputime.totals.stime = cputime_zero; 2239*f06febc9SFrank Mayhar sig->cputime.totals.sum_exec_runtime = 0; 2240*f06febc9SFrank Mayhar } 2241*f06febc9SFrank Mayhar 2242*f06febc9SFrank Mayhar static inline int thread_group_cputime_alloc(struct task_struct *tsk) 2243*f06febc9SFrank Mayhar { 2244*f06febc9SFrank Mayhar return 0; 2245*f06febc9SFrank Mayhar } 2246*f06febc9SFrank Mayhar 2247*f06febc9SFrank Mayhar static inline void thread_group_cputime_free(struct signal_struct *sig) 2248*f06febc9SFrank Mayhar { 2249*f06febc9SFrank Mayhar } 2250*f06febc9SFrank Mayhar 2251*f06febc9SFrank Mayhar static inline int thread_group_cputime_clone_thread(struct task_struct *curr, 2252*f06febc9SFrank Mayhar struct task_struct *tsk) 2253*f06febc9SFrank Mayhar { 2254*f06febc9SFrank Mayhar } 2255*f06febc9SFrank Mayhar 2256*f06febc9SFrank Mayhar static inline void thread_group_cputime(struct task_struct *tsk, 2257*f06febc9SFrank Mayhar struct task_cputime *cputime) 2258*f06febc9SFrank Mayhar { 2259*f06febc9SFrank Mayhar *cputime = tsk->signal->cputime.totals; 2260*f06febc9SFrank Mayhar } 2261*f06febc9SFrank Mayhar 2262*f06febc9SFrank Mayhar static inline void thread_group_cputime_account_user( 2263*f06febc9SFrank Mayhar struct thread_group_cputime *tgtimes, 2264*f06febc9SFrank Mayhar cputime_t cputime) 2265*f06febc9SFrank Mayhar { 2266*f06febc9SFrank Mayhar tgtimes->totals->utime = cputime_add(tgtimes->totals->utime, cputime); 2267*f06febc9SFrank Mayhar } 2268*f06febc9SFrank Mayhar 2269*f06febc9SFrank Mayhar static inline void thread_group_cputime_account_system( 2270*f06febc9SFrank Mayhar struct thread_group_cputime *tgtimes, 2271*f06febc9SFrank Mayhar cputime_t cputime) 2272*f06febc9SFrank Mayhar { 2273*f06febc9SFrank Mayhar tgtimes->totals->stime = cputime_add(tgtimes->totals->stime, cputime); 2274*f06febc9SFrank Mayhar } 2275*f06febc9SFrank Mayhar 2276*f06febc9SFrank Mayhar static inline void thread_group_cputime_account_exec_runtime( 2277*f06febc9SFrank Mayhar struct thread_group_cputime *tgtimes, 2278*f06febc9SFrank Mayhar unsigned long long ns) 2279*f06febc9SFrank Mayhar { 2280*f06febc9SFrank Mayhar tgtimes->totals->sum_exec_runtime += ns; 2281*f06febc9SFrank Mayhar } 2282*f06febc9SFrank Mayhar 2283*f06febc9SFrank Mayhar #endif /* CONFIG_SMP */ 2284*f06febc9SFrank Mayhar 2285*f06febc9SFrank Mayhar static inline void account_group_user_time(struct task_struct *tsk, 2286*f06febc9SFrank Mayhar cputime_t cputime) 2287*f06febc9SFrank Mayhar { 2288*f06febc9SFrank Mayhar struct signal_struct *sig; 2289*f06febc9SFrank Mayhar 2290*f06febc9SFrank Mayhar sig = tsk->signal; 2291*f06febc9SFrank Mayhar if (likely(sig)) 2292*f06febc9SFrank Mayhar thread_group_cputime_account_user(&sig->cputime, cputime); 2293*f06febc9SFrank Mayhar } 2294*f06febc9SFrank Mayhar 2295*f06febc9SFrank Mayhar static inline void account_group_system_time(struct task_struct *tsk, 2296*f06febc9SFrank Mayhar cputime_t cputime) 2297*f06febc9SFrank Mayhar { 2298*f06febc9SFrank Mayhar struct signal_struct *sig; 2299*f06febc9SFrank Mayhar 2300*f06febc9SFrank Mayhar sig = tsk->signal; 2301*f06febc9SFrank Mayhar if (likely(sig)) 2302*f06febc9SFrank Mayhar thread_group_cputime_account_system(&sig->cputime, cputime); 2303*f06febc9SFrank Mayhar } 2304*f06febc9SFrank Mayhar 2305*f06febc9SFrank Mayhar static inline void account_group_exec_runtime(struct task_struct *tsk, 2306*f06febc9SFrank Mayhar unsigned long long ns) 2307*f06febc9SFrank Mayhar { 2308*f06febc9SFrank Mayhar struct signal_struct *sig; 2309*f06febc9SFrank Mayhar 2310*f06febc9SFrank Mayhar sig = tsk->signal; 2311*f06febc9SFrank Mayhar if (likely(sig)) 2312*f06febc9SFrank Mayhar thread_group_cputime_account_exec_runtime(&sig->cputime, ns); 2313*f06febc9SFrank Mayhar } 2314*f06febc9SFrank Mayhar 2315*f06febc9SFrank Mayhar /* 23167bb44adeSRoland McGrath * Reevaluate whether the task has signals pending delivery. 23177bb44adeSRoland McGrath * Wake the task if so. 23187bb44adeSRoland McGrath * This is required every time the blocked sigset_t changes. 23197bb44adeSRoland McGrath * callers must hold sighand->siglock. 23207bb44adeSRoland McGrath */ 23217bb44adeSRoland McGrath extern void recalc_sigpending_and_wake(struct task_struct *t); 23221da177e4SLinus Torvalds extern void recalc_sigpending(void); 23231da177e4SLinus Torvalds 23241da177e4SLinus Torvalds extern void signal_wake_up(struct task_struct *t, int resume_stopped); 23251da177e4SLinus Torvalds 23261da177e4SLinus Torvalds /* 23271da177e4SLinus Torvalds * Wrappers for p->thread_info->cpu access. No-op on UP. 23281da177e4SLinus Torvalds */ 23291da177e4SLinus Torvalds #ifdef CONFIG_SMP 23301da177e4SLinus Torvalds 23311da177e4SLinus Torvalds static inline unsigned int task_cpu(const struct task_struct *p) 23321da177e4SLinus Torvalds { 2333a1261f54SAl Viro return task_thread_info(p)->cpu; 23341da177e4SLinus Torvalds } 23351da177e4SLinus Torvalds 2336c65cc870SIngo Molnar extern void set_task_cpu(struct task_struct *p, unsigned int cpu); 23371da177e4SLinus Torvalds 23381da177e4SLinus Torvalds #else 23391da177e4SLinus Torvalds 23401da177e4SLinus Torvalds static inline unsigned int task_cpu(const struct task_struct *p) 23411da177e4SLinus Torvalds { 23421da177e4SLinus Torvalds return 0; 23431da177e4SLinus Torvalds } 23441da177e4SLinus Torvalds 23451da177e4SLinus Torvalds static inline void set_task_cpu(struct task_struct *p, unsigned int cpu) 23461da177e4SLinus Torvalds { 23471da177e4SLinus Torvalds } 23481da177e4SLinus Torvalds 23491da177e4SLinus Torvalds #endif /* CONFIG_SMP */ 23501da177e4SLinus Torvalds 23511da177e4SLinus Torvalds extern void arch_pick_mmap_layout(struct mm_struct *mm); 23521da177e4SLinus Torvalds 23531a3c3034SIngo Molnar #ifdef CONFIG_TRACING 23541a3c3034SIngo Molnar extern void 23551a3c3034SIngo Molnar __trace_special(void *__tr, void *__data, 23561a3c3034SIngo Molnar unsigned long arg1, unsigned long arg2, unsigned long arg3); 23571a3c3034SIngo Molnar #else 23581a3c3034SIngo Molnar static inline void 23591a3c3034SIngo Molnar __trace_special(void *__tr, void *__data, 23601a3c3034SIngo Molnar unsigned long arg1, unsigned long arg2, unsigned long arg3) 23611a3c3034SIngo Molnar { 23621a3c3034SIngo Molnar } 23631a3c3034SIngo Molnar #endif 23641a3c3034SIngo Molnar 2365b53e921bSMike Travis extern long sched_setaffinity(pid_t pid, const cpumask_t *new_mask); 23661da177e4SLinus Torvalds extern long sched_getaffinity(pid_t pid, cpumask_t *mask); 23671da177e4SLinus Torvalds 23685c45bf27SSiddha, Suresh B extern int sched_mc_power_savings, sched_smt_power_savings; 23695c45bf27SSiddha, Suresh B 23701da177e4SLinus Torvalds extern void normalize_rt_tasks(void); 23711da177e4SLinus Torvalds 2372052f1dc7SPeter Zijlstra #ifdef CONFIG_GROUP_SCHED 23739b5b7751SSrivatsa Vaddagiri 23744cf86d77SIngo Molnar extern struct task_group init_task_group; 2375eff766a6SPeter Zijlstra #ifdef CONFIG_USER_SCHED 2376eff766a6SPeter Zijlstra extern struct task_group root_task_group; 2377eff766a6SPeter Zijlstra #endif 23789b5b7751SSrivatsa Vaddagiri 2379ec7dc8acSDhaval Giani extern struct task_group *sched_create_group(struct task_group *parent); 23804cf86d77SIngo Molnar extern void sched_destroy_group(struct task_group *tg); 23819b5b7751SSrivatsa Vaddagiri extern void sched_move_task(struct task_struct *tsk); 2382052f1dc7SPeter Zijlstra #ifdef CONFIG_FAIR_GROUP_SCHED 23834cf86d77SIngo Molnar extern int sched_group_set_shares(struct task_group *tg, unsigned long shares); 23845cb350baSDhaval Giani extern unsigned long sched_group_shares(struct task_group *tg); 2385052f1dc7SPeter Zijlstra #endif 2386052f1dc7SPeter Zijlstra #ifdef CONFIG_RT_GROUP_SCHED 23879f0c1e56SPeter Zijlstra extern int sched_group_set_rt_runtime(struct task_group *tg, 23889f0c1e56SPeter Zijlstra long rt_runtime_us); 23899f0c1e56SPeter Zijlstra extern long sched_group_rt_runtime(struct task_group *tg); 2390d0b27fa7SPeter Zijlstra extern int sched_group_set_rt_period(struct task_group *tg, 2391d0b27fa7SPeter Zijlstra long rt_period_us); 2392d0b27fa7SPeter Zijlstra extern long sched_group_rt_period(struct task_group *tg); 2393052f1dc7SPeter Zijlstra #endif 23949b5b7751SSrivatsa Vaddagiri #endif 23959b5b7751SSrivatsa Vaddagiri 23964b98d11bSAlexey Dobriyan #ifdef CONFIG_TASK_XACCT 23974b98d11bSAlexey Dobriyan static inline void add_rchar(struct task_struct *tsk, ssize_t amt) 23984b98d11bSAlexey Dobriyan { 2399940389b8SAndrea Righi tsk->ioac.rchar += amt; 24004b98d11bSAlexey Dobriyan } 24014b98d11bSAlexey Dobriyan 24024b98d11bSAlexey Dobriyan static inline void add_wchar(struct task_struct *tsk, ssize_t amt) 24034b98d11bSAlexey Dobriyan { 2404940389b8SAndrea Righi tsk->ioac.wchar += amt; 24054b98d11bSAlexey Dobriyan } 24064b98d11bSAlexey Dobriyan 24074b98d11bSAlexey Dobriyan static inline void inc_syscr(struct task_struct *tsk) 24084b98d11bSAlexey Dobriyan { 2409940389b8SAndrea Righi tsk->ioac.syscr++; 24104b98d11bSAlexey Dobriyan } 24114b98d11bSAlexey Dobriyan 24124b98d11bSAlexey Dobriyan static inline void inc_syscw(struct task_struct *tsk) 24134b98d11bSAlexey Dobriyan { 2414940389b8SAndrea Righi tsk->ioac.syscw++; 24154b98d11bSAlexey Dobriyan } 24164b98d11bSAlexey Dobriyan #else 24174b98d11bSAlexey Dobriyan static inline void add_rchar(struct task_struct *tsk, ssize_t amt) 24184b98d11bSAlexey Dobriyan { 24194b98d11bSAlexey Dobriyan } 24204b98d11bSAlexey Dobriyan 24214b98d11bSAlexey Dobriyan static inline void add_wchar(struct task_struct *tsk, ssize_t amt) 24224b98d11bSAlexey Dobriyan { 24234b98d11bSAlexey Dobriyan } 24244b98d11bSAlexey Dobriyan 24254b98d11bSAlexey Dobriyan static inline void inc_syscr(struct task_struct *tsk) 24264b98d11bSAlexey Dobriyan { 24274b98d11bSAlexey Dobriyan } 24284b98d11bSAlexey Dobriyan 24294b98d11bSAlexey Dobriyan static inline void inc_syscw(struct task_struct *tsk) 24304b98d11bSAlexey Dobriyan { 24314b98d11bSAlexey Dobriyan } 24324b98d11bSAlexey Dobriyan #endif 24334b98d11bSAlexey Dobriyan 243482455257SDave Hansen #ifndef TASK_SIZE_OF 243582455257SDave Hansen #define TASK_SIZE_OF(tsk) TASK_SIZE 243682455257SDave Hansen #endif 243782455257SDave Hansen 2438cf475ad2SBalbir Singh #ifdef CONFIG_MM_OWNER 2439cf475ad2SBalbir Singh extern void mm_update_next_owner(struct mm_struct *mm); 2440cf475ad2SBalbir Singh extern void mm_init_owner(struct mm_struct *mm, struct task_struct *p); 2441cf475ad2SBalbir Singh #else 2442cf475ad2SBalbir Singh static inline void mm_update_next_owner(struct mm_struct *mm) 2443cf475ad2SBalbir Singh { 2444cf475ad2SBalbir Singh } 2445cf475ad2SBalbir Singh 2446cf475ad2SBalbir Singh static inline void mm_init_owner(struct mm_struct *mm, struct task_struct *p) 2447cf475ad2SBalbir Singh { 2448cf475ad2SBalbir Singh } 2449cf475ad2SBalbir Singh #endif /* CONFIG_MM_OWNER */ 2450cf475ad2SBalbir Singh 24517c731e0aSSteven Rostedt #define TASK_STATE_TO_CHAR_STR "RSDTtZX" 24527c731e0aSSteven Rostedt 24531da177e4SLinus Torvalds #endif /* __KERNEL__ */ 24541da177e4SLinus Torvalds 24551da177e4SLinus Torvalds #endif 2456