1#ifndef _LINUX_SCHED_H
2#define _LINUX_SCHED_H
3
4
5
6
7#define CSIGNAL 0x000000ff
8#define CLONE_VM 0x00000100
9#define CLONE_FS 0x00000200
10#define CLONE_FILES 0x00000400
11#define CLONE_SIGHAND 0x00000800
12#define CLONE_PTRACE 0x00002000
13#define CLONE_VFORK 0x00004000
14#define CLONE_PARENT 0x00008000
15#define CLONE_THREAD 0x00010000
16#define CLONE_NEWNS 0x00020000
17#define CLONE_SYSVSEM 0x00040000
18#define CLONE_SETTLS 0x00080000
19#define CLONE_PARENT_SETTID 0x00100000
20#define CLONE_CHILD_CLEARTID 0x00200000
21#define CLONE_DETACHED 0x00400000
22#define CLONE_UNTRACED 0x00800000
23#define CLONE_CHILD_SETTID 0x01000000
24#define CLONE_STOPPED 0x02000000
25#define CLONE_NEWUTS 0x04000000
26#define CLONE_NEWIPC 0x08000000
27#define CLONE_NEWUSER 0x10000000
28#define CLONE_NEWPID 0x20000000
29#define CLONE_NEWNET 0x40000000
30#define CLONE_IO 0x80000000
31
32
33
34
35#define SCHED_NORMAL 0
36#define SCHED_FIFO 1
37#define SCHED_RR 2
38#define SCHED_BATCH 3
39
40#define SCHED_IDLE 5
41
42#define SCHED_RESET_ON_FORK 0x40000000
43
44#ifdef __KERNEL__
45
46struct sched_param {
47 int sched_priority;
48};
49
50#include <asm/param.h>
51
52#include <linux/capability.h>
53#include <linux/threads.h>
54#include <linux/kernel.h>
55#include <linux/types.h>
56#include <linux/timex.h>
57#include <linux/jiffies.h>
58#include <linux/rbtree.h>
59#include <linux/thread_info.h>
60#include <linux/cpumask.h>
61#include <linux/errno.h>
62#include <linux/nodemask.h>
63#include <linux/mm_types.h>
64
65#include <asm/system.h>
66#include <asm/page.h>
67#include <asm/ptrace.h>
68#include <asm/cputime.h>
69
70#include <linux/smp.h>
71#include <linux/sem.h>
72#include <linux/signal.h>
73#include <linux/path.h>
74#include <linux/compiler.h>
75#include <linux/completion.h>
76#include <linux/pid.h>
77#include <linux/percpu.h>
78#include <linux/topology.h>
79#include <linux/proportions.h>
80#include <linux/seccomp.h>
81#include <linux/rcupdate.h>
82#include <linux/rculist.h>
83#include <linux/rtmutex.h>
84
85#include <linux/time.h>
86#include <linux/param.h>
87#include <linux/resource.h>
88#include <linux/timer.h>
89#include <linux/hrtimer.h>
90#include <linux/task_io_accounting.h>
91#include <linux/kobject.h>
92#include <linux/latencytop.h>
93#include <linux/cred.h>
94
95#include <asm/processor.h>
96
97struct exec_domain;
98struct futex_pi_state;
99struct robust_list_head;
100struct bio;
101struct fs_struct;
102struct bts_context;
103struct perf_event_context;
104
105
106
107
108
109#define CLONE_KERNEL (CLONE_FS | CLONE_FILES | CLONE_SIGHAND)
110
111
112
113
114
115
116
117
118
119
120
121extern unsigned long avenrun[];
122extern void get_avenrun(unsigned long *loads, unsigned long offset, int shift);
123
124#define FSHIFT 11
125#define FIXED_1 (1<<FSHIFT)
126#define LOAD_FREQ (5*HZ+1)
127#define EXP_1 1884
128#define EXP_5 2014
129#define EXP_15 2037
130
131#define CALC_LOAD(load,exp,n) \
132 load *= exp; \
133 load += n*(FIXED_1-exp); \
134 load >>= FSHIFT;
135
136extern unsigned long total_forks;
137extern int nr_threads;
138DECLARE_PER_CPU(unsigned long, process_counts);
139extern int nr_processes(void);
140extern unsigned long nr_running(void);
141extern unsigned long nr_uninterruptible(void);
142extern unsigned long nr_iowait(void);
143extern unsigned long nr_iowait_cpu(void);
144extern unsigned long this_cpu_load(void);
145
146
147extern void calc_global_load(void);
148extern u64 cpu_nr_migrations(int cpu);
149
150extern unsigned long get_parent_ip(unsigned long addr);
151
152struct seq_file;
153struct cfs_rq;
154struct task_group;
155#ifdef CONFIG_SCHED_DEBUG
156extern void proc_sched_show_task(struct task_struct *p, struct seq_file *m);
157extern void proc_sched_set_task(struct task_struct *p);
158extern void
159print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq);
160#else
161static inline void
162proc_sched_show_task(struct task_struct *p, struct seq_file *m)
163{
164}
165static inline void proc_sched_set_task(struct task_struct *p)
166{
167}
168static inline void
169print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
170{
171}
172#endif
173
174extern unsigned long long time_sync_thresh;
175
176
177
178
179
180
181
182
183
184
185
186#define TASK_RUNNING 0
187#define TASK_INTERRUPTIBLE 1
188#define TASK_UNINTERRUPTIBLE 2
189#define __TASK_STOPPED 4
190#define __TASK_TRACED 8
191
192#define EXIT_ZOMBIE 16
193#define EXIT_DEAD 32
194
195#define TASK_DEAD 64
196#define TASK_WAKEKILL 128
197#define TASK_WAKING 256
198
199
200#define TASK_KILLABLE (TASK_WAKEKILL | TASK_UNINTERRUPTIBLE)
201#define TASK_STOPPED (TASK_WAKEKILL | __TASK_STOPPED)
202#define TASK_TRACED (TASK_WAKEKILL | __TASK_TRACED)
203
204
205#define TASK_NORMAL (TASK_INTERRUPTIBLE | TASK_UNINTERRUPTIBLE)
206#define TASK_ALL (TASK_NORMAL | __TASK_STOPPED | __TASK_TRACED)
207
208
209#define TASK_REPORT (TASK_RUNNING | TASK_INTERRUPTIBLE | \
210 TASK_UNINTERRUPTIBLE | __TASK_STOPPED | \
211 __TASK_TRACED)
212
213#define task_is_traced(task) ((task->state & __TASK_TRACED) != 0)
214#define task_is_stopped(task) ((task->state & __TASK_STOPPED) != 0)
215#define task_is_stopped_or_traced(task) \
216 ((task->state & (__TASK_STOPPED | __TASK_TRACED)) != 0)
217#define task_contributes_to_load(task) \
218 ((task->state & TASK_UNINTERRUPTIBLE) != 0 && \
219 (task->flags & PF_FREEZING) == 0)
220
221#define __set_task_state(tsk, state_value) \
222 do { (tsk)->state = (state_value); } while (0)
223#define set_task_state(tsk, state_value) \
224 set_mb((tsk)->state, (state_value))
225
226
227
228
229
230
231
232
233
234
235
236
237#define __set_current_state(state_value) \
238 do { current->state = (state_value); } while (0)
239#define set_current_state(state_value) \
240 set_mb(current->state, (state_value))
241
242
243#define TASK_COMM_LEN 16
244
245#include <linux/spinlock.h>
246
247
248
249
250
251
252
253extern rwlock_t tasklist_lock;
254extern spinlock_t mmlist_lock;
255
256struct task_struct;
257
258extern void sched_init(void);
259extern void sched_init_smp(void);
260extern asmlinkage void schedule_tail(struct task_struct *prev);
261extern void init_idle(struct task_struct *idle, int cpu);
262extern void init_idle_bootup_task(struct task_struct *idle);
263
264extern int runqueue_is_locked(int cpu);
265extern void task_rq_unlock_wait(struct task_struct *p);
266
267extern cpumask_var_t nohz_cpu_mask;
268#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ)
269extern int select_nohz_load_balancer(int cpu);
270extern int get_nohz_load_balancer(void);
271#else
272static inline int select_nohz_load_balancer(int cpu)
273{
274 return 0;
275}
276#endif
277
278
279
280
281extern void show_state_filter(unsigned long state_filter);
282
283static inline void show_state(void)
284{
285 show_state_filter(0);
286}
287
288extern void show_regs(struct pt_regs *);
289
290
291
292
293
294
295extern void show_stack(struct task_struct *task, unsigned long *sp);
296
297void io_schedule(void);
298long io_schedule_timeout(long timeout);
299
300extern void cpu_init (void);
301extern void trap_init(void);
302extern void update_process_times(int user);
303extern void scheduler_tick(void);
304
305extern void sched_show_task(struct task_struct *p);
306
307#ifdef CONFIG_DETECT_SOFTLOCKUP
308extern void softlockup_tick(void);
309extern void touch_softlockup_watchdog(void);
310extern void touch_all_softlockup_watchdogs(void);
311extern int proc_dosoftlockup_thresh(struct ctl_table *table, int write,
312 void __user *buffer,
313 size_t *lenp, loff_t *ppos);
314extern unsigned int softlockup_panic;
315extern int softlockup_thresh;
316#else
317static inline void softlockup_tick(void)
318{
319}
320static inline void touch_softlockup_watchdog(void)
321{
322}
323static inline void touch_all_softlockup_watchdogs(void)
324{
325}
326#endif
327
328#ifdef CONFIG_DETECT_HUNG_TASK
329extern unsigned int sysctl_hung_task_panic;
330extern unsigned long sysctl_hung_task_check_count;
331extern unsigned long sysctl_hung_task_timeout_secs;
332extern unsigned long sysctl_hung_task_warnings;
333extern int proc_dohung_task_timeout_secs(struct ctl_table *table, int write,
334 void __user *buffer,
335 size_t *lenp, loff_t *ppos);
336#endif
337
338
339#define __sched __attribute__((__section__(".sched.text")))
340
341
342extern char __sched_text_start[], __sched_text_end[];
343
344
345extern int in_sched_functions(unsigned long addr);
346
347#define MAX_SCHEDULE_TIMEOUT LONG_MAX
348extern signed long schedule_timeout(signed long timeout);
349extern signed long schedule_timeout_interruptible(signed long timeout);
350extern signed long schedule_timeout_killable(signed long timeout);
351extern signed long schedule_timeout_uninterruptible(signed long timeout);
352asmlinkage void __schedule(void);
353asmlinkage void schedule(void);
354extern int mutex_spin_on_owner(struct mutex *lock, struct thread_info *owner);
355
356struct nsproxy;
357struct user_namespace;
358
359
360
361
362
363
364
365
366
367
368
369
370
371#define MAPCOUNT_ELF_CORE_MARGIN (5)
372#define DEFAULT_MAX_MAP_COUNT (USHORT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
373
374extern int sysctl_max_map_count;
375
376#include <linux/aio.h>
377
378extern unsigned long
379arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
380 unsigned long, unsigned long);
381extern unsigned long
382arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
383 unsigned long len, unsigned long pgoff,
384 unsigned long flags);
385extern void arch_unmap_area(struct mm_struct *, unsigned long);
386extern void arch_unmap_area_topdown(struct mm_struct *, unsigned long);
387
388#if USE_SPLIT_PTLOCKS
389
390
391
392
393#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
394#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
395#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
396#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
397#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
398
399#else
400
401
402
403
404#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
405#define get_mm_counter(mm, member) ((mm)->_##member)
406#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
407#define inc_mm_counter(mm, member) (mm)->_##member++
408#define dec_mm_counter(mm, member) (mm)->_##member--
409
410#endif
411
412#define get_mm_rss(mm) \
413 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
414#define update_hiwater_rss(mm) do { \
415 unsigned long _rss = get_mm_rss(mm); \
416 if ((mm)->hiwater_rss < _rss) \
417 (mm)->hiwater_rss = _rss; \
418} while (0)
419#define update_hiwater_vm(mm) do { \
420 if ((mm)->hiwater_vm < (mm)->total_vm) \
421 (mm)->hiwater_vm = (mm)->total_vm; \
422} while (0)
423
424static inline unsigned long get_mm_hiwater_rss(struct mm_struct *mm)
425{
426 return max(mm->hiwater_rss, get_mm_rss(mm));
427}
428
429static inline void setmax_mm_hiwater_rss(unsigned long *maxrss,
430 struct mm_struct *mm)
431{
432 unsigned long hiwater_rss = get_mm_hiwater_rss(mm);
433
434 if (*maxrss < hiwater_rss)
435 *maxrss = hiwater_rss;
436}
437
438static inline unsigned long get_mm_hiwater_vm(struct mm_struct *mm)
439{
440 return max(mm->hiwater_vm, mm->total_vm);
441}
442
443extern void set_dumpable(struct mm_struct *mm, int value);
444extern int get_dumpable(struct mm_struct *mm);
445
446
447
448#define MMF_DUMPABLE 0
449#define MMF_DUMP_SECURELY 1
450
451#define MMF_DUMPABLE_BITS 2
452#define MMF_DUMPABLE_MASK ((1 << MMF_DUMPABLE_BITS) - 1)
453
454
455#define MMF_DUMP_ANON_PRIVATE 2
456#define MMF_DUMP_ANON_SHARED 3
457#define MMF_DUMP_MAPPED_PRIVATE 4
458#define MMF_DUMP_MAPPED_SHARED 5
459#define MMF_DUMP_ELF_HEADERS 6
460#define MMF_DUMP_HUGETLB_PRIVATE 7
461#define MMF_DUMP_HUGETLB_SHARED 8
462
463#define MMF_DUMP_FILTER_SHIFT MMF_DUMPABLE_BITS
464#define MMF_DUMP_FILTER_BITS 7
465#define MMF_DUMP_FILTER_MASK \
466 (((1 << MMF_DUMP_FILTER_BITS) - 1) << MMF_DUMP_FILTER_SHIFT)
467#define MMF_DUMP_FILTER_DEFAULT \
468 ((1 << MMF_DUMP_ANON_PRIVATE) | (1 << MMF_DUMP_ANON_SHARED) |\
469 (1 << MMF_DUMP_HUGETLB_PRIVATE) | MMF_DUMP_MASK_DEFAULT_ELF)
470
471#ifdef CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS
472# define MMF_DUMP_MASK_DEFAULT_ELF (1 << MMF_DUMP_ELF_HEADERS)
473#else
474# define MMF_DUMP_MASK_DEFAULT_ELF 0
475#endif
476
477#define MMF_VM_MERGEABLE 16
478
479#define MMF_INIT_MASK (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK)
480
481struct sighand_struct {
482 atomic_t count;
483 struct k_sigaction action[_NSIG];
484 spinlock_t siglock;
485 wait_queue_head_t signalfd_wqh;
486};
487
488struct pacct_struct {
489 int ac_flag;
490 long ac_exitcode;
491 unsigned long ac_mem;
492 cputime_t ac_utime, ac_stime;
493 unsigned long ac_minflt, ac_majflt;
494};
495
496struct cpu_itimer {
497 cputime_t expires;
498 cputime_t incr;
499 u32 error;
500 u32 incr_error;
501};
502
503
504
505
506
507
508
509
510
511
512
513
514struct task_cputime {
515 cputime_t utime;
516 cputime_t stime;
517 unsigned long long sum_exec_runtime;
518};
519
520#define prof_exp stime
521#define virt_exp utime
522#define sched_exp sum_exec_runtime
523
524#define INIT_CPUTIME \
525 (struct task_cputime) { \
526 .utime = cputime_zero, \
527 .stime = cputime_zero, \
528 .sum_exec_runtime = 0, \
529 }
530
531
532
533
534
535
536
537
538#define INIT_PREEMPT_COUNT (1 + PREEMPT_ACTIVE)
539
540
541
542
543
544
545
546
547
548
549
550struct thread_group_cputimer {
551 struct task_cputime cputime;
552 int running;
553 spinlock_t lock;
554};
555
556
557
558
559
560
561
562
563struct signal_struct {
564 atomic_t count;
565 atomic_t live;
566
567 wait_queue_head_t wait_chldexit;
568
569
570 struct task_struct *curr_target;
571
572
573 struct sigpending shared_pending;
574
575
576 int group_exit_code;
577
578
579
580
581
582 int notify_count;
583 struct task_struct *group_exit_task;
584
585
586 int group_stop_count;
587 unsigned int flags;
588
589
590 struct list_head posix_timers;
591
592
593 struct hrtimer real_timer;
594 struct pid *leader_pid;
595 ktime_t it_real_incr;
596
597
598
599
600
601
602 struct cpu_itimer it[2];
603
604
605
606
607
608 struct thread_group_cputimer cputimer;
609
610
611 struct task_cputime cputime_expires;
612
613 struct list_head cpu_timers[3];
614
615 struct pid *tty_old_pgrp;
616
617
618 int leader;
619
620 struct tty_struct *tty;
621
622
623
624
625
626
627
628 cputime_t utime, stime, cutime, cstime;
629 cputime_t gtime;
630 cputime_t cgtime;
631 unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;
632 unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
633 unsigned long inblock, oublock, cinblock, coublock;
634 unsigned long maxrss, cmaxrss;
635 struct task_io_accounting ioac;
636
637
638
639
640
641
642
643 unsigned long long sum_sched_runtime;
644
645
646
647
648
649
650
651
652
653
654 struct rlimit rlim[RLIM_NLIMITS];
655
656#ifdef CONFIG_BSD_PROCESS_ACCT
657 struct pacct_struct pacct;
658#endif
659#ifdef CONFIG_TASKSTATS
660 struct taskstats *stats;
661#endif
662#ifdef CONFIG_AUDIT
663 unsigned audit_tty;
664 struct tty_audit_buf *tty_audit_buf;
665#endif
666
667 int oom_adj;
668};
669
670
671#ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW
672# define __ARCH_WANT_UNLOCKED_CTXSW
673#endif
674
675
676
677
678#define SIGNAL_STOP_STOPPED 0x00000001
679#define SIGNAL_STOP_DEQUEUED 0x00000002
680#define SIGNAL_STOP_CONTINUED 0x00000004
681#define SIGNAL_GROUP_EXIT 0x00000008
682
683
684
685#define SIGNAL_CLD_STOPPED 0x00000010
686#define SIGNAL_CLD_CONTINUED 0x00000020
687#define SIGNAL_CLD_MASK (SIGNAL_CLD_STOPPED|SIGNAL_CLD_CONTINUED)
688
689#define SIGNAL_UNKILLABLE 0x00000040
690
691
692static inline int signal_group_exit(const struct signal_struct *sig)
693{
694 return (sig->flags & SIGNAL_GROUP_EXIT) ||
695 (sig->group_exit_task != NULL);
696}
697
698
699
700
701struct user_struct {
702 atomic_t __count;
703 atomic_t processes;
704 atomic_t files;
705 atomic_t sigpending;
706#ifdef CONFIG_INOTIFY_USER
707 atomic_t inotify_watches;
708 atomic_t inotify_devs;
709#endif
710#ifdef CONFIG_EPOLL
711 atomic_t epoll_watches;
712#endif
713#ifdef CONFIG_POSIX_MQUEUE
714
715 unsigned long mq_bytes;
716#endif
717 unsigned long locked_shm;
718
719#ifdef CONFIG_KEYS
720 struct key *uid_keyring;
721 struct key *session_keyring;
722#endif
723
724
725 struct hlist_node uidhash_node;
726 uid_t uid;
727 struct user_namespace *user_ns;
728
729#ifdef CONFIG_USER_SCHED
730 struct task_group *tg;
731#ifdef CONFIG_SYSFS
732 struct kobject kobj;
733 struct delayed_work work;
734#endif
735#endif
736
737#ifdef CONFIG_PERF_EVENTS
738 atomic_long_t locked_vm;
739#endif
740};
741
742extern int uids_sysfs_init(void);
743
744extern struct user_struct *find_user(uid_t);
745
746extern struct user_struct root_user;
747#define INIT_USER (&root_user)
748
749
750struct backing_dev_info;
751struct reclaim_state;
752
753#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
754struct sched_info {
755
756 unsigned long pcount;
757 unsigned long long run_delay;
758
759
760 unsigned long long last_arrival,
761 last_queued;
762#ifdef CONFIG_SCHEDSTATS
763
764 unsigned int bkl_count;
765#endif
766};
767#endif
768
769#ifdef CONFIG_TASK_DELAY_ACCT
770struct task_delay_info {
771 spinlock_t lock;
772 unsigned int flags;
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789 struct timespec blkio_start, blkio_end;
790 u64 blkio_delay;
791 u64 swapin_delay;
792 u32 blkio_count;
793
794 u32 swapin_count;
795
796
797 struct timespec freepages_start, freepages_end;
798 u64 freepages_delay;
799 u32 freepages_count;
800};
801#endif
802
803static inline int sched_info_on(void)
804{
805#ifdef CONFIG_SCHEDSTATS
806 return 1;
807#elif defined(CONFIG_TASK_DELAY_ACCT)
808 extern int delayacct_on;
809 return delayacct_on;
810#else
811 return 0;
812#endif
813}
814
815enum cpu_idle_type {
816 CPU_IDLE,
817 CPU_NOT_IDLE,
818 CPU_NEWLY_IDLE,
819 CPU_MAX_IDLE_TYPES
820};
821
822
823
824
825
826
827
828
829#define SCHED_LOAD_SHIFT 10
830#define SCHED_LOAD_SCALE (1L << SCHED_LOAD_SHIFT)
831
832#define SCHED_LOAD_SCALE_FUZZ SCHED_LOAD_SCALE
833
834#ifdef CONFIG_SMP
835#define SD_LOAD_BALANCE 0x0001
836#define SD_BALANCE_NEWIDLE 0x0002
837#define SD_BALANCE_EXEC 0x0004
838#define SD_BALANCE_FORK 0x0008
839#define SD_BALANCE_WAKE 0x0010
840#define SD_WAKE_AFFINE 0x0020
841#define SD_PREFER_LOCAL 0x0040
842#define SD_SHARE_CPUPOWER 0x0080
843#define SD_POWERSAVINGS_BALANCE 0x0100
844#define SD_SHARE_PKG_RESOURCES 0x0200
845#define SD_SERIALIZE 0x0400
846
847#define SD_PREFER_SIBLING 0x1000
848
849enum powersavings_balance_level {
850 POWERSAVINGS_BALANCE_NONE = 0,
851 POWERSAVINGS_BALANCE_BASIC,
852
853
854 POWERSAVINGS_BALANCE_WAKEUP,
855
856
857 MAX_POWERSAVINGS_BALANCE_LEVELS
858};
859
860extern int sched_mc_power_savings, sched_smt_power_savings;
861
862static inline int sd_balance_for_mc_power(void)
863{
864 if (sched_smt_power_savings)
865 return SD_POWERSAVINGS_BALANCE;
866
867 return SD_PREFER_SIBLING;
868}
869
870static inline int sd_balance_for_package_power(void)
871{
872 if (sched_mc_power_savings | sched_smt_power_savings)
873 return SD_POWERSAVINGS_BALANCE;
874
875 return SD_PREFER_SIBLING;
876}
877
878
879
880
881
882
883
884static inline int sd_power_saving_flags(void)
885{
886 if (sched_mc_power_savings | sched_smt_power_savings)
887 return SD_BALANCE_NEWIDLE;
888
889 return 0;
890}
891
892struct sched_group {
893 struct sched_group *next;
894
895
896
897
898
899 unsigned int cpu_power;
900
901
902
903
904
905
906
907
908
909
910
911 unsigned long cpumask[0];
912};
913
914static inline struct cpumask *sched_group_cpus(struct sched_group *sg)
915{
916 return to_cpumask(sg->cpumask);
917}
918
919enum sched_domain_level {
920 SD_LV_NONE = 0,
921 SD_LV_SIBLING,
922 SD_LV_MC,
923 SD_LV_CPU,
924 SD_LV_NODE,
925 SD_LV_ALLNODES,
926 SD_LV_MAX
927};
928
929struct sched_domain_attr {
930 int relax_domain_level;
931};
932
933#define SD_ATTR_INIT (struct sched_domain_attr) { \
934 .relax_domain_level = -1, \
935}
936
937struct sched_domain {
938
939 struct sched_domain *parent;
940 struct sched_domain *child;
941 struct sched_group *groups;
942 unsigned long min_interval;
943 unsigned long max_interval;
944 unsigned int busy_factor;
945 unsigned int imbalance_pct;
946 unsigned int cache_nice_tries;
947 unsigned int busy_idx;
948 unsigned int idle_idx;
949 unsigned int newidle_idx;
950 unsigned int wake_idx;
951 unsigned int forkexec_idx;
952 unsigned int smt_gain;
953 int flags;
954 enum sched_domain_level level;
955
956
957 unsigned long last_balance;
958 unsigned int balance_interval;
959 unsigned int nr_balance_failed;
960
961 u64 last_update;
962
963#ifdef CONFIG_SCHEDSTATS
964
965 unsigned int lb_count[CPU_MAX_IDLE_TYPES];
966 unsigned int lb_failed[CPU_MAX_IDLE_TYPES];
967 unsigned int lb_balanced[CPU_MAX_IDLE_TYPES];
968 unsigned int lb_imbalance[CPU_MAX_IDLE_TYPES];
969 unsigned int lb_gained[CPU_MAX_IDLE_TYPES];
970 unsigned int lb_hot_gained[CPU_MAX_IDLE_TYPES];
971 unsigned int lb_nobusyg[CPU_MAX_IDLE_TYPES];
972 unsigned int lb_nobusyq[CPU_MAX_IDLE_TYPES];
973
974
975 unsigned int alb_count;
976 unsigned int alb_failed;
977 unsigned int alb_pushed;
978
979
980 unsigned int sbe_count;
981 unsigned int sbe_balanced;
982 unsigned int sbe_pushed;
983
984
985 unsigned int sbf_count;
986 unsigned int sbf_balanced;
987 unsigned int sbf_pushed;
988
989
990 unsigned int ttwu_wake_remote;
991 unsigned int ttwu_move_affine;
992 unsigned int ttwu_move_balance;
993#endif
994#ifdef CONFIG_SCHED_DEBUG
995 char *name;
996#endif
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008 unsigned long span[0];
1009};
1010
1011static inline struct cpumask *sched_domain_span(struct sched_domain *sd)
1012{
1013 return to_cpumask(sd->span);
1014}
1015
1016extern void partition_sched_domains(int ndoms_new, struct cpumask *doms_new,
1017 struct sched_domain_attr *dattr_new);
1018
1019
1020static inline int test_sd_parent(struct sched_domain *sd, int flag)
1021{
1022 if (sd->parent && (sd->parent->flags & flag))
1023 return 1;
1024
1025 return 0;
1026}
1027
1028unsigned long default_scale_freq_power(struct sched_domain *sd, int cpu);
1029unsigned long default_scale_smt_power(struct sched_domain *sd, int cpu);
1030
1031#else
1032
1033struct sched_domain_attr;
1034
1035static inline void
1036partition_sched_domains(int ndoms_new, struct cpumask *doms_new,
1037 struct sched_domain_attr *dattr_new)
1038{
1039}
1040#endif
1041
1042
1043struct io_context;
1044
1045
1046#ifdef ARCH_HAS_PREFETCH_SWITCH_STACK
1047extern void prefetch_stack(struct task_struct *t);
1048#else
1049static inline void prefetch_stack(struct task_struct *t) { }
1050#endif
1051
1052struct audit_context;
1053struct mempolicy;
1054struct pipe_inode_info;
1055struct uts_namespace;
1056
1057struct rq;
1058struct sched_domain;
1059
1060
1061
1062
1063#define WF_SYNC 0x01
1064#define WF_FORK 0x02
1065
1066struct sched_class {
1067 const struct sched_class *next;
1068
1069 void (*enqueue_task) (struct rq *rq, struct task_struct *p, int wakeup);
1070 void (*dequeue_task) (struct rq *rq, struct task_struct *p, int sleep);
1071 void (*yield_task) (struct rq *rq);
1072
1073 void (*check_preempt_curr) (struct rq *rq, struct task_struct *p, int flags);
1074
1075 struct task_struct * (*pick_next_task) (struct rq *rq);
1076 void (*put_prev_task) (struct rq *rq, struct task_struct *p);
1077
1078#ifdef CONFIG_SMP
1079 int (*select_task_rq)(struct task_struct *p, int sd_flag, int flags);
1080
1081 unsigned long (*load_balance) (struct rq *this_rq, int this_cpu,
1082 struct rq *busiest, unsigned long max_load_move,
1083 struct sched_domain *sd, enum cpu_idle_type idle,
1084 int *all_pinned, int *this_best_prio);
1085
1086 int (*move_one_task) (struct rq *this_rq, int this_cpu,
1087 struct rq *busiest, struct sched_domain *sd,
1088 enum cpu_idle_type idle);
1089 void (*pre_schedule) (struct rq *this_rq, struct task_struct *task);
1090 void (*post_schedule) (struct rq *this_rq);
1091 void (*task_wake_up) (struct rq *this_rq, struct task_struct *task);
1092
1093 void (*set_cpus_allowed)(struct task_struct *p,
1094 const struct cpumask *newmask);
1095
1096 void (*rq_online)(struct rq *rq);
1097 void (*rq_offline)(struct rq *rq);
1098#endif
1099
1100 void (*set_curr_task) (struct rq *rq);
1101 void (*task_tick) (struct rq *rq, struct task_struct *p, int queued);
1102 void (*task_new) (struct rq *rq, struct task_struct *p);
1103
1104 void (*switched_from) (struct rq *this_rq, struct task_struct *task,
1105 int running);
1106 void (*switched_to) (struct rq *this_rq, struct task_struct *task,
1107 int running);
1108 void (*prio_changed) (struct rq *this_rq, struct task_struct *task,
1109 int oldprio, int running);
1110
1111 unsigned int (*get_rr_interval) (struct task_struct *task);
1112
1113#ifdef CONFIG_FAIR_GROUP_SCHED
1114 void (*moved_group) (struct task_struct *p);
1115#endif
1116};
1117
1118struct load_weight {
1119 unsigned long weight, inv_weight;
1120};
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132struct sched_entity {
1133 struct load_weight load;
1134 struct rb_node run_node;
1135 struct list_head group_node;
1136 unsigned int on_rq;
1137
1138 u64 exec_start;
1139 u64 sum_exec_runtime;
1140 u64 vruntime;
1141 u64 prev_sum_exec_runtime;
1142
1143 u64 last_wakeup;
1144 u64 avg_overlap;
1145
1146 u64 nr_migrations;
1147
1148 u64 start_runtime;
1149 u64 avg_wakeup;
1150
1151 u64 avg_running;
1152
1153#ifdef CONFIG_SCHEDSTATS
1154 u64 wait_start;
1155 u64 wait_max;
1156 u64 wait_count;
1157 u64 wait_sum;
1158 u64 iowait_count;
1159 u64 iowait_sum;
1160
1161 u64 sleep_start;
1162 u64 sleep_max;
1163 s64 sum_sleep_runtime;
1164
1165 u64 block_start;
1166 u64 block_max;
1167 u64 exec_max;
1168 u64 slice_max;
1169
1170 u64 nr_migrations_cold;
1171 u64 nr_failed_migrations_affine;
1172 u64 nr_failed_migrations_running;
1173 u64 nr_failed_migrations_hot;
1174 u64 nr_forced_migrations;
1175 u64 nr_forced2_migrations;
1176
1177 u64 nr_wakeups;
1178 u64 nr_wakeups_sync;
1179 u64 nr_wakeups_migrate;
1180 u64 nr_wakeups_local;
1181 u64 nr_wakeups_remote;
1182 u64 nr_wakeups_affine;
1183 u64 nr_wakeups_affine_attempts;
1184 u64 nr_wakeups_passive;
1185 u64 nr_wakeups_idle;
1186#endif
1187
1188#ifdef CONFIG_FAIR_GROUP_SCHED
1189 struct sched_entity *parent;
1190
1191 struct cfs_rq *cfs_rq;
1192
1193 struct cfs_rq *my_q;
1194#endif
1195};
1196
1197struct sched_rt_entity {
1198 struct list_head run_list;
1199 unsigned long timeout;
1200 unsigned int time_slice;
1201 int nr_cpus_allowed;
1202
1203 struct sched_rt_entity *back;
1204#ifdef CONFIG_RT_GROUP_SCHED
1205 struct sched_rt_entity *parent;
1206
1207 struct rt_rq *rt_rq;
1208
1209 struct rt_rq *my_q;
1210#endif
1211};
1212
1213struct rcu_node;
1214
1215struct task_struct {
1216 volatile long state;
1217 void *stack;
1218 atomic_t usage;
1219 unsigned int flags;
1220 unsigned int ptrace;
1221
1222 int lock_depth;
1223
1224#ifdef CONFIG_SMP
1225#ifdef __ARCH_WANT_UNLOCKED_CTXSW
1226 int oncpu;
1227#endif
1228#endif
1229
1230 int prio, static_prio, normal_prio;
1231 unsigned int rt_priority;
1232 const struct sched_class *sched_class;
1233 struct sched_entity se;
1234 struct sched_rt_entity rt;
1235
1236#ifdef CONFIG_PREEMPT_NOTIFIERS
1237
1238 struct hlist_head preempt_notifiers;
1239#endif
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249 unsigned char fpu_counter;
1250#ifdef CONFIG_BLK_DEV_IO_TRACE
1251 unsigned int btrace_seq;
1252#endif
1253
1254 unsigned int policy;
1255 cpumask_t cpus_allowed;
1256
1257#ifdef CONFIG_TREE_PREEMPT_RCU
1258 int rcu_read_lock_nesting;
1259 char rcu_read_unlock_special;
1260 struct rcu_node *rcu_blocked_node;
1261 struct list_head rcu_node_entry;
1262#endif
1263
1264#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
1265 struct sched_info sched_info;
1266#endif
1267
1268 struct list_head tasks;
1269 struct plist_node pushable_tasks;
1270
1271 struct mm_struct *mm, *active_mm;
1272
1273
1274 int exit_state;
1275 int exit_code, exit_signal;
1276 int pdeath_signal;
1277
1278 unsigned int personality;
1279 unsigned did_exec:1;
1280 unsigned in_execve:1;
1281
1282 unsigned in_iowait:1;
1283
1284
1285
1286 unsigned sched_reset_on_fork:1;
1287
1288 pid_t pid;
1289 pid_t tgid;
1290
1291#ifdef CONFIG_CC_STACKPROTECTOR
1292
1293 unsigned long stack_canary;
1294#endif
1295
1296
1297
1298
1299
1300
1301 struct task_struct *real_parent;
1302 struct task_struct *parent;
1303
1304
1305
1306 struct list_head children;
1307 struct list_head sibling;
1308 struct task_struct *group_leader;
1309
1310
1311
1312
1313
1314
1315 struct list_head ptraced;
1316 struct list_head ptrace_entry;
1317
1318
1319
1320
1321
1322 struct bts_context *bts;
1323
1324
1325 struct pid_link pids[PIDTYPE_MAX];
1326 struct list_head thread_group;
1327
1328 struct completion *vfork_done;
1329 int __user *set_child_tid;
1330 int __user *clear_child_tid;
1331
1332 cputime_t utime, stime, utimescaled, stimescaled;
1333 cputime_t gtime;
1334 cputime_t prev_utime, prev_stime;
1335 unsigned long nvcsw, nivcsw;
1336 struct timespec start_time;
1337 struct timespec real_start_time;
1338
1339 unsigned long min_flt, maj_flt;
1340
1341 struct task_cputime cputime_expires;
1342 struct list_head cpu_timers[3];
1343
1344
1345 const struct cred *real_cred;
1346
1347 const struct cred *cred;
1348
1349 struct mutex cred_guard_mutex;
1350
1351
1352 struct cred *replacement_session_keyring;
1353
1354 char comm[TASK_COMM_LEN];
1355
1356
1357
1358
1359 int link_count, total_link_count;
1360#ifdef CONFIG_SYSVIPC
1361
1362 struct sysv_sem sysvsem;
1363#endif
1364#ifdef CONFIG_DETECT_HUNG_TASK
1365
1366 unsigned long last_switch_count;
1367#endif
1368
1369 struct thread_struct thread;
1370
1371 struct fs_struct *fs;
1372
1373 struct files_struct *files;
1374
1375 struct nsproxy *nsproxy;
1376
1377 struct signal_struct *signal;
1378 struct sighand_struct *sighand;
1379
1380 sigset_t blocked, real_blocked;
1381 sigset_t saved_sigmask;
1382 struct sigpending pending;
1383
1384 unsigned long sas_ss_sp;
1385 size_t sas_ss_size;
1386 int (*notifier)(void *priv);
1387 void *notifier_data;
1388 sigset_t *notifier_mask;
1389 struct audit_context *audit_context;
1390#ifdef CONFIG_AUDITSYSCALL
1391 uid_t loginuid;
1392 unsigned int sessionid;
1393#endif
1394 seccomp_t seccomp;
1395
1396
1397 u32 parent_exec_id;
1398 u32 self_exec_id;
1399
1400
1401 spinlock_t alloc_lock;
1402
1403#ifdef CONFIG_GENERIC_HARDIRQS
1404
1405 struct irqaction *irqaction;
1406#endif
1407
1408
1409 spinlock_t pi_lock;
1410
1411#ifdef CONFIG_RT_MUTEXES
1412
1413 struct plist_head pi_waiters;
1414
1415 struct rt_mutex_waiter *pi_blocked_on;
1416#endif
1417
1418#ifdef CONFIG_DEBUG_MUTEXES
1419
1420 struct mutex_waiter *blocked_on;
1421#endif
1422#ifdef CONFIG_TRACE_IRQFLAGS
1423 unsigned int irq_events;
1424 int hardirqs_enabled;
1425 unsigned long hardirq_enable_ip;
1426 unsigned int hardirq_enable_event;
1427 unsigned long hardirq_disable_ip;
1428 unsigned int hardirq_disable_event;
1429 int softirqs_enabled;
1430 unsigned long softirq_disable_ip;
1431 unsigned int softirq_disable_event;
1432 unsigned long softirq_enable_ip;
1433 unsigned int softirq_enable_event;
1434 int hardirq_context;
1435 int softirq_context;
1436#endif
1437#ifdef CONFIG_LOCKDEP
1438# define MAX_LOCK_DEPTH 48UL
1439 u64 curr_chain_key;
1440 int lockdep_depth;
1441 unsigned int lockdep_recursion;
1442 struct held_lock held_locks[MAX_LOCK_DEPTH];
1443 gfp_t lockdep_reclaim_gfp;
1444#endif
1445
1446
1447 void *journal_info;
1448
1449
1450 struct bio *bio_list, **bio_tail;
1451
1452
1453 struct reclaim_state *reclaim_state;
1454
1455 struct backing_dev_info *backing_dev_info;
1456
1457 struct io_context *io_context;
1458
1459 unsigned long ptrace_message;
1460 siginfo_t *last_siginfo;
1461 struct task_io_accounting ioac;
1462#if defined(CONFIG_TASK_XACCT)
1463 u64 acct_rss_mem1;
1464 u64 acct_vm_mem1;
1465 cputime_t acct_timexpd;
1466#endif
1467#ifdef CONFIG_CPUSETS
1468 nodemask_t mems_allowed;
1469 int cpuset_mem_spread_rotor;
1470#endif
1471#ifdef CONFIG_CGROUPS
1472
1473 struct css_set *cgroups;
1474
1475 struct list_head cg_list;
1476#endif
1477#ifdef CONFIG_FUTEX
1478 struct robust_list_head __user *robust_list;
1479#ifdef CONFIG_COMPAT
1480 struct compat_robust_list_head __user *compat_robust_list;
1481#endif
1482 struct list_head pi_state_list;
1483 struct futex_pi_state *pi_state_cache;
1484#endif
1485#ifdef CONFIG_PERF_EVENTS
1486 struct perf_event_context *perf_event_ctxp;
1487 struct mutex perf_event_mutex;
1488 struct list_head perf_event_list;
1489#endif
1490#ifdef CONFIG_NUMA
1491 struct mempolicy *mempolicy;
1492 short il_next;
1493#endif
1494 atomic_t fs_excl;
1495 struct rcu_head rcu;
1496
1497
1498
1499
1500 struct pipe_inode_info *splice_pipe;
1501#ifdef CONFIG_TASK_DELAY_ACCT
1502 struct task_delay_info *delays;
1503#endif
1504#ifdef CONFIG_FAULT_INJECTION
1505 int make_it_fail;
1506#endif
1507 struct prop_local_single dirties;
1508#ifdef CONFIG_LATENCYTOP
1509 int latency_record_count;
1510 struct latency_record latency_record[LT_SAVECOUNT];
1511#endif
1512
1513
1514
1515
1516 unsigned long timer_slack_ns;
1517 unsigned long default_timer_slack_ns;
1518
1519 struct list_head *scm_work_list;
1520#ifdef CONFIG_FUNCTION_GRAPH_TRACER
1521
1522 int curr_ret_stack;
1523
1524 struct ftrace_ret_stack *ret_stack;
1525
1526 unsigned long long ftrace_timestamp;
1527
1528
1529
1530
1531 atomic_t trace_overrun;
1532
1533 atomic_t tracing_graph_pause;
1534#endif
1535#ifdef CONFIG_TRACING
1536
1537 unsigned long trace;
1538
1539 unsigned long trace_recursion;
1540#endif
1541 unsigned long stack_start;
1542};
1543
1544
1545#define tsk_cpumask(tsk) (&(tsk)->cpus_allowed)
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560#define MAX_USER_RT_PRIO 100
1561#define MAX_RT_PRIO MAX_USER_RT_PRIO
1562
1563#define MAX_PRIO (MAX_RT_PRIO + 40)
1564#define DEFAULT_PRIO (MAX_RT_PRIO + 20)
1565
1566static inline int rt_prio(int prio)
1567{
1568 if (unlikely(prio < MAX_RT_PRIO))
1569 return 1;
1570 return 0;
1571}
1572
1573static inline int rt_task(struct task_struct *p)
1574{
1575 return rt_prio(p->prio);
1576}
1577
1578static inline struct pid *task_pid(struct task_struct *task)
1579{
1580 return task->pids[PIDTYPE_PID].pid;
1581}
1582
1583static inline struct pid *task_tgid(struct task_struct *task)
1584{
1585 return task->group_leader->pids[PIDTYPE_PID].pid;
1586}
1587
1588
1589
1590
1591
1592
1593static inline struct pid *task_pgrp(struct task_struct *task)
1594{
1595 return task->group_leader->pids[PIDTYPE_PGID].pid;
1596}
1597
1598static inline struct pid *task_session(struct task_struct *task)
1599{
1600 return task->group_leader->pids[PIDTYPE_SID].pid;
1601}
1602
1603struct pid_namespace;
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
1619 struct pid_namespace *ns);
1620
1621static inline pid_t task_pid_nr(struct task_struct *tsk)
1622{
1623 return tsk->pid;
1624}
1625
1626static inline pid_t task_pid_nr_ns(struct task_struct *tsk,
1627 struct pid_namespace *ns)
1628{
1629 return __task_pid_nr_ns(tsk, PIDTYPE_PID, ns);
1630}
1631
1632static inline pid_t task_pid_vnr(struct task_struct *tsk)
1633{
1634 return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
1635}
1636
1637
1638static inline pid_t task_tgid_nr(struct task_struct *tsk)
1639{
1640 return tsk->tgid;
1641}
1642
1643pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns);
1644
1645static inline pid_t task_tgid_vnr(struct task_struct *tsk)
1646{
1647 return pid_vnr(task_tgid(tsk));
1648}
1649
1650
1651static inline pid_t task_pgrp_nr_ns(struct task_struct *tsk,
1652 struct pid_namespace *ns)
1653{
1654 return __task_pid_nr_ns(tsk, PIDTYPE_PGID, ns);
1655}
1656
1657static inline pid_t task_pgrp_vnr(struct task_struct *tsk)
1658{
1659 return __task_pid_nr_ns(tsk, PIDTYPE_PGID, NULL);
1660}
1661
1662
1663static inline pid_t task_session_nr_ns(struct task_struct *tsk,
1664 struct pid_namespace *ns)
1665{
1666 return __task_pid_nr_ns(tsk, PIDTYPE_SID, ns);
1667}
1668
1669static inline pid_t task_session_vnr(struct task_struct *tsk)
1670{
1671 return __task_pid_nr_ns(tsk, PIDTYPE_SID, NULL);
1672}
1673
1674
1675static inline pid_t task_pgrp_nr(struct task_struct *tsk)
1676{
1677 return task_pgrp_nr_ns(tsk, &init_pid_ns);
1678}
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688static inline int pid_alive(struct task_struct *p)
1689{
1690 return p->pids[PIDTYPE_PID].pid != NULL;
1691}
1692
1693
1694
1695
1696
1697
1698
1699static inline int is_global_init(struct task_struct *tsk)
1700{
1701 return tsk->pid == 1;
1702}
1703
1704
1705
1706
1707
1708extern int is_container_init(struct task_struct *tsk);
1709
1710extern struct pid *cad_pid;
1711
1712extern void free_task(struct task_struct *tsk);
1713#define get_task_struct(tsk) do { atomic_inc(&(tsk)->usage); } while(0)
1714
1715extern void __put_task_struct(struct task_struct *t);
1716
1717static inline void put_task_struct(struct task_struct *t)
1718{
1719 if (atomic_dec_and_test(&t->usage))
1720 __put_task_struct(t);
1721}
1722
1723extern cputime_t task_utime(struct task_struct *p);
1724extern cputime_t task_stime(struct task_struct *p);
1725extern cputime_t task_gtime(struct task_struct *p);
1726
1727
1728
1729
1730#define PF_ALIGNWARN 0x00000001
1731
1732#define PF_STARTING 0x00000002
1733#define PF_EXITING 0x00000004
1734#define PF_EXITPIDONE 0x00000008
1735#define PF_VCPU 0x00000010
1736#define PF_FORKNOEXEC 0x00000040
1737#define PF_MCE_PROCESS 0x00000080
1738#define PF_SUPERPRIV 0x00000100
1739#define PF_DUMPCORE 0x00000200
1740#define PF_SIGNALED 0x00000400
1741#define PF_MEMALLOC 0x00000800
1742#define PF_FLUSHER 0x00001000
1743#define PF_USED_MATH 0x00002000
1744#define PF_FREEZING 0x00004000
1745#define PF_NOFREEZE 0x00008000
1746#define PF_FROZEN 0x00010000
1747#define PF_FSTRANS 0x00020000
1748#define PF_KSWAPD 0x00040000
1749#define PF_OOM_ORIGIN 0x00080000
1750#define PF_LESS_THROTTLE 0x00100000
1751#define PF_KTHREAD 0x00200000
1752#define PF_RANDOMIZE 0x00400000
1753#define PF_SWAPWRITE 0x00800000
1754#define PF_SPREAD_PAGE 0x01000000
1755#define PF_SPREAD_SLAB 0x02000000
1756#define PF_THREAD_BOUND 0x04000000
1757#define PF_MCE_EARLY 0x08000000
1758#define PF_MEMPOLICY 0x10000000
1759#define PF_MUTEX_TESTER 0x20000000
1760#define PF_FREEZER_SKIP 0x40000000
1761#define PF_FREEZER_NOSIG 0x80000000
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774#define clear_stopped_child_used_math(child) do { (child)->flags &= ~PF_USED_MATH; } while (0)
1775#define set_stopped_child_used_math(child) do { (child)->flags |= PF_USED_MATH; } while (0)
1776#define clear_used_math() clear_stopped_child_used_math(current)
1777#define set_used_math() set_stopped_child_used_math(current)
1778#define conditional_stopped_child_used_math(condition, child) \
1779 do { (child)->flags &= ~PF_USED_MATH, (child)->flags |= (condition) ? PF_USED_MATH : 0; } while (0)
1780#define conditional_used_math(condition) \
1781 conditional_stopped_child_used_math(condition, current)
1782#define copy_to_stopped_child_used_math(child) \
1783 do { (child)->flags &= ~PF_USED_MATH, (child)->flags |= current->flags & PF_USED_MATH; } while (0)
1784
1785#define tsk_used_math(p) ((p)->flags & PF_USED_MATH)
1786#define used_math() tsk_used_math(current)
1787
1788#ifdef CONFIG_TREE_PREEMPT_RCU
1789
1790#define RCU_READ_UNLOCK_BLOCKED (1 << 0)
1791#define RCU_READ_UNLOCK_NEED_QS (1 << 1)
1792
1793static inline void rcu_copy_process(struct task_struct *p)
1794{
1795 p->rcu_read_lock_nesting = 0;
1796 p->rcu_read_unlock_special = 0;
1797 p->rcu_blocked_node = NULL;
1798 INIT_LIST_HEAD(&p->rcu_node_entry);
1799}
1800
1801#else
1802
1803static inline void rcu_copy_process(struct task_struct *p)
1804{
1805}
1806
1807#endif
1808
1809#ifdef CONFIG_SMP
1810extern int set_cpus_allowed_ptr(struct task_struct *p,
1811 const struct cpumask *new_mask);
1812#else
1813static inline int set_cpus_allowed_ptr(struct task_struct *p,
1814 const struct cpumask *new_mask)
1815{
1816 if (!cpumask_test_cpu(0, new_mask))
1817 return -EINVAL;
1818 return 0;
1819}
1820#endif
1821
1822#ifndef CONFIG_CPUMASK_OFFSTACK
1823static inline int set_cpus_allowed(struct task_struct *p, cpumask_t new_mask)
1824{
1825 return set_cpus_allowed_ptr(p, &new_mask);
1826}
1827#endif
1828
1829
1830
1831
1832
1833
1834
1835#ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
1836extern int sched_clock_stable;
1837#endif
1838
1839extern unsigned long long sched_clock(void);
1840
1841extern void sched_clock_init(void);
1842extern u64 sched_clock_cpu(int cpu);
1843
1844#ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
1845static inline void sched_clock_tick(void)
1846{
1847}
1848
1849static inline void sched_clock_idle_sleep_event(void)
1850{
1851}
1852
1853static inline void sched_clock_idle_wakeup_event(u64 delta_ns)
1854{
1855}
1856#else
1857extern void sched_clock_tick(void);
1858extern void sched_clock_idle_sleep_event(void);
1859extern void sched_clock_idle_wakeup_event(u64 delta_ns);
1860#endif
1861
1862
1863
1864
1865
1866extern unsigned long long cpu_clock(int cpu);
1867
1868extern unsigned long long
1869task_sched_runtime(struct task_struct *task);
1870extern unsigned long long thread_group_sched_runtime(struct task_struct *task);
1871
1872
1873#ifdef CONFIG_SMP
1874extern void sched_exec(void);
1875#else
1876#define sched_exec() {}
1877#endif
1878
1879extern void sched_clock_idle_sleep_event(void);
1880extern void sched_clock_idle_wakeup_event(u64 delta_ns);
1881
1882#ifdef CONFIG_HOTPLUG_CPU
1883extern void idle_task_exit(void);
1884#else
1885static inline void idle_task_exit(void) {}
1886#endif
1887
1888extern void sched_idle_next(void);
1889
1890#if defined(CONFIG_NO_HZ) && defined(CONFIG_SMP)
1891extern void wake_up_idle_cpu(int cpu);
1892#else
1893static inline void wake_up_idle_cpu(int cpu) { }
1894#endif
1895
1896extern unsigned int sysctl_sched_latency;
1897extern unsigned int sysctl_sched_min_granularity;
1898extern unsigned int sysctl_sched_wakeup_granularity;
1899extern unsigned int sysctl_sched_shares_ratelimit;
1900extern unsigned int sysctl_sched_shares_thresh;
1901extern unsigned int sysctl_sched_child_runs_first;
1902#ifdef CONFIG_SCHED_DEBUG
1903extern unsigned int sysctl_sched_features;
1904extern unsigned int sysctl_sched_migration_cost;
1905extern unsigned int sysctl_sched_nr_migrate;
1906extern unsigned int sysctl_sched_time_avg;
1907extern unsigned int sysctl_timer_migration;
1908
1909int sched_nr_latency_handler(struct ctl_table *table, int write,
1910 void __user *buffer, size_t *length,
1911 loff_t *ppos);
1912#endif
1913#ifdef CONFIG_SCHED_DEBUG
1914static inline unsigned int get_sysctl_timer_migration(void)
1915{
1916 return sysctl_timer_migration;
1917}
1918#else
1919static inline unsigned int get_sysctl_timer_migration(void)
1920{
1921 return 1;
1922}
1923#endif
1924extern unsigned int sysctl_sched_rt_period;
1925extern int sysctl_sched_rt_runtime;
1926
1927int sched_rt_handler(struct ctl_table *table, int write,
1928 void __user *buffer, size_t *lenp,
1929 loff_t *ppos);
1930
1931extern unsigned int sysctl_sched_compat_yield;
1932
1933#ifdef CONFIG_RT_MUTEXES
1934extern int rt_mutex_getprio(struct task_struct *p);
1935extern void rt_mutex_setprio(struct task_struct *p, int prio);
1936extern void rt_mutex_adjust_pi(struct task_struct *p);
1937#else
1938static inline int rt_mutex_getprio(struct task_struct *p)
1939{
1940 return p->normal_prio;
1941}
1942# define rt_mutex_adjust_pi(p) do { } while (0)
1943#endif
1944
1945extern void set_user_nice(struct task_struct *p, long nice);
1946extern int task_prio(const struct task_struct *p);
1947extern int task_nice(const struct task_struct *p);
1948extern int can_nice(const struct task_struct *p, const int nice);
1949extern int task_curr(const struct task_struct *p);
1950extern int idle_cpu(int cpu);
1951extern int sched_setscheduler(struct task_struct *, int, struct sched_param *);
1952extern int sched_setscheduler_nocheck(struct task_struct *, int,
1953 struct sched_param *);
1954extern struct task_struct *idle_task(int cpu);
1955extern struct task_struct *curr_task(int cpu);
1956extern void set_curr_task(int cpu, struct task_struct *p);
1957
1958void yield(void);
1959
1960
1961
1962
1963extern struct exec_domain default_exec_domain;
1964
1965union thread_union {
1966 struct thread_info thread_info;
1967 unsigned long stack[THREAD_SIZE/sizeof(long)];
1968};
1969
1970#ifndef __HAVE_ARCH_KSTACK_END
1971static inline int kstack_end(void *addr)
1972{
1973
1974
1975
1976 return !(((unsigned long)addr+sizeof(void*)-1) & (THREAD_SIZE-sizeof(void*)));
1977}
1978#endif
1979
1980extern union thread_union init_thread_union;
1981extern struct task_struct init_task;
1982
1983extern struct mm_struct init_mm;
1984
1985extern struct pid_namespace init_pid_ns;
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998extern struct task_struct *find_task_by_vpid(pid_t nr);
1999extern struct task_struct *find_task_by_pid_ns(pid_t nr,
2000 struct pid_namespace *ns);
2001
2002extern void __set_special_pids(struct pid *pid);
2003
2004
2005extern struct user_struct * alloc_uid(struct user_namespace *, uid_t);
2006static inline struct user_struct *get_uid(struct user_struct *u)
2007{
2008 atomic_inc(&u->__count);
2009 return u;
2010}
2011extern void free_uid(struct user_struct *);
2012extern void release_uids(struct user_namespace *ns);
2013
2014#include <asm/current.h>
2015
2016extern void do_timer(unsigned long ticks);
2017
2018extern int wake_up_state(struct task_struct *tsk, unsigned int state);
2019extern int wake_up_process(struct task_struct *tsk);
2020extern void wake_up_new_task(struct task_struct *tsk,
2021 unsigned long clone_flags);
2022#ifdef CONFIG_SMP
2023 extern void kick_process(struct task_struct *tsk);
2024#else
2025 static inline void kick_process(struct task_struct *tsk) { }
2026#endif
2027extern void sched_fork(struct task_struct *p, int clone_flags);
2028extern void sched_dead(struct task_struct *p);
2029
2030extern void proc_caches_init(void);
2031extern void flush_signals(struct task_struct *);
2032extern void __flush_signals(struct task_struct *);
2033extern void ignore_signals(struct task_struct *);
2034extern void flush_signal_handlers(struct task_struct *, int force_default);
2035extern int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info);
2036
2037static inline int dequeue_signal_lock(struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
2038{
2039 unsigned long flags;
2040 int ret;
2041
2042 spin_lock_irqsave(&tsk->sighand->siglock, flags);
2043 ret = dequeue_signal(tsk, mask, info);
2044 spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
2045
2046 return ret;
2047}
2048
2049extern void block_all_signals(int (*notifier)(void *priv), void *priv,
2050 sigset_t *mask);
2051extern void unblock_all_signals(void);
2052extern void release_task(struct task_struct * p);
2053extern int send_sig_info(int, struct siginfo *, struct task_struct *);
2054extern int force_sigsegv(int, struct task_struct *);
2055extern int force_sig_info(int, struct siginfo *, struct task_struct *);
2056extern int __kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp);
2057extern int kill_pid_info(int sig, struct siginfo *info, struct pid *pid);
2058extern int kill_pid_info_as_uid(int, struct siginfo *, struct pid *, uid_t, uid_t, u32);
2059extern int kill_pgrp(struct pid *pid, int sig, int priv);
2060extern int kill_pid(struct pid *pid, int sig, int priv);
2061extern int kill_proc_info(int, struct siginfo *, pid_t);
2062extern int do_notify_parent(struct task_struct *, int);
2063extern void __wake_up_parent(struct task_struct *p, struct task_struct *parent);
2064extern void force_sig(int, struct task_struct *);
2065extern void force_sig_specific(int, struct task_struct *);
2066extern int send_sig(int, struct task_struct *, int);
2067extern void zap_other_threads(struct task_struct *p);
2068extern struct sigqueue *sigqueue_alloc(void);
2069extern void sigqueue_free(struct sigqueue *);
2070extern int send_sigqueue(struct sigqueue *, struct task_struct *, int group);
2071extern int do_sigaction(int, struct k_sigaction *, struct k_sigaction *);
2072extern int do_sigaltstack(const stack_t __user *, stack_t __user *, unsigned long);
2073
2074static inline int kill_cad_pid(int sig, int priv)
2075{
2076 return kill_pid(cad_pid, sig, priv);
2077}
2078
2079
2080#define SEND_SIG_NOINFO ((struct siginfo *) 0)
2081#define SEND_SIG_PRIV ((struct siginfo *) 1)
2082#define SEND_SIG_FORCED ((struct siginfo *) 2)
2083
2084static inline int is_si_special(const struct siginfo *info)
2085{
2086 return info <= SEND_SIG_FORCED;
2087}
2088
2089
2090
2091static inline int on_sig_stack(unsigned long sp)
2092{
2093 return (sp - current->sas_ss_sp < current->sas_ss_size);
2094}
2095
2096static inline int sas_ss_flags(unsigned long sp)
2097{
2098 return (current->sas_ss_size == 0 ? SS_DISABLE
2099 : on_sig_stack(sp) ? SS_ONSTACK : 0);
2100}
2101
2102
2103
2104
2105extern struct mm_struct * mm_alloc(void);
2106
2107
2108extern void __mmdrop(struct mm_struct *);
2109static inline void mmdrop(struct mm_struct * mm)
2110{
2111 if (unlikely(atomic_dec_and_test(&mm->mm_count)))
2112 __mmdrop(mm);
2113}
2114
2115
2116extern void mmput(struct mm_struct *);
2117
2118extern struct mm_struct *get_task_mm(struct task_struct *task);
2119
2120extern void mm_release(struct task_struct *, struct mm_struct *);
2121
2122extern struct mm_struct *dup_mm(struct task_struct *tsk);
2123
2124extern int copy_thread(unsigned long, unsigned long, unsigned long,
2125 struct task_struct *, struct pt_regs *);
2126extern void flush_thread(void);
2127extern void exit_thread(void);
2128
2129extern void exit_files(struct task_struct *);
2130extern void __cleanup_signal(struct signal_struct *);
2131extern void __cleanup_sighand(struct sighand_struct *);
2132
2133extern void exit_itimers(struct signal_struct *);
2134extern void flush_itimer_signals(void);
2135
2136extern NORET_TYPE void do_group_exit(int);
2137
2138extern void daemonize(const char *, ...);
2139extern int allow_signal(int);
2140extern int disallow_signal(int);
2141
2142extern int do_execve(char *, char __user * __user *, char __user * __user *, struct pt_regs *);
2143extern long do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *);
2144struct task_struct *fork_idle(int);
2145
2146extern void set_task_comm(struct task_struct *tsk, char *from);
2147extern char *get_task_comm(char *to, struct task_struct *tsk);
2148
2149#ifdef CONFIG_SMP
2150extern void wait_task_context_switch(struct task_struct *p);
2151extern unsigned long wait_task_inactive(struct task_struct *, long match_state);
2152#else
2153static inline void wait_task_context_switch(struct task_struct *p) {}
2154static inline unsigned long wait_task_inactive(struct task_struct *p,
2155 long match_state)
2156{
2157 return 1;
2158}
2159#endif
2160
2161#define next_task(p) \
2162 list_entry_rcu((p)->tasks.next, struct task_struct, tasks)
2163
2164#define for_each_process(p) \
2165 for (p = &init_task ; (p = next_task(p)) != &init_task ; )
2166
2167extern bool current_is_single_threaded(void);
2168
2169
2170
2171
2172
2173#define do_each_thread(g, t) \
2174 for (g = t = &init_task ; (g = t = next_task(g)) != &init_task ; ) do
2175
2176#define while_each_thread(g, t) \
2177 while ((t = next_thread(t)) != g)
2178
2179
2180#define thread_group_leader(p) (p == p->group_leader)
2181
2182
2183
2184
2185
2186
2187
2188static inline int has_group_leader_pid(struct task_struct *p)
2189{
2190 return p->pid == p->tgid;
2191}
2192
2193static inline
2194int same_thread_group(struct task_struct *p1, struct task_struct *p2)
2195{
2196 return p1->tgid == p2->tgid;
2197}
2198
2199static inline struct task_struct *next_thread(const struct task_struct *p)
2200{
2201 return list_entry_rcu(p->thread_group.next,
2202 struct task_struct, thread_group);
2203}
2204
2205static inline int thread_group_empty(struct task_struct *p)
2206{
2207 return list_empty(&p->thread_group);
2208}
2209
2210#define delay_group_leader(p) \
2211 (thread_group_leader(p) && !thread_group_empty(p))
2212
2213static inline int task_detached(struct task_struct *p)
2214{
2215 return p->exit_signal == -1;
2216}
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228static inline void task_lock(struct task_struct *p)
2229{
2230 spin_lock(&p->alloc_lock);
2231}
2232
2233static inline void task_unlock(struct task_struct *p)
2234{
2235 spin_unlock(&p->alloc_lock);
2236}
2237
2238extern struct sighand_struct *lock_task_sighand(struct task_struct *tsk,
2239 unsigned long *flags);
2240
2241static inline void unlock_task_sighand(struct task_struct *tsk,
2242 unsigned long *flags)
2243{
2244 spin_unlock_irqrestore(&tsk->sighand->siglock, *flags);
2245}
2246
2247#ifndef __HAVE_THREAD_FUNCTIONS
2248
2249#define task_thread_info(task) ((struct thread_info *)(task)->stack)
2250#define task_stack_page(task) ((task)->stack)
2251
2252static inline void setup_thread_stack(struct task_struct *p, struct task_struct *org)
2253{
2254 *task_thread_info(p) = *task_thread_info(org);
2255 task_thread_info(p)->task = p;
2256}
2257
2258static inline unsigned long *end_of_stack(struct task_struct *p)
2259{
2260 return (unsigned long *)(task_thread_info(p) + 1);
2261}
2262
2263#endif
2264
2265static inline int object_is_on_stack(void *obj)
2266{
2267 void *stack = task_stack_page(current);
2268
2269 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
2270}
2271
2272extern void thread_info_cache_init(void);
2273
2274#ifdef CONFIG_DEBUG_STACK_USAGE
2275static inline unsigned long stack_not_used(struct task_struct *p)
2276{
2277 unsigned long *n = end_of_stack(p);
2278
2279 do {
2280 n++;
2281 } while (!*n);
2282
2283 return (unsigned long)n - (unsigned long)end_of_stack(p);
2284}
2285#endif
2286
2287
2288
2289
2290static inline void set_tsk_thread_flag(struct task_struct *tsk, int flag)
2291{
2292 set_ti_thread_flag(task_thread_info(tsk), flag);
2293}
2294
2295static inline void clear_tsk_thread_flag(struct task_struct *tsk, int flag)
2296{
2297 clear_ti_thread_flag(task_thread_info(tsk), flag);
2298}
2299
2300static inline int test_and_set_tsk_thread_flag(struct task_struct *tsk, int flag)
2301{
2302 return test_and_set_ti_thread_flag(task_thread_info(tsk), flag);
2303}
2304
2305static inline int test_and_clear_tsk_thread_flag(struct task_struct *tsk, int flag)
2306{
2307 return test_and_clear_ti_thread_flag(task_thread_info(tsk), flag);
2308}
2309
2310static inline int test_tsk_thread_flag(struct task_struct *tsk, int flag)
2311{
2312 return test_ti_thread_flag(task_thread_info(tsk), flag);
2313}
2314
2315static inline void set_tsk_need_resched(struct task_struct *tsk)
2316{
2317 set_tsk_thread_flag(tsk,TIF_NEED_RESCHED);
2318}
2319
2320static inline void clear_tsk_need_resched(struct task_struct *tsk)
2321{
2322 clear_tsk_thread_flag(tsk,TIF_NEED_RESCHED);
2323}
2324
2325static inline int test_tsk_need_resched(struct task_struct *tsk)
2326{
2327 return unlikely(test_tsk_thread_flag(tsk,TIF_NEED_RESCHED));
2328}
2329
2330static inline int restart_syscall(void)
2331{
2332 set_tsk_thread_flag(current, TIF_SIGPENDING);
2333 return -ERESTARTNOINTR;
2334}
2335
2336static inline int signal_pending(struct task_struct *p)
2337{
2338 return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING));
2339}
2340
2341static inline int __fatal_signal_pending(struct task_struct *p)
2342{
2343 return unlikely(sigismember(&p->pending.signal, SIGKILL));
2344}
2345
2346static inline int fatal_signal_pending(struct task_struct *p)
2347{
2348 return signal_pending(p) && __fatal_signal_pending(p);
2349}
2350
2351static inline int signal_pending_state(long state, struct task_struct *p)
2352{
2353 if (!(state & (TASK_INTERRUPTIBLE | TASK_WAKEKILL)))
2354 return 0;
2355 if (!signal_pending(p))
2356 return 0;
2357
2358 return (state & TASK_INTERRUPTIBLE) || __fatal_signal_pending(p);
2359}
2360
2361static inline int need_resched(void)
2362{
2363 return unlikely(test_thread_flag(TIF_NEED_RESCHED));
2364}
2365
2366
2367
2368
2369
2370
2371
2372
2373extern int _cond_resched(void);
2374
2375#define cond_resched() ({ \
2376 __might_sleep(__FILE__, __LINE__, 0); \
2377 _cond_resched(); \
2378})
2379
2380extern int __cond_resched_lock(spinlock_t *lock);
2381
2382#ifdef CONFIG_PREEMPT
2383#define PREEMPT_LOCK_OFFSET PREEMPT_OFFSET
2384#else
2385#define PREEMPT_LOCK_OFFSET 0
2386#endif
2387
2388#define cond_resched_lock(lock) ({ \
2389 __might_sleep(__FILE__, __LINE__, PREEMPT_LOCK_OFFSET); \
2390 __cond_resched_lock(lock); \
2391})
2392
2393extern int __cond_resched_softirq(void);
2394
2395#define cond_resched_softirq() ({ \
2396 __might_sleep(__FILE__, __LINE__, SOFTIRQ_OFFSET); \
2397 __cond_resched_softirq(); \
2398})
2399
2400
2401
2402
2403
2404
2405static inline int spin_needbreak(spinlock_t *lock)
2406{
2407#ifdef CONFIG_PREEMPT
2408 return spin_is_contended(lock);
2409#else
2410 return 0;
2411#endif
2412}
2413
2414
2415
2416
2417void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times);
2418void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times);
2419
2420static inline void thread_group_cputime_init(struct signal_struct *sig)
2421{
2422 sig->cputimer.cputime = INIT_CPUTIME;
2423 spin_lock_init(&sig->cputimer.lock);
2424 sig->cputimer.running = 0;
2425}
2426
2427static inline void thread_group_cputime_free(struct signal_struct *sig)
2428{
2429}
2430
2431
2432
2433
2434
2435
2436
2437extern void recalc_sigpending_and_wake(struct task_struct *t);
2438extern void recalc_sigpending(void);
2439
2440extern void signal_wake_up(struct task_struct *t, int resume_stopped);
2441
2442
2443
2444
2445#ifdef CONFIG_SMP
2446
2447static inline unsigned int task_cpu(const struct task_struct *p)
2448{
2449 return task_thread_info(p)->cpu;
2450}
2451
2452extern void set_task_cpu(struct task_struct *p, unsigned int cpu);
2453
2454#else
2455
2456static inline unsigned int task_cpu(const struct task_struct *p)
2457{
2458 return 0;
2459}
2460
2461static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)
2462{
2463}
2464
2465#endif
2466
2467extern void arch_pick_mmap_layout(struct mm_struct *mm);
2468
2469#ifdef CONFIG_TRACING
2470extern void
2471__trace_special(void *__tr, void *__data,
2472 unsigned long arg1, unsigned long arg2, unsigned long arg3);
2473#else
2474static inline void
2475__trace_special(void *__tr, void *__data,
2476 unsigned long arg1, unsigned long arg2, unsigned long arg3)
2477{
2478}
2479#endif
2480
2481extern long sched_setaffinity(pid_t pid, const struct cpumask *new_mask);
2482extern long sched_getaffinity(pid_t pid, struct cpumask *mask);
2483
2484extern void normalize_rt_tasks(void);
2485
2486#ifdef CONFIG_GROUP_SCHED
2487
2488extern struct task_group init_task_group;
2489#ifdef CONFIG_USER_SCHED
2490extern struct task_group root_task_group;
2491extern void set_tg_uid(struct user_struct *user);
2492#endif
2493
2494extern struct task_group *sched_create_group(struct task_group *parent);
2495extern void sched_destroy_group(struct task_group *tg);
2496extern void sched_move_task(struct task_struct *tsk);
2497#ifdef CONFIG_FAIR_GROUP_SCHED
2498extern int sched_group_set_shares(struct task_group *tg, unsigned long shares);
2499extern unsigned long sched_group_shares(struct task_group *tg);
2500#endif
2501#ifdef CONFIG_RT_GROUP_SCHED
2502extern int sched_group_set_rt_runtime(struct task_group *tg,
2503 long rt_runtime_us);
2504extern long sched_group_rt_runtime(struct task_group *tg);
2505extern int sched_group_set_rt_period(struct task_group *tg,
2506 long rt_period_us);
2507extern long sched_group_rt_period(struct task_group *tg);
2508extern int sched_rt_can_attach(struct task_group *tg, struct task_struct *tsk);
2509#endif
2510#endif
2511
2512extern int task_can_switch_user(struct user_struct *up,
2513 struct task_struct *tsk);
2514
2515#ifdef CONFIG_TASK_XACCT
2516static inline void add_rchar(struct task_struct *tsk, ssize_t amt)
2517{
2518 tsk->ioac.rchar += amt;
2519}
2520
2521static inline void add_wchar(struct task_struct *tsk, ssize_t amt)
2522{
2523 tsk->ioac.wchar += amt;
2524}
2525
2526static inline void inc_syscr(struct task_struct *tsk)
2527{
2528 tsk->ioac.syscr++;
2529}
2530
2531static inline void inc_syscw(struct task_struct *tsk)
2532{
2533 tsk->ioac.syscw++;
2534}
2535#else
2536static inline void add_rchar(struct task_struct *tsk, ssize_t amt)
2537{
2538}
2539
2540static inline void add_wchar(struct task_struct *tsk, ssize_t amt)
2541{
2542}
2543
2544static inline void inc_syscr(struct task_struct *tsk)
2545{
2546}
2547
2548static inline void inc_syscw(struct task_struct *tsk)
2549{
2550}
2551#endif
2552
2553#ifndef TASK_SIZE_OF
2554#define TASK_SIZE_OF(tsk) TASK_SIZE
2555#endif
2556
2557
2558
2559
2560extern void task_oncpu_function_call(struct task_struct *p,
2561 void (*func) (void *info), void *info);
2562
2563
2564#ifdef CONFIG_MM_OWNER
2565extern void mm_update_next_owner(struct mm_struct *mm);
2566extern void mm_init_owner(struct mm_struct *mm, struct task_struct *p);
2567#else
2568static inline void mm_update_next_owner(struct mm_struct *mm)
2569{
2570}
2571
2572static inline void mm_init_owner(struct mm_struct *mm, struct task_struct *p)
2573{
2574}
2575#endif
2576
2577#define TASK_STATE_TO_CHAR_STR "RSDTtZX"
2578
2579#endif
2580
2581#endif
2582