diff options
Diffstat (limited to 'include/linux/sched.h')
| -rw-r--r-- | include/linux/sched.h | 275 | 
1 files changed, 61 insertions, 214 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index d35d2b6ddbf..6f950048b6e 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -127,18 +127,6 @@ 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  /* @@ -163,9 +151,10 @@ print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)  #define TASK_DEAD		64  #define TASK_WAKEKILL		128  #define TASK_WAKING		256 -#define TASK_STATE_MAX		512 +#define TASK_PARKED		512 +#define TASK_STATE_MAX		1024 -#define TASK_STATE_TO_CHAR_STR "RSDTtZXxKW" +#define TASK_STATE_TO_CHAR_STR "RSDTtZXxKWP"  extern char ___assert_task_state[1 - 2*!!(  		sizeof(TASK_STATE_TO_CHAR_STR)-1 != ilog2(TASK_STATE_MAX)+1)]; @@ -320,7 +309,6 @@ 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; @@ -526,7 +514,8 @@ struct signal_struct {  	unsigned int		has_child_subreaper:1;  	/* POSIX.1b Interval Timers */ -	struct list_head posix_timers; +	int			posix_timer_id; +	struct list_head	posix_timers;  	/* ITIMER_REAL timer for the process */  	struct hrtimer real_timer; @@ -570,7 +559,7 @@ struct signal_struct {  	cputime_t utime, stime, cutime, cstime;  	cputime_t gtime;  	cputime_t cgtime; -#ifndef CONFIG_VIRT_CPU_ACCOUNTING +#ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE  	struct cputime prev_cputime;  #endif  	unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw; @@ -637,6 +626,7 @@ struct 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 */ +#define SIGNAL_GROUP_COREDUMP	0x00000008 /* coredump in progress */  /*   * Pending notifications to parent.   */ @@ -768,31 +758,6 @@ enum cpu_idle_type {  };  /* - * 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 @@ -817,62 +782,6 @@ enum cpu_idle_type {  extern int __weak arch_sd_sibiling_asym_packing(void); -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; - -	unsigned long cpumask[0]; /* iteration mask */ -}; - -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); -} - -/* - * cpumask masking which cpus in the group are allowed to iterate up the domain - * tree. - */ -static inline struct cpumask *sched_group_mask(struct sched_group *sg) -{ -	return to_cpumask(sg->sgp->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;  }; @@ -883,6 +792,8 @@ struct sched_domain_attr {  extern int sched_domain_level_max; +struct sched_group; +  struct sched_domain {  	/* These fields must be setup */  	struct sched_domain *parent;	/* top domain must be null terminated */ @@ -899,6 +810,8 @@ struct sched_domain {  	unsigned int wake_idx;  	unsigned int forkexec_idx;  	unsigned int smt_gain; + +	int nohz_idle;			/* NOHZ IDLE status */  	int flags;			/* See SD_* */  	int level; @@ -971,18 +884,6 @@ extern void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[],  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 */ @@ -1017,72 +918,6 @@ 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 (*migrate_task_rq)(struct task_struct *p, int next_cpu); - -	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;  }; @@ -1274,8 +1109,10 @@ struct task_struct {  	int exit_code, exit_signal;  	int pdeath_signal;  /*  The signal sent when the parent dies  */  	unsigned int jobctl;	/* JOBCTL_*, siglock protected */ -	/* ??? */ + +	/* Used for emulating ABI behavior of previous Linux versions */  	unsigned int personality; +  	unsigned did_exec:1;  	unsigned in_execve:1;	/* Tell the LSMs that the process is doing an  				 * execve */ @@ -1327,7 +1164,7 @@ struct task_struct {  	cputime_t utime, stime, utimescaled, stimescaled;  	cputime_t gtime; -#ifndef CONFIG_VIRT_CPU_ACCOUNTING +#ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE  	struct cputime prev_cputime;  #endif  #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN @@ -1793,7 +1630,7 @@ extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut,  #define PF_SWAPWRITE	0x00800000	/* Allowed to write to swap */  #define PF_SPREAD_PAGE	0x01000000	/* Spread page cache over cpuset */  #define PF_SPREAD_SLAB	0x02000000	/* Spread some slab caches over cpuset */ -#define PF_THREAD_BOUND	0x04000000	/* Thread bound to specific cpu */ +#define PF_NO_SETAFFINITY 0x04000000	/* Userland is not allowed to meddle with cpus_allowed */  #define PF_MCE_EARLY    0x08000000      /* Early kill for mce process policy */  #define PF_MEMPOLICY	0x10000000	/* Non-default NUMA mempolicy */  #define PF_MUTEX_TESTER	0x20000000	/* Thread belongs to the rt mutex tester */ @@ -2412,27 +2249,18 @@ static inline void threadgroup_change_end(struct task_struct *tsk)   *   * Lock the threadgroup @tsk belongs to.  No new task is allowed to enter   * and member tasks aren't allowed to exit (as indicated by PF_EXITING) or - * perform exec.  This is useful for cases where the threadgroup needs to - * stay stable across blockable operations. + * change ->group_leader/pid.  This is useful for cases where the threadgroup + * needs to stay stable across blockable operations.   *   * fork and exit paths explicitly call threadgroup_change_{begin|end}() for   * synchronization.  While held, no new task will be added to threadgroup   * and no existing live task will have its PF_EXITING set.   * - * During exec, a task goes and puts its thread group through unusual - * changes.  After de-threading, exclusive access is assumed to resources - * which are usually shared by tasks in the same group - e.g. sighand may - * be replaced with a new one.  Also, the exec'ing task takes over group - * leader role including its pid.  Exclude these changes while locked by - * grabbing cred_guard_mutex which is used to synchronize exec path. + * de_thread() does threadgroup_change_{begin|end}() when a non-leader + * sub-thread becomes a new leader.   */  static inline void threadgroup_lock(struct task_struct *tsk)  { -	/* -	 * exec uses exit for de-threading nesting group_rwsem inside -	 * cred_guard_mutex. Grab cred_guard_mutex first. -	 */ -	mutex_lock(&tsk->signal->cred_guard_mutex);  	down_write(&tsk->signal->group_rwsem);  } @@ -2445,7 +2273,6 @@ static inline void threadgroup_lock(struct task_struct *tsk)  static inline void threadgroup_unlock(struct task_struct *tsk)  {  	up_write(&tsk->signal->group_rwsem); -	mutex_unlock(&tsk->signal->cred_guard_mutex);  }  #else  static inline void threadgroup_change_begin(struct task_struct *tsk) {} @@ -2622,6 +2449,47 @@ static inline int spin_needbreak(spinlock_t *lock)  }  /* + * Idle thread specific functions to determine the need_resched + * polling state. We have two versions, one based on TS_POLLING in + * thread_info.status and one based on TIF_POLLING_NRFLAG in + * thread_info.flags + */ +#ifdef TS_POLLING +static inline int tsk_is_polling(struct task_struct *p) +{ +	return task_thread_info(p)->status & TS_POLLING; +} +static inline void current_set_polling(void) +{ +	current_thread_info()->status |= TS_POLLING; +} + +static inline void current_clr_polling(void) +{ +	current_thread_info()->status &= ~TS_POLLING; +	smp_mb__after_clear_bit(); +} +#elif defined(TIF_POLLING_NRFLAG) +static inline int tsk_is_polling(struct task_struct *p) +{ +	return test_tsk_thread_flag(p, TIF_POLLING_NRFLAG); +} +static inline void current_set_polling(void) +{ +	set_thread_flag(TIF_POLLING_NRFLAG); +} + +static inline void current_clr_polling(void) +{ +	clear_thread_flag(TIF_POLLING_NRFLAG); +} +#else +static inline int tsk_is_polling(struct task_struct *p) { return 0; } +static inline void current_set_polling(void) { } +static inline void current_clr_polling(void) { } +#endif + +/*   * Thread group CPU time accounting.   */  void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times); @@ -2681,28 +2549,7 @@ extern long sched_setaffinity(pid_t pid, const struct cpumask *new_mask);  extern long sched_getaffinity(pid_t pid, struct cpumask *mask);  #ifdef CONFIG_CGROUP_SCHED -  extern struct task_group root_task_group; - -extern struct task_group *sched_create_group(struct task_group *parent); -extern void sched_online_group(struct task_group *tg, -			       struct task_group *parent); -extern void sched_destroy_group(struct task_group *tg); -extern void sched_offline_group(struct task_group *tg); -extern void sched_move_task(struct task_struct *tsk); -#ifdef CONFIG_FAIR_GROUP_SCHED -extern int sched_group_set_shares(struct task_group *tg, unsigned long shares); -extern unsigned long sched_group_shares(struct task_group *tg); -#endif -#ifdef CONFIG_RT_GROUP_SCHED -extern int sched_group_set_rt_runtime(struct task_group *tg, -				      long rt_runtime_us); -extern long sched_group_rt_runtime(struct task_group *tg); -extern int sched_group_set_rt_period(struct task_group *tg, -				      long rt_period_us); -extern long sched_group_rt_period(struct task_group *tg); -extern int sched_rt_can_attach(struct task_group *tg, struct task_struct *tsk); -#endif  #endif /* CONFIG_CGROUP_SCHED */  extern int task_can_switch_user(struct user_struct *up,  |