aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sched.h
diff options
context:
space:
mode:
authorMike Galbraith <efault@gmx.de>2010-11-30 08:18:03 -0500
committerIngo Molnar <mingo@elte.hu>2010-11-30 10:03:35 -0500
commit5091faa449ee0b7d73bc296a93bca9540fc51d0a (patch)
tree55f5e96e189af65c85c769fce48627b8a5abb86b /include/linux/sched.h
parent822bc180a7f7a7bc5fcaaea195f41b487cc8cae8 (diff)
sched: Add 'autogroup' scheduling feature: automated per session task groups
A recurring complaint from CFS users is that parallel kbuild has a negative impact on desktop interactivity. This patch implements an idea from Linus, to automatically create task groups. Currently, only per session autogroups are implemented, but the patch leaves the way open for enhancement. Implementation: each task's signal struct contains an inherited pointer to a refcounted autogroup struct containing a task group pointer, the default for all tasks pointing to the init_task_group. When a task calls setsid(), a new task group is created, the process is moved into the new task group, and a reference to the preveious task group is dropped. Child processes inherit this task group thereafter, and increase it's refcount. When the last thread of a process exits, the process's reference is dropped, such that when the last process referencing an autogroup exits, the autogroup is destroyed. At runqueue selection time, IFF a task has no cgroup assignment, its current autogroup is used. Autogroup bandwidth is controllable via setting it's nice level through the proc filesystem: cat /proc/<pid>/autogroup Displays the task's group and the group's nice level. echo <nice level> > /proc/<pid>/autogroup Sets the task group's shares to the weight of nice <level> task. Setting nice level is rate limited for !admin users due to the abuse risk of task group locking. The feature is enabled from boot by default if CONFIG_SCHED_AUTOGROUP=y is selected, but can be disabled via the boot option noautogroup, and can also be turned on/off on the fly via: echo [01] > /proc/sys/kernel/sched_autogroup_enabled ... which will automatically move tasks to/from the root task group. Signed-off-by: Mike Galbraith <efault@gmx.de> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Markus Trippelsdorf <markus@trippelsdorf.de> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Paul Turner <pjt@google.com> Cc: Oleg Nesterov <oleg@redhat.com> [ Removed the task_group_path() debug code, and fixed !EVENTFD build failure. ] Signed-off-by: Ingo Molnar <mingo@elte.hu> LKML-Reference: <1290281700.28711.9.camel@maggy.simson.net> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r--include/linux/sched.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index a5b92c70c737..9c2d46da486e 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -509,6 +509,8 @@ struct thread_group_cputimer {
509 spinlock_t lock; 509 spinlock_t lock;
510}; 510};
511 511
512struct autogroup;
513
512/* 514/*
513 * NOTE! "signal_struct" does not have it's own 515 * NOTE! "signal_struct" does not have it's own
514 * locking, because a shared signal_struct always 516 * locking, because a shared signal_struct always
@@ -576,6 +578,9 @@ struct signal_struct {
576 578
577 struct tty_struct *tty; /* NULL if no tty */ 579 struct tty_struct *tty; /* NULL if no tty */
578 580
581#ifdef CONFIG_SCHED_AUTOGROUP
582 struct autogroup *autogroup;
583#endif
579 /* 584 /*
580 * Cumulative resource counters for dead threads in the group, 585 * Cumulative resource counters for dead threads in the group,
581 * and for reaped dead child processes forked by this group. 586 * and for reaped dead child processes forked by this group.
@@ -1927,6 +1932,24 @@ int sched_rt_handler(struct ctl_table *table, int write,
1927 1932
1928extern unsigned int sysctl_sched_compat_yield; 1933extern unsigned int sysctl_sched_compat_yield;
1929 1934
1935#ifdef CONFIG_SCHED_AUTOGROUP
1936extern unsigned int sysctl_sched_autogroup_enabled;
1937
1938extern void sched_autogroup_create_attach(struct task_struct *p);
1939extern void sched_autogroup_detach(struct task_struct *p);
1940extern void sched_autogroup_fork(struct signal_struct *sig);
1941extern void sched_autogroup_exit(struct signal_struct *sig);
1942#ifdef CONFIG_PROC_FS
1943extern void proc_sched_autogroup_show_task(struct task_struct *p, struct seq_file *m);
1944extern int proc_sched_autogroup_set_nice(struct task_struct *p, int *nice);
1945#endif
1946#else
1947static inline void sched_autogroup_create_attach(struct task_struct *p) { }
1948static inline void sched_autogroup_detach(struct task_struct *p) { }
1949static inline void sched_autogroup_fork(struct signal_struct *sig) { }
1950static inline void sched_autogroup_exit(struct signal_struct *sig) { }
1951#endif
1952
1930#ifdef CONFIG_RT_MUTEXES 1953#ifdef CONFIG_RT_MUTEXES
1931extern int rt_mutex_getprio(struct task_struct *p); 1954extern int rt_mutex_getprio(struct task_struct *p);
1932extern void rt_mutex_setprio(struct task_struct *p, int prio); 1955extern void rt_mutex_setprio(struct task_struct *p, int prio);