fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / include / linux / sched.h
index 45a8e67..b59c83d 100644 (file)
@@ -24,6 +24,9 @@
 #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 */
 #define CLONE_STOPPED          0x02000000      /* Start in stopped state */
+#define CLONE_NEWUTS           0x04000000      /* New utsname group? */
+#define CLONE_NEWIPC           0x08000000      /* New ipcs */
+#define CLONE_KTHREAD          0x10000000      /* clone a kernel thread */
 
 /*
  * Scheduling policies
@@ -52,7 +55,6 @@ struct sched_param {
 #include <linux/cpumask.h>
 #include <linux/errno.h>
 #include <linux/nodemask.h>
-#include <linux/vs_base.h>
 
 #include <asm/system.h>
 #include <asm/semaphore.h>
@@ -81,6 +83,7 @@ struct sched_param {
 #include <linux/resource.h>
 #include <linux/timer.h>
 #include <linux/hrtimer.h>
+#include <linux/task_io_accounting.h>
 
 #include <asm/processor.h>
 
@@ -93,7 +96,7 @@ extern int print_fatal_signals;
  * 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)
+#define CLONE_KERNEL   (CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_KTHREAD)
 
 /*
  * These are the constant used to fake the fixed-point load-average
@@ -121,7 +124,6 @@ extern unsigned long avenrun[];             /* Load averages */
 
 extern unsigned long total_forks;
 extern int nr_threads;
-extern int last_pid;
 DECLARE_PER_CPU(unsigned long, process_counts);
 extern int nr_processes(void);
 extern unsigned long nr_running(void);
@@ -146,12 +148,13 @@ extern unsigned long weighted_cpuload(const int cpu);
 #define TASK_UNINTERRUPTIBLE   2
 #define TASK_STOPPED           4
 #define TASK_TRACED            8
+#define TASK_ONHOLD            16
 /* in tsk->exit_state */
-#define EXIT_ZOMBIE            16
-#define EXIT_DEAD              32
+#define EXIT_ZOMBIE            32
+#define EXIT_DEAD              64
 /* in tsk->state again */
-#define TASK_NONINTERACTIVE    64
-#define TASK_ONHOLD            128
+#define TASK_NONINTERACTIVE    128
+#define TASK_DEAD              256
 
 #define __set_task_state(tsk, state_value)             \
        do { (tsk)->state = (state_value); } while (0)
@@ -196,7 +199,16 @@ extern void init_idle(struct task_struct *idle, int cpu);
 
 extern cpumask_t nohz_cpu_mask;
 
-extern void show_state(void);
+/*
+ * Only dump TASK_* tasks. (-1 for all tasks)
+ */
+extern void show_state_filter(unsigned long state_filter);
+
+static inline void show_state(void)
+{
+       show_state_filter(-1);
+}
+
 extern void show_regs(struct pt_regs *);
 
 /*
@@ -242,7 +254,7 @@ extern signed long schedule_timeout_interruptible(signed long timeout);
 extern signed long schedule_timeout_uninterruptible(signed long timeout);
 asmlinkage void schedule(void);
 
-struct namespace;
+struct nsproxy;
 
 /* Maximum number of active map areas.. This is a random (large) number */
 #define DEFAULT_MAX_MAP_COUNT  65536
@@ -350,16 +362,24 @@ struct mm_struct {
 
        unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */
 
-       unsigned dumpable:2;
        cpumask_t cpu_vm_mask;
 
        /* Architecture-specific MM context */
        mm_context_t context;
        struct vx_info *mm_vx_info;
 
-       /* Token based thrashing protection. */
-       unsigned long swap_token_time;
-       char recent_pagein;
+       /* Swap token stuff */
+       /*
+        * Last value of global fault stamp as seen by this process.
+        * In other words, this value gives an indication of how long
+        * it has been since this task got the token.
+        * Look at mm/thrash.c
+        */
+       unsigned int faultstamp;
+       unsigned int token_priority;
+       unsigned int last_interval;
+
+       unsigned char dumpable:2;
 
        /* coredumping support */
        int core_waiters;
@@ -432,7 +452,12 @@ struct signal_struct {
        /* job control IDs */
        pid_t pgrp;
        pid_t tty_old_pgrp;
-       pid_t session;
+
+       union {
+               pid_t session __deprecated;
+               pid_t __session;
+       };
+
        /* boolean value for session group leader */
        int leader;
 
@@ -479,7 +504,6 @@ struct signal_struct {
        struct pacct_struct pacct;      /* per-process accounting information */
 #endif
 #ifdef CONFIG_TASKSTATS
-       spinlock_t stats_lock;
        struct taskstats *stats;
 #endif
 };
@@ -519,8 +543,8 @@ struct signal_struct {
 #define rt_prio(prio)          unlikely((prio) < MAX_RT_PRIO)
 #define rt_task(p)             rt_prio((p)->prio)
 #define batch_task(p)          (unlikely((p)->policy == SCHED_BATCH))
-#define has_rt_policy(p) \
-       unlikely((p)->policy != SCHED_NORMAL && (p)->policy != SCHED_BATCH)
+#define is_rt_policy(p)                ((p) != SCHED_NORMAL && (p) != SCHED_BATCH)
+#define has_rt_policy(p)       unlikely(is_rt_policy((p)->policy))
 
 /*
  * Some day this will be a full-fledged user tracking system..
@@ -571,7 +595,7 @@ struct sched_info {
 #endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */
 
 #ifdef CONFIG_SCHEDSTATS
-extern struct file_operations proc_schedstat_operations;
+extern const struct file_operations proc_schedstat_operations;
 #endif /* CONFIG_SCHEDSTATS */
 
 #ifdef CONFIG_TASK_DELAY_ACCT
@@ -639,9 +663,18 @@ enum idle_type
 #define SD_WAKE_BALANCE                64      /* Perform balancing at task wakeup */
 #define SD_SHARE_CPUPOWER      128     /* Domain members share cpu power */
 #define SD_POWERSAVINGS_BALANCE        256     /* Balance for power savings */
+#define SD_SHARE_PKG_RESOURCES 512     /* Domain members share cpu pkg resources */
+#define SD_SERIALIZE           1024    /* Only a single load balancing instance */
 
-#define BALANCE_FOR_POWER      ((sched_mc_power_savings || sched_smt_power_savings) \
-                                ? SD_POWERSAVINGS_BALANCE : 0)
+#define BALANCE_FOR_MC_POWER   \
+       (sched_smt_power_savings ? SD_POWERSAVINGS_BALANCE : 0)
+
+#define BALANCE_FOR_PKG_POWER  \
+       ((sched_mc_power_savings || sched_smt_power_savings) ?  \
+        SD_POWERSAVINGS_BALANCE : 0)
+
+#define test_sd_parent(sd, flag)       ((sd->parent &&         \
+                                        (sd->parent->flags & flag)) ? 1 : 0)
 
 
 struct sched_group {
@@ -658,6 +691,7 @@ struct sched_group {
 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 */
        cpumask_t span;                 /* span of all CPUs in this domain */
        unsigned long min_interval;     /* Minimum balance interval ms */
@@ -725,7 +759,6 @@ extern unsigned int max_cache_size;
 
 
 struct io_context;                     /* See blkdev.h */
-void exit_io_context(void);
 struct cpuset;
 
 #define NGROUPS_SMALL          32
@@ -770,6 +803,7 @@ static inline void prefetch_stack(struct task_struct *t) { }
 struct audit_context;          /* See audit.c */
 struct mempolicy;
 struct pipe_inode_info;
+struct uts_namespace;
 
 enum sleep_type {
        SLEEP_NORMAL,
@@ -785,7 +819,6 @@ struct task_struct {
        struct thread_info *thread_info;
        atomic_t usage;
        unsigned long flags;    /* per process flags, defined below */
-       unsigned long ptrace;
 
        int lock_depth;         /* BKL lock depth */
 
@@ -800,8 +833,9 @@ struct task_struct {
        struct prio_array *array;
 
        unsigned short ioprio;
+#ifdef CONFIG_BLK_DEV_IO_TRACE
        unsigned int btrace_seq;
-
+#endif
        unsigned long sleep_avg;
        unsigned long long timestamp, last_ran;
        unsigned long long sched_time; /* sched_clock time spent running */
@@ -816,12 +850,6 @@ struct task_struct {
 #endif
 
        struct list_head tasks;
-       /*
-        * ptrace_list/ptrace_children forms the list of my children
-        * that were stolen by a ptracer.
-        */
-       struct list_head ptrace_children;
-       struct list_head ptrace_list;
 
        struct mm_struct *mm, *active_mm;
 
@@ -835,16 +863,19 @@ struct task_struct {
        unsigned did_exec:1;
        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,
+        * pointers to parent process, youngest child, younger sibling,
         * older sibling, respectively.  (p->father can be replaced with 
         * p->parent->pid)
         */
-       struct task_struct *real_parent; /* real parent process (when being debugged) */
        struct task_struct *parent;     /* parent process */
        /*
-        * children/sibling forms the list of my children plus the
-        * tasks I'm ptracing.
+        * children/sibling forms the list of my children
         */
        struct list_head children;      /* list of my children */
        struct list_head sibling;       /* linkage in my parent's children list */
@@ -881,6 +912,15 @@ struct task_struct {
        struct key *thread_keyring;     /* keyring private to this thread */
        unsigned char jit_keyring;      /* default keyring to attach requested keys to */
 #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;
        int oomkilladj; /* OOM kill score adjustment (bit shift). */
        char comm[TASK_COMM_LEN]; /* executable name excluding path
                                     - access with [gs]et_task_comm (which lock
@@ -888,16 +928,18 @@ struct task_struct {
                                     - initialized normally by flush_old_exec */
 /* file system info */
        int link_count, total_link_count;
+#ifdef CONFIG_SYSVIPC
 /* ipc stuff */
        struct sysv_sem sysvsem;
+#endif
 /* CPU-specific state of this task */
        struct thread_struct thread;
 /* filesystem information */
        struct fs_struct *fs;
 /* open file information */
        struct files_struct *files;
-/* namespace */
-       struct namespace *namespace;
+/* namespaces */
+       struct nsproxy *nsproxy;
 /* signal handlers */
        struct signal_struct *signal;
        struct sighand_struct *sighand;
@@ -911,11 +953,6 @@ struct task_struct {
        int (*notifier)(void *priv);
        void *notifier_data;
        sigset_t *notifier_mask;
-
-       /* TUX state */
-       void *tux_info;
-       void (*tux_exit)(void);
-
        
        void *security;
        struct audit_context *audit_context;
@@ -929,6 +966,11 @@ struct task_struct {
 
        seccomp_t seccomp;
 
+#ifdef CONFIG_UTRACE
+       struct utrace *utrace;
+       unsigned long utrace_flags;
+#endif
+
 /* Thread group tracking */
        u32 parent_exec_id;
        u32 self_exec_id;
@@ -982,8 +1024,6 @@ struct task_struct {
 
        struct io_context *io_context;
 
-       unsigned long ptrace_message;
-       siginfo_t *last_siginfo; /* For ptrace use.  */
 /*
  * current io wait handle: wait queue entry to use for io waits
  * If this thread is processing aio, this points at the waitqueue
@@ -993,10 +1033,11 @@ struct task_struct {
        wait_queue_t *io_wait;
 /* i/o counters(bytes read/written, #syscalls */
        u64 rchar, wchar, syscr, syscw;
-#if defined(CONFIG_BSD_PROCESS_ACCT)
+       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 */
-       clock_t acct_stimexpd;  /* clock_t-converted stime since last update */
+       cputime_t acct_stimexpd;/* stime since last update */
 #endif
 #ifdef CONFIG_NUMA
        struct mempolicy *mempolicy;
@@ -1018,6 +1059,10 @@ struct task_struct {
        atomic_t fs_excl;       /* holding fs exclusive resources */
        struct rcu_head rcu;
 
+#ifdef CONFIG_PTRACE
+       struct list_head ptracees;
+#endif
+
        /*
         * cache last used pipe for splice
         */
@@ -1025,6 +1070,9 @@ struct task_struct {
 #ifdef CONFIG_TASK_DELAY_ACCT
        struct task_delay_info *delays;
 #endif
+#ifdef CONFIG_FAULT_INJECTION
+       int make_it_fail;
+#endif
 };
 
 static inline pid_t process_group(struct task_struct *tsk)
@@ -1032,6 +1080,41 @@ static inline pid_t process_group(struct task_struct *tsk)
        return tsk->signal->pgrp;
 }
 
+static inline pid_t signal_session(struct signal_struct *sig)
+{
+       return sig->__session;
+}
+
+static inline pid_t process_session(struct task_struct *tsk)
+{
+       return signal_session(tsk->signal);
+}
+
+static inline void set_signal_session(struct signal_struct *sig, pid_t session)
+{
+       sig->__session = session;
+}
+
+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;
+}
+
+static inline struct pid *task_pgrp(struct task_struct *task)
+{
+       return task->group_leader->pids[PIDTYPE_PGID].pid;
+}
+
+static inline struct pid *task_session(struct task_struct *task)
+{
+       return task->group_leader->pids[PIDTYPE_SID].pid;
+}
+
 /**
  * pid_alive - check that a task structure is not stale
  * @p: Task structure to be checked.
@@ -1045,6 +1128,19 @@ static inline int pid_alive(struct task_struct *p)
        return p->pids[PIDTYPE_PID].pid != NULL;
 }
 
+/**
+ * is_init - check if a task structure is init
+ * @tsk: Task structure to be checked.
+ *
+ * Check if a task structure is the first user space task the kernel created.
+ */
+static inline int is_init(struct task_struct *tsk)
+{
+       return tsk->pid == 1;
+}
+
+extern struct pid *cad_pid;
+
 extern void free_task(struct task_struct *tsk);
 #define get_task_struct(tsk) do { atomic_inc(&(tsk)->usage); } while(0)
 
@@ -1063,7 +1159,6 @@ static inline void put_task_struct(struct task_struct *t)
                                        /* Not implemented yet, only for 486*/
 #define PF_STARTING    0x00000002      /* being created */
 #define PF_EXITING     0x00000004      /* getting shut down */
-#define PF_DEAD                0x00000008      /* Dead */
 #define PF_FORKNOEXEC  0x00000040      /* forked but didn't exec */
 #define PF_SUPERPRIV   0x00000100      /* used super-user privileges */
 #define PF_DUMPCORE    0x00000200      /* dumped core */
@@ -1071,7 +1166,6 @@ static inline void put_task_struct(struct task_struct *t)
 #define PF_MEMALLOC    0x00000800      /* Allocating memory */
 #define PF_FLUSHER     0x00001000      /* responsible for disk writeback */
 #define PF_USED_MATH   0x00002000      /* if unset the fpu must be initialized before use */
-#define PF_FREEZE      0x00004000      /* this task is being frozen for suspend now */
 #define PF_NOFREEZE    0x00008000      /* this thread should not be frozen */
 #define PF_FROZEN      0x00010000      /* frozen for system suspend */
 #define PF_FSTRANS     0x00020000      /* inside a filesystem transaction */
@@ -1191,14 +1285,12 @@ extern struct task_struct init_task;
 
 extern struct   mm_struct init_mm;
 
-
 #define find_task_by_real_pid(nr) \
        find_task_by_pid_type(PIDTYPE_REALPID, nr)
 #define find_task_by_pid(nr) \
        find_task_by_pid_type(PIDTYPE_PID, nr)
 
 extern struct task_struct *find_task_by_pid_type(int type, int pid);
-extern void set_special_pids(pid_t session, pid_t pgrp);
 extern void __set_special_pids(pid_t session, pid_t pgrp);
 
 /* per-UID process charging. */
@@ -1213,7 +1305,7 @@ extern void switch_uid(struct user_struct *);
 
 #include <asm/current.h>
 
-extern void do_timer(struct pt_regs *);
+extern void do_timer(unsigned long ticks);
 
 extern int FASTCALL(wake_up_state(struct task_struct * tsk, unsigned int state));
 extern int FASTCALL(wake_up_process(struct task_struct * tsk));
@@ -1255,11 +1347,16 @@ extern int send_sig_info(int, struct siginfo *, struct task_struct *);
 extern int send_group_sig_info(int, struct siginfo *, struct task_struct *);
 extern int force_sigsegv(int, struct task_struct *);
 extern int force_sig_info(int, struct siginfo *, struct task_struct *);
+extern int __kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp);
+extern int kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp);
+extern int kill_pid_info(int sig, struct siginfo *info, struct pid *pid);
+extern int kill_pid_info_as_uid(int, struct siginfo *, struct pid *, uid_t, uid_t, u32);
+extern int kill_pgrp(struct pid *pid, int sig, int priv);
+extern int kill_pid(struct pid *pid, int sig, int priv);
 extern int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp);
 extern int kill_pg_info(int, struct siginfo *, pid_t);
-extern int kill_proc_info(int, struct siginfo *, pid_t);
-extern int kill_proc_info_as_uid(int, struct siginfo *, pid_t, uid_t, uid_t, u32);
 extern void do_notify_parent(struct task_struct *, int);
+extern void do_notify_parent_cldstop(struct task_struct *, int);
 extern void force_sig(int, struct task_struct *);
 extern void force_sig_specific(int, struct task_struct *);
 extern int send_sig(int, struct task_struct *, int);
@@ -1273,6 +1370,11 @@ extern int send_group_sigqueue(int, struct sigqueue *,  struct task_struct *);
 extern int do_sigaction(int, struct k_sigaction *, struct k_sigaction *);
 extern int do_sigaltstack(const stack_t __user *, stack_t __user *, unsigned long);
 
+static inline int kill_cad_pid(int sig, int priv)
+{
+       return kill_pid(cad_pid, sig, priv);
+}
+
 /* These can be the second arg to send_sig_info/send_group_sig_info.  */
 #define SEND_SIG_NOINFO ((struct siginfo *) 0)
 #define SEND_SIG_PRIV  ((struct siginfo *) 1)
@@ -1330,7 +1432,6 @@ extern NORET_TYPE void do_group_exit(int);
 extern void daemonize(const char *, ...);
 extern int allow_signal(int);
 extern int disallow_signal(int);
-extern struct task_struct *child_reaper;
 
 extern int do_execve(char *, char __user * __user *, char __user * __user *, struct pt_regs *);
 extern long do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *);
@@ -1366,6 +1467,17 @@ extern void wait_task_inactive(struct task_struct * p);
 /* de_thread depends on thread_group_leader not being a pid based check */
 #define thread_group_leader(p) (p == p->group_leader)
 
+/* Do to the insanities of de_thread it is possible for a process
+ * to have the pid of the thread group leader without actually being
+ * the thread group leader.  For iteration through the pids in proc
+ * all we care about is that we have a task with the appropriate
+ * pid, we don't actually care if we have the right task.
+ */
+static inline int has_group_leader_pid(struct task_struct *p)
+{
+       return p->pid == p->tgid;
+}
+
 static inline struct task_struct *next_thread(const struct task_struct *p)
 {
        return list_entry(rcu_dereference(p->thread_group.next),
@@ -1564,87 +1676,6 @@ extern int sched_create_sysfs_power_savings_entries(struct sysdev_class *cls);
 
 extern void normalize_rt_tasks(void);
 
-#ifdef CONFIG_PM
-/*
- * Check if a process has been frozen
- */
-static inline int frozen(struct task_struct *p)
-{
-       return p->flags & PF_FROZEN;
-}
-
-/*
- * Check if there is a request to freeze a process
- */
-static inline int freezing(struct task_struct *p)
-{
-       return p->flags & PF_FREEZE;
-}
-
-/*
- * Request that a process be frozen
- * FIXME: SMP problem. We may not modify other process' flags!
- */
-static inline void freeze(struct task_struct *p)
-{
-       p->flags |= PF_FREEZE;
-}
-
-/*
- * Sometimes we may need to cancel the previous 'freeze' request
- */
-static inline void do_not_freeze(struct task_struct *p)
-{
-       p->flags &= ~PF_FREEZE;
-}
-
-/*
- * Wake up a frozen process
- */
-static inline int thaw_process(struct task_struct *p)
-{
-       if (frozen(p)) {
-               p->flags &= ~PF_FROZEN;
-               wake_up_process(p);
-               return 1;
-       }
-       return 0;
-}
-
-/*
- * freezing is complete, mark process as frozen
- */
-static inline void frozen_process(struct task_struct *p)
-{
-       p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN;
-}
-
-extern void refrigerator(void);
-extern int freeze_processes(void);
-extern void thaw_processes(void);
-
-static inline int try_to_freeze(void)
-{
-       if (freezing(current)) {
-               refrigerator();
-               return 1;
-       } else
-               return 0;
-}
-#else
-static inline int frozen(struct task_struct *p) { return 0; }
-static inline int freezing(struct task_struct *p) { return 0; }
-static inline void freeze(struct task_struct *p) { BUG(); }
-static inline int thaw_process(struct task_struct *p) { return 1; }
-static inline void frozen_process(struct task_struct *p) { BUG(); }
-
-static inline void refrigerator(void) {}
-static inline int freeze_processes(void) { BUG(); return 0; }
-static inline void thaw_processes(void) {}
-
-static inline int try_to_freeze(void) { return 0; }
-
-#endif /* CONFIG_PM */
 #endif /* __KERNEL__ */
 
 #endif