/include/linux/sched.h
C Header | 2844 lines | 1839 code | 433 blank | 572 comment | 50 complexity | 2c2ee53594a7deea2bcea736805a2847 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
Large files files are truncated, but you can click here to view the full file
- #ifndef _LINUX_SCHED_H
- #define _LINUX_SCHED_H
- /*
- * cloning flags:
- */
- #define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
- #define CLONE_VM 0x00000100 /* set if VM shared between processes */
- #define CLONE_FS 0x00000200 /* set if fs info shared between processes */
- #define CLONE_FILES 0x00000400 /* set if open files shared between processes */
- #define CLONE_SIGHAND 0x00000800 /* set if signal handlers and blocked signals shared */
- #define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
- #define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
- #define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
- #define CLONE_THREAD 0x00010000 /* Same thread group? */
- #define CLONE_NEWNS 0x00020000 /* New namespace group? */
- #define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
- #define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
- #define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
- #define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */
- #define CLONE_DETACHED 0x00400000 /* Unused, ignored */
- #define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
- #define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
- /* 0x02000000 was previously the unused CLONE_STOPPED (Start in stopped state)
- and is now available for re-use. */
- #define CLONE_NEWUTS 0x04000000 /* New utsname group? */
- #define CLONE_NEWIPC 0x08000000 /* New ipcs */
- #define CLONE_NEWUSER 0x10000000 /* New user namespace */
- #define CLONE_NEWPID 0x20000000 /* New pid namespace */
- #define CLONE_NEWNET 0x40000000 /* New network namespace */
- #define CLONE_IO 0x80000000 /* Clone io context */
- /*
- * Scheduling policies
- */
- #define SCHED_NORMAL 0
- #define SCHED_FIFO 1
- #define SCHED_RR 2
- #define SCHED_BATCH 3
- /* SCHED_ISO: reserved but not implemented yet */
- #define SCHED_IDLE 5
- /* Can be ORed in to make sure the process is reverted back to SCHED_NORMAL on fork */
- #define SCHED_RESET_ON_FORK 0x40000000
- #ifdef __KERNEL__
- struct sched_param {
- int sched_priority;
- };
- #include <asm/param.h> /* for HZ */
- #include <linux/capability.h>
- #include <linux/threads.h>
- #include <linux/kernel.h>
- #include <linux/types.h>
- #include <linux/timex.h>
- #include <linux/jiffies.h>
- #include <linux/rbtree.h>
- #include <linux/thread_info.h>
- #include <linux/cpumask.h>
- #include <linux/errno.h>
- #include <linux/nodemask.h>
- #include <linux/mm_types.h>
- #include <asm/page.h>
- #include <asm/ptrace.h>
- #include <asm/cputime.h>
- #include <linux/smp.h>
- #include <linux/sem.h>
- #include <linux/signal.h>
- #include <linux/compiler.h>
- #include <linux/completion.h>
- #include <linux/pid.h>
- #include <linux/percpu.h>
- #include <linux/topology.h>
- #include <linux/proportions.h>
- #include <linux/seccomp.h>
- #include <linux/rcupdate.h>
- #include <linux/rculist.h>
- #include <linux/rtmutex.h>
- #include <linux/time.h>
- #include <linux/param.h>
- #include <linux/resource.h>
- #include <linux/timer.h>
- #include <linux/hrtimer.h>
- #include <linux/task_io_accounting.h>
- #include <linux/latencytop.h>
- #include <linux/cred.h>
- #include <linux/llist.h>
- #include <asm/processor.h>
- struct exec_domain;
- struct futex_pi_state;
- struct robust_list_head;
- struct bio_list;
- struct fs_struct;
- struct perf_event_context;
- struct blk_plug;
- /*
- * List of flags we want to share for kernel threads,
- * if only because they are not used by them anyway.
- */
- #define CLONE_KERNEL (CLONE_FS | CLONE_FILES | CLONE_SIGHAND)
- /*
- * These are the constant used to fake the fixed-point load-average
- * counting. Some notes:
- * - 11 bit fractions expand to 22 bits by the multiplies: this gives
- * a load-average precision of 10 bits integer + 11 bits fractional
- * - if you want to count load-averages more often, you need more
- * precision, or rounding will get you. With 2-second counting freq,
- * the EXP_n values would be 1981, 2034 and 2043 if still using only
- * 11 bit fractions.
- */
- extern unsigned long avenrun[]; /* Load averages */
- extern void get_avenrun(unsigned long *loads, unsigned long offset, int shift);
- #define FSHIFT 11 /* nr of bits of precision */
- #define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */
- #define LOAD_FREQ (5*HZ+1) /* 5 sec intervals */
- #define EXP_1 1884 /* 1/exp(5sec/1min) as fixed-point */
- #define EXP_5 2014 /* 1/exp(5sec/5min) */
- #define EXP_15 2037 /* 1/exp(5sec/15min) */
- #define CALC_LOAD(load,exp,n) \
- load *= exp; \
- load += n*(FIXED_1-exp); \
- load >>= FSHIFT;
- extern unsigned long total_forks;
- extern int nr_threads;
- DECLARE_PER_CPU(unsigned long, process_counts);
- extern int nr_processes(void);
- extern unsigned long nr_running(void);
- extern unsigned long nr_uninterruptible(void);
- extern unsigned long nr_iowait(void);
- extern unsigned long nr_iowait_cpu(int cpu);
- extern unsigned long this_cpu_load(void);
- extern void calc_global_load(unsigned long ticks);
- extern unsigned long get_parent_ip(unsigned long addr);
- struct seq_file;
- struct cfs_rq;
- struct task_group;
- #ifdef CONFIG_SCHED_DEBUG
- extern void proc_sched_show_task(struct task_struct *p, struct seq_file *m);
- extern void proc_sched_set_task(struct task_struct *p);
- extern void
- print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq);
- #else
- static inline void
- proc_sched_show_task(struct task_struct *p, struct seq_file *m)
- {
- }
- static inline void proc_sched_set_task(struct task_struct *p)
- {
- }
- static inline void
- print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
- {
- }
- #endif
- /*
- * Task state bitmask. NOTE! These bits are also
- * encoded in fs/proc/array.c: get_task_state().
- *
- * We have two separate sets of flags: task->state
- * is about runnability, while task->exit_state are
- * about the task exiting. Confusing, but this way
- * modifying one set can't modify the other one by
- * mistake.
- */
- #define TASK_RUNNING 0
- #define TASK_INTERRUPTIBLE 1
- #define TASK_UNINTERRUPTIBLE 2
- #define __TASK_STOPPED 4
- #define __TASK_TRACED 8
- /* in tsk->exit_state */
- #define EXIT_ZOMBIE 16
- #define EXIT_DEAD 32
- /* in tsk->state again */
- #define TASK_DEAD 64
- #define TASK_WAKEKILL 128
- #define TASK_WAKING 256
- #define TASK_STATE_MAX 512
- #define TASK_STATE_TO_CHAR_STR "RSDTtZXxKW"
- extern char ___assert_task_state[1 - 2*!!(
- sizeof(TASK_STATE_TO_CHAR_STR)-1 != ilog2(TASK_STATE_MAX)+1)];
- /* Convenience macros for the sake of set_task_state */
- #define TASK_KILLABLE (TASK_WAKEKILL | TASK_UNINTERRUPTIBLE)
- #define TASK_STOPPED (TASK_WAKEKILL | __TASK_STOPPED)
- #define TASK_TRACED (TASK_WAKEKILL | __TASK_TRACED)
- /* Convenience macros for the sake of wake_up */
- #define TASK_NORMAL (TASK_INTERRUPTIBLE | TASK_UNINTERRUPTIBLE)
- #define TASK_ALL (TASK_NORMAL | __TASK_STOPPED | __TASK_TRACED)
- /* get_task_state() */
- #define TASK_REPORT (TASK_RUNNING | TASK_INTERRUPTIBLE | \
- TASK_UNINTERRUPTIBLE | __TASK_STOPPED | \
- __TASK_TRACED)
- #define task_is_traced(task) ((task->state & __TASK_TRACED) != 0)
- #define task_is_stopped(task) ((task->state & __TASK_STOPPED) != 0)
- #define task_is_dead(task) ((task)->exit_state != 0)
- #define task_is_stopped_or_traced(task) \
- ((task->state & (__TASK_STOPPED | __TASK_TRACED)) != 0)
- #define task_contributes_to_load(task) \
- ((task->state & TASK_UNINTERRUPTIBLE) != 0 && \
- (task->flags & PF_FROZEN) == 0)
- #define __set_task_state(tsk, state_value) \
- do { (tsk)->state = (state_value); } while (0)
- #define set_task_state(tsk, state_value) \
- set_mb((tsk)->state, (state_value))
- /*
- * set_current_state() includes a barrier so that the write of current->state
- * is correctly serialised wrt the caller's subsequent test of whether to
- * actually sleep:
- *
- * set_current_state(TASK_UNINTERRUPTIBLE);
- * if (do_i_need_to_sleep())
- * schedule();
- *
- * If the caller does not need such serialisation then use __set_current_state()
- */
- #define __set_current_state(state_value) \
- do { current->state = (state_value); } while (0)
- #define set_current_state(state_value) \
- set_mb(current->state, (state_value))
- /* Task command name length */
- #define TASK_COMM_LEN 16
- #include <linux/spinlock.h>
- /*
- * This serializes "schedule()" and also protects
- * the run-queue from deletions/modifications (but
- * _adding_ to the beginning of the run-queue has
- * a separate lock).
- */
- extern rwlock_t tasklist_lock;
- extern spinlock_t mmlist_lock;
- struct task_struct;
- #ifdef CONFIG_PROVE_RCU
- extern int lockdep_tasklist_lock_is_held(void);
- #endif /* #ifdef CONFIG_PROVE_RCU */
- extern void sched_init(void);
- extern void sched_init_smp(void);
- extern asmlinkage void schedule_tail(struct task_struct *prev);
- extern void init_idle(struct task_struct *idle, int cpu);
- extern void init_idle_bootup_task(struct task_struct *idle);
- extern int runqueue_is_locked(int cpu);
- #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ)
- extern void select_nohz_load_balancer(int stop_tick);
- extern void set_cpu_sd_state_idle(void);
- extern int get_nohz_timer_target(void);
- #else
- static inline void select_nohz_load_balancer(int stop_tick) { }
- static inline void set_cpu_sd_state_idle(void) { }
- #endif
- /*
- * Only dump TASK_* tasks. (0 for all tasks)
- */
- extern void show_state_filter(unsigned long state_filter);
- static inline void show_state(void)
- {
- show_state_filter(0);
- }
- extern void show_regs(struct pt_regs *);
- /*
- * TASK is a pointer to the task whose backtrace we want to see (or NULL for current
- * task), SP is the stack pointer of the first frame that should be shown in the back
- * trace (or NULL if the entire call-chain of the task should be shown).
- */
- extern void show_stack(struct task_struct *task, unsigned long *sp);
- void io_schedule(void);
- long io_schedule_timeout(long timeout);
- extern void cpu_init (void);
- extern void trap_init(void);
- extern void update_process_times(int user);
- extern void scheduler_tick(void);
- extern void sched_show_task(struct task_struct *p);
- #ifdef CONFIG_LOCKUP_DETECTOR
- extern void touch_softlockup_watchdog(void);
- extern void touch_softlockup_watchdog_sync(void);
- extern void touch_all_softlockup_watchdogs(void);
- extern int proc_dowatchdog_thresh(struct ctl_table *table, int write,
- void __user *buffer,
- size_t *lenp, loff_t *ppos);
- extern unsigned int softlockup_panic;
- void lockup_detector_init(void);
- #else
- static inline void touch_softlockup_watchdog(void)
- {
- }
- static inline void touch_softlockup_watchdog_sync(void)
- {
- }
- static inline void touch_all_softlockup_watchdogs(void)
- {
- }
- static inline void lockup_detector_init(void)
- {
- }
- #endif
- #ifdef CONFIG_DETECT_HUNG_TASK
- extern unsigned int sysctl_hung_task_panic;
- extern unsigned long sysctl_hung_task_check_count;
- extern unsigned long sysctl_hung_task_timeout_secs;
- extern unsigned long sysctl_hung_task_warnings;
- extern int proc_dohung_task_timeout_secs(struct ctl_table *table, int write,
- void __user *buffer,
- size_t *lenp, loff_t *ppos);
- #else
- /* Avoid need for ifdefs elsewhere in the code */
- enum { sysctl_hung_task_timeout_secs = 0 };
- #endif
- /* Attach to any functions which should be ignored in wchan output. */
- #define __sched __attribute__((__section__(".sched.text")))
- /* Linker adds these: start and end of __sched functions */
- extern char __sched_text_start[], __sched_text_end[];
- /* Is this address in the __sched functions? */
- extern int in_sched_functions(unsigned long addr);
- #define MAX_SCHEDULE_TIMEOUT LONG_MAX
- extern signed long schedule_timeout(signed long timeout);
- extern signed long schedule_timeout_interruptible(signed long timeout);
- extern signed long schedule_timeout_killable(signed long timeout);
- extern signed long schedule_timeout_uninterruptible(signed long timeout);
- asmlinkage void schedule(void);
- extern void schedule_preempt_disabled(void);
- extern int mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner);
- struct nsproxy;
- struct user_namespace;
- /*
- * Default maximum number of active map areas, this limits the number of vmas
- * per mm struct. Users can overwrite this number by sysctl but there is a
- * problem.
- *
- * When a program's coredump is generated as ELF format, a section is created
- * per a vma. In ELF, the number of sections is represented in unsigned short.
- * This means the number of sections should be smaller than 65535 at coredump.
- * Because the kernel adds some informative sections to a image of program at
- * generating coredump, we need some margin. The number of extra sections is
- * 1-3 now and depends on arch. We use "5" as safe margin, here.
- */
- #define MAPCOUNT_ELF_CORE_MARGIN (5)
- #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
- extern int sysctl_max_map_count;
- #include <linux/aio.h>
- #ifdef CONFIG_MMU
- extern void arch_pick_mmap_layout(struct mm_struct *mm);
- extern unsigned long
- arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
- unsigned long, unsigned long);
- extern unsigned long
- arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
- unsigned long len, unsigned long pgoff,
- unsigned long flags);
- extern void arch_unmap_area(struct mm_struct *, unsigned long);
- extern void arch_unmap_area_topdown(struct mm_struct *, unsigned long);
- #else
- static inline void arch_pick_mmap_layout(struct mm_struct *mm) {}
- #endif
- extern void set_dumpable(struct mm_struct *mm, int value);
- extern int get_dumpable(struct mm_struct *mm);
- /* mm flags */
- /* dumpable bits */
- #define MMF_DUMPABLE 0 /* core dump is permitted */
- #define MMF_DUMP_SECURELY 1 /* core file is readable only by root */
- #define MMF_DUMPABLE_BITS 2
- #define MMF_DUMPABLE_MASK ((1 << MMF_DUMPABLE_BITS) - 1)
- /* coredump filter bits */
- #define MMF_DUMP_ANON_PRIVATE 2
- #define MMF_DUMP_ANON_SHARED 3
- #define MMF_DUMP_MAPPED_PRIVATE 4
- #define MMF_DUMP_MAPPED_SHARED 5
- #define MMF_DUMP_ELF_HEADERS 6
- #define MMF_DUMP_HUGETLB_PRIVATE 7
- #define MMF_DUMP_HUGETLB_SHARED 8
- #define MMF_DUMP_FILTER_SHIFT MMF_DUMPABLE_BITS
- #define MMF_DUMP_FILTER_BITS 7
- #define MMF_DUMP_FILTER_MASK \
- (((1 << MMF_DUMP_FILTER_BITS) - 1) << MMF_DUMP_FILTER_SHIFT)
- #define MMF_DUMP_FILTER_DEFAULT \
- ((1 << MMF_DUMP_ANON_PRIVATE) | (1 << MMF_DUMP_ANON_SHARED) |\
- (1 << MMF_DUMP_HUGETLB_PRIVATE) | MMF_DUMP_MASK_DEFAULT_ELF)
- #ifdef CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS
- # define MMF_DUMP_MASK_DEFAULT_ELF (1 << MMF_DUMP_ELF_HEADERS)
- #else
- # define MMF_DUMP_MASK_DEFAULT_ELF 0
- #endif
- /* leave room for more dump flags */
- #define MMF_VM_MERGEABLE 16 /* KSM may merge identical pages */
- #define MMF_VM_HUGEPAGE 17 /* set when VM_HUGEPAGE is set on vma */
- #define MMF_INIT_MASK (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK)
- struct sighand_struct {
- atomic_t count;
- struct k_sigaction action[_NSIG];
- spinlock_t siglock;
- wait_queue_head_t signalfd_wqh;
- };
- struct pacct_struct {
- int ac_flag;
- long ac_exitcode;
- unsigned long ac_mem;
- cputime_t ac_utime, ac_stime;
- unsigned long ac_minflt, ac_majflt;
- };
- struct cpu_itimer {
- cputime_t expires;
- cputime_t incr;
- u32 error;
- u32 incr_error;
- };
- /**
- * struct task_cputime - collected CPU time counts
- * @utime: time spent in user mode, in &cputime_t units
- * @stime: time spent in kernel mode, in &cputime_t units
- * @sum_exec_runtime: total time spent on the CPU, in nanoseconds
- *
- * This structure groups together three kinds of CPU time that are
- * tracked for threads and thread groups. Most things considering
- * CPU time want to group these counts together and treat all three
- * of them in parallel.
- */
- struct task_cputime {
- cputime_t utime;
- cputime_t stime;
- unsigned long long sum_exec_runtime;
- };
- /* Alternate field names when used to cache expirations. */
- #define prof_exp stime
- #define virt_exp utime
- #define sched_exp sum_exec_runtime
- #define INIT_CPUTIME \
- (struct task_cputime) { \
- .utime = 0, \
- .stime = 0, \
- .sum_exec_runtime = 0, \
- }
- /*
- * Disable preemption until the scheduler is running.
- * Reset by start_kernel()->sched_init()->init_idle().
- *
- * We include PREEMPT_ACTIVE to avoid cond_resched() from working
- * before the scheduler is active -- see should_resched().
- */
- #define INIT_PREEMPT_COUNT (1 + PREEMPT_ACTIVE)
- /**
- * struct thread_group_cputimer - thread group interval timer counts
- * @cputime: thread group interval timers.
- * @running: non-zero when there are timers running and
- * @cputime receives updates.
- * @lock: lock for fields in this struct.
- *
- * This structure contains the version of task_cputime, above, that is
- * used for thread group CPU timer calculations.
- */
- struct thread_group_cputimer {
- struct task_cputime cputime;
- int running;
- raw_spinlock_t lock;
- };
- #include <linux/rwsem.h>
- struct autogroup;
- /*
- * NOTE! "signal_struct" does not have its own
- * locking, because a shared signal_struct always
- * implies a shared sighand_struct, so locking
- * sighand_struct is always a proper superset of
- * the locking of signal_struct.
- */
- struct signal_struct {
- atomic_t sigcnt;
- atomic_t live;
- int nr_threads;
- wait_queue_head_t wait_chldexit; /* for wait4() */
- /* current thread group signal load-balancing target: */
- struct task_struct *curr_target;
- /* shared signal handling: */
- struct sigpending shared_pending;
- /* thread group exit support */
- int group_exit_code;
- /* overloaded:
- * - notify group_exit_task when ->count is equal to notify_count
- * - everyone except group_exit_task is stopped during signal delivery
- * of fatal signals, group_exit_task processes the signal.
- */
- int notify_count;
- struct task_struct *group_exit_task;
- /* thread group stop support, overloads group_exit_code too */
- int group_stop_count;
- unsigned int flags; /* see SIGNAL_* flags below */
- /*
- * PR_SET_CHILD_SUBREAPER marks a process, like a service
- * manager, to re-parent orphan (double-forking) child processes
- * to this process instead of 'init'. The service manager is
- * able to receive SIGCHLD signals and is able to investigate
- * the process until it calls wait(). All children of this
- * process will inherit a flag if they should look for a
- * child_subreaper process at exit.
- */
- unsigned int is_child_subreaper:1;
- unsigned int has_child_subreaper:1;
- /* POSIX.1b Interval Timers */
- struct list_head posix_timers;
- /* ITIMER_REAL timer for the process */
- struct hrtimer real_timer;
- struct pid *leader_pid;
- ktime_t it_real_incr;
- /*
- * ITIMER_PROF and ITIMER_VIRTUAL timers for the process, we use
- * CPUCLOCK_PROF and CPUCLOCK_VIRT for indexing array as these
- * values are defined to 0 and 1 respectively
- */
- struct cpu_itimer it[2];
- /*
- * Thread group totals for process CPU timers.
- * See thread_group_cputimer(), et al, for details.
- */
- struct thread_group_cputimer cputimer;
- /* Earliest-expiration cache. */
- struct task_cputime cputime_expires;
- struct list_head cpu_timers[3];
- struct pid *tty_old_pgrp;
- /* boolean value for session group leader */
- int leader;
- struct tty_struct *tty; /* NULL if no tty */
- #ifdef CONFIG_SCHED_AUTOGROUP
- struct autogroup *autogroup;
- #endif
- /*
- * Cumulative resource counters for dead threads in the group,
- * and for reaped dead child processes forked by this group.
- * Live threads maintain their own counters and add to these
- * in __exit_signal, except for the group leader.
- */
- cputime_t utime, stime, cutime, cstime;
- cputime_t gtime;
- cputime_t cgtime;
- #ifndef CONFIG_VIRT_CPU_ACCOUNTING
- cputime_t prev_utime, prev_stime;
- #endif
- unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;
- unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
- unsigned long inblock, oublock, cinblock, coublock;
- unsigned long maxrss, cmaxrss;
- struct task_io_accounting ioac;
- /*
- * Cumulative ns of schedule CPU time fo dead threads in the
- * group, not including a zombie group leader, (This only differs
- * from jiffies_to_ns(utime + stime) if sched_clock uses something
- * other than jiffies.)
- */
- unsigned long long sum_sched_runtime;
- /*
- * We don't bother to synchronize most readers of this at all,
- * because there is no reader checking a limit that actually needs
- * to get both rlim_cur and rlim_max atomically, and either one
- * alone is a single word that can safely be read normally.
- * getrlimit/setrlimit use task_lock(current->group_leader) to
- * protect this instead of the siglock, because they really
- * have no need to disable irqs.
- */
- struct rlimit rlim[RLIM_NLIMITS];
- #ifdef CONFIG_BSD_PROCESS_ACCT
- struct pacct_struct pacct; /* per-process accounting information */
- #endif
- #ifdef CONFIG_TASKSTATS
- struct taskstats *stats;
- #endif
- #ifdef CONFIG_AUDIT
- unsigned audit_tty;
- struct tty_audit_buf *tty_audit_buf;
- #endif
- #ifdef CONFIG_CGROUPS
- /*
- * group_rwsem prevents new tasks from entering the threadgroup and
- * member tasks from exiting,a more specifically, setting of
- * PF_EXITING. fork and exit paths are protected with this rwsem
- * using threadgroup_change_begin/end(). Users which require
- * threadgroup to remain stable should use threadgroup_[un]lock()
- * which also takes care of exec path. Currently, cgroup is the
- * only user.
- */
- struct rw_semaphore group_rwsem;
- #endif
- int oom_adj; /* OOM kill score adjustment (bit shift) */
- int oom_score_adj; /* OOM kill score adjustment */
- int oom_score_adj_min; /* OOM kill score adjustment minimum value.
- * Only settable by CAP_SYS_RESOURCE. */
- struct mutex cred_guard_mutex; /* guard against foreign influences on
- * credential calculations
- * (notably. ptrace) */
- };
- /* Context switch must be unlocked if interrupts are to be enabled */
- #ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW
- # define __ARCH_WANT_UNLOCKED_CTXSW
- #endif
- /*
- * Bits in flags field of signal_struct.
- */
- #define SIGNAL_STOP_STOPPED 0x00000001 /* job control stop in effect */
- #define SIGNAL_STOP_CONTINUED 0x00000002 /* SIGCONT since WCONTINUED reap */
- #define SIGNAL_GROUP_EXIT 0x00000004 /* group exit in progress */
- /*
- * Pending notifications to parent.
- */
- #define SIGNAL_CLD_STOPPED 0x00000010
- #define SIGNAL_CLD_CONTINUED 0x00000020
- #define SIGNAL_CLD_MASK (SIGNAL_CLD_STOPPED|SIGNAL_CLD_CONTINUED)
- #define SIGNAL_UNKILLABLE 0x00000040 /* for init: ignore fatal signals */
- /* If true, all threads except ->group_exit_task have pending SIGKILL */
- static inline int signal_group_exit(const struct signal_struct *sig)
- {
- return (sig->flags & SIGNAL_GROUP_EXIT) ||
- (sig->group_exit_task != NULL);
- }
- /*
- * Some day this will be a full-fledged user tracking system..
- */
- struct user_struct {
- atomic_t __count; /* reference count */
- atomic_t processes; /* How many processes does this user have? */
- atomic_t files; /* How many open files does this user have? */
- atomic_t sigpending; /* How many pending signals does this user have? */
- #ifdef CONFIG_INOTIFY_USER
- atomic_t inotify_watches; /* How many inotify watches does this user have? */
- atomic_t inotify_devs; /* How many inotify devs does this user have opened? */
- #endif
- #ifdef CONFIG_FANOTIFY
- atomic_t fanotify_listeners;
- #endif
- #ifdef CONFIG_EPOLL
- atomic_long_t epoll_watches; /* The number of file descriptors currently watched */
- #endif
- #ifdef CONFIG_POSIX_MQUEUE
- /* protected by mq_lock */
- unsigned long mq_bytes; /* How many bytes can be allocated to mqueue? */
- #endif
- unsigned long locked_shm; /* How many pages of mlocked shm ? */
- #ifdef CONFIG_KEYS
- struct key *uid_keyring; /* UID specific keyring */
- struct key *session_keyring; /* UID's default session keyring */
- #endif
- /* Hash table maintenance information */
- struct hlist_node uidhash_node;
- uid_t uid;
- struct user_namespace *user_ns;
- #ifdef CONFIG_PERF_EVENTS
- atomic_long_t locked_vm;
- #endif
- };
- extern int uids_sysfs_init(void);
- extern struct user_struct *find_user(uid_t);
- extern struct user_struct root_user;
- #define INIT_USER (&root_user)
- struct backing_dev_info;
- struct reclaim_state;
- #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
- struct sched_info {
- /* cumulative counters */
- unsigned long pcount; /* # of times run on this cpu */
- unsigned long long run_delay; /* time spent waiting on a runqueue */
- /* timestamps */
- unsigned long long last_arrival,/* when we last ran on a cpu */
- last_queued; /* when we were last queued to run */
- };
- #endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */
- #ifdef CONFIG_TASK_DELAY_ACCT
- struct task_delay_info {
- spinlock_t lock;
- unsigned int flags; /* Private per-task flags */
- /* For each stat XXX, add following, aligned appropriately
- *
- * struct timespec XXX_start, XXX_end;
- * u64 XXX_delay;
- * u32 XXX_count;
- *
- * Atomicity of updates to XXX_delay, XXX_count protected by
- * single lock above (split into XXX_lock if contention is an issue).
- */
- /*
- * XXX_count is incremented on every XXX operation, the delay
- * associated with the operation is added to XXX_delay.
- * XXX_delay contains the accumulated delay time in nanoseconds.
- */
- struct timespec blkio_start, blkio_end; /* Shared by blkio, swapin */
- u64 blkio_delay; /* wait for sync block io completion */
- u64 swapin_delay; /* wait for swapin block io completion */
- u32 blkio_count; /* total count of the number of sync block */
- /* io operations performed */
- u32 swapin_count; /* total count of the number of swapin block */
- /* io operations performed */
- struct timespec freepages_start, freepages_end;
- u64 freepages_delay; /* wait for memory reclaim */
- u32 freepages_count; /* total count of memory reclaim */
- };
- #endif /* CONFIG_TASK_DELAY_ACCT */
- static inline int sched_info_on(void)
- {
- #ifdef CONFIG_SCHEDSTATS
- return 1;
- #elif defined(CONFIG_TASK_DELAY_ACCT)
- extern int delayacct_on;
- return delayacct_on;
- #else
- return 0;
- #endif
- }
- enum cpu_idle_type {
- CPU_IDLE,
- CPU_NOT_IDLE,
- CPU_NEWLY_IDLE,
- CPU_MAX_IDLE_TYPES
- };
- /*
- * Increase resolution of nice-level calculations for 64-bit architectures.
- * The extra resolution improves shares distribution and load balancing of
- * low-weight task groups (eg. nice +19 on an autogroup), deeper taskgroup
- * hierarchies, especially on larger systems. This is not a user-visible change
- * and does not change the user-interface for setting shares/weights.
- *
- * We increase resolution only if we have enough bits to allow this increased
- * resolution (i.e. BITS_PER_LONG > 32). The costs for increasing resolution
- * when BITS_PER_LONG <= 32 are pretty high and the returns do not justify the
- * increased costs.
- */
- #if 0 /* BITS_PER_LONG > 32 -- currently broken: it increases power usage under light load */
- # define SCHED_LOAD_RESOLUTION 10
- # define scale_load(w) ((w) << SCHED_LOAD_RESOLUTION)
- # define scale_load_down(w) ((w) >> SCHED_LOAD_RESOLUTION)
- #else
- # define SCHED_LOAD_RESOLUTION 0
- # define scale_load(w) (w)
- # define scale_load_down(w) (w)
- #endif
- #define SCHED_LOAD_SHIFT (10 + SCHED_LOAD_RESOLUTION)
- #define SCHED_LOAD_SCALE (1L << SCHED_LOAD_SHIFT)
- /*
- * Increase resolution of cpu_power calculations
- */
- #define SCHED_POWER_SHIFT 10
- #define SCHED_POWER_SCALE (1L << SCHED_POWER_SHIFT)
- /*
- * sched-domains (multiprocessor balancing) declarations:
- */
- #ifdef CONFIG_SMP
- #define SD_LOAD_BALANCE 0x0001 /* Do load balancing on this domain. */
- #define SD_BALANCE_NEWIDLE 0x0002 /* Balance when about to become idle */
- #define SD_BALANCE_EXEC 0x0004 /* Balance on exec */
- #define SD_BALANCE_FORK 0x0008 /* Balance on fork, clone */
- #define SD_BALANCE_WAKE 0x0010 /* Balance on wakeup */
- #define SD_WAKE_AFFINE 0x0020 /* Wake task to waking CPU */
- #define SD_PREFER_LOCAL 0x0040 /* Prefer to keep tasks local to this domain */
- #define SD_SHARE_CPUPOWER 0x0080 /* Domain members share cpu power */
- #define SD_POWERSAVINGS_BALANCE 0x0100 /* Balance for power savings */
- #define SD_SHARE_PKG_RESOURCES 0x0200 /* Domain members share cpu pkg resources */
- #define SD_SERIALIZE 0x0400 /* Only a single load balancing instance */
- #define SD_ASYM_PACKING 0x0800 /* Place busy groups earlier in the domain */
- #define SD_PREFER_SIBLING 0x1000 /* Prefer to place tasks in a sibling domain */
- #define SD_OVERLAP 0x2000 /* sched_domains of this level overlap */
- enum powersavings_balance_level {
- POWERSAVINGS_BALANCE_NONE = 0, /* No power saving load balance */
- POWERSAVINGS_BALANCE_BASIC, /* Fill one thread/core/package
- * first for long running threads
- */
- POWERSAVINGS_BALANCE_WAKEUP, /* Also bias task wakeups to semi-idle
- * cpu package for power savings
- */
- MAX_POWERSAVINGS_BALANCE_LEVELS
- };
- extern int sched_mc_power_savings, sched_smt_power_savings;
- static inline int sd_balance_for_mc_power(void)
- {
- if (sched_smt_power_savings)
- return SD_POWERSAVINGS_BALANCE;
- if (!sched_mc_power_savings)
- return SD_PREFER_SIBLING;
- return 0;
- }
- static inline int sd_balance_for_package_power(void)
- {
- if (sched_mc_power_savings | sched_smt_power_savings)
- return SD_POWERSAVINGS_BALANCE;
- return SD_PREFER_SIBLING;
- }
- extern int __weak arch_sd_sibiling_asym_packing(void);
- /*
- * Optimise SD flags for power savings:
- * SD_BALANCE_NEWIDLE helps aggressive task consolidation and power savings.
- * Keep default SD flags if sched_{smt,mc}_power_saving=0
- */
- static inline int sd_power_saving_flags(void)
- {
- if (sched_mc_power_savings | sched_smt_power_savings)
- return SD_BALANCE_NEWIDLE;
- return 0;
- }
- struct sched_group_power {
- atomic_t ref;
- /*
- * CPU power of this group, SCHED_LOAD_SCALE being max power for a
- * single CPU.
- */
- unsigned int power, power_orig;
- unsigned long next_update;
- /*
- * Number of busy cpus in this group.
- */
- atomic_t nr_busy_cpus;
- };
- struct sched_group {
- struct sched_group *next; /* Must be a circular list */
- atomic_t ref;
- unsigned int group_weight;
- struct sched_group_power *sgp;
- /*
- * The CPUs this group covers.
- *
- * NOTE: this field is variable length. (Allocated dynamically
- * by attaching extra space to the end of the structure,
- * depending on how many CPUs the kernel has booted up with)
- */
- unsigned long cpumask[0];
- };
- static inline struct cpumask *sched_group_cpus(struct sched_group *sg)
- {
- return to_cpumask(sg->cpumask);
- }
- /**
- * group_first_cpu - Returns the first cpu in the cpumask of a sched_group.
- * @group: The group whose first cpu is to be returned.
- */
- static inline unsigned int group_first_cpu(struct sched_group *group)
- {
- return cpumask_first(sched_group_cpus(group));
- }
- struct sched_domain_attr {
- int relax_domain_level;
- };
- #define SD_ATTR_INIT (struct sched_domain_attr) { \
- .relax_domain_level = -1, \
- }
- extern int sched_domain_level_max;
- struct sched_domain {
- /* These fields must be setup */
- struct sched_domain *parent; /* top domain must be null terminated */
- struct sched_domain *child; /* bottom domain must be null terminated */
- struct sched_group *groups; /* the balancing groups of the domain */
- unsigned long min_interval; /* Minimum balance interval ms */
- unsigned long max_interval; /* Maximum balance interval ms */
- unsigned int busy_factor; /* less balancing by factor if busy */
- unsigned int imbalance_pct; /* No balance until over watermark */
- unsigned int cache_nice_tries; /* Leave cache hot tasks for # tries */
- unsigned int busy_idx;
- unsigned int idle_idx;
- unsigned int newidle_idx;
- unsigned int wake_idx;
- unsigned int forkexec_idx;
- unsigned int smt_gain;
- int flags; /* See SD_* */
- int level;
- /* Runtime fields. */
- unsigned long last_balance; /* init to jiffies. units in jiffies */
- unsigned int balance_interval; /* initialise to 1. units in ms. */
- unsigned int nr_balance_failed; /* initialise to 0 */
- u64 last_update;
- #ifdef CONFIG_SCHEDSTATS
- /* load_balance() stats */
- unsigned int lb_count[CPU_MAX_IDLE_TYPES];
- unsigned int lb_failed[CPU_MAX_IDLE_TYPES];
- unsigned int lb_balanced[CPU_MAX_IDLE_TYPES];
- unsigned int lb_imbalance[CPU_MAX_IDLE_TYPES];
- unsigned int lb_gained[CPU_MAX_IDLE_TYPES];
- unsigned int lb_hot_gained[CPU_MAX_IDLE_TYPES];
- unsigned int lb_nobusyg[CPU_MAX_IDLE_TYPES];
- unsigned int lb_nobusyq[CPU_MAX_IDLE_TYPES];
- /* Active load balancing */
- unsigned int alb_count;
- unsigned int alb_failed;
- unsigned int alb_pushed;
- /* SD_BALANCE_EXEC stats */
- unsigned int sbe_count;
- unsigned int sbe_balanced;
- unsigned int sbe_pushed;
- /* SD_BALANCE_FORK stats */
- unsigned int sbf_count;
- unsigned int sbf_balanced;
- unsigned int sbf_pushed;
- /* try_to_wake_up() stats */
- unsigned int ttwu_wake_remote;
- unsigned int ttwu_move_affine;
- unsigned int ttwu_move_balance;
- #endif
- #ifdef CONFIG_SCHED_DEBUG
- char *name;
- #endif
- union {
- void *private; /* used during construction */
- struct rcu_head rcu; /* used during destruction */
- };
- unsigned int span_weight;
- /*
- * Span of all CPUs in this domain.
- *
- * NOTE: this field is variable length. (Allocated dynamically
- * by attaching extra space to the end of the structure,
- * depending on how many CPUs the kernel has booted up with)
- */
- unsigned long span[0];
- };
- static inline struct cpumask *sched_domain_span(struct sched_domain *sd)
- {
- return to_cpumask(sd->span);
- }
- extern void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
- struct sched_domain_attr *dattr_new);
- /* Allocate an array of sched domains, for partition_sched_domains(). */
- cpumask_var_t *alloc_sched_domains(unsigned int ndoms);
- void free_sched_domains(cpumask_var_t doms[], unsigned int ndoms);
- /* Test a flag in parent sched domain */
- static inline int test_sd_parent(struct sched_domain *sd, int flag)
- {
- if (sd->parent && (sd->parent->flags & flag))
- return 1;
- return 0;
- }
- unsigned long default_scale_freq_power(struct sched_domain *sd, int cpu);
- unsigned long default_scale_smt_power(struct sched_domain *sd, int cpu);
- bool cpus_share_cache(int this_cpu, int that_cpu);
- #else /* CONFIG_SMP */
- struct sched_domain_attr;
- static inline void
- partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
- struct sched_domain_attr *dattr_new)
- {
- }
- static inline bool cpus_share_cache(int this_cpu, int that_cpu)
- {
- return true;
- }
- #endif /* !CONFIG_SMP */
- struct io_context; /* See blkdev.h */
- #ifdef ARCH_HAS_PREFETCH_SWITCH_STACK
- extern void prefetch_stack(struct task_struct *t);
- #else
- static inline void prefetch_stack(struct task_struct *t) { }
- #endif
- struct audit_context; /* See audit.c */
- struct mempolicy;
- struct pipe_inode_info;
- struct uts_namespace;
- struct rq;
- struct sched_domain;
- /*
- * wake flags
- */
- #define WF_SYNC 0x01 /* waker goes to sleep after wakup */
- #define WF_FORK 0x02 /* child wakeup after fork */
- #define WF_MIGRATED 0x04 /* internal use, task got migrated */
- #define ENQUEUE_WAKEUP 1
- #define ENQUEUE_HEAD 2
- #ifdef CONFIG_SMP
- #define ENQUEUE_WAKING 4 /* sched_class::task_waking was called */
- #else
- #define ENQUEUE_WAKING 0
- #endif
- #define DEQUEUE_SLEEP 1
- struct sched_class {
- const struct sched_class *next;
- void (*enqueue_task) (struct rq *rq, struct task_struct *p, int flags);
- void (*dequeue_task) (struct rq *rq, struct task_struct *p, int flags);
- void (*yield_task) (struct rq *rq);
- bool (*yield_to_task) (struct rq *rq, struct task_struct *p, bool preempt);
- void (*check_preempt_curr) (struct rq *rq, struct task_struct *p, int flags);
- struct task_struct * (*pick_next_task) (struct rq *rq);
- void (*put_prev_task) (struct rq *rq, struct task_struct *p);
- #ifdef CONFIG_SMP
- int (*select_task_rq)(struct task_struct *p, int sd_flag, int flags);
- void (*pre_schedule) (struct rq *this_rq, struct task_struct *task);
- void (*post_schedule) (struct rq *this_rq);
- void (*task_waking) (struct task_struct *task);
- void (*task_woken) (struct rq *this_rq, struct task_struct *task);
- void (*set_cpus_allowed)(struct task_struct *p,
- const struct cpumask *newmask);
- void (*rq_online)(struct rq *rq);
- void (*rq_offline)(struct rq *rq);
- #endif
- void (*set_curr_task) (struct rq *rq);
- void (*task_tick) (struct rq *rq, struct task_struct *p, int queued);
- void (*task_fork) (struct task_struct *p);
- void (*switched_from) (struct rq *this_rq, struct task_struct *task);
- void (*switched_to) (struct rq *this_rq, struct task_struct *task);
- void (*prio_changed) (struct rq *this_rq, struct task_struct *task,
- int oldprio);
- unsigned int (*get_rr_interval) (struct rq *rq,
- struct task_struct *task);
- #ifdef CONFIG_FAIR_GROUP_SCHED
- void (*task_move_group) (struct task_struct *p, int on_rq);
- #endif
- };
- struct load_weight {
- unsigned long weight, inv_weight;
- };
- #ifdef CONFIG_SCHEDSTATS
- struct sched_statistics {
- u64 wait_start;
- u64 wait_max;
- u64 wait_count;
- u64 wait_sum;
- u64 iowait_count;
- u64 iowait_sum;
- u64 sleep_start;
- u64 sleep_max;
- s64 sum_sleep_runtime;
- u64 block_start;
- u64 block_max;
- u64 exec_max;
- u64 slice_max;
- u64 nr_migrations_cold;
- u64 nr_failed_migrations_affine;
- u64 nr_failed_migrations_running;
- u64 nr_failed_migrations_hot;
- u64 nr_forced_migrations;
- u64 nr_wakeups;
- u64 nr_wakeups_sync;
- u64 nr_wakeups_migrate;
- u64 nr_wakeups_local;
- u64 nr_wakeups_remote;
- u64 nr_wakeups_affine;
- u64 nr_wakeups_affine_attempts;
- u64 nr_wakeups_passive;
- u64 nr_wakeups_idle;
- };
- #endif
- struct sched_entity {
- struct load_weight load; /* for load-balancing */
- struct rb_node run_node;
- struct list_head group_node;
- unsigned int on_rq;
- u64 exec_start;
- u64 sum_exec_runtime;
- u64 vruntime;
- u64 prev_sum_exec_runtime;
- u64 nr_migrations;
- #ifdef CONFIG_SCHEDSTATS
- struct sched_statistics statistics;
- #endif
- #ifdef CONFIG_FAIR_GROUP_SCHED
- struct sched_entity *parent;
- /* rq on which this entity is (to be) queued: */
- struct cfs_rq *cfs_rq;
- /* rq "owned" by this entity/group: */
- struct cfs_rq *my_q;
- #endif
- };
- struct sched_rt_entity {
- struct list_head run_list;
- unsigned long timeout;
- unsigned int time_slice;
- int nr_cpus_allowed;
- struct sched_rt_entity *back;
- #ifdef CONFIG_RT_GROUP_SCHED
- struct sched_rt_entity *parent;
- /* rq on which this entity is (to be) queued: */
- struct rt_rq *rt_rq;
- /* rq "owned" by this entity/group: */
- struct rt_rq *my_q;
- #endif
- };
- /*
- * default timeslice is 100 msecs (used only for SCHED_RR tasks).
- * Timeslices get refilled after they expire.
- */
- #define RR_TIMESLICE (100 * HZ / 1000)
- struct rcu_node;
- enum perf_event_task_context {
- perf_invalid_context = -1,
- perf_hw_context = 0,
- perf_sw_context,
- perf_nr_task_contexts,
- };
- struct task_struct {
- volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
- void *stack;
- atomic_t usage;
- unsigned int flags; /* per process flags, defined below */
- unsigned int ptrace;
- #ifdef CONFIG_SMP
- struct llist_node wake_entry;
- int on_cpu;
- #endif
- int on_rq;
- int prio, static_prio, normal_prio;
- unsigned int rt_priority;
- const struct sched_class *sched_class;
- struct sched_entity se;
- struct sched_rt_entity rt;
- #ifdef CONFIG_PREEMPT_NOTIFIERS
- /* list of struct preempt_notifier: */
- struct hlist_head preempt_notifiers;
- #endif
- /*
- * fpu_counter contains the number of consecutive context switches
- * that the FPU is used. If this is over a threshold, the lazy fpu
- * saving becomes unlazy to save the trap. This is an unsigned char
- * so that after 256 times the counter wraps and the behavior turns
- * lazy again; this to deal with bursty apps that only use FPU for
- * a short time
- */
- unsigned char fpu_counter;
- #ifdef CONFIG_BLK_DEV_IO_TRACE
- unsigned int btrace_seq;
- #endif
- unsigned int policy;
- cpumask_t cpus_allowed;
- #ifdef CONFIG_PREEMPT_RCU
- int rcu_read_lock_nesting;
- char rcu_read_unlock_special;
- struct list_head rcu_node_entry;
- #endif /* #ifdef CONFIG_PREEMPT_RCU */
- #ifdef CONFIG_TREE_PREEMPT_RCU
- struct rcu_node *rcu_blocked_node;
- #endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */
- #ifdef CONFIG_RCU_BOOST
- struct rt_mutex *rcu_boost_mutex;
- #endif /* #ifdef CONFIG_RCU_BOOST */
- #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
- struct sched_info sched_info;
- #endif
- struct list_head tasks;
- #ifdef CONFIG_SMP
- struct plist_node pushable_tasks;
- #endif
- struct mm_struct *mm, *active_mm;
- #ifdef CONFIG_COMPAT_BRK
- unsigned brk_randomized:1;
- #endif
- #if defined(SPLIT_RSS_COUNTING)
- struct task_rss_stat rss_stat;
- #endif
- /* task state */
- int exit_state;
- int exit_code, exit_signal;
- int pdeath_signal; /* The signal sent when the parent dies */
- unsigned int jobctl; /* JOBCTL_*, siglock protected */
- /* ??? */
- unsigned int personality;
- unsigned did_exec:1;
- unsigned in_execve:1; /* Tell the LSMs that the process is doing an
- * execve */
- unsigned in_iowait:1;
- /* Revert to default priority/policy when forking */
- unsigned sched_reset_on_fork:1;
- unsigned sched_contributes_to_load:1;
- #ifdef CONFIG_GENERIC_HARDIRQS
- /* IRQ handler threads */
- unsigned irq_thread:1;
- #endif
- pid_t pid;
- pid_t tgid;
- #ifdef CONFIG_CC_STACKPROTECTOR
- /* Canary value for the -fstack-protector gcc feature */
- unsigned long stack_canary;
- #endif
- /*
- * pointers to (original) parent process, youngest child, younger sibling,
- * older sibling, respectively. (p->father can be replaced with
- * p->real_parent->pid)
- */
- struct task_struct __rcu *real_parent; /* real parent process */
- struct task_struct __rcu *parent; /* recipient of SIGCHLD, wait4() reports */
- /*
- * children/sibling forms the list of my natural children
- */
- struct list_head children; /* list of my children */
- struct list_head sibling; /* linkage in my parent's children list */
- struct task_struct *group_leader; /* threadgroup leader */
- /*
- * ptraced is the list of tasks this task is using ptrace on.
- * This includes both natural children and PTRACE_ATTACH targets.
- * p->ptrace_entry is p's link on the p->parent->ptraced list.
- */
- struct list_head ptraced;
- struct list_head ptrace_entry;
- /* PID/PID hash table linkage. */
- struct pid_link pids[PIDTYPE_MAX];
- struct list_head thread_group;
- struct completion *vfork_done; /* for vfork() */
- int __user *set_child_tid; /* CLONE_CHILD_SETTID */
- int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
- cputime_t utime, stime, utimescaled, stimescaled;
- cputime_t gtime;
- #ifndef CONFIG_VIRT_CPU_ACCOUNTING
- cputime_t prev_utime, prev_stime;
- #endif
- unsigned long nvcsw, nivcsw; /* context switch counts */
- struct timespec start_time; /* monotonic time */
- struct timespec real_start_time; /* boot based time */
- /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
- unsigned long min_flt, maj_flt;
- struct task_cputime cputime_expires;
- struct list_head cpu_timers[3];
- /* process credentials */
- const struct cred __rcu *real_cred; /* objective and real subjective task
- * credentials (COW) */
- const struct cred __rcu *cred; /* effective (overridable) subjective task
- * credentials (COW) */
- struct cred *replacement_session_keyring; /* for KEYCTL_SESSION_TO_PARENT */
- char comm[TASK_COMM_LEN]; /* executable name excluding path
- - access with [gs]et_task_comm (which lock
- it with task_lock())
- - initialized normally by setup_new_exec */
- /* file system info */
- int link_count, total_link_count;
- #ifdef CONFIG_SYSVIPC
- /* ipc stuff */
- struct sysv_sem sysvsem;
- #endif
- #ifdef CONFIG_DETECT_HUNG_TASK
- /* hung task detection */
- unsigned long last_switch_count;
- #endif
- /* CPU-specific state of this task */
- struct thread_struct thread;
- /* filesystem information */
- struct fs_struct *fs;
- /* open file information */
- struct files_struct *files;
- /* namespaces */
- struct nsproxy *nsproxy;
- /* signal handlers */
- struct signal_struct *signal;
- struct sighand_struct *sighand;
- sigset_t blocked, real_blocked;
- sigset_t saved_sigmask; /* restored if set_restore_sigmask() was used */
- struct sigpending pending;
- unsigned long sas_ss_sp;
- size_t sas_ss_size;
- int (*notifier)(void *priv);
- void *notifier_data;
- sigset_t *notifier_mask;
- struct audit_context *audit_context;
- #ifdef CONFIG_AUDITSYSCALL
- uid_t loginuid;
- unsigned int sessionid;
- #endif
- seccomp_t seccomp;
- /* Thread group tracking */
- u32 parent_exec_id;
- u32 self_exec_id;
- /* Protection of (de-)allocation: mm, files, fs, tty, keyrings, mems_allowed,
- * mempolicy */
- spinlock_t alloc_lock;
- /* Protection of the PI data structures: */
- raw_spinlock_t pi_lock;
- #ifdef CONFIG_RT_MUTEXES
- /* PI waiters blocked on a rt_mutex held by this task */
- struct plist_head pi_waiters;
- /* Deadlock detection and priority inheritance handling */
- struct rt_mutex_waiter *pi_blocked_on;
- #endif
- #ifdef CONFIG_DEBUG_MUTEXES
- /* mutex deadlock detection */
- struct mutex_waiter *blocked_on;
- #endif
- #ifdef CONFIG_TRACE_IRQFLAGS
- unsigned int irq_events;
- unsigned long hardirq_enable_ip;
- unsigned long hardirq_disable_ip;
- unsigned int hardirq_enable_event;
- unsigned int hardirq_disable_event;
- int hardirqs_enabled;
- int hardirq_context;
- unsigned long softirq_disable_ip;
- unsigned long softirq_enable_ip;
- unsigned int softirq_disable_event;
- unsigned int softirq_enable_event;
- int softirqs_enabled;
- int softirq_context;
- #endif
- #ifdef CONFIG_LOCKDEP
- # define MAX_LOCK_DEPTH 48UL
- u64 curr_chain_key;
- int lockdep_depth;
- unsigned int lockdep_recursion;
- struct held_lock held_locks[MAX_LOCK_DEPTH];
- gfp_t lockdep_reclaim_gfp;
- #endif
- /* journalling filesystem info */
- void *journal_info;
- /* stacked block device info */
- struct bio_list *bio_list;
- #ifdef CONFIG_BLOCK
- /* stack plugging */
- struct blk_plug *plug;
- #endif
- /* VM state */
- struct reclaim_state *reclaim_state;
- struct backing_dev_info *backing_dev_info;
- struct io_context *io_context;
- unsigned long ptrace_message;
- siginfo_t *last_siginfo; /* For ptrace use. */
- struct task_io_accounting ioac;
- #if defined(CONFIG_TASK_XACCT)
- u64 acct_rss_mem1; /* accumulated rss usage */
- u64 acct_vm_mem1; /* accumulated virtual memory usage */
- cputime_t acct_timexpd; /* stime + utime since last update */
- #endif
- #ifdef CONFIG_CPUSETS
- nodemask_t mems_allowed; /* Protected by alloc_lock */
- seqcount_t mems_allowed_seq; /* Seqence no to catch updates */
- int cpuset_mem_spread_rotor;
- int cpuset_slab_spread_rotor;
- #endif
- #ifdef CONFIG_CGROUPS
- /* Control Group info protected by css_set_lock */
- struct css_set __rcu *cgroups;
- /* cg_list protected by css_set_lock and tsk->alloc_lock */
- struct list_head cg_list;
- #endif
- #ifdef CONFIG_FUTEX
- struct robust_list_head __user *robust_list;
- #ifdef CONFIG_COMPAT
- struct compat_robust_list_head __user *compat_robust_list;
- #endif
- struct list_head pi_state_list;
- struct futex_pi_state *pi_state_cache;
- #endif
- #ifdef CONFIG_PERF_EVENTS
- struct perf_event_context *perf_event_ctxp[perf_nr_task_contexts];
- struct mutex perf_event_mutex;
- struct list_head perf_event_list;
- #endif
- #ifdef CONFIG_NUMA
- struct mempolicy *mempolicy; /* Protected by alloc_lock */
- short il_next;
- short pref_node_fork;
- #endif
- struct rcu_head rcu;
- /*
- * cache last used pipe for splice
- */
- struct pipe_inode_info *splice_pipe;
- #ifdef CONFIG_TASK_DELAY_ACCT
- struct task_delay_info *delays;
- #endif
- #ifdef CONFIG_FAULT_INJECTION
- int make_it_fail;
- #endif
- /*
- * when (nr_dirtied >= nr_dirtied_pause), it's time to call
- * balance_dirty_pages() for some dirty throttling pause
- */
- int nr_dirtied;
- int nr_dirtied_pause;
- unsigned long dirty_paused_when; /* start of a write-and-pause period */
- #ifdef CONFIG_LATENCYTOP
- int latency_record_count;
- struct latency_record latency_record[LT_SAVECOUNT];
- #endif
- /*
- * time slack values; these are used to round up poll() and
- * select() etc timeout values. These are in nanoseconds.
- */
- unsigned long timer_slack_ns;
- unsigned long default_timer_slack_ns;
- struct list_head *scm_work_list;
- #ifdef CONFIG_FUNCTION_GRAPH_TRACER
- /* Index of current stored address in ret_stack */
- int curr_ret_stack;
- /* Stack of return addresses for return function tracing */
- struct ftrace_ret_stack *ret_stack;
- /* time stamp for last schedule */
- unsigned long long ftrace_timestamp;
- /*
- * Number of functions that haven't been traced
- * because of depth overrun.
- */
- atomic_t trace_overrun;
- /* Pause for the tracing */
- atomic_t tracing_graph_pause;
- #endif
- #ifdef CONFIG_TRACING
- /* state flags for use by tracers */
- unsigned long trace;
- /* bitmask and counter of trace recursion */
- unsigned long trace_recursion;
- #endif /* CONFIG_TRACING */
- #ifdef CONFIG_CGROUP_MEM_RES_CTLR /* memcg uses this to do batch job */
- struct memcg_batch_info {
- int do_batch; /* incremented when batch uncharge started */
- struct mem_cgroup *memcg; /* target memcg of uncharge */
- unsigned long nr_pages; /* uncharged usage */
- unsigned long memsw_nr_pages; /* uncharged mem+swap usage */
- } memcg_batch;
- #endif
- #ifdef CONFIG_HAVE_HW_BREAKPOINT
- atomic_t ptrace_bp_refcnt;
- #endif
- };
- /* Future-safe accessor for struct task_struct's cpus_allowed. */
- #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
- /*
- * Priority of a process goes from 0..MAX_PRIO-1, valid RT
- * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH
- * tasks are in the range MAX_RT_PRIO..MAX_PRIO-1. Priority
- * values are inverted: lower p->prio value means higher priority.
- *
- * The MAX_USER_RT_PRIO value allows the actual maximum
- * RT priority to be separate from the value exported to
- * user-space. This allows kernel threads to set their
- * priority to a value higher than any user task. Note:
- * MAX_RT_PRIO must not be smaller than MAX_USER_RT_PRIO.
- */
- #define MAX_USER_RT_PRIO 100
- #define MAX_RT_PRIO MAX_USER_RT_PRIO
- #define MAX_PRIO (MAX_RT_PRIO + 40)
- #define DEFAULT_PRIO (MAX_RT_PRIO + 20)
- static inline int rt_prio(int prio)
- {
- if (unlikely(prio < MAX_RT_PRIO))
- return 1;
- return 0;
- }
- static inline int rt_task(struct task_struct *p)
- {
- return rt_prio(p->prio);
- }
- static inline struct pid *task_pid(struct task_struct *task)
- {
- return task->pids[PIDTYPE_PID].pid;
- }
- static inline struct pid *task_tgid(struct task_struct *task)
- {
- return task->group_leader->pids[PIDTYPE_PID].pid;
- }
- /*
- * Without tasklist or rcu lock it is not safe to dereference
- * the result of task_pgrp/task_session even if task == current,
- * we can race with another thread doing sys_setsid/sys_setpgid.
- */
- static inline struct pid *task_pgrp(struct task_struct *task)
- {
- r…
Large files files are truncated, but you can click here to view the full file