aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sched.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r--include/linux/sched.h253
1 files changed, 223 insertions, 30 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 0f72548732f1..25f54c79f757 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -3,6 +3,8 @@
3 3
4#include <uapi/linux/sched.h> 4#include <uapi/linux/sched.h>
5 5
6#include <linux/sched/prio.h>
7
6 8
7struct sched_param { 9struct sched_param {
8 int sched_priority; 10 int sched_priority;
@@ -16,6 +18,7 @@ struct sched_param {
16#include <linux/types.h> 18#include <linux/types.h>
17#include <linux/timex.h> 19#include <linux/timex.h>
18#include <linux/jiffies.h> 20#include <linux/jiffies.h>
21#include <linux/plist.h>
19#include <linux/rbtree.h> 22#include <linux/rbtree.h>
20#include <linux/thread_info.h> 23#include <linux/thread_info.h>
21#include <linux/cpumask.h> 24#include <linux/cpumask.h>
@@ -26,7 +29,7 @@ struct sched_param {
26 29
27#include <asm/page.h> 30#include <asm/page.h>
28#include <asm/ptrace.h> 31#include <asm/ptrace.h>
29#include <asm/cputime.h> 32#include <linux/cputime.h>
30 33
31#include <linux/smp.h> 34#include <linux/smp.h>
32#include <linux/sem.h> 35#include <linux/sem.h>
@@ -56,6 +59,70 @@ struct sched_param {
56 59
57#include <asm/processor.h> 60#include <asm/processor.h>
58 61
62#define SCHED_ATTR_SIZE_VER0 48 /* sizeof first published struct */
63
64/*
65 * Extended scheduling parameters data structure.
66 *
67 * This is needed because the original struct sched_param can not be
68 * altered without introducing ABI issues with legacy applications
69 * (e.g., in sched_getparam()).
70 *
71 * However, the possibility of specifying more than just a priority for
72 * the tasks may be useful for a wide variety of application fields, e.g.,
73 * multimedia, streaming, automation and control, and many others.
74 *
75 * This variant (sched_attr) is meant at describing a so-called
76 * sporadic time-constrained task. In such model a task is specified by:
77 * - the activation period or minimum instance inter-arrival time;
78 * - the maximum (or average, depending on the actual scheduling
79 * discipline) computation time of all instances, a.k.a. runtime;
80 * - the deadline (relative to the actual activation time) of each
81 * instance.
82 * Very briefly, a periodic (sporadic) task asks for the execution of
83 * some specific computation --which is typically called an instance--
84 * (at most) every period. Moreover, each instance typically lasts no more
85 * than the runtime and must be completed by time instant t equal to
86 * the instance activation time + the deadline.
87 *
88 * This is reflected by the actual fields of the sched_attr structure:
89 *
90 * @size size of the structure, for fwd/bwd compat.
91 *
92 * @sched_policy task's scheduling policy
93 * @sched_flags for customizing the scheduler behaviour
94 * @sched_nice task's nice value (SCHED_NORMAL/BATCH)
95 * @sched_priority task's static priority (SCHED_FIFO/RR)
96 * @sched_deadline representative of the task's deadline
97 * @sched_runtime representative of the task's runtime
98 * @sched_period representative of the task's period
99 *
100 * Given this task model, there are a multiplicity of scheduling algorithms
101 * and policies, that can be used to ensure all the tasks will make their
102 * timing constraints.
103 *
104 * As of now, the SCHED_DEADLINE policy (sched_dl scheduling class) is the
105 * only user of this new interface. More information about the algorithm
106 * available in the scheduling class file or in Documentation/.
107 */
108struct sched_attr {
109 u32 size;
110
111 u32 sched_policy;
112 u64 sched_flags;
113
114 /* SCHED_NORMAL, SCHED_BATCH */
115 s32 sched_nice;
116
117 /* SCHED_FIFO, SCHED_RR */
118 u32 sched_priority;
119
120 /* SCHED_DEADLINE */
121 u64 sched_runtime;
122 u64 sched_deadline;
123 u64 sched_period;
124};
125
59struct exec_domain; 126struct exec_domain;
60struct futex_pi_state; 127struct futex_pi_state;
61struct robust_list_head; 128struct robust_list_head;
@@ -63,6 +130,11 @@ struct bio_list;
63struct fs_struct; 130struct fs_struct;
64struct perf_event_context; 131struct perf_event_context;
65struct blk_plug; 132struct blk_plug;
133struct filename;
134
135#define VMACACHE_BITS 2
136#define VMACACHE_SIZE (1U << VMACACHE_BITS)
137#define VMACACHE_MASK (VMACACHE_SIZE - 1)
66 138
67/* 139/*
68 * List of flags we want to share for kernel threads, 140 * List of flags we want to share for kernel threads,
@@ -138,8 +210,9 @@ print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq);
138#define __TASK_STOPPED 4 210#define __TASK_STOPPED 4
139#define __TASK_TRACED 8 211#define __TASK_TRACED 8
140/* in tsk->exit_state */ 212/* in tsk->exit_state */
141#define EXIT_ZOMBIE 16 213#define EXIT_DEAD 16
142#define EXIT_DEAD 32 214#define EXIT_ZOMBIE 32
215#define EXIT_TRACE (EXIT_ZOMBIE | EXIT_DEAD)
143/* in tsk->state again */ 216/* in tsk->state again */
144#define TASK_DEAD 64 217#define TASK_DEAD 64
145#define TASK_WAKEKILL 128 218#define TASK_WAKEKILL 128
@@ -164,11 +237,10 @@ extern char ___assert_task_state[1 - 2*!!(
164/* get_task_state() */ 237/* get_task_state() */
165#define TASK_REPORT (TASK_RUNNING | TASK_INTERRUPTIBLE | \ 238#define TASK_REPORT (TASK_RUNNING | TASK_INTERRUPTIBLE | \
166 TASK_UNINTERRUPTIBLE | __TASK_STOPPED | \ 239 TASK_UNINTERRUPTIBLE | __TASK_STOPPED | \
167 __TASK_TRACED) 240 __TASK_TRACED | EXIT_ZOMBIE | EXIT_DEAD)
168 241
169#define task_is_traced(task) ((task->state & __TASK_TRACED) != 0) 242#define task_is_traced(task) ((task->state & __TASK_TRACED) != 0)
170#define task_is_stopped(task) ((task->state & __TASK_STOPPED) != 0) 243#define task_is_stopped(task) ((task->state & __TASK_STOPPED) != 0)
171#define task_is_dead(task) ((task)->exit_state != 0)
172#define task_is_stopped_or_traced(task) \ 244#define task_is_stopped_or_traced(task) \
173 ((task->state & (__TASK_STOPPED | __TASK_TRACED)) != 0) 245 ((task->state & (__TASK_STOPPED | __TASK_TRACED)) != 0)
174#define task_contributes_to_load(task) \ 246#define task_contributes_to_load(task) \
@@ -227,10 +299,14 @@ extern int runqueue_is_locked(int cpu);
227#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) 299#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
228extern void nohz_balance_enter_idle(int cpu); 300extern void nohz_balance_enter_idle(int cpu);
229extern void set_cpu_sd_state_idle(void); 301extern void set_cpu_sd_state_idle(void);
230extern int get_nohz_timer_target(void); 302extern int get_nohz_timer_target(int pinned);
231#else 303#else
232static inline void nohz_balance_enter_idle(int cpu) { } 304static inline void nohz_balance_enter_idle(int cpu) { }
233static inline void set_cpu_sd_state_idle(void) { } 305static inline void set_cpu_sd_state_idle(void) { }
306static inline int get_nohz_timer_target(int pinned)
307{
308 return smp_processor_id();
309}
234#endif 310#endif
235 311
236/* 312/*
@@ -327,22 +403,33 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
327static inline void arch_pick_mmap_layout(struct mm_struct *mm) {} 403static inline void arch_pick_mmap_layout(struct mm_struct *mm) {}
328#endif 404#endif
329 405
330
331extern void set_dumpable(struct mm_struct *mm, int value);
332extern int get_dumpable(struct mm_struct *mm);
333
334#define SUID_DUMP_DISABLE 0 /* No setuid dumping */ 406#define SUID_DUMP_DISABLE 0 /* No setuid dumping */
335#define SUID_DUMP_USER 1 /* Dump as user of process */ 407#define SUID_DUMP_USER 1 /* Dump as user of process */
336#define SUID_DUMP_ROOT 2 /* Dump as root */ 408#define SUID_DUMP_ROOT 2 /* Dump as root */
337 409
338/* mm flags */ 410/* mm flags */
339/* dumpable bits */
340#define MMF_DUMPABLE 0 /* core dump is permitted */
341#define MMF_DUMP_SECURELY 1 /* core file is readable only by root */
342 411
412/* for SUID_DUMP_* above */
343#define MMF_DUMPABLE_BITS 2 413#define MMF_DUMPABLE_BITS 2
344#define MMF_DUMPABLE_MASK ((1 << MMF_DUMPABLE_BITS) - 1) 414#define MMF_DUMPABLE_MASK ((1 << MMF_DUMPABLE_BITS) - 1)
345 415
416extern void set_dumpable(struct mm_struct *mm, int value);
417/*
418 * This returns the actual value of the suid_dumpable flag. For things
419 * that are using this for checking for privilege transitions, it must
420 * test against SUID_DUMP_USER rather than treating it as a boolean
421 * value.
422 */
423static inline int __get_dumpable(unsigned long mm_flags)
424{
425 return mm_flags & MMF_DUMPABLE_MASK;
426}
427
428static inline int get_dumpable(struct mm_struct *mm)
429{
430 return __get_dumpable(mm->flags);
431}
432
346/* coredump filter bits */ 433/* coredump filter bits */
347#define MMF_DUMP_ANON_PRIVATE 2 434#define MMF_DUMP_ANON_PRIVATE 2
348#define MMF_DUMP_ANON_SHARED 3 435#define MMF_DUMP_ANON_SHARED 3
@@ -485,6 +572,7 @@ struct signal_struct {
485 atomic_t sigcnt; 572 atomic_t sigcnt;
486 atomic_t live; 573 atomic_t live;
487 int nr_threads; 574 int nr_threads;
575 struct list_head thread_head;
488 576
489 wait_queue_head_t wait_chldexit; /* for wait4() */ 577 wait_queue_head_t wait_chldexit; /* for wait4() */
490 578
@@ -1000,6 +1088,7 @@ struct sched_entity {
1000#endif 1088#endif
1001 1089
1002#ifdef CONFIG_FAIR_GROUP_SCHED 1090#ifdef CONFIG_FAIR_GROUP_SCHED
1091 int depth;
1003 struct sched_entity *parent; 1092 struct sched_entity *parent;
1004 /* rq on which this entity is (to be) queued: */ 1093 /* rq on which this entity is (to be) queued: */
1005 struct cfs_rq *cfs_rq; 1094 struct cfs_rq *cfs_rq;
@@ -1029,6 +1118,51 @@ struct sched_rt_entity {
1029#endif 1118#endif
1030}; 1119};
1031 1120
1121struct sched_dl_entity {
1122 struct rb_node rb_node;
1123
1124 /*
1125 * Original scheduling parameters. Copied here from sched_attr
1126 * during sched_setscheduler2(), they will remain the same until
1127 * the next sched_setscheduler2().
1128 */
1129 u64 dl_runtime; /* maximum runtime for each instance */
1130 u64 dl_deadline; /* relative deadline of each instance */
1131 u64 dl_period; /* separation of two instances (period) */
1132 u64 dl_bw; /* dl_runtime / dl_deadline */
1133
1134 /*
1135 * Actual scheduling parameters. Initialized with the values above,
1136 * they are continously updated during task execution. Note that
1137 * the remaining runtime could be < 0 in case we are in overrun.
1138 */
1139 s64 runtime; /* remaining runtime for this instance */
1140 u64 deadline; /* absolute deadline for this instance */
1141 unsigned int flags; /* specifying the scheduler behaviour */
1142
1143 /*
1144 * Some bool flags:
1145 *
1146 * @dl_throttled tells if we exhausted the runtime. If so, the
1147 * task has to wait for a replenishment to be performed at the
1148 * next firing of dl_timer.
1149 *
1150 * @dl_new tells if a new instance arrived. If so we must
1151 * start executing it with full runtime and reset its absolute
1152 * deadline;
1153 *
1154 * @dl_boosted tells if we are boosted due to DI. If so we are
1155 * outside bandwidth enforcement mechanism (but only until we
1156 * exit the critical section).
1157 */
1158 int dl_throttled, dl_new, dl_boosted;
1159
1160 /*
1161 * Bandwidth enforcement timer. Each -deadline task has its
1162 * own bandwidth to be enforced, thus we need one timer per task.
1163 */
1164 struct hrtimer dl_timer;
1165};
1032 1166
1033struct rcu_node; 1167struct rcu_node;
1034 1168
@@ -1065,6 +1199,7 @@ struct task_struct {
1065#ifdef CONFIG_CGROUP_SCHED 1199#ifdef CONFIG_CGROUP_SCHED
1066 struct task_group *sched_task_group; 1200 struct task_group *sched_task_group;
1067#endif 1201#endif
1202 struct sched_dl_entity dl;
1068 1203
1069#ifdef CONFIG_PREEMPT_NOTIFIERS 1204#ifdef CONFIG_PREEMPT_NOTIFIERS
1070 /* list of struct preempt_notifier: */ 1205 /* list of struct preempt_notifier: */
@@ -1098,12 +1233,16 @@ struct task_struct {
1098 struct list_head tasks; 1233 struct list_head tasks;
1099#ifdef CONFIG_SMP 1234#ifdef CONFIG_SMP
1100 struct plist_node pushable_tasks; 1235 struct plist_node pushable_tasks;
1236 struct rb_node pushable_dl_tasks;
1101#endif 1237#endif
1102 1238
1103 struct mm_struct *mm, *active_mm; 1239 struct mm_struct *mm, *active_mm;
1104#ifdef CONFIG_COMPAT_BRK 1240#ifdef CONFIG_COMPAT_BRK
1105 unsigned brk_randomized:1; 1241 unsigned brk_randomized:1;
1106#endif 1242#endif
1243 /* per-thread vma caching */
1244 u32 vmacache_seqnum;
1245 struct vm_area_struct *vmacache[VMACACHE_SIZE];
1107#if defined(SPLIT_RSS_COUNTING) 1246#if defined(SPLIT_RSS_COUNTING)
1108 struct task_rss_stat rss_stat; 1247 struct task_rss_stat rss_stat;
1109#endif 1248#endif
@@ -1116,7 +1255,6 @@ struct task_struct {
1116 /* Used for emulating ABI behavior of previous Linux versions */ 1255 /* Used for emulating ABI behavior of previous Linux versions */
1117 unsigned int personality; 1256 unsigned int personality;
1118 1257
1119 unsigned did_exec:1;
1120 unsigned in_execve:1; /* Tell the LSMs that the process is doing an 1258 unsigned in_execve:1; /* Tell the LSMs that the process is doing an
1121 * execve */ 1259 * execve */
1122 unsigned in_iowait:1; 1260 unsigned in_iowait:1;
@@ -1160,6 +1298,7 @@ struct task_struct {
1160 /* PID/PID hash table linkage. */ 1298 /* PID/PID hash table linkage. */
1161 struct pid_link pids[PIDTYPE_MAX]; 1299 struct pid_link pids[PIDTYPE_MAX];
1162 struct list_head thread_group; 1300 struct list_head thread_group;
1301 struct list_head thread_node;
1163 1302
1164 struct completion *vfork_done; /* for vfork() */ 1303 struct completion *vfork_done; /* for vfork() */
1165 int __user *set_child_tid; /* CLONE_CHILD_SETTID */ 1304 int __user *set_child_tid; /* CLONE_CHILD_SETTID */
@@ -1249,9 +1388,12 @@ struct task_struct {
1249 1388
1250#ifdef CONFIG_RT_MUTEXES 1389#ifdef CONFIG_RT_MUTEXES
1251 /* PI waiters blocked on a rt_mutex held by this task */ 1390 /* PI waiters blocked on a rt_mutex held by this task */
1252 struct plist_head pi_waiters; 1391 struct rb_root pi_waiters;
1392 struct rb_node *pi_waiters_leftmost;
1253 /* Deadlock detection and priority inheritance handling */ 1393 /* Deadlock detection and priority inheritance handling */
1254 struct rt_mutex_waiter *pi_blocked_on; 1394 struct rt_mutex_waiter *pi_blocked_on;
1395 /* Top pi_waiters task */
1396 struct task_struct *pi_top_task;
1255#endif 1397#endif
1256 1398
1257#ifdef CONFIG_DEBUG_MUTEXES 1399#ifdef CONFIG_DEBUG_MUTEXES
@@ -1333,6 +1475,9 @@ struct task_struct {
1333 struct mutex perf_event_mutex; 1475 struct mutex perf_event_mutex;
1334 struct list_head perf_event_list; 1476 struct list_head perf_event_list;
1335#endif 1477#endif
1478#ifdef CONFIG_DEBUG_PREEMPT
1479 unsigned long preempt_disable_ip;
1480#endif
1336#ifdef CONFIG_NUMA 1481#ifdef CONFIG_NUMA
1337 struct mempolicy *mempolicy; /* Protected by alloc_lock */ 1482 struct mempolicy *mempolicy; /* Protected by alloc_lock */
1338 short il_next; 1483 short il_next;
@@ -1343,9 +1488,10 @@ struct task_struct {
1343 unsigned int numa_scan_period; 1488 unsigned int numa_scan_period;
1344 unsigned int numa_scan_period_max; 1489 unsigned int numa_scan_period_max;
1345 int numa_preferred_nid; 1490 int numa_preferred_nid;
1346 int numa_migrate_deferred;
1347 unsigned long numa_migrate_retry; 1491 unsigned long numa_migrate_retry;
1348 u64 node_stamp; /* migration stamp */ 1492 u64 node_stamp; /* migration stamp */
1493 u64 last_task_numa_placement;
1494 u64 last_sum_exec_runtime;
1349 struct callback_head numa_work; 1495 struct callback_head numa_work;
1350 1496
1351 struct list_head numa_entry; 1497 struct list_head numa_entry;
@@ -1356,15 +1502,22 @@ struct task_struct {
1356 * Scheduling placement decisions are made based on the these counts. 1502 * Scheduling placement decisions are made based on the these counts.
1357 * The values remain static for the duration of a PTE scan 1503 * The values remain static for the duration of a PTE scan
1358 */ 1504 */
1359 unsigned long *numa_faults; 1505 unsigned long *numa_faults_memory;
1360 unsigned long total_numa_faults; 1506 unsigned long total_numa_faults;
1361 1507
1362 /* 1508 /*
1363 * numa_faults_buffer records faults per node during the current 1509 * numa_faults_buffer records faults per node during the current
1364 * scan window. When the scan completes, the counts in numa_faults 1510 * scan window. When the scan completes, the counts in
1365 * decay and these values are copied. 1511 * numa_faults_memory decay and these values are copied.
1366 */ 1512 */
1367 unsigned long *numa_faults_buffer; 1513 unsigned long *numa_faults_buffer_memory;
1514
1515 /*
1516 * Track the nodes the process was running on when a NUMA hinting
1517 * fault was incurred.
1518 */
1519 unsigned long *numa_faults_cpu;
1520 unsigned long *numa_faults_buffer_cpu;
1368 1521
1369 /* 1522 /*
1370 * numa_faults_locality tracks if faults recorded during the last 1523 * numa_faults_locality tracks if faults recorded during the last
@@ -1469,8 +1622,8 @@ extern void task_numa_fault(int last_node, int node, int pages, int flags);
1469extern pid_t task_numa_group_id(struct task_struct *p); 1622extern pid_t task_numa_group_id(struct task_struct *p);
1470extern void set_numabalancing_state(bool enabled); 1623extern void set_numabalancing_state(bool enabled);
1471extern void task_numa_free(struct task_struct *p); 1624extern void task_numa_free(struct task_struct *p);
1472 1625extern bool should_numa_migrate_memory(struct task_struct *p, struct page *page,
1473extern unsigned int sysctl_numa_balancing_migrate_deferred; 1626 int src_nid, int dst_cpu);
1474#else 1627#else
1475static inline void task_numa_fault(int last_node, int node, int pages, 1628static inline void task_numa_fault(int last_node, int node, int pages,
1476 int flags) 1629 int flags)
@@ -1486,6 +1639,11 @@ static inline void set_numabalancing_state(bool enabled)
1486static inline void task_numa_free(struct task_struct *p) 1639static inline void task_numa_free(struct task_struct *p)
1487{ 1640{
1488} 1641}
1642static inline bool should_numa_migrate_memory(struct task_struct *p,
1643 struct page *page, int src_nid, int dst_cpu)
1644{
1645 return true;
1646}
1489#endif 1647#endif
1490 1648
1491static inline struct pid *task_pid(struct task_struct *task) 1649static inline struct pid *task_pid(struct task_struct *task)
@@ -1712,7 +1870,6 @@ extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut,
1712#define PF_SPREAD_SLAB 0x02000000 /* Spread some slab caches over cpuset */ 1870#define PF_SPREAD_SLAB 0x02000000 /* Spread some slab caches over cpuset */
1713#define PF_NO_SETAFFINITY 0x04000000 /* Userland is not allowed to meddle with cpus_allowed */ 1871#define PF_NO_SETAFFINITY 0x04000000 /* Userland is not allowed to meddle with cpus_allowed */
1714#define PF_MCE_EARLY 0x08000000 /* Early kill for mce process policy */ 1872#define PF_MCE_EARLY 0x08000000 /* Early kill for mce process policy */
1715#define PF_MEMPOLICY 0x10000000 /* Non-default NUMA mempolicy */
1716#define PF_MUTEX_TESTER 0x20000000 /* Thread belongs to the rt mutex tester */ 1873#define PF_MUTEX_TESTER 0x20000000 /* Thread belongs to the rt mutex tester */
1717#define PF_FREEZER_SKIP 0x40000000 /* Freezer should not count it as freezable */ 1874#define PF_FREEZER_SKIP 0x40000000 /* Freezer should not count it as freezable */
1718#define PF_SUSPEND_TASK 0x80000000 /* this thread called freeze_processes and should not be frozen */ 1875#define PF_SUSPEND_TASK 0x80000000 /* this thread called freeze_processes and should not be frozen */
@@ -1898,7 +2055,9 @@ static inline void sched_clock_idle_wakeup_event(u64 delta_ns)
1898 * but then during bootup it turns out that sched_clock() 2055 * but then during bootup it turns out that sched_clock()
1899 * is reliable after all: 2056 * is reliable after all:
1900 */ 2057 */
1901extern int sched_clock_stable; 2058extern int sched_clock_stable(void);
2059extern void set_sched_clock_stable(void);
2060extern void clear_sched_clock_stable(void);
1902 2061
1903extern void sched_clock_tick(void); 2062extern void sched_clock_tick(void);
1904extern void sched_clock_idle_sleep_event(void); 2063extern void sched_clock_idle_sleep_event(void);
@@ -1969,7 +2128,16 @@ static inline void sched_autogroup_exit(struct signal_struct *sig) { }
1969extern bool yield_to(struct task_struct *p, bool preempt); 2128extern bool yield_to(struct task_struct *p, bool preempt);
1970extern void set_user_nice(struct task_struct *p, long nice); 2129extern void set_user_nice(struct task_struct *p, long nice);
1971extern int task_prio(const struct task_struct *p); 2130extern int task_prio(const struct task_struct *p);
1972extern int task_nice(const struct task_struct *p); 2131/**
2132 * task_nice - return the nice value of a given task.
2133 * @p: the task in question.
2134 *
2135 * Return: The nice value [ -20 ... 0 ... 19 ].
2136 */
2137static inline int task_nice(const struct task_struct *p)
2138{
2139 return PRIO_TO_NICE((p)->static_prio);
2140}
1973extern int can_nice(const struct task_struct *p, const int nice); 2141extern int can_nice(const struct task_struct *p, const int nice);
1974extern int task_curr(const struct task_struct *p); 2142extern int task_curr(const struct task_struct *p);
1975extern int idle_cpu(int cpu); 2143extern int idle_cpu(int cpu);
@@ -1977,6 +2145,8 @@ extern int sched_setscheduler(struct task_struct *, int,
1977 const struct sched_param *); 2145 const struct sched_param *);
1978extern int sched_setscheduler_nocheck(struct task_struct *, int, 2146extern int sched_setscheduler_nocheck(struct task_struct *, int,
1979 const struct sched_param *); 2147 const struct sched_param *);
2148extern int sched_setattr(struct task_struct *,
2149 const struct sched_attr *);
1980extern struct task_struct *idle_task(int cpu); 2150extern struct task_struct *idle_task(int cpu);
1981/** 2151/**
1982 * is_idle_task - is the specified task an idle task? 2152 * is_idle_task - is the specified task an idle task?
@@ -2056,7 +2226,7 @@ extern void wake_up_new_task(struct task_struct *tsk);
2056#else 2226#else
2057 static inline void kick_process(struct task_struct *tsk) { } 2227 static inline void kick_process(struct task_struct *tsk) { }
2058#endif 2228#endif
2059extern void sched_fork(unsigned long clone_flags, struct task_struct *p); 2229extern int sched_fork(unsigned long clone_flags, struct task_struct *p);
2060extern void sched_dead(struct task_struct *p); 2230extern void sched_dead(struct task_struct *p);
2061 2231
2062extern void proc_caches_init(void); 2232extern void proc_caches_init(void);
@@ -2182,8 +2352,6 @@ extern struct mm_struct *get_task_mm(struct task_struct *task);
2182extern struct mm_struct *mm_access(struct task_struct *task, unsigned int mode); 2352extern struct mm_struct *mm_access(struct task_struct *task, unsigned int mode);
2183/* Remove the current tasks stale references to the old mm_struct */ 2353/* Remove the current tasks stale references to the old mm_struct */
2184extern void mm_release(struct task_struct *, struct mm_struct *); 2354extern void mm_release(struct task_struct *, struct mm_struct *);
2185/* Allocate a new mm structure and copy contents from tsk->mm */
2186extern struct mm_struct *dup_mm(struct task_struct *tsk);
2187 2355
2188extern int copy_thread(unsigned long, unsigned long, unsigned long, 2356extern int copy_thread(unsigned long, unsigned long, unsigned long,
2189 struct task_struct *); 2357 struct task_struct *);
@@ -2201,14 +2369,14 @@ extern void do_group_exit(int);
2201extern int allow_signal(int); 2369extern int allow_signal(int);
2202extern int disallow_signal(int); 2370extern int disallow_signal(int);
2203 2371
2204extern int do_execve(const char *, 2372extern int do_execve(struct filename *,
2205 const char __user * const __user *, 2373 const char __user * const __user *,
2206 const char __user * const __user *); 2374 const char __user * const __user *);
2207extern long do_fork(unsigned long, unsigned long, unsigned long, int __user *, int __user *); 2375extern long do_fork(unsigned long, unsigned long, unsigned long, int __user *, int __user *);
2208struct task_struct *fork_idle(int); 2376struct task_struct *fork_idle(int);
2209extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); 2377extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
2210 2378
2211extern void set_task_comm(struct task_struct *tsk, char *from); 2379extern void set_task_comm(struct task_struct *tsk, const char *from);
2212extern char *get_task_comm(char *to, struct task_struct *tsk); 2380extern char *get_task_comm(char *to, struct task_struct *tsk);
2213 2381
2214#ifdef CONFIG_SMP 2382#ifdef CONFIG_SMP
@@ -2241,6 +2409,16 @@ extern bool current_is_single_threaded(void);
2241#define while_each_thread(g, t) \ 2409#define while_each_thread(g, t) \
2242 while ((t = next_thread(t)) != g) 2410 while ((t = next_thread(t)) != g)
2243 2411
2412#define __for_each_thread(signal, t) \
2413 list_for_each_entry_rcu(t, &(signal)->thread_head, thread_node)
2414
2415#define for_each_thread(p, t) \
2416 __for_each_thread((p)->signal, t)
2417
2418/* Careful: this is a double loop, 'break' won't work as expected. */
2419#define for_each_process_thread(p, t) \
2420 for_each_process(p) for_each_thread(p, t)
2421
2244static inline int get_nr_threads(struct task_struct *tsk) 2422static inline int get_nr_threads(struct task_struct *tsk)
2245{ 2423{
2246 return tsk->signal->nr_threads; 2424 return tsk->signal->nr_threads;
@@ -2645,6 +2823,21 @@ static inline bool __must_check current_clr_polling_and_test(void)
2645} 2823}
2646#endif 2824#endif
2647 2825
2826static inline void current_clr_polling(void)
2827{
2828 __current_clr_polling();
2829
2830 /*
2831 * Ensure we check TIF_NEED_RESCHED after we clear the polling bit.
2832 * Once the bit is cleared, we'll get IPIs with every new
2833 * TIF_NEED_RESCHED and the IPI handler, scheduler_ipi(), will also
2834 * fold.
2835 */
2836 smp_mb(); /* paired with resched_task() */
2837
2838 preempt_fold_need_resched();
2839}
2840
2648static __always_inline bool need_resched(void) 2841static __always_inline bool need_resched(void)
2649{ 2842{
2650 return unlikely(tif_need_resched()); 2843 return unlikely(tif_need_resched());