aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sched.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r--include/linux/sched.h54
1 files changed, 41 insertions, 13 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 42888d715fb1..05a8c00e8339 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -167,6 +167,7 @@ extern int nr_threads;
167DECLARE_PER_CPU(unsigned long, process_counts); 167DECLARE_PER_CPU(unsigned long, process_counts);
168extern int nr_processes(void); 168extern int nr_processes(void);
169extern unsigned long nr_running(void); 169extern unsigned long nr_running(void);
170extern bool single_task_running(void);
170extern unsigned long nr_iowait(void); 171extern unsigned long nr_iowait(void);
171extern unsigned long nr_iowait_cpu(int cpu); 172extern unsigned long nr_iowait_cpu(int cpu);
172extern void get_iowait_load(unsigned long *nr_waiters, unsigned long *load); 173extern void get_iowait_load(unsigned long *nr_waiters, unsigned long *load);
@@ -1916,8 +1917,6 @@ extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut,
1916#define PF_KTHREAD 0x00200000 /* I am a kernel thread */ 1917#define PF_KTHREAD 0x00200000 /* I am a kernel thread */
1917#define PF_RANDOMIZE 0x00400000 /* randomize virtual address space */ 1918#define PF_RANDOMIZE 0x00400000 /* randomize virtual address space */
1918#define PF_SWAPWRITE 0x00800000 /* Allowed to write to swap */ 1919#define PF_SWAPWRITE 0x00800000 /* Allowed to write to swap */
1919#define PF_SPREAD_PAGE 0x01000000 /* Spread page cache over cpuset */
1920#define PF_SPREAD_SLAB 0x02000000 /* Spread some slab caches over cpuset */
1921#define PF_NO_SETAFFINITY 0x04000000 /* Userland is not allowed to meddle with cpus_allowed */ 1920#define PF_NO_SETAFFINITY 0x04000000 /* Userland is not allowed to meddle with cpus_allowed */
1922#define PF_MCE_EARLY 0x08000000 /* Early kill for mce process policy */ 1921#define PF_MCE_EARLY 0x08000000 /* Early kill for mce process policy */
1923#define PF_MUTEX_TESTER 0x20000000 /* Thread belongs to the rt mutex tester */ 1922#define PF_MUTEX_TESTER 0x20000000 /* Thread belongs to the rt mutex tester */
@@ -1949,11 +1948,13 @@ extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut,
1949#define tsk_used_math(p) ((p)->flags & PF_USED_MATH) 1948#define tsk_used_math(p) ((p)->flags & PF_USED_MATH)
1950#define used_math() tsk_used_math(current) 1949#define used_math() tsk_used_math(current)
1951 1950
1952/* __GFP_IO isn't allowed if PF_MEMALLOC_NOIO is set in current->flags */ 1951/* __GFP_IO isn't allowed if PF_MEMALLOC_NOIO is set in current->flags
1952 * __GFP_FS is also cleared as it implies __GFP_IO.
1953 */
1953static inline gfp_t memalloc_noio_flags(gfp_t flags) 1954static inline gfp_t memalloc_noio_flags(gfp_t flags)
1954{ 1955{
1955 if (unlikely(current->flags & PF_MEMALLOC_NOIO)) 1956 if (unlikely(current->flags & PF_MEMALLOC_NOIO))
1956 flags &= ~__GFP_IO; 1957 flags &= ~(__GFP_IO | __GFP_FS);
1957 return flags; 1958 return flags;
1958} 1959}
1959 1960
@@ -1970,17 +1971,31 @@ static inline void memalloc_noio_restore(unsigned int flags)
1970} 1971}
1971 1972
1972/* Per-process atomic flags. */ 1973/* Per-process atomic flags. */
1973#define PFA_NO_NEW_PRIVS 0x00000001 /* May not gain new privileges. */ 1974#define PFA_NO_NEW_PRIVS 0 /* May not gain new privileges. */
1975#define PFA_SPREAD_PAGE 1 /* Spread page cache over cpuset */
1976#define PFA_SPREAD_SLAB 2 /* Spread some slab caches over cpuset */
1974 1977
1975static inline bool task_no_new_privs(struct task_struct *p)
1976{
1977 return test_bit(PFA_NO_NEW_PRIVS, &p->atomic_flags);
1978}
1979 1978
1980static inline void task_set_no_new_privs(struct task_struct *p) 1979#define TASK_PFA_TEST(name, func) \
1981{ 1980 static inline bool task_##func(struct task_struct *p) \
1982 set_bit(PFA_NO_NEW_PRIVS, &p->atomic_flags); 1981 { return test_bit(PFA_##name, &p->atomic_flags); }
1983} 1982#define TASK_PFA_SET(name, func) \
1983 static inline void task_set_##func(struct task_struct *p) \
1984 { set_bit(PFA_##name, &p->atomic_flags); }
1985#define TASK_PFA_CLEAR(name, func) \
1986 static inline void task_clear_##func(struct task_struct *p) \
1987 { clear_bit(PFA_##name, &p->atomic_flags); }
1988
1989TASK_PFA_TEST(NO_NEW_PRIVS, no_new_privs)
1990TASK_PFA_SET(NO_NEW_PRIVS, no_new_privs)
1991
1992TASK_PFA_TEST(SPREAD_PAGE, spread_page)
1993TASK_PFA_SET(SPREAD_PAGE, spread_page)
1994TASK_PFA_CLEAR(SPREAD_PAGE, spread_page)
1995
1996TASK_PFA_TEST(SPREAD_SLAB, spread_slab)
1997TASK_PFA_SET(SPREAD_SLAB, spread_slab)
1998TASK_PFA_CLEAR(SPREAD_SLAB, spread_slab)
1984 1999
1985/* 2000/*
1986 * task->jobctl flags 2001 * task->jobctl flags
@@ -2613,9 +2628,22 @@ static inline void setup_thread_stack(struct task_struct *p, struct task_struct
2613 task_thread_info(p)->task = p; 2628 task_thread_info(p)->task = p;
2614} 2629}
2615 2630
2631/*
2632 * Return the address of the last usable long on the stack.
2633 *
2634 * When the stack grows down, this is just above the thread
2635 * info struct. Going any lower will corrupt the threadinfo.
2636 *
2637 * When the stack grows up, this is the highest address.
2638 * Beyond that position, we corrupt data on the next page.
2639 */
2616static inline unsigned long *end_of_stack(struct task_struct *p) 2640static inline unsigned long *end_of_stack(struct task_struct *p)
2617{ 2641{
2642#ifdef CONFIG_STACK_GROWSUP
2643 return (unsigned long *)((unsigned long)task_thread_info(p) + THREAD_SIZE) - 1;
2644#else
2618 return (unsigned long *)(task_thread_info(p) + 1); 2645 return (unsigned long *)(task_thread_info(p) + 1);
2646#endif
2619} 2647}
2620 2648
2621#endif 2649#endif