1#ifndef _LINUX_SCHED_H 2#define _LINUX_SCHED_H 3 4#include <linux/auxvec.h> /* For AT_VECTOR_SIZE */ 5 6#define DEFINE_PER_CPU_SHARED_ALIGNED(x,y) \ 7 DEFINE_PER_CPU(x,y) ____cacheline_aligned_in_smp 8 9#define COMPAT_REGISTER_SYSCTL 10 11/* backporting helper macro: */ 12#define cpu_sibling_map(cpu) cpu_sibling_map[cpu] 13 14/* 15 * * Control groups are not backported - we use a few compatibility 16 * * defines to be able to use the upstream sched.c as-is: 17 * */ 18#define task_pid_nr(task) (task)->pid 19#define task_pid_vnr(task) (task)->pid 20#define find_task_by_vpid(pid) find_task_by_pid(pid) 21 22/* 23 * cloning flags: 24 */ 25#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */ 26#define CLONE_VM 0x00000100 /* set if VM shared between processes */ 27#define CLONE_FS 0x00000200 /* set if fs info shared between processes */ 28#define CLONE_FILES 0x00000400 /* set if open files shared between processes */ 29#define CLONE_SIGHAND 0x00000800 /* set if signal handlers and blocked signals shared */ 30#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */ 31#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */ 32#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */ 33#define CLONE_THREAD 0x00010000 /* Same thread group? */ 34#define CLONE_NEWNS 0x00020000 /* New namespace group? */ 35#define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */ 36#define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */ 37#define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */ 38#define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */ 39#define CLONE_DETACHED 0x00400000 /* Unused, ignored */ 40#define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */ 41#define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */ 42#define CLONE_STOPPED 0x02000000 /* Start in stopped state */ 43#define CLONE_NEWUTS 0x04000000 /* New utsname group? */ 44#define CLONE_NEWIPC 0x08000000 /* New ipcs */ 45#define CLONE_NEWUSER 0x10000000 /* New user namespace */ 46 47/* 48 * Scheduling policies 49 */ 50#define SCHED_NORMAL 0 51#define SCHED_FIFO 1 52#define SCHED_RR 2 53#define SCHED_BATCH 3 54/* SCHED_ISO: reserved but not implemented yet */ 55#define SCHED_IDLE 5 56 57#ifdef __KERNEL__ 58 59struct sched_param { 60 int sched_priority; 61}; 62 63#include <asm/param.h> /* for HZ */ 64 65#include <linux/capability.h> 66#include <linux/threads.h> 67#include <linux/kernel.h> 68#include <linux/types.h> 69#include <linux/timex.h> 70#include <linux/jiffies.h> 71#include <linux/rbtree.h> 72#include <linux/thread_info.h> 73#include <linux/cpumask.h> 74#include <linux/errno.h> 75#include <linux/nodemask.h> 76 77#include <asm/system.h> 78#include <asm/semaphore.h> 79#include <asm/page.h> 80#include <asm/ptrace.h> 81#include <asm/mmu.h> 82#include <asm/cputime.h> 83 84#include <linux/smp.h> 85#include <linux/sem.h> 86#include <linux/signal.h> 87#include <linux/securebits.h> 88#include <linux/fs_struct.h> 89#include <linux/compiler.h> 90#include <linux/completion.h> 91#include <linux/pid.h> 92#include <linux/percpu.h> 93#include <linux/topology.h> 94#include <linux/seccomp.h> 95#include <linux/rcupdate.h> 96#include <linux/futex.h> 97#include <linux/rtmutex.h> 98 99#include <linux/time.h> 100#include <linux/param.h> 101#include <linux/resource.h> 102#include <linux/timer.h> 103#include <linux/hrtimer.h> 104#include <linux/task_io_accounting.h> 105#include <linux/kobject.h> 106 107#include <asm/processor.h> 108 109struct exec_domain; 110struct futex_pi_state; 111struct bio; 112 113/* 114 * List of flags we want to share for kernel threads, 115 * if only because they are not used by them anyway. 116 */ 117#define CLONE_KERNEL (CLONE_FS | CLONE_FILES | CLONE_SIGHAND) 118 119/* 120 * These are the constant used to fake the fixed-point load-average 121 * counting. Some notes: 122 * - 11 bit fractions expand to 22 bits by the multiplies: this gives 123 * a load-average precision of 10 bits integer + 11 bits fractional 124 * - if you want to count load-averages more often, you need more 125 * precision, or rounding will get you. With 2-second counting freq, 126 * the EXP_n values would be 1981, 2034 and 2043 if still using only 127 * 11 bit fractions. 128 */ 129extern unsigned long avenrun[]; /* Load averages */ 130 131#define FSHIFT 11 /* nr of bits of precision */ 132#define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */ 133#define LOAD_FREQ (5*HZ+1) /* 5 sec intervals */ 134#define EXP_1 1884 /* 1/exp(5sec/1min) as fixed-point */ 135#define EXP_5 2014 /* 1/exp(5sec/5min) */ 136#define EXP_15 2037 /* 1/exp(5sec/15min) */ 137 138#define CALC_LOAD(load,exp,n) \ 139 load *= exp; \ 140 load += n*(FIXED_1-exp); \ 141 load >>= FSHIFT; 142 143extern unsigned long total_forks; 144extern int nr_threads; 145DECLARE_PER_CPU(unsigned long, process_counts); 146extern int nr_processes(void); 147extern unsigned long nr_running(void); 148extern unsigned long nr_uninterruptible(void); 149extern unsigned long nr_active(void); 150extern unsigned long nr_iowait(void); 151extern unsigned long weighted_cpuload(const int cpu); 152 153struct seq_file; 154struct cfs_rq; 155struct task_group; 156#ifdef CONFIG_SCHED_DEBUG 157extern void proc_sched_show_task(struct task_struct *p, struct seq_file *m); 158extern void proc_sched_set_task(struct task_struct *p); 159extern void 160print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq); 161#else 162static inline void 163proc_sched_show_task(struct task_struct *p, struct seq_file *m) 164{ 165} 166static inline void proc_sched_set_task(struct task_struct *p) 167{ 168} 169static inline void 170print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq) 171{ 172} 173#endif 174 175/* 176 * Task state bitmask. NOTE! These bits are also 177 * encoded in fs/proc/array.c: get_task_state(). 178 * 179 * We have two separate sets of flags: task->state 180 * is about runnability, while task->exit_state are 181 * about the task exiting. Confusing, but this way 182 * modifying one set can't modify the other one by 183 * mistake. 184 */ 185#define TASK_RUNNING 0 186#define TASK_INTERRUPTIBLE 1 187#define TASK_UNINTERRUPTIBLE 2 188#define TASK_STOPPED 4 189#define TASK_TRACED 8 190/* in tsk->exit_state */ 191#define EXIT_ZOMBIE 16 192#define EXIT_DEAD 32 193/* in tsk->state again */ 194#define TASK_DEAD 64 195 196#define __set_task_state(tsk, state_value) \ 197 do { (tsk)->state = (state_value); } while (0) 198#define set_task_state(tsk, state_value) \ 199 set_mb((tsk)->state, (state_value)) 200 201/* 202 * set_current_state() includes a barrier so that the write of current->state 203 * is correctly serialised wrt the caller's subsequent test of whether to 204 * actually sleep: 205 * 206 * set_current_state(TASK_UNINTERRUPTIBLE); 207 * if (do_i_need_to_sleep()) 208 * schedule(); 209 * 210 * If the caller does not need such serialisation then use __set_current_state() 211 */ 212#define __set_current_state(state_value) \ 213 do { current->state = (state_value); } while (0) 214#define set_current_state(state_value) \ 215 set_mb(current->state, (state_value)) 216 217/* Task command name length */ 218#define TASK_COMM_LEN 16 219 220#include <linux/spinlock.h> 221 222/* 223 * This serializes "schedule()" and also protects 224 * the run-queue from deletions/modifications (but 225 * _adding_ to the beginning of the run-queue has 226 * a separate lock). 227 */ 228extern rwlock_t tasklist_lock; 229extern spinlock_t mmlist_lock; 230 231struct task_struct; 232 233extern void sched_init(void); 234extern void sched_init_smp(void); 235extern void init_idle(struct task_struct *idle, int cpu); 236extern void init_idle_bootup_task(struct task_struct *idle); 237 238extern cpumask_t nohz_cpu_mask; 239#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ) 240extern int select_nohz_load_balancer(int cpu); 241#else 242static inline int select_nohz_load_balancer(int cpu) 243{ 244 return 0; 245} 246#endif 247 248/* 249 * Only dump TASK_* tasks. (0 for all tasks) 250 */ 251extern void show_state_filter(unsigned long state_filter); 252 253static inline void show_state(void) 254{ 255 show_state_filter(0); 256} 257 258extern void show_regs(struct pt_regs *); 259 260/* 261 * TASK is a pointer to the task whose backtrace we want to see (or NULL for current 262 * task), SP is the stack pointer of the first frame that should be shown in the back 263 * trace (or NULL if the entire call-chain of the task should be shown). 264 */ 265extern void show_stack(struct task_struct *task, unsigned long *sp); 266 267void io_schedule(void); 268long io_schedule_timeout(long timeout); 269 270extern void cpu_init (void); 271extern void trap_init(void); 272extern void update_process_times(int user); 273extern void scheduler_tick(void); 274 275#ifdef CONFIG_DETECT_SOFTLOCKUP 276extern void softlockup_tick(void); 277extern void spawn_softlockup_task(void); 278extern void touch_softlockup_watchdog(void); 279extern void touch_all_softlockup_watchdogs(void); 280#else 281static inline void softlockup_tick(void) 282{ 283} 284static inline void spawn_softlockup_task(void) 285{ 286} 287static inline void touch_softlockup_watchdog(void) 288{ 289} 290static inline void touch_all_softlockup_watchdogs(void) 291{ 292} 293#endif 294 295 296/* Attach to any functions which should be ignored in wchan output. */ 297#define __sched __attribute__((__section__(".sched.text"))) 298 299/* Linker adds these: start and end of __sched functions */ 300extern char __sched_text_start[], __sched_text_end[]; 301 302/* Is this address in the __sched functions? */ 303extern int in_sched_functions(unsigned long addr); 304 305#define MAX_SCHEDULE_TIMEOUT LONG_MAX 306extern signed long FASTCALL(schedule_timeout(signed long timeout)); 307extern signed long schedule_timeout_interruptible(signed long timeout); 308extern signed long schedule_timeout_uninterruptible(signed long timeout); 309asmlinkage void schedule(void); 310 311struct nsproxy; 312struct user_namespace; 313 314/* Maximum number of active map areas.. This is a random (large) number */ 315#define DEFAULT_MAX_MAP_COUNT 65536 316 317extern int sysctl_max_map_count; 318 319#include <linux/aio.h> 320 321extern unsigned long 322arch_get_unmapped_area(struct file *, unsigned long, unsigned long, 323 unsigned long, unsigned long); 324extern unsigned long 325arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr, 326 unsigned long len, unsigned long pgoff, 327 unsigned long flags); 328extern void arch_unmap_area(struct mm_struct *, unsigned long); 329extern void arch_unmap_area_topdown(struct mm_struct *, unsigned long); 330 331#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS 332/* 333 * The mm counters are not protected by its page_table_lock, 334 * so must be incremented atomically. 335 */ 336#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value) 337#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member)) 338#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member) 339#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member) 340#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member) 341typedef atomic_long_t mm_counter_t; 342 343#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */ 344/* 345 * The mm counters are protected by its page_table_lock, 346 * so can be incremented directly. 347 */ 348#define set_mm_counter(mm, member, value) (mm)->_##member = (value) 349#define get_mm_counter(mm, member) ((mm)->_##member) 350#define add_mm_counter(mm, member, value) (mm)->_##member += (value) 351#define inc_mm_counter(mm, member) (mm)->_##member++ 352#define dec_mm_counter(mm, member) (mm)->_##member-- 353typedef unsigned long mm_counter_t; 354 355#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */ 356 357#define get_mm_rss(mm) \ 358 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss)) 359#define update_hiwater_rss(mm) do { \ 360 unsigned long _rss = get_mm_rss(mm); \ 361 if ((mm)->hiwater_rss < _rss) \ 362 (mm)->hiwater_rss = _rss; \ 363} while (0) 364#define update_hiwater_vm(mm) do { \ 365 if ((mm)->hiwater_vm < (mm)->total_vm) \ 366 (mm)->hiwater_vm = (mm)->total_vm; \ 367} while (0) 368 369struct mm_struct { 370 struct vm_area_struct * mmap; /* list of VMAs */ 371 struct rb_root mm_rb; 372 struct vm_area_struct * mmap_cache; /* last find_vma result */ 373 unsigned long (*get_unmapped_area) (struct file *filp, 374 unsigned long addr, unsigned long len, 375 unsigned long pgoff, unsigned long flags); 376 void (*unmap_area) (struct mm_struct *mm, unsigned long addr); 377 unsigned long mmap_base; /* base of mmap area */ 378 unsigned long task_size; /* size of task vm space */ 379 unsigned long cached_hole_size; /* if non-zero, the largest hole below free_area_cache */ 380 unsigned long free_area_cache; /* first hole of size cached_hole_size or larger */ 381 pgd_t * pgd; 382 atomic_t mm_users; /* How many users with user space? */ 383 atomic_t mm_count; /* How many references to "struct mm_struct" (users count as 1) */ 384 int map_count; /* number of VMAs */ 385 struct rw_semaphore mmap_sem; 386 spinlock_t page_table_lock; /* Protects page tables and some counters */ 387 388 struct list_head mmlist; /* List of maybe swapped mm's. These are globally strung 389 * together off init_mm.mmlist, and are protected 390 * by mmlist_lock 391 */ 392 393 /* Special counters, in some configurations protected by the 394 * page_table_lock, in other configurations by being atomic. 395 */ 396 mm_counter_t _file_rss; 397 mm_counter_t _anon_rss; 398 399 unsigned long hiwater_rss; /* High-watermark of RSS usage */ 400 unsigned long hiwater_vm; /* High-water virtual memory usage */ 401 402 unsigned long total_vm, locked_vm, shared_vm, exec_vm; 403 unsigned long stack_vm, reserved_vm, def_flags, nr_ptes; 404 unsigned long start_code, end_code, start_data, end_data; 405 unsigned long start_brk, brk, start_stack; 406 unsigned long arg_start, arg_end, env_start, env_end; 407 408 unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */ 409 410 cpumask_t cpu_vm_mask; 411 412 /* Architecture-specific MM context */ 413 mm_context_t context; 414 415 /* Swap token stuff */ 416 /* 417 * Last value of global fault stamp as seen by this process. 418 * In other words, this value gives an indication of how long 419 * it has been since this task got the token. 420 * Look at mm/thrash.c 421 */ 422 unsigned int faultstamp; 423 unsigned int token_priority; 424 unsigned int last_interval; 425 426 unsigned char dumpable:2; 427 428 /* coredumping support */ 429 int core_waiters; 430 struct completion *core_startup_done, core_done; 431 432 /* aio bits */ 433 rwlock_t ioctx_list_lock; 434 struct kioctx *ioctx_list; 435}; 436 437struct sighand_struct { 438 atomic_t count; 439 struct k_sigaction action[_NSIG]; 440 spinlock_t siglock; 441 struct list_head signalfd_list; 442}; 443 444struct pacct_struct { 445 int ac_flag; 446 long ac_exitcode; 447 unsigned long ac_mem; 448 cputime_t ac_utime, ac_stime; 449 unsigned long ac_minflt, ac_majflt; 450}; 451 452/* 453 * NOTE! "signal_struct" does not have it's own 454 * locking, because a shared signal_struct always 455 * implies a shared sighand_struct, so locking 456 * sighand_struct is always a proper superset of 457 * the locking of signal_struct. 458 */ 459struct signal_struct { 460 atomic_t count; 461 atomic_t live; 462 463 wait_queue_head_t wait_chldexit; /* for wait4() */ 464 465 /* current thread group signal load-balancing target: */ 466 struct task_struct *curr_target; 467 468 /* shared signal handling: */ 469 struct sigpending shared_pending; 470 471 /* thread group exit support */ 472 int group_exit_code; 473 /* overloaded: 474 * - notify group_exit_task when ->count is equal to notify_count 475 * - everyone except group_exit_task is stopped during signal delivery 476 * of fatal signals, group_exit_task processes the signal. 477 */ 478 struct task_struct *group_exit_task; 479 int notify_count; 480 481 /* thread group stop support, overloads group_exit_code too */ 482 int group_stop_count; 483 unsigned int flags; /* see SIGNAL_* flags below */ 484 485 /* POSIX.1b Interval Timers */ 486 struct list_head posix_timers; 487 488 /* ITIMER_REAL timer for the process */ 489 struct hrtimer real_timer; 490 struct task_struct *tsk; 491 ktime_t it_real_incr; 492 493 /* ITIMER_PROF and ITIMER_VIRTUAL timers for the process */ 494 cputime_t it_prof_expires, it_virt_expires; 495 cputime_t it_prof_incr, it_virt_incr; 496 497 /* job control IDs */ 498 pid_t pgrp; 499 struct pid *tty_old_pgrp; 500 501 union { 502 pid_t session __deprecated; 503 pid_t __session; 504 }; 505 506 /* boolean value for session group leader */ 507 int leader; 508 509 struct tty_struct *tty; /* NULL if no tty */ 510 511 /* 512 * Cumulative resource counters for dead threads in the group, 513 * and for reaped dead child processes forked by this group. 514 * Live threads maintain their own counters and add to these 515 * in __exit_signal, except for the group leader. 516 */ 517 cputime_t utime, stime, cutime, cstime; 518 cputime_t gtime; 519 cputime_t cgtime; 520 unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw; 521 unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt; 522 unsigned long inblock, oublock, cinblock, coublock; 523 524 /* 525 * Cumulative ns of scheduled CPU time for dead threads in the 526 * group, not including a zombie group leader. (This only differs 527 * from jiffies_to_ns(utime + stime) if sched_clock uses something 528 * other than jiffies.) 529 */ 530 unsigned long long sum_sched_runtime; 531 532 /* 533 * We don't bother to synchronize most readers of this at all, 534 * because there is no reader checking a limit that actually needs 535 * to get both rlim_cur and rlim_max atomically, and either one 536 * alone is a single word that can safely be read normally. 537 * getrlimit/setrlimit use task_lock(current->group_leader) to 538 * protect this instead of the siglock, because they really 539 * have no need to disable irqs. 540 */ 541 struct rlimit rlim[RLIM_NLIMITS]; 542 543 struct list_head cpu_timers[3]; 544 545 /* keep the process-shared keyrings here so that they do the right 546 * thing in threads created with CLONE_THREAD */ 547#ifdef CONFIG_KEYS 548 struct key *session_keyring; /* keyring inherited over fork */ 549 struct key *process_keyring; /* keyring private to this process */ 550#endif 551#ifdef CONFIG_BSD_PROCESS_ACCT 552 struct pacct_struct pacct; /* per-process accounting information */ 553#endif 554#ifdef CONFIG_TASKSTATS 555 struct taskstats *stats; 556#endif 557}; 558 559/* Context switch must be unlocked if interrupts are to be enabled */ 560#ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW 561# define __ARCH_WANT_UNLOCKED_CTXSW 562#endif 563 564/* 565 * Bits in flags field of signal_struct. 566 */ 567#define SIGNAL_STOP_STOPPED 0x00000001 /* job control stop in effect */ 568#define SIGNAL_STOP_DEQUEUED 0x00000002 /* stop signal dequeued */ 569#define SIGNAL_STOP_CONTINUED 0x00000004 /* SIGCONT since WCONTINUED reap */ 570#define SIGNAL_GROUP_EXIT 0x00000008 /* group exit in progress */ 571 572/* 573 * Some day this will be a full-fledged user tracking system.. 574 */ 575struct user_struct { 576 atomic_t __count; /* reference count */ 577 atomic_t processes; /* How many processes does this user have? */ 578 atomic_t files; /* How many open files does this user have? */ 579 atomic_t sigpending; /* How many pending signals does this user have? */ 580#ifdef CONFIG_INOTIFY_USER 581 atomic_t inotify_watches; /* How many inotify watches does this user have? */ 582 atomic_t inotify_devs; /* How many inotify devs does this user have opened? */ 583#endif 584 /* protected by mq_lock */ 585 unsigned long mq_bytes; /* How many bytes can be allocated to mqueue? */ 586 unsigned long locked_shm; /* How many pages of mlocked shm ? */ 587 588#ifdef CONFIG_KEYS 589 struct key *uid_keyring; /* UID specific keyring */ 590 struct key *session_keyring; /* UID's default session keyring */ 591#endif 592 593 /* Hash table maintenance information */ 594 struct hlist_node uidhash_node; 595 uid_t uid; 596 597#ifdef CONFIG_FAIR_USER_SCHED 598 struct task_group *tg; 599#ifdef CONFIG_SYSFS 600 struct kset kset; 601 struct subsys_attribute user_attr; 602 struct work_struct work; 603#endif 604#endif 605}; 606 607#ifdef CONFIG_FAIR_USER_SCHED 608extern int uids_kobject_init(void); 609#else 610static inline int uids_kobject_init(void) { return 0; } 611#endif 612 613extern struct user_struct *find_user(uid_t); 614 615extern struct user_struct root_user; 616#define INIT_USER (&root_user) 617 618struct backing_dev_info; 619struct reclaim_state; 620 621#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) 622struct sched_info { 623 /* cumulative counters */ 624 unsigned long pcount; /* # of times run on this cpu */ 625 unsigned long long cpu_time, /* time spent on the cpu */ 626 run_delay; /* time spent waiting on a runqueue */ 627 628 /* timestamps */ 629 unsigned long long last_arrival,/* when we last ran on a cpu */ 630 last_queued; /* when we were last queued to run */ 631#ifdef CONFIG_SCHEDSTATS 632 /* BKL stats */ 633 unsigned int bkl_count; 634#endif 635}; 636#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */ 637 638#ifdef CONFIG_SCHEDSTATS 639extern const struct file_operations proc_schedstat_operations; 640#endif /* CONFIG_SCHEDSTATS */ 641 642#ifdef CONFIG_TASK_DELAY_ACCT 643struct task_delay_info { 644 spinlock_t lock; 645 unsigned int flags; /* Private per-task flags */ 646 647 648 struct timespec blkio_start, blkio_end; /* Shared by blkio, swapin */ 649 u64 blkio_delay; /* wait for sync block io completion */ 650 u64 swapin_delay; /* wait for swapin block io completion */ 651 u32 blkio_count; /* total count of the number of sync block */ 652 /* io operations performed */ 653 u32 swapin_count; /* total count of the number of swapin block */ 654 /* io operations performed */ 655}; 656#endif /* CONFIG_TASK_DELAY_ACCT */ 657 658static inline int sched_info_on(void) 659{ 660#ifdef CONFIG_SCHEDSTATS 661 return 1; 662#elif defined(CONFIG_TASK_DELAY_ACCT) 663 extern int delayacct_on; 664 return delayacct_on; 665#else 666 return 0; 667#endif 668} 669 670enum cpu_idle_type { 671 CPU_IDLE, 672 CPU_NOT_IDLE, 673 CPU_NEWLY_IDLE, 674 CPU_MAX_IDLE_TYPES 675}; 676 677/* 678 * sched-domains (multiprocessor balancing) declarations: 679 */ 680 681/* 682 * Increase resolution of nice-level calculations: 683 */ 684#define SCHED_LOAD_SHIFT 10 685#define SCHED_LOAD_SCALE (1L << SCHED_LOAD_SHIFT) 686 687#define SCHED_LOAD_SCALE_FUZZ SCHED_LOAD_SCALE 688 689#ifdef CONFIG_SMP 690#define SD_LOAD_BALANCE 1 /* Do load balancing on this domain. */ 691#define SD_BALANCE_NEWIDLE 2 /* Balance when about to become idle */ 692#define SD_BALANCE_EXEC 4 /* Balance on exec */ 693#define SD_BALANCE_FORK 8 /* Balance on fork, clone */ 694#define SD_WAKE_IDLE 16 /* Wake to idle CPU on task wakeup */ 695#define SD_WAKE_AFFINE 32 /* Wake task to waking CPU */ 696#define SD_WAKE_BALANCE 64 /* Perform balancing at task wakeup */ 697#define SD_SHARE_CPUPOWER 128 /* Domain members share cpu power */ 698#define SD_POWERSAVINGS_BALANCE 256 /* Balance for power savings */ 699#define SD_SHARE_PKG_RESOURCES 512 /* Domain members share cpu pkg resources */ 700#define SD_SERIALIZE 1024 /* Only a single load balancing instance */ 701 702#define BALANCE_FOR_MC_POWER \ 703 (sched_smt_power_savings ? SD_POWERSAVINGS_BALANCE : 0) 704 705#define BALANCE_FOR_PKG_POWER \ 706 ((sched_mc_power_savings || sched_smt_power_savings) ? \ 707 SD_POWERSAVINGS_BALANCE : 0) 708 709#define test_sd_parent(sd, flag) ((sd->parent && \ 710 (sd->parent->flags & flag)) ? 1 : 0) 711 712 713struct sched_group { 714 struct sched_group *next; /* Must be a circular list */ 715 cpumask_t cpumask; 716 717 /* 718 * CPU power of this group, SCHED_LOAD_SCALE being max power for a 719 * single CPU. This is read only (except for setup, hotplug CPU). 720 * Note : Never change cpu_power without recompute its reciprocal 721 */ 722 unsigned int __cpu_power; 723 /* 724 * reciprocal value of cpu_power to avoid expensive divides 725 * (see include/linux/reciprocal_div.h) 726 */ 727 u32 reciprocal_cpu_power; 728}; 729 730struct sched_domain { 731 /* These fields must be setup */ 732 struct sched_domain *parent; /* top domain must be null terminated */ 733 struct sched_domain *child; /* bottom domain must be null terminated */ 734 struct sched_group *groups; /* the balancing groups of the domain */ 735 cpumask_t span; /* span of all CPUs in this domain */ 736 unsigned long min_interval; /* Minimum balance interval ms */ 737 unsigned long max_interval; /* Maximum balance interval ms */ 738 unsigned int busy_factor; /* less balancing by factor if busy */ 739 unsigned int imbalance_pct; /* No balance until over watermark */ 740 unsigned int cache_nice_tries; /* Leave cache hot tasks for # tries */ 741 unsigned int busy_idx; 742 unsigned int idle_idx; 743 unsigned int newidle_idx; 744 unsigned int wake_idx; 745 unsigned int forkexec_idx; 746 int flags; /* See SD_* */ 747 748 /* Runtime fields. */ 749 unsigned long last_balance; /* init to jiffies. units in jiffies */ 750 unsigned int balance_interval; /* initialise to 1. units in ms. */ 751 unsigned int nr_balance_failed; /* initialise to 0 */ 752 753#ifdef CONFIG_SCHEDSTATS 754 /* load_balance() stats */ 755 unsigned int lb_count[CPU_MAX_IDLE_TYPES]; 756 unsigned int lb_failed[CPU_MAX_IDLE_TYPES]; 757 unsigned int lb_balanced[CPU_MAX_IDLE_TYPES]; 758 unsigned int lb_imbalance[CPU_MAX_IDLE_TYPES]; 759 unsigned int lb_gained[CPU_MAX_IDLE_TYPES]; 760 unsigned int lb_hot_gained[CPU_MAX_IDLE_TYPES]; 761 unsigned int lb_nobusyg[CPU_MAX_IDLE_TYPES]; 762 unsigned int lb_nobusyq[CPU_MAX_IDLE_TYPES]; 763 764 /* Active load balancing */ 765 unsigned int alb_count; 766 unsigned int alb_failed; 767 unsigned int alb_pushed; 768 769 /* SD_BALANCE_EXEC stats */ 770 unsigned int sbe_count; 771 unsigned int sbe_balanced; 772 unsigned int sbe_pushed; 773 774 /* SD_BALANCE_FORK stats */ 775 unsigned int sbf_count; 776 unsigned int sbf_balanced; 777 unsigned int sbf_pushed; 778 779 /* try_to_wake_up() stats */ 780 unsigned int ttwu_wake_remote; 781 unsigned int ttwu_move_affine; 782 unsigned int ttwu_move_balance; 783#endif 784}; 785 786extern void partition_sched_domains(int ndoms_new, cpumask_t *doms_new); 787 788#endif /* CONFIG_SMP */ 789 790/* 791 * A runqueue laden with a single nice 0 task scores a weighted_cpuload of 792 * SCHED_LOAD_SCALE. This function returns 1 if any cpu is laden with a 793 * task of nice 0 or enough lower priority tasks to bring up the 794 * weighted_cpuload 795 */ 796static inline int above_background_load(void) 797{ 798 unsigned long cpu; 799 800 for_each_online_cpu(cpu) { 801 if (weighted_cpuload(cpu) >= SCHED_LOAD_SCALE) 802 return 1; 803 } 804 return 0; 805} 806 807struct io_context; /* See blkdev.h */ 808struct cpuset; 809 810#define NGROUPS_SMALL 32 811#define NGROUPS_PER_BLOCK ((int)(PAGE_SIZE / sizeof(gid_t))) 812struct group_info { 813 int ngroups; 814 atomic_t usage; 815 gid_t small_block[NGROUPS_SMALL]; 816 int nblocks; 817 gid_t *blocks[0]; 818}; 819 820/* 821 * get_group_info() must be called with the owning task locked (via task_lock()) 822 * when task != current. The reason being that the vast majority of callers are 823 * looking at current->group_info, which can not be changed except by the 824 * current task. Changing current->group_info requires the task lock, too. 825 */ 826#define get_group_info(group_info) do { \ 827 atomic_inc(&(group_info)->usage); \ 828} while (0) 829 830#define put_group_info(group_info) do { \ 831 if (atomic_dec_and_test(&(group_info)->usage)) \ 832 groups_free(group_info); \ 833} while (0) 834 835extern struct group_info *groups_alloc(int gidsetsize); 836extern void groups_free(struct group_info *group_info); 837extern int set_current_groups(struct group_info *group_info); 838extern int groups_search(struct group_info *group_info, gid_t grp); 839/* access the groups "array" with this macro */ 840#define GROUP_AT(gi, i) \ 841 ((gi)->blocks[(i)/NGROUPS_PER_BLOCK][(i)%NGROUPS_PER_BLOCK]) 842 843#ifdef ARCH_HAS_PREFETCH_SWITCH_STACK 844extern void prefetch_stack(struct task_struct *t); 845#else 846static inline void prefetch_stack(struct task_struct *t) { } 847#endif 848 849struct audit_context; /* See audit.c */ 850struct mempolicy; 851struct pipe_inode_info; 852struct uts_namespace; 853 854struct rq; 855struct sched_domain; 856 857struct sched_class { 858 const struct sched_class *next; 859 860 void (*enqueue_task) (struct rq *rq, struct task_struct *p, int wakeup); 861 void (*dequeue_task) (struct rq *rq, struct task_struct *p, int sleep); 862 void (*yield_task) (struct rq *rq); 863 864 void (*check_preempt_curr) (struct rq *rq, struct task_struct *p); 865 866 struct task_struct * (*pick_next_task) (struct rq *rq); 867 void (*put_prev_task) (struct rq *rq, struct task_struct *p); 868 869#ifdef CONFIG_SMP 870 unsigned long (*load_balance) (struct rq *this_rq, int this_cpu, 871 struct rq *busiest, unsigned long max_load_move, 872 struct sched_domain *sd, enum cpu_idle_type idle, 873 int *all_pinned, int *this_best_prio); 874 875 int (*move_one_task) (struct rq *this_rq, int this_cpu, 876 struct rq *busiest, struct sched_domain *sd, 877 enum cpu_idle_type idle); 878#endif 879 880 void (*set_curr_task) (struct rq *rq); 881 void (*task_tick) (struct rq *rq, struct task_struct *p); 882 void (*task_new) (struct rq *rq, struct task_struct *p); 883}; 884 885struct load_weight { 886 unsigned long weight, inv_weight; 887}; 888 889/* 890 * CFS stats for a schedulable entity (task, task-group etc) 891 * 892 * Current field usage histogram: 893 * 894 * 4 se->block_start 895 * 4 se->run_node 896 * 4 se->sleep_start 897 * 6 se->load.weight 898 */ 899struct sched_entity { 900 struct load_weight load; /* for load-balancing */ 901 struct rb_node run_node; 902 unsigned int on_rq; 903 904 u64 exec_start; 905 u64 sum_exec_runtime; 906 u64 vruntime; 907 u64 prev_sum_exec_runtime; 908 909#ifdef CONFIG_SCHEDSTATS 910 u64 wait_start; 911 u64 wait_max; 912 913 u64 sleep_start; 914 u64 sleep_max; 915 s64 sum_sleep_runtime; 916 917 u64 block_start; 918 u64 block_max; 919 u64 exec_max; 920 u64 slice_max; 921 922 u64 nr_migrations; 923 u64 nr_migrations_cold; 924 u64 nr_failed_migrations_affine; 925 u64 nr_failed_migrations_running; 926 u64 nr_failed_migrations_hot; 927 u64 nr_forced_migrations; 928 u64 nr_forced2_migrations; 929 930 u64 nr_wakeups; 931 u64 nr_wakeups_sync; 932 u64 nr_wakeups_migrate; 933 u64 nr_wakeups_local; 934 u64 nr_wakeups_remote; 935 u64 nr_wakeups_affine; 936 u64 nr_wakeups_affine_attempts; 937 u64 nr_wakeups_passive; 938 u64 nr_wakeups_idle; 939#endif 940 941#ifdef CONFIG_FAIR_GROUP_SCHED 942 struct sched_entity *parent; 943 /* rq on which this entity is (to be) queued: */ 944 struct cfs_rq *cfs_rq; 945 /* rq "owned" by this entity/group: */ 946 struct cfs_rq *my_q; 947#endif 948}; 949 950struct task_struct { 951 volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */ 952 void *stack; 953 atomic_t usage; 954 unsigned int flags; /* per process flags, defined below */ 955 unsigned int ptrace; 956 957 int lock_depth; /* BKL lock depth */ 958 959#ifdef CONFIG_SMP 960#ifdef __ARCH_WANT_UNLOCKED_CTXSW 961 int oncpu; 962#endif 963#endif 964 965 int prio, static_prio, normal_prio; 966 struct list_head run_list; 967 const struct sched_class *sched_class; 968 struct sched_entity se; 969 970#ifdef CONFIG_PREEMPT_NOTIFIERS 971 /* list of struct preempt_notifier: */ 972 struct hlist_head preempt_notifiers; 973#endif 974 975 unsigned short ioprio; 976#ifdef CONFIG_BLK_DEV_IO_TRACE 977 unsigned int btrace_seq; 978#endif 979 980 unsigned int policy; 981 cpumask_t cpus_allowed; 982 unsigned int time_slice; 983 984#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) 985 struct sched_info sched_info; 986#endif 987 988 struct list_head tasks; 989 /* 990 * ptrace_list/ptrace_children forms the list of my children 991 * that were stolen by a ptracer. 992 */ 993 struct list_head ptrace_children; 994 struct list_head ptrace_list; 995 996 struct mm_struct *mm, *active_mm; 997 998/* task state */ 999 struct linux_binfmt *binfmt; 1000 int exit_state; 1001 int exit_code, exit_signal; 1002 int pdeath_signal; /* The signal sent when the parent dies */ 1003 /* ??? */ 1004 unsigned int personality; 1005 unsigned did_exec:1; 1006 pid_t pid; 1007 pid_t tgid; 1008 1009#ifdef CONFIG_CC_STACKPROTECTOR 1010 /* Canary value for the -fstack-protector gcc feature */ 1011 unsigned long stack_canary; 1012#endif 1013 /* 1014 * pointers to (original) parent process, youngest child, younger sibling, 1015 * older sibling, respectively. (p->father can be replaced with 1016 * p->parent->pid) 1017 */ 1018 struct task_struct *real_parent; /* real parent process (when being debugged) */ 1019 struct task_struct *parent; /* parent process */ 1020 /* 1021 * children/sibling forms the list of my children plus the 1022 * tasks I'm ptracing. 1023 */ 1024 struct list_head children; /* list of my children */ 1025 struct list_head sibling; /* linkage in my parent's children list */ 1026 struct task_struct *group_leader; /* threadgroup leader */ 1027 1028 /* PID/PID hash table linkage. */ 1029 struct pid_link pids[PIDTYPE_MAX]; 1030 struct list_head thread_group; 1031 1032 struct completion *vfork_done; /* for vfork() */ 1033 int __user *set_child_tid; /* CLONE_CHILD_SETTID */ 1034 int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */ 1035 1036 unsigned int rt_priority; 1037 cputime_t utime, stime, utimescaled, stimescaled; 1038 cputime_t gtime; 1039 cputime_t prev_utime, prev_stime; 1040 unsigned long nvcsw, nivcsw; /* context switch counts */ 1041 struct timespec start_time; /* monotonic time */ 1042 struct timespec real_start_time; /* boot based time */ 1043/* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */ 1044 unsigned long min_flt, maj_flt; 1045 1046 cputime_t it_prof_expires, it_virt_expires; 1047 unsigned long long it_sched_expires; 1048 struct list_head cpu_timers[3]; 1049 1050/* process credentials */ 1051 uid_t uid,euid,suid,fsuid; 1052 gid_t gid,egid,sgid,fsgid; 1053 struct group_info *group_info; 1054 kernel_cap_t cap_effective, cap_inheritable, cap_permitted; 1055 unsigned keep_capabilities:1; 1056 struct user_struct *user; 1057#ifdef CONFIG_KEYS 1058 struct key *request_key_auth; /* assumed request_key authority */ 1059 struct key *thread_keyring; /* keyring private to this thread */ 1060 unsigned char jit_keyring; /* default keyring to attach requested keys to */ 1061#endif 1062 /* 1063 * fpu_counter contains the number of consecutive context switches 1064 * that the FPU is used. If this is over a threshold, the lazy fpu 1065 * saving becomes unlazy to save the trap. This is an unsigned char 1066 * so that after 256 times the counter wraps and the behavior turns 1067 * lazy again; this to deal with bursty apps that only use FPU for 1068 * a short time 1069 */ 1070 unsigned char fpu_counter; 1071 int oomkilladj; /* OOM kill score adjustment (bit shift). */ 1072 char comm[TASK_COMM_LEN]; /* executable name excluding path 1073 - access with [gs]et_task_comm (which lock 1074 it with task_lock()) 1075 - initialized normally by flush_old_exec */ 1076/* file system info */ 1077 int link_count, total_link_count; 1078#ifdef CONFIG_SYSVIPC 1079/* ipc stuff */ 1080 struct sysv_sem sysvsem; 1081#endif 1082/* CPU-specific state of this task */ 1083 struct thread_struct thread; 1084/* filesystem information */ 1085 struct fs_struct *fs; 1086/* open file information */ 1087 struct files_struct *files; 1088/* namespaces */ 1089 struct nsproxy *nsproxy; 1090/* signal handlers */ 1091 struct signal_struct *signal; 1092 struct sighand_struct *sighand; 1093 1094 sigset_t blocked, real_blocked; 1095 sigset_t saved_sigmask; /* To be restored with TIF_RESTORE_SIGMASK */ 1096 struct sigpending pending; 1097 1098 unsigned long sas_ss_sp; 1099 size_t sas_ss_size; 1100 int (*notifier)(void *priv); 1101 void *notifier_data; 1102 sigset_t *notifier_mask; 1103 1104 void *security; 1105 struct audit_context *audit_context; 1106 seccomp_t seccomp; 1107 1108/* Thread group tracking */ 1109 u32 parent_exec_id; 1110 u32 self_exec_id; 1111/* Protection of (de-)allocation: mm, files, fs, tty, keyrings */ 1112 spinlock_t alloc_lock; 1113 1114 /* Protection of the PI data structures: */ 1115 spinlock_t pi_lock; 1116 1117#ifdef CONFIG_RT_MUTEXES 1118 /* PI waiters blocked on a rt_mutex held by this task */ 1119 struct plist_head pi_waiters; 1120 /* Deadlock detection and priority inheritance handling */ 1121 struct rt_mutex_waiter *pi_blocked_on; 1122#endif 1123 1124#ifdef CONFIG_DEBUG_MUTEXES 1125 /* mutex deadlock detection */ 1126 struct mutex_waiter *blocked_on; 1127#endif 1128#ifdef CONFIG_TRACE_IRQFLAGS 1129 unsigned int irq_events; 1130 int hardirqs_enabled; 1131 unsigned long hardirq_enable_ip; 1132 unsigned int hardirq_enable_event; 1133 unsigned long hardirq_disable_ip; 1134 unsigned int hardirq_disable_event; 1135 int softirqs_enabled; 1136 unsigned long softirq_disable_ip; 1137 unsigned int softirq_disable_event; 1138 unsigned long softirq_enable_ip; 1139 unsigned int softirq_enable_event; 1140 int hardirq_context; 1141 int softirq_context; 1142#endif 1143#ifdef CONFIG_LOCKDEP 1144# define MAX_LOCK_DEPTH 30UL 1145 u64 curr_chain_key; 1146 int lockdep_depth; 1147 struct held_lock held_locks[MAX_LOCK_DEPTH]; 1148 unsigned int lockdep_recursion; 1149#endif 1150 1151/* journalling filesystem info */ 1152 void *journal_info; 1153 1154/* stacked block device info */ 1155 struct bio *bio_list, **bio_tail; 1156 1157/* VM state */ 1158 struct reclaim_state *reclaim_state; 1159 1160 struct backing_dev_info *backing_dev_info; 1161 1162 struct io_context *io_context; 1163 1164 unsigned long ptrace_message; 1165 siginfo_t *last_siginfo; /* For ptrace use. */ 1166/* 1167 * current io wait handle: wait queue entry to use for io waits 1168 * If this thread is processing aio, this points at the waitqueue 1169 * inside the currently handled kiocb. It may be NULL (i.e. default 1170 * to a stack based synchronous wait) if its doing sync IO. 1171 */ 1172 wait_queue_t *io_wait; 1173#ifdef CONFIG_TASK_XACCT 1174/* i/o counters(bytes read/written, #syscalls */ 1175 u64 rchar, wchar, syscr, syscw; 1176#endif 1177 struct task_io_accounting ioac; 1178#if defined(CONFIG_TASK_XACCT) 1179 u64 acct_rss_mem1; /* accumulated rss usage */ 1180 u64 acct_vm_mem1; /* accumulated virtual memory usage */ 1181 cputime_t acct_stimexpd;/* stime since last update */ 1182#endif 1183#ifdef CONFIG_NUMA 1184 struct mempolicy *mempolicy; 1185 short il_next; 1186#endif 1187#ifdef CONFIG_CPUSETS 1188 struct cpuset *cpuset; 1189 nodemask_t mems_allowed; 1190 int cpuset_mems_generation; 1191 int cpuset_mem_spread_rotor; 1192#endif 1193 struct robust_list_head __user *robust_list; 1194#ifdef CONFIG_COMPAT 1195 struct compat_robust_list_head __user *compat_robust_list; 1196#endif 1197 struct list_head pi_state_list; 1198 struct futex_pi_state *pi_state_cache; 1199 1200 atomic_t fs_excl; /* holding fs exclusive resources */ 1201 struct rcu_head rcu; 1202 1203 /* 1204 * cache last used pipe for splice 1205 */ 1206 struct pipe_inode_info *splice_pipe; 1207#ifdef CONFIG_TASK_DELAY_ACCT 1208 struct task_delay_info *delays; 1209#endif 1210#ifdef CONFIG_FAULT_INJECTION 1211 int make_it_fail; 1212#endif 1213}; 1214 1215/* 1216 * Priority of a process goes from 0..MAX_PRIO-1, valid RT 1217 * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH 1218 * tasks are in the range MAX_RT_PRIO..MAX_PRIO-1. Priority 1219 * values are inverted: lower p->prio value means higher priority. 1220 * 1221 * The MAX_USER_RT_PRIO value allows the actual maximum 1222 * RT priority to be separate from the value exported to 1223 * user-space. This allows kernel threads to set their 1224 * priority to a value higher than any user task. Note: 1225 * MAX_RT_PRIO must not be smaller than MAX_USER_RT_PRIO. 1226 */ 1227 1228#define MAX_USER_RT_PRIO 100 1229#define MAX_RT_PRIO MAX_USER_RT_PRIO 1230 1231#define MAX_PRIO (MAX_RT_PRIO + 40) 1232#define DEFAULT_PRIO (MAX_RT_PRIO + 20) 1233 1234static inline int rt_prio(int prio) 1235{ 1236 if (unlikely(prio < MAX_RT_PRIO)) 1237 return 1; 1238 return 0; 1239} 1240 1241static inline int rt_task(struct task_struct *p) 1242{ 1243 return rt_prio(p->prio); 1244} 1245 1246static inline pid_t process_group(struct task_struct *tsk) 1247{ 1248 return tsk->signal->pgrp; 1249} 1250 1251static inline pid_t signal_session(struct signal_struct *sig) 1252{ 1253 return sig->__session; 1254} 1255 1256static inline pid_t process_session(struct task_struct *tsk) 1257{ 1258 return signal_session(tsk->signal); 1259} 1260 1261static inline void set_signal_session(struct signal_struct *sig, pid_t session) 1262{ 1263 sig->__session = session; 1264} 1265 1266static inline struct pid *task_pid(struct task_struct *task) 1267{ 1268 return task->pids[PIDTYPE_PID].pid; 1269} 1270 1271static inline struct pid *task_tgid(struct task_struct *task) 1272{ 1273 return task->group_leader->pids[PIDTYPE_PID].pid; 1274} 1275 1276static inline struct pid *task_pgrp(struct task_struct *task) 1277{ 1278 return task->group_leader->pids[PIDTYPE_PGID].pid; 1279} 1280 1281static inline struct pid *task_session(struct task_struct *task) 1282{ 1283 return task->group_leader->pids[PIDTYPE_SID].pid; 1284} 1285 1286/** 1287 * pid_alive - check that a task structure is not stale 1288 * @p: Task structure to be checked. 1289 * 1290 * Test if a process is not yet dead (at most zombie state) 1291 * If pid_alive fails, then pointers within the task structure 1292 * can be stale and must not be dereferenced. 1293 */ 1294static inline int pid_alive(struct task_struct *p) 1295{ 1296 return p->pids[PIDTYPE_PID].pid != NULL; 1297} 1298 1299/** 1300 * is_init - check if a task structure is init 1301 * @tsk: Task structure to be checked. 1302 * 1303 * Check if a task structure is the first user space task the kernel created. 1304 */ 1305static inline int is_init(struct task_struct *tsk) 1306{ 1307 return tsk->pid == 1; 1308} 1309 1310extern struct pid *cad_pid; 1311 1312extern void free_task(struct task_struct *tsk); 1313#define get_task_struct(tsk) do { atomic_inc(&(tsk)->usage); } while(0) 1314 1315extern void __put_task_struct(struct task_struct *t); 1316 1317static inline void put_task_struct(struct task_struct *t) 1318{ 1319 if (atomic_dec_and_test(&t->usage)) 1320 __put_task_struct(t); 1321} 1322 1323/* 1324 * Per process flags 1325 */ 1326#define PF_ALIGNWARN 0x00000001 /* Print alignment warning msgs */ 1327 /* Not implemented yet, only for 486*/ 1328#define PF_STARTING 0x00000002 /* being created */ 1329#define PF_EXITING 0x00000004 /* getting shut down */ 1330#define PF_EXITPIDONE 0x00000008 /* pi exit done on shut down */ 1331#define PF_VCPU 0x00000010 /* I'm a virtual CPU */ 1332#define PF_FORKNOEXEC 0x00000040 /* forked but didn't exec */ 1333#define PF_SUPERPRIV 0x00000100 /* used super-user privileges */ 1334#define PF_DUMPCORE 0x00000200 /* dumped core */ 1335#define PF_SIGNALED 0x00000400 /* killed by a signal */ 1336#define PF_MEMALLOC 0x00000800 /* Allocating memory */ 1337#define PF_FLUSHER 0x00001000 /* responsible for disk writeback */ 1338#define PF_USED_MATH 0x00002000 /* if unset the fpu must be initialized before use */ 1339#define PF_NOFREEZE 0x00008000 /* this thread should not be frozen */ 1340#define PF_FROZEN 0x00010000 /* frozen for system suspend */ 1341#define PF_FSTRANS 0x00020000 /* inside a filesystem transaction */ 1342#define PF_KSWAPD 0x00040000 /* I am kswapd */ 1343#define PF_SWAPOFF 0x00080000 /* I am in swapoff */ 1344#define PF_LESS_THROTTLE 0x00100000 /* Throttle me less: I clean memory */ 1345#define PF_BORROWED_MM 0x00200000 /* I am a kthread doing use_mm */ 1346#define PF_RANDOMIZE 0x00400000 /* randomize virtual address space */ 1347#define PF_SWAPWRITE 0x00800000 /* Allowed to write to swap */ 1348#define PF_SPREAD_PAGE 0x01000000 /* Spread page cache over cpuset */ 1349#define PF_SPREAD_SLAB 0x02000000 /* Spread some slab caches over cpuset */ 1350#define PF_MEMPOLICY 0x10000000 /* Non-default NUMA mempolicy */ 1351#define PF_MUTEX_TESTER 0x20000000 /* Thread belongs to the rt mutex tester */ 1352#define PF_FREEZER_SKIP 0x40000000 /* Freezer should not count it as freezeable */ 1353 1354/* 1355 * Only the _current_ task can read/write to tsk->flags, but other 1356 * tasks can access tsk->flags in readonly mode for example 1357 * with tsk_used_math (like during threaded core dumping). 1358 * There is however an exception to this rule during ptrace 1359 * or during fork: the ptracer task is allowed to write to the 1360 * child->flags of its traced child (same goes for fork, the parent 1361 * can write to the child->flags), because we're guaranteed the 1362 * child is not running and in turn not changing child->flags 1363 * at the same time the parent does it. 1364 */ 1365#define clear_stopped_child_used_math(child) do { (child)->flags &= ~PF_USED_MATH; } while (0) 1366#define set_stopped_child_used_math(child) do { (child)->flags |= PF_USED_MATH; } while (0) 1367#define clear_used_math() clear_stopped_child_used_math(current) 1368#define set_used_math() set_stopped_child_used_math(current) 1369#define conditional_stopped_child_used_math(condition, child) \ 1370 do { (child)->flags &= ~PF_USED_MATH, (child)->flags |= (condition) ? PF_USED_MATH : 0; } while (0) 1371#define conditional_used_math(condition) \ 1372 conditional_stopped_child_used_math(condition, current) 1373#define copy_to_stopped_child_used_math(child) \ 1374 do { (child)->flags &= ~PF_USED_MATH, (child)->flags |= current->flags & PF_USED_MATH; } while (0) 1375/* NOTE: this will return 0 or PF_USED_MATH, it will never return 1 */ 1376#define tsk_used_math(p) ((p)->flags & PF_USED_MATH) 1377#define used_math() tsk_used_math(current) 1378 1379#ifdef CONFIG_SMP 1380extern int set_cpus_allowed(struct task_struct *p, cpumask_t new_mask); 1381#else 1382static inline int set_cpus_allowed(struct task_struct *p, cpumask_t new_mask) 1383{ 1384 if (!cpu_isset(0, new_mask)) 1385 return -EINVAL; 1386 return 0; 1387} 1388#endif 1389 1390extern unsigned long long sched_clock(void); 1391 1392/* 1393 * For kernel-internal use: high-speed (but slightly incorrect) per-cpu 1394 * clock constructed from sched_clock(): 1395 */ 1396extern unsigned long long cpu_clock(int cpu); 1397 1398extern unsigned long long 1399task_sched_runtime(struct task_struct *task); 1400 1401/* sched_exec is called by processes performing an exec */ 1402#ifdef CONFIG_SMP 1403extern void sched_exec(void); 1404#else 1405#define sched_exec() {} 1406#endif 1407 1408extern void sched_clock_idle_sleep_event(void); 1409extern void sched_clock_idle_wakeup_event(u64 delta_ns); 1410 1411#ifdef CONFIG_HOTPLUG_CPU 1412extern void idle_task_exit(void); 1413#else 1414static inline void idle_task_exit(void) {} 1415#endif 1416 1417extern void sched_idle_next(void); 1418 1419#ifdef CONFIG_SCHED_DEBUG 1420extern unsigned int sysctl_sched_latency; 1421extern unsigned int sysctl_sched_min_granularity; 1422extern unsigned int sysctl_sched_wakeup_granularity; 1423extern unsigned int sysctl_sched_batch_wakeup_granularity; 1424extern unsigned int sysctl_sched_child_runs_first; 1425extern unsigned int sysctl_sched_features; 1426extern unsigned int sysctl_sched_migration_cost; 1427extern unsigned int sysctl_sched_nr_migrate; 1428#ifdef CONFIG_FAIR_GROUP_SCHED 1429extern unsigned int sysctl_sched_min_bal_int_shares; 1430extern unsigned int sysctl_sched_max_bal_int_shares; 1431#endif 1432 1433int sched_nr_latency_handler(struct ctl_table *table, int write, 1434 struct file *file, void __user *buffer, size_t *length, 1435 loff_t *ppos); 1436#endif 1437 1438extern unsigned int sysctl_sched_compat_yield; 1439 1440#ifdef CONFIG_RT_MUTEXES 1441extern int rt_mutex_getprio(struct task_struct *p); 1442extern void rt_mutex_setprio(struct task_struct *p, int prio); 1443extern void rt_mutex_adjust_pi(struct task_struct *p); 1444#else 1445static inline int rt_mutex_getprio(struct task_struct *p) 1446{ 1447 return p->normal_prio; 1448} 1449# define rt_mutex_adjust_pi(p) do { } while (0) 1450#endif 1451 1452extern void set_user_nice(struct task_struct *p, long nice); 1453extern int task_prio(const struct task_struct *p); 1454extern int task_nice(const struct task_struct *p); 1455extern int can_nice(const struct task_struct *p, const int nice); 1456extern int task_curr(const struct task_struct *p); 1457extern int idle_cpu(int cpu); 1458extern int sched_setscheduler(struct task_struct *, int, struct sched_param *); 1459extern struct task_struct *idle_task(int cpu); 1460extern struct task_struct *curr_task(int cpu); 1461extern void set_curr_task(int cpu, struct task_struct *p); 1462 1463void yield(void); 1464 1465/* 1466 * The default (Linux) execution domain. 1467 */ 1468extern struct exec_domain default_exec_domain; 1469 1470union thread_union { 1471 struct thread_info thread_info; 1472 unsigned long stack[THREAD_SIZE/sizeof(long)]; 1473}; 1474 1475#ifndef __HAVE_ARCH_KSTACK_END 1476static inline int kstack_end(void *addr) 1477{ 1478 /* Reliable end of stack detection: 1479 * Some APM bios versions misalign the stack 1480 */ 1481 return !(((unsigned long)addr+sizeof(void*)-1) & (THREAD_SIZE-sizeof(void*))); 1482} 1483#endif 1484 1485extern union thread_union init_thread_union; 1486extern struct task_struct init_task; 1487 1488extern struct mm_struct init_mm; 1489 1490#define find_task_by_pid(nr) find_task_by_pid_type(PIDTYPE_PID, nr) 1491extern struct task_struct *find_task_by_pid_type(int type, int pid); 1492extern void __set_special_pids(pid_t session, pid_t pgrp); 1493 1494/* per-UID process charging. */ 1495extern struct user_struct * alloc_uid(struct user_namespace *, uid_t); 1496static inline struct user_struct *get_uid(struct user_struct *u) 1497{ 1498 atomic_inc(&u->__count); 1499 return u; 1500} 1501extern void free_uid(struct user_struct *); 1502extern void switch_uid(struct user_struct *); 1503extern void release_uids(struct user_namespace *ns); 1504 1505#include <asm/current.h> 1506 1507extern void do_timer(unsigned long ticks); 1508 1509extern int FASTCALL(wake_up_state(struct task_struct * tsk, unsigned int state)); 1510extern int FASTCALL(wake_up_process(struct task_struct * tsk)); 1511extern void FASTCALL(wake_up_new_task(struct task_struct * tsk, 1512 unsigned long clone_flags)); 1513#ifdef CONFIG_SMP 1514 extern void kick_process(struct task_struct *tsk); 1515#else 1516 static inline void kick_process(struct task_struct *tsk) { } 1517#endif 1518extern void sched_fork(struct task_struct *p, int clone_flags); 1519extern void sched_dead(struct task_struct *p); 1520 1521extern int in_group_p(gid_t); 1522extern int in_egroup_p(gid_t); 1523 1524extern void proc_caches_init(void); 1525extern void flush_signals(struct task_struct *); 1526extern void ignore_signals(struct task_struct *); 1527extern void flush_signal_handlers(struct task_struct *, int force_default); 1528extern int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info); 1529 1530static inline int dequeue_signal_lock(struct task_struct *tsk, sigset_t *mask, siginfo_t *info) 1531{ 1532 unsigned long flags; 1533 int ret; 1534 1535 spin_lock_irqsave(&tsk->sighand->siglock, flags); 1536 ret = dequeue_signal(tsk, mask, info); 1537 spin_unlock_irqrestore(&tsk->sighand->siglock, flags); 1538 1539 return ret; 1540} 1541 1542extern void block_all_signals(int (*notifier)(void *priv), void *priv, 1543 sigset_t *mask); 1544extern void unblock_all_signals(void); 1545extern void release_task(struct task_struct * p); 1546extern int send_sig_info(int, struct siginfo *, struct task_struct *); 1547extern int send_group_sig_info(int, struct siginfo *, struct task_struct *); 1548extern int force_sigsegv(int, struct task_struct *); 1549extern int force_sig_info(int, struct siginfo *, struct task_struct *); 1550extern int __kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp); 1551extern int kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp); 1552extern int kill_pid_info(int sig, struct siginfo *info, struct pid *pid); 1553extern int kill_pid_info_as_uid(int, struct siginfo *, struct pid *, uid_t, uid_t, u32); 1554extern int kill_pgrp(struct pid *pid, int sig, int priv); 1555extern int kill_pid(struct pid *pid, int sig, int priv); 1556extern int kill_proc_info(int, struct siginfo *, pid_t); 1557extern void do_notify_parent(struct task_struct *, int); 1558extern void force_sig(int, struct task_struct *); 1559extern void force_sig_specific(int, struct task_struct *); 1560extern int send_sig(int, struct task_struct *, int); 1561extern void zap_other_threads(struct task_struct *p); 1562extern int kill_proc(pid_t, int, int); 1563extern struct sigqueue *sigqueue_alloc(void); 1564extern void sigqueue_free(struct sigqueue *); 1565extern int send_sigqueue(int, struct sigqueue *, struct task_struct *); 1566extern int send_group_sigqueue(int, struct sigqueue *, struct task_struct *); 1567extern int do_sigaction(int, struct k_sigaction *, struct k_sigaction *); 1568extern int do_sigaltstack(const stack_t __user *, stack_t __user *, unsigned long); 1569 1570static inline int kill_cad_pid(int sig, int priv) 1571{ 1572 return kill_pid(cad_pid, sig, priv); 1573} 1574 1575/* These can be the second arg to send_sig_info/send_group_sig_info. */ 1576#define SEND_SIG_NOINFO ((struct siginfo *) 0) 1577#define SEND_SIG_PRIV ((struct siginfo *) 1) 1578#define SEND_SIG_FORCED ((struct siginfo *) 2) 1579 1580static inline int is_si_special(const struct siginfo *info) 1581{ 1582 return info <= SEND_SIG_FORCED; 1583} 1584 1585/* True if we are on the alternate signal stack. */ 1586 1587static inline int on_sig_stack(unsigned long sp) 1588{ 1589 return (sp - current->sas_ss_sp < current->sas_ss_size); 1590} 1591 1592static inline int sas_ss_flags(unsigned long sp) 1593{ 1594 return (current->sas_ss_size == 0 ? SS_DISABLE 1595 : on_sig_stack(sp) ? SS_ONSTACK : 0); 1596} 1597 1598/* 1599 * Routines for handling mm_structs 1600 */ 1601extern struct mm_struct * mm_alloc(void); 1602 1603/* mmdrop drops the mm and the page tables */ 1604extern void FASTCALL(__mmdrop(struct mm_struct *)); 1605static inline void mmdrop(struct mm_struct * mm) 1606{ 1607 if (unlikely(atomic_dec_and_test(&mm->mm_count))) 1608 __mmdrop(mm); 1609} 1610 1611/* mmput gets rid of the mappings and all user-space */ 1612extern void mmput(struct mm_struct *); 1613/* Grab a reference to a task's mm, if it is not already going away */ 1614extern struct mm_struct *get_task_mm(struct task_struct *task); 1615/* Remove the current tasks stale references to the old mm_struct */ 1616extern void mm_release(struct task_struct *, struct mm_struct *); 1617 1618extern int copy_thread(int, unsigned long, unsigned long, unsigned long, struct task_struct *, struct pt_regs *); 1619extern void flush_thread(void); 1620extern void exit_thread(void); 1621 1622extern void exit_files(struct task_struct *); 1623extern void __cleanup_signal(struct signal_struct *); 1624extern void __cleanup_sighand(struct sighand_struct *); 1625extern void exit_itimers(struct signal_struct *); 1626 1627extern NORET_TYPE void do_group_exit(int); 1628 1629extern void daemonize(const char *, ...); 1630extern int allow_signal(int); 1631extern int disallow_signal(int); 1632 1633extern int do_execve(char *, char __user * __user *, char __user * __user *, struct pt_regs *); 1634extern long do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *); 1635struct task_struct *fork_idle(int); 1636 1637extern void set_task_comm(struct task_struct *tsk, char *from); 1638extern void get_task_comm(char *to, struct task_struct *tsk); 1639 1640#ifdef CONFIG_SMP 1641extern void wait_task_inactive(struct task_struct * p); 1642#else 1643#define wait_task_inactive(p) do { } while (0) 1644#endif 1645 1646#define remove_parent(p) list_del_init(&(p)->sibling) 1647#define add_parent(p) list_add_tail(&(p)->sibling,&(p)->parent->children) 1648 1649#define next_task(p) list_entry(rcu_dereference((p)->tasks.next), struct task_struct, tasks) 1650 1651#define for_each_process(p) \ 1652 for (p = &init_task ; (p = next_task(p)) != &init_task ; ) 1653 1654/* 1655 * Careful: do_each_thread/while_each_thread is a double loop so 1656 * 'break' will not work as expected - use goto instead. 1657 */ 1658#define do_each_thread(g, t) \ 1659 for (g = t = &init_task ; (g = t = next_task(g)) != &init_task ; ) do 1660 1661#define while_each_thread(g, t) \ 1662 while ((t = next_thread(t)) != g) 1663 1664/* de_thread depends on thread_group_leader not being a pid based check */ 1665#define thread_group_leader(p) (p == p->group_leader) 1666 1667/* Do to the insanities of de_thread it is possible for a process 1668 * to have the pid of the thread group leader without actually being 1669 * the thread group leader. For iteration through the pids in proc 1670 * all we care about is that we have a task with the appropriate 1671 * pid, we don't actually care if we have the right task. 1672 */ 1673static inline int has_group_leader_pid(struct task_struct *p) 1674{ 1675 return p->pid == p->tgid; 1676} 1677 1678static inline struct task_struct *next_thread(const struct task_struct *p) 1679{ 1680 return list_entry(rcu_dereference(p->thread_group.next), 1681 struct task_struct, thread_group); 1682} 1683 1684static inline int thread_group_empty(struct task_struct *p) 1685{ 1686 return list_empty(&p->thread_group); 1687} 1688 1689#define delay_group_leader(p) \ 1690 (thread_group_leader(p) && !thread_group_empty(p)) 1691 1692/* 1693 * Protects ->fs, ->files, ->mm, ->group_info, ->comm, keyring 1694 * subscriptions and synchronises with wait4(). Also used in procfs. Also 1695 * pins the final release of task.io_context. Also protects ->cpuset. 1696 * 1697 * Nests both inside and outside of read_lock(&tasklist_lock). 1698 * It must not be nested with write_lock_irq(&tasklist_lock), 1699 * neither inside nor outside. 1700 */ 1701static inline void task_lock(struct task_struct *p) 1702{ 1703 spin_lock(&p->alloc_lock); 1704} 1705 1706static inline void task_unlock(struct task_struct *p) 1707{ 1708 spin_unlock(&p->alloc_lock); 1709} 1710 1711extern struct sighand_struct *lock_task_sighand(struct task_struct *tsk, 1712 unsigned long *flags); 1713 1714static inline void unlock_task_sighand(struct task_struct *tsk, 1715 unsigned long *flags) 1716{ 1717 spin_unlock_irqrestore(&tsk->sighand->siglock, *flags); 1718} 1719 1720#ifndef __HAVE_THREAD_FUNCTIONS 1721 1722#define task_thread_info(task) ((struct thread_info *)(task)->stack) 1723#define task_stack_page(task) ((task)->stack) 1724 1725static inline void setup_thread_stack(struct task_struct *p, struct task_struct *org) 1726{ 1727 *task_thread_info(p) = *task_thread_info(org); 1728 task_thread_info(p)->task = p; 1729} 1730 1731static inline unsigned long *end_of_stack(struct task_struct *p) 1732{ 1733 return (unsigned long *)(task_thread_info(p) + 1); 1734} 1735 1736#endif 1737 1738/* set thread flags in other task's structures 1739 * - see asm/thread_info.h for TIF_xxxx flags available 1740 */ 1741static inline void set_tsk_thread_flag(struct task_struct *tsk, int flag) 1742{ 1743 set_ti_thread_flag(task_thread_info(tsk), flag); 1744} 1745 1746static inline void clear_tsk_thread_flag(struct task_struct *tsk, int flag) 1747{ 1748 clear_ti_thread_flag(task_thread_info(tsk), flag); 1749} 1750 1751static inline int test_and_set_tsk_thread_flag(struct task_struct *tsk, int flag) 1752{ 1753 return test_and_set_ti_thread_flag(task_thread_info(tsk), flag); 1754} 1755 1756static inline int test_and_clear_tsk_thread_flag(struct task_struct *tsk, int flag) 1757{ 1758 return test_and_clear_ti_thread_flag(task_thread_info(tsk), flag); 1759} 1760 1761static inline int test_tsk_thread_flag(struct task_struct *tsk, int flag) 1762{ 1763 return test_ti_thread_flag(task_thread_info(tsk), flag); 1764} 1765 1766static inline void set_tsk_need_resched(struct task_struct *tsk) 1767{ 1768 set_tsk_thread_flag(tsk,TIF_NEED_RESCHED); 1769} 1770 1771static inline void clear_tsk_need_resched(struct task_struct *tsk) 1772{ 1773 clear_tsk_thread_flag(tsk,TIF_NEED_RESCHED); 1774} 1775 1776static inline int signal_pending(struct task_struct *p) 1777{ 1778 return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING)); 1779} 1780 1781static inline int need_resched(void) 1782{ 1783 return unlikely(test_thread_flag(TIF_NEED_RESCHED)); 1784} 1785 1786/* 1787 * cond_resched() and cond_resched_lock(): latency reduction via 1788 * explicit rescheduling in places that are safe. The return 1789 * value indicates whether a reschedule was done in fact. 1790 * cond_resched_lock() will drop the spinlock before scheduling, 1791 * cond_resched_softirq() will enable bhs before scheduling. 1792 */ 1793extern int cond_resched(void); 1794extern int cond_resched_lock(spinlock_t * lock); 1795extern int cond_resched_softirq(void); 1796 1797/* 1798 * Does a critical section need to be broken due to another 1799 * task waiting?: 1800 */ 1801#if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP) 1802# define need_lockbreak(lock) ((lock)->break_lock) 1803#else 1804# define need_lockbreak(lock) 0 1805#endif 1806 1807/* 1808 * Does a critical section need to be broken due to another 1809 * task waiting or preemption being signalled: 1810 */ 1811static inline int lock_need_resched(spinlock_t *lock) 1812{ 1813 if (need_lockbreak(lock) || need_resched()) 1814 return 1; 1815 return 0; 1816} 1817 1818/* 1819 * Reevaluate whether the task has signals pending delivery. 1820 * Wake the task if so. 1821 * This is required every time the blocked sigset_t changes. 1822 * callers must hold sighand->siglock. 1823 */ 1824extern void recalc_sigpending_and_wake(struct task_struct *t); 1825extern void recalc_sigpending(void); 1826 1827extern void signal_wake_up(struct task_struct *t, int resume_stopped); 1828 1829/* 1830 * Wrappers for p->thread_info->cpu access. No-op on UP. 1831 */ 1832#ifdef CONFIG_SMP 1833 1834static inline unsigned int task_cpu(const struct task_struct *p) 1835{ 1836 return task_thread_info(p)->cpu; 1837} 1838 1839extern void set_task_cpu(struct task_struct *p, unsigned int cpu); 1840 1841#else 1842 1843static inline unsigned int task_cpu(const struct task_struct *p) 1844{ 1845 return 0; 1846} 1847 1848static inline void set_task_cpu(struct task_struct *p, unsigned int cpu) 1849{ 1850} 1851 1852#endif /* CONFIG_SMP */ 1853 1854#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 1855extern void arch_pick_mmap_layout(struct mm_struct *mm); 1856#else 1857static inline void arch_pick_mmap_layout(struct mm_struct *mm) 1858{ 1859 mm->mmap_base = TASK_UNMAPPED_BASE; 1860 mm->get_unmapped_area = arch_get_unmapped_area; 1861 mm->unmap_area = arch_unmap_area; 1862} 1863#endif 1864 1865extern long sched_setaffinity(pid_t pid, cpumask_t new_mask); 1866extern long sched_getaffinity(pid_t pid, cpumask_t *mask); 1867 1868extern int sched_mc_power_savings, sched_smt_power_savings; 1869 1870extern void normalize_rt_tasks(void); 1871 1872#ifdef CONFIG_FAIR_GROUP_SCHED 1873 1874extern struct task_group init_task_group; 1875 1876extern struct task_group *sched_create_group(void); 1877extern void sched_destroy_group(struct task_group *tg); 1878extern void sched_move_task(struct task_struct *tsk); 1879extern int sched_group_set_shares(struct task_group *tg, unsigned long shares); 1880extern unsigned long sched_group_shares(struct task_group *tg); 1881 1882#endif 1883 1884#ifdef CONFIG_TASK_XACCT 1885static inline void add_rchar(struct task_struct *tsk, ssize_t amt) 1886{ 1887 tsk->rchar += amt; 1888} 1889 1890static inline void add_wchar(struct task_struct *tsk, ssize_t amt) 1891{ 1892 tsk->wchar += amt; 1893} 1894 1895static inline void inc_syscr(struct task_struct *tsk) 1896{ 1897 tsk->syscr++; 1898} 1899 1900static inline void inc_syscw(struct task_struct *tsk) 1901{ 1902 tsk->syscw++; 1903} 1904#else 1905static inline void add_rchar(struct task_struct *tsk, ssize_t amt) 1906{ 1907} 1908 1909static inline void add_wchar(struct task_struct *tsk, ssize_t amt) 1910{ 1911} 1912 1913static inline void inc_syscr(struct task_struct *tsk) 1914{ 1915} 1916 1917static inline void inc_syscw(struct task_struct *tsk) 1918{ 1919} 1920#endif 1921 1922#ifdef CONFIG_SMP 1923void migration_init(void); 1924#else 1925static inline void migration_init(void) 1926{ 1927} 1928#endif 1929 1930#endif /* __KERNEL__ */ 1931 1932#endif 1933