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.h101
1 files changed, 57 insertions, 44 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 471e36d30123..c96140210d1c 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -68,7 +68,7 @@ struct sched_param {
68#include <linux/smp.h> 68#include <linux/smp.h>
69#include <linux/sem.h> 69#include <linux/sem.h>
70#include <linux/signal.h> 70#include <linux/signal.h>
71#include <linux/fs_struct.h> 71#include <linux/path.h>
72#include <linux/compiler.h> 72#include <linux/compiler.h>
73#include <linux/completion.h> 73#include <linux/completion.h>
74#include <linux/pid.h> 74#include <linux/pid.h>
@@ -97,6 +97,7 @@ struct futex_pi_state;
97struct robust_list_head; 97struct robust_list_head;
98struct bio; 98struct bio;
99struct bts_tracer; 99struct bts_tracer;
100struct fs_struct;
100 101
101/* 102/*
102 * List of flags we want to share for kernel threads, 103 * List of flags we want to share for kernel threads,
@@ -393,8 +394,15 @@ extern void arch_unmap_area_topdown(struct mm_struct *, unsigned long);
393 (mm)->hiwater_vm = (mm)->total_vm; \ 394 (mm)->hiwater_vm = (mm)->total_vm; \
394} while (0) 395} while (0)
395 396
396#define get_mm_hiwater_rss(mm) max((mm)->hiwater_rss, get_mm_rss(mm)) 397static inline unsigned long get_mm_hiwater_rss(struct mm_struct *mm)
397#define get_mm_hiwater_vm(mm) max((mm)->hiwater_vm, (mm)->total_vm) 398{
399 return max(mm->hiwater_rss, get_mm_rss(mm));
400}
401
402static inline unsigned long get_mm_hiwater_vm(struct mm_struct *mm)
403{
404 return max(mm->hiwater_vm, mm->total_vm);
405}
398 406
399extern void set_dumpable(struct mm_struct *mm, int value); 407extern void set_dumpable(struct mm_struct *mm, int value);
400extern int get_dumpable(struct mm_struct *mm); 408extern int get_dumpable(struct mm_struct *mm);
@@ -542,25 +550,8 @@ struct signal_struct {
542 550
543 struct list_head cpu_timers[3]; 551 struct list_head cpu_timers[3];
544 552
545 /* job control IDs */
546
547 /*
548 * pgrp and session fields are deprecated.
549 * use the task_session_Xnr and task_pgrp_Xnr routines below
550 */
551
552 union {
553 pid_t pgrp __deprecated;
554 pid_t __pgrp;
555 };
556
557 struct pid *tty_old_pgrp; 553 struct pid *tty_old_pgrp;
558 554
559 union {
560 pid_t session __deprecated;
561 pid_t __session;
562 };
563
564 /* boolean value for session group leader */ 555 /* boolean value for session group leader */
565 int leader; 556 int leader;
566 557
@@ -1002,6 +993,7 @@ struct sched_class {
1002 struct rq *busiest, struct sched_domain *sd, 993 struct rq *busiest, struct sched_domain *sd,
1003 enum cpu_idle_type idle); 994 enum cpu_idle_type idle);
1004 void (*pre_schedule) (struct rq *this_rq, struct task_struct *task); 995 void (*pre_schedule) (struct rq *this_rq, struct task_struct *task);
996 int (*needs_post_schedule) (struct rq *this_rq);
1005 void (*post_schedule) (struct rq *this_rq); 997 void (*post_schedule) (struct rq *this_rq);
1006 void (*task_wake_up) (struct rq *this_rq, struct task_struct *task); 998 void (*task_wake_up) (struct rq *this_rq, struct task_struct *task);
1007 999
@@ -1056,6 +1048,10 @@ struct sched_entity {
1056 u64 last_wakeup; 1048 u64 last_wakeup;
1057 u64 avg_overlap; 1049 u64 avg_overlap;
1058 1050
1051 u64 start_runtime;
1052 u64 avg_wakeup;
1053 u64 nr_migrations;
1054
1059#ifdef CONFIG_SCHEDSTATS 1055#ifdef CONFIG_SCHEDSTATS
1060 u64 wait_start; 1056 u64 wait_start;
1061 u64 wait_max; 1057 u64 wait_max;
@@ -1071,7 +1067,6 @@ struct sched_entity {
1071 u64 exec_max; 1067 u64 exec_max;
1072 u64 slice_max; 1068 u64 slice_max;
1073 1069
1074 u64 nr_migrations;
1075 u64 nr_migrations_cold; 1070 u64 nr_migrations_cold;
1076 u64 nr_failed_migrations_affine; 1071 u64 nr_failed_migrations_affine;
1077 u64 nr_failed_migrations_running; 1072 u64 nr_failed_migrations_running;
@@ -1168,6 +1163,7 @@ struct task_struct {
1168#endif 1163#endif
1169 1164
1170 struct list_head tasks; 1165 struct list_head tasks;
1166 struct plist_node pushable_tasks;
1171 1167
1172 struct mm_struct *mm, *active_mm; 1168 struct mm_struct *mm, *active_mm;
1173 1169
@@ -1179,6 +1175,8 @@ struct task_struct {
1179 /* ??? */ 1175 /* ??? */
1180 unsigned int personality; 1176 unsigned int personality;
1181 unsigned did_exec:1; 1177 unsigned did_exec:1;
1178 unsigned in_execve:1; /* Tell the LSMs that the process is doing an
1179 * execve */
1182 pid_t pid; 1180 pid_t pid;
1183 pid_t tgid; 1181 pid_t tgid;
1184 1182
@@ -1296,6 +1294,11 @@ struct task_struct {
1296/* Protection of (de-)allocation: mm, files, fs, tty, keyrings */ 1294/* Protection of (de-)allocation: mm, files, fs, tty, keyrings */
1297 spinlock_t alloc_lock; 1295 spinlock_t alloc_lock;
1298 1296
1297#ifdef CONFIG_GENERIC_HARDIRQS
1298 /* IRQ handler threads */
1299 struct irqaction *irqaction;
1300#endif
1301
1299 /* Protection of the PI data structures: */ 1302 /* Protection of the PI data structures: */
1300 spinlock_t pi_lock; 1303 spinlock_t pi_lock;
1301 1304
@@ -1459,16 +1462,6 @@ static inline int rt_task(struct task_struct *p)
1459 return rt_prio(p->prio); 1462 return rt_prio(p->prio);
1460} 1463}
1461 1464
1462static inline void set_task_session(struct task_struct *tsk, pid_t session)
1463{
1464 tsk->signal->__session = session;
1465}
1466
1467static inline void set_task_pgrp(struct task_struct *tsk, pid_t pgrp)
1468{
1469 tsk->signal->__pgrp = pgrp;
1470}
1471
1472static inline struct pid *task_pid(struct task_struct *task) 1465static inline struct pid *task_pid(struct task_struct *task)
1473{ 1466{
1474 return task->pids[PIDTYPE_PID].pid; 1467 return task->pids[PIDTYPE_PID].pid;
@@ -1479,6 +1472,11 @@ static inline struct pid *task_tgid(struct task_struct *task)
1479 return task->group_leader->pids[PIDTYPE_PID].pid; 1472 return task->group_leader->pids[PIDTYPE_PID].pid;
1480} 1473}
1481 1474
1475/*
1476 * Without tasklist or rcu lock it is not safe to dereference
1477 * the result of task_pgrp/task_session even if task == current,
1478 * we can race with another thread doing sys_setsid/sys_setpgid.
1479 */
1482static inline struct pid *task_pgrp(struct task_struct *task) 1480static inline struct pid *task_pgrp(struct task_struct *task)
1483{ 1481{
1484 return task->group_leader->pids[PIDTYPE_PGID].pid; 1482 return task->group_leader->pids[PIDTYPE_PGID].pid;
@@ -1504,17 +1502,23 @@ struct pid_namespace;
1504 * 1502 *
1505 * see also pid_nr() etc in include/linux/pid.h 1503 * see also pid_nr() etc in include/linux/pid.h
1506 */ 1504 */
1505pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
1506 struct pid_namespace *ns);
1507 1507
1508static inline pid_t task_pid_nr(struct task_struct *tsk) 1508static inline pid_t task_pid_nr(struct task_struct *tsk)
1509{ 1509{
1510 return tsk->pid; 1510 return tsk->pid;
1511} 1511}
1512 1512
1513pid_t task_pid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns); 1513static inline pid_t task_pid_nr_ns(struct task_struct *tsk,
1514 struct pid_namespace *ns)
1515{
1516 return __task_pid_nr_ns(tsk, PIDTYPE_PID, ns);
1517}
1514 1518
1515static inline pid_t task_pid_vnr(struct task_struct *tsk) 1519static inline pid_t task_pid_vnr(struct task_struct *tsk)
1516{ 1520{
1517 return pid_vnr(task_pid(tsk)); 1521 return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
1518} 1522}
1519 1523
1520 1524
@@ -1531,31 +1535,34 @@ static inline pid_t task_tgid_vnr(struct task_struct *tsk)
1531} 1535}
1532 1536
1533 1537
1534static inline pid_t task_pgrp_nr(struct task_struct *tsk) 1538static inline pid_t task_pgrp_nr_ns(struct task_struct *tsk,
1539 struct pid_namespace *ns)
1535{ 1540{
1536 return tsk->signal->__pgrp; 1541 return __task_pid_nr_ns(tsk, PIDTYPE_PGID, ns);
1537} 1542}
1538 1543
1539pid_t task_pgrp_nr_ns(struct task_struct *tsk, struct pid_namespace *ns);
1540
1541static inline pid_t task_pgrp_vnr(struct task_struct *tsk) 1544static inline pid_t task_pgrp_vnr(struct task_struct *tsk)
1542{ 1545{
1543 return pid_vnr(task_pgrp(tsk)); 1546 return __task_pid_nr_ns(tsk, PIDTYPE_PGID, NULL);
1544} 1547}
1545 1548
1546 1549
1547static inline pid_t task_session_nr(struct task_struct *tsk) 1550static inline pid_t task_session_nr_ns(struct task_struct *tsk,
1551 struct pid_namespace *ns)
1548{ 1552{
1549 return tsk->signal->__session; 1553 return __task_pid_nr_ns(tsk, PIDTYPE_SID, ns);
1550} 1554}
1551 1555
1552pid_t task_session_nr_ns(struct task_struct *tsk, struct pid_namespace *ns);
1553
1554static inline pid_t task_session_vnr(struct task_struct *tsk) 1556static inline pid_t task_session_vnr(struct task_struct *tsk)
1555{ 1557{
1556 return pid_vnr(task_session(tsk)); 1558 return __task_pid_nr_ns(tsk, PIDTYPE_SID, NULL);
1557} 1559}
1558 1560
1561/* obsolete, do not use */
1562static inline pid_t task_pgrp_nr(struct task_struct *tsk)
1563{
1564 return task_pgrp_nr_ns(tsk, &init_pid_ns);
1565}
1559 1566
1560/** 1567/**
1561 * pid_alive - check that a task structure is not stale 1568 * pid_alive - check that a task structure is not stale
@@ -1965,7 +1972,8 @@ extern void mm_release(struct task_struct *, struct mm_struct *);
1965/* Allocate a new mm structure and copy contents from tsk->mm */ 1972/* Allocate a new mm structure and copy contents from tsk->mm */
1966extern struct mm_struct *dup_mm(struct task_struct *tsk); 1973extern struct mm_struct *dup_mm(struct task_struct *tsk);
1967 1974
1968extern int copy_thread(int, unsigned long, unsigned long, unsigned long, struct task_struct *, struct pt_regs *); 1975extern int copy_thread(unsigned long, unsigned long, unsigned long,
1976 struct task_struct *, struct pt_regs *);
1969extern void flush_thread(void); 1977extern void flush_thread(void);
1970extern void exit_thread(void); 1978extern void exit_thread(void);
1971 1979
@@ -2050,6 +2058,11 @@ static inline int thread_group_empty(struct task_struct *p)
2050#define delay_group_leader(p) \ 2058#define delay_group_leader(p) \
2051 (thread_group_leader(p) && !thread_group_empty(p)) 2059 (thread_group_leader(p) && !thread_group_empty(p))
2052 2060
2061static inline int task_detached(struct task_struct *p)
2062{
2063 return p->exit_signal == -1;
2064}
2065
2053/* 2066/*
2054 * Protects ->fs, ->files, ->mm, ->group_info, ->comm, keyring 2067 * Protects ->fs, ->files, ->mm, ->group_info, ->comm, keyring
2055 * subscriptions and synchronises with wait4(). Also used in procfs. Also 2068 * subscriptions and synchronises with wait4(). Also used in procfs. Also