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.h102
1 files changed, 75 insertions, 27 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 5e344bbe63ec..8db31ef98d2f 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -243,6 +243,43 @@ extern char ___assert_task_state[1 - 2*!!(
243 ((task->state & TASK_UNINTERRUPTIBLE) != 0 && \ 243 ((task->state & TASK_UNINTERRUPTIBLE) != 0 && \
244 (task->flags & PF_FROZEN) == 0) 244 (task->flags & PF_FROZEN) == 0)
245 245
246#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
247
248#define __set_task_state(tsk, state_value) \
249 do { \
250 (tsk)->task_state_change = _THIS_IP_; \
251 (tsk)->state = (state_value); \
252 } while (0)
253#define set_task_state(tsk, state_value) \
254 do { \
255 (tsk)->task_state_change = _THIS_IP_; \
256 set_mb((tsk)->state, (state_value)); \
257 } while (0)
258
259/*
260 * set_current_state() includes a barrier so that the write of current->state
261 * is correctly serialised wrt the caller's subsequent test of whether to
262 * actually sleep:
263 *
264 * set_current_state(TASK_UNINTERRUPTIBLE);
265 * if (do_i_need_to_sleep())
266 * schedule();
267 *
268 * If the caller does not need such serialisation then use __set_current_state()
269 */
270#define __set_current_state(state_value) \
271 do { \
272 current->task_state_change = _THIS_IP_; \
273 current->state = (state_value); \
274 } while (0)
275#define set_current_state(state_value) \
276 do { \
277 current->task_state_change = _THIS_IP_; \
278 set_mb(current->state, (state_value)); \
279 } while (0)
280
281#else
282
246#define __set_task_state(tsk, state_value) \ 283#define __set_task_state(tsk, state_value) \
247 do { (tsk)->state = (state_value); } while (0) 284 do { (tsk)->state = (state_value); } while (0)
248#define set_task_state(tsk, state_value) \ 285#define set_task_state(tsk, state_value) \
@@ -259,11 +296,13 @@ extern char ___assert_task_state[1 - 2*!!(
259 * 296 *
260 * If the caller does not need such serialisation then use __set_current_state() 297 * If the caller does not need such serialisation then use __set_current_state()
261 */ 298 */
262#define __set_current_state(state_value) \ 299#define __set_current_state(state_value) \
263 do { current->state = (state_value); } while (0) 300 do { current->state = (state_value); } while (0)
264#define set_current_state(state_value) \ 301#define set_current_state(state_value) \
265 set_mb(current->state, (state_value)) 302 set_mb(current->state, (state_value))
266 303
304#endif
305
267/* Task command name length */ 306/* Task command name length */
268#define TASK_COMM_LEN 16 307#define TASK_COMM_LEN 16
269 308
@@ -1278,9 +1317,9 @@ struct task_struct {
1278 union rcu_special rcu_read_unlock_special; 1317 union rcu_special rcu_read_unlock_special;
1279 struct list_head rcu_node_entry; 1318 struct list_head rcu_node_entry;
1280#endif /* #ifdef CONFIG_PREEMPT_RCU */ 1319#endif /* #ifdef CONFIG_PREEMPT_RCU */
1281#ifdef CONFIG_TREE_PREEMPT_RCU 1320#ifdef CONFIG_PREEMPT_RCU
1282 struct rcu_node *rcu_blocked_node; 1321 struct rcu_node *rcu_blocked_node;
1283#endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */ 1322#endif /* #ifdef CONFIG_PREEMPT_RCU */
1284#ifdef CONFIG_TASKS_RCU 1323#ifdef CONFIG_TASKS_RCU
1285 unsigned long rcu_tasks_nvcsw; 1324 unsigned long rcu_tasks_nvcsw;
1286 bool rcu_tasks_holdout; 1325 bool rcu_tasks_holdout;
@@ -1325,6 +1364,10 @@ struct task_struct {
1325 unsigned sched_reset_on_fork:1; 1364 unsigned sched_reset_on_fork:1;
1326 unsigned sched_contributes_to_load:1; 1365 unsigned sched_contributes_to_load:1;
1327 1366
1367#ifdef CONFIG_MEMCG_KMEM
1368 unsigned memcg_kmem_skip_account:1;
1369#endif
1370
1328 unsigned long atomic_flags; /* Flags needing atomic access. */ 1371 unsigned long atomic_flags; /* Flags needing atomic access. */
1329 1372
1330 pid_t pid; 1373 pid_t pid;
@@ -1558,28 +1601,23 @@ struct task_struct {
1558 struct numa_group *numa_group; 1601 struct numa_group *numa_group;
1559 1602
1560 /* 1603 /*
1561 * Exponential decaying average of faults on a per-node basis. 1604 * numa_faults is an array split into four regions:
1562 * Scheduling placement decisions are made based on the these counts. 1605 * faults_memory, faults_cpu, faults_memory_buffer, faults_cpu_buffer
1563 * The values remain static for the duration of a PTE scan 1606 * in this precise order.
1607 *
1608 * faults_memory: Exponential decaying average of faults on a per-node
1609 * basis. Scheduling placement decisions are made based on these
1610 * counts. The values remain static for the duration of a PTE scan.
1611 * faults_cpu: Track the nodes the process was running on when a NUMA
1612 * hinting fault was incurred.
1613 * faults_memory_buffer and faults_cpu_buffer: Record faults per node
1614 * during the current scan window. When the scan completes, the counts
1615 * in faults_memory and faults_cpu decay and these values are copied.
1564 */ 1616 */
1565 unsigned long *numa_faults_memory; 1617 unsigned long *numa_faults;
1566 unsigned long total_numa_faults; 1618 unsigned long total_numa_faults;
1567 1619
1568 /* 1620 /*
1569 * numa_faults_buffer records faults per node during the current
1570 * scan window. When the scan completes, the counts in
1571 * numa_faults_memory decay and these values are copied.
1572 */
1573 unsigned long *numa_faults_buffer_memory;
1574
1575 /*
1576 * Track the nodes the process was running on when a NUMA hinting
1577 * fault was incurred.
1578 */
1579 unsigned long *numa_faults_cpu;
1580 unsigned long *numa_faults_buffer_cpu;
1581
1582 /*
1583 * numa_faults_locality tracks if faults recorded during the last 1621 * numa_faults_locality tracks if faults recorded during the last
1584 * scan window were remote/local. The task scan period is adapted 1622 * scan window were remote/local. The task scan period is adapted
1585 * based on the locality of the faults with different weights 1623 * based on the locality of the faults with different weights
@@ -1645,8 +1683,7 @@ struct task_struct {
1645 /* bitmask and counter of trace recursion */ 1683 /* bitmask and counter of trace recursion */
1646 unsigned long trace_recursion; 1684 unsigned long trace_recursion;
1647#endif /* CONFIG_TRACING */ 1685#endif /* CONFIG_TRACING */
1648#ifdef CONFIG_MEMCG /* memcg uses this to do batch job */ 1686#ifdef CONFIG_MEMCG
1649 unsigned int memcg_kmem_skip_account;
1650 struct memcg_oom_info { 1687 struct memcg_oom_info {
1651 struct mem_cgroup *memcg; 1688 struct mem_cgroup *memcg;
1652 gfp_t gfp_mask; 1689 gfp_t gfp_mask;
@@ -1661,6 +1698,9 @@ struct task_struct {
1661 unsigned int sequential_io; 1698 unsigned int sequential_io;
1662 unsigned int sequential_io_avg; 1699 unsigned int sequential_io_avg;
1663#endif 1700#endif
1701#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
1702 unsigned long task_state_change;
1703#endif
1664}; 1704};
1665 1705
1666/* Future-safe accessor for struct task_struct's cpus_allowed. */ 1706/* Future-safe accessor for struct task_struct's cpus_allowed. */
@@ -2052,6 +2092,10 @@ static inline void tsk_restore_flags(struct task_struct *task,
2052 task->flags |= orig_flags & flags; 2092 task->flags |= orig_flags & flags;
2053} 2093}
2054 2094
2095extern int cpuset_cpumask_can_shrink(const struct cpumask *cur,
2096 const struct cpumask *trial);
2097extern int task_can_attach(struct task_struct *p,
2098 const struct cpumask *cs_cpus_allowed);
2055#ifdef CONFIG_SMP 2099#ifdef CONFIG_SMP
2056extern void do_set_cpus_allowed(struct task_struct *p, 2100extern void do_set_cpus_allowed(struct task_struct *p,
2057 const struct cpumask *new_mask); 2101 const struct cpumask *new_mask);
@@ -2441,6 +2485,10 @@ extern void do_group_exit(int);
2441extern int do_execve(struct filename *, 2485extern int do_execve(struct filename *,
2442 const char __user * const __user *, 2486 const char __user * const __user *,
2443 const char __user * const __user *); 2487 const char __user * const __user *);
2488extern int do_execveat(int, struct filename *,
2489 const char __user * const __user *,
2490 const char __user * const __user *,
2491 int);
2444extern long do_fork(unsigned long, unsigned long, unsigned long, int __user *, int __user *); 2492extern long do_fork(unsigned long, unsigned long, unsigned long, int __user *, int __user *);
2445struct task_struct *fork_idle(int); 2493struct task_struct *fork_idle(int);
2446extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); 2494extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
@@ -2760,7 +2808,7 @@ static inline int signal_pending_state(long state, struct task_struct *p)
2760extern int _cond_resched(void); 2808extern int _cond_resched(void);
2761 2809
2762#define cond_resched() ({ \ 2810#define cond_resched() ({ \
2763 __might_sleep(__FILE__, __LINE__, 0); \ 2811 ___might_sleep(__FILE__, __LINE__, 0); \
2764 _cond_resched(); \ 2812 _cond_resched(); \
2765}) 2813})
2766 2814
@@ -2773,14 +2821,14 @@ extern int __cond_resched_lock(spinlock_t *lock);
2773#endif 2821#endif
2774 2822
2775#define cond_resched_lock(lock) ({ \ 2823#define cond_resched_lock(lock) ({ \
2776 __might_sleep(__FILE__, __LINE__, PREEMPT_LOCK_OFFSET); \ 2824 ___might_sleep(__FILE__, __LINE__, PREEMPT_LOCK_OFFSET);\
2777 __cond_resched_lock(lock); \ 2825 __cond_resched_lock(lock); \
2778}) 2826})
2779 2827
2780extern int __cond_resched_softirq(void); 2828extern int __cond_resched_softirq(void);
2781 2829
2782#define cond_resched_softirq() ({ \ 2830#define cond_resched_softirq() ({ \
2783 __might_sleep(__FILE__, __LINE__, SOFTIRQ_DISABLE_OFFSET); \ 2831 ___might_sleep(__FILE__, __LINE__, SOFTIRQ_DISABLE_OFFSET); \
2784 __cond_resched_softirq(); \ 2832 __cond_resched_softirq(); \
2785}) 2833})
2786 2834