Release 4.7 kernel/sched/auto_group.c
#include "sched.h"
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/kallsyms.h>
#include <linux/utsname.h>
#include <linux/security.h>
#include <linux/export.h>
unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
static struct autogroup autogroup_default;
static atomic_t autogroup_seq_nr;
void __init autogroup_init(struct task_struct *init_task)
{
autogroup_default.tg = &root_task_group;
kref_init(&autogroup_default.kref);
init_rwsem(&autogroup_default.lock);
init_task->signal->autogroup = &autogroup_default;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| mike galbraith | mike galbraith | 41 | 95.35% | 1 | 33.33% |
| yong zhang | yong zhang | 2 | 4.65% | 2 | 66.67% |
| Total | 43 | 100.00% | 3 | 100.00% |
void autogroup_free(struct task_group *tg)
{
kfree(tg->autogroup);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| mike galbraith | mike galbraith | 17 | 100.00% | 1 | 100.00% |
| Total | 17 | 100.00% | 1 | 100.00% |
static inline void autogroup_destroy(struct kref *kref)
{
struct autogroup *ag = container_of(kref, struct autogroup, kref);
#ifdef CONFIG_RT_GROUP_SCHED
/* We've redirected RT tasks to the root task group... */
ag->tg->rt_se = NULL;
ag->tg->rt_rq = NULL;
#endif
sched_offline_group(ag->tg);
sched_destroy_group(ag->tg);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| mike galbraith | mike galbraith | 56 | 88.89% | 2 | 66.67% |
| li zefan | li zefan | 7 | 11.11% | 1 | 33.33% |
| Total | 63 | 100.00% | 3 | 100.00% |
static inline void autogroup_kref_put(struct autogroup *ag)
{
kref_put(&ag->kref, autogroup_destroy);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| mike galbraith | mike galbraith | 22 | 100.00% | 1 | 100.00% |
| Total | 22 | 100.00% | 1 | 100.00% |
static inline struct autogroup *autogroup_kref_get(struct autogroup *ag)
{
kref_get(&ag->kref);
return ag;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| mike galbraith | mike galbraith | 25 | 100.00% | 1 | 100.00% |
| Total | 25 | 100.00% | 1 | 100.00% |
static inline struct autogroup *autogroup_task_get(struct task_struct *p)
{
struct autogroup *ag;
unsigned long flags;
if (!lock_task_sighand(p, &flags))
return autogroup_kref_get(&autogroup_default);
ag = autogroup_kref_get(p->signal->autogroup);
unlock_task_sighand(p, &flags);
return ag;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| mike galbraith | mike galbraith | 63 | 100.00% | 1 | 100.00% |
| Total | 63 | 100.00% | 1 | 100.00% |
static inline struct autogroup *autogroup_create(void)
{
struct autogroup *ag = kzalloc(sizeof(*ag), GFP_KERNEL);
struct task_group *tg;
if (!ag)
goto out_fail;
tg = sched_create_group(&root_task_group);
if (IS_ERR(tg))
goto out_free;
kref_init(&ag->kref);
init_rwsem(&ag->lock);
ag->id = atomic_inc_return(&autogroup_seq_nr);
ag->tg = tg;
#ifdef CONFIG_RT_GROUP_SCHED
/*
* Autogroup RT tasks are redirected to the root task group
* so we don't have to move tasks around upon policy change,
* or flail around trying to allocate bandwidth on the fly.
* A bandwidth exception in __sched_setscheduler() allows
* the policy change to proceed.
*/
free_rt_sched_group(tg);
tg->rt_se = root_task_group.rt_se;
tg->rt_rq = root_task_group.rt_rq;
#endif
tg->autogroup = ag;
sched_online_group(tg, &root_task_group);
return ag;
out_free:
kfree(ag);
out_fail:
if (printk_ratelimit()) {
printk(KERN_WARNING "autogroup_create: %s failure.\n",
ag ? "sched_create_group()" : "kmalloc()");
}
return autogroup_kref_get(&autogroup_default);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| mike galbraith | mike galbraith | 159 | 94.08% | 2 | 40.00% |
| gerald schaefer | gerald schaefer | 8 | 4.73% | 1 | 20.00% |
| peter zijlstra | peter zijlstra | 1 | 0.59% | 1 | 20.00% |
| yong zhang | yong zhang | 1 | 0.59% | 1 | 20.00% |
| Total | 169 | 100.00% | 5 | 100.00% |
bool task_wants_autogroup(struct task_struct *p, struct task_group *tg)
{
if (tg != &root_task_group)
return false;
/*
* We can only assume the task group can't go away on us if
* autogroup_move_group() can see us on ->thread_group list.
*/
if (p->flags & PF_EXITING)
return false;
return true;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| mike galbraith | mike galbraith | 39 | 97.50% | 1 | 50.00% |
| peter zijlstra | peter zijlstra | 1 | 2.50% | 1 | 50.00% |
| Total | 40 | 100.00% | 2 | 100.00% |
static void
autogroup_move_group(struct task_struct *p, struct autogroup *ag)
{
struct autogroup *prev;
struct task_struct *t;
unsigned long flags;
BUG_ON(!lock_task_sighand(p, &flags));
prev = p->signal->autogroup;
if (prev == ag) {
unlock_task_sighand(p, &flags);
return;
}
p->signal->autogroup = autogroup_kref_get(ag);
if (!READ_ONCE(sysctl_sched_autogroup_enabled))
goto out;
for_each_thread(p, t)
sched_move_task(t);
out:
unlock_task_sighand(p, &flags);
autogroup_kref_put(prev);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| mike galbraith | mike galbraith | 95 | 82.61% | 1 | 25.00% |
| ingo molnar | ingo molnar | 12 | 10.43% | 1 | 25.00% |
| oleg nesterov | oleg nesterov | 7 | 6.09% | 1 | 25.00% |
| jason low | jason low | 1 | 0.87% | 1 | 25.00% |
| Total | 115 | 100.00% | 4 | 100.00% |
/* Allocates GFP_KERNEL, cannot be called under any spinlock */
void sched_autogroup_create_attach(struct task_struct *p)
{
struct autogroup *ag = autogroup_create();
autogroup_move_group(p, ag);
/* drop extra reference added by autogroup_create() */
autogroup_kref_put(ag);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| mike galbraith | mike galbraith | 21 | 67.74% | 1 | 25.00% |
| oleg nesterov | oleg nesterov | 7 | 22.58% | 1 | 25.00% |
| ingo molnar | ingo molnar | 2 | 6.45% | 1 | 25.00% |
| lucas de marchi | lucas de marchi | 1 | 3.23% | 1 | 25.00% |
| Total | 31 | 100.00% | 4 | 100.00% |
EXPORT_SYMBOL(sched_autogroup_create_attach);
/* Cannot be called under siglock. Currently has no users */
void sched_autogroup_detach(struct task_struct *p)
{
autogroup_move_group(p, &autogroup_default);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| mike galbraith | mike galbraith | 18 | 100.00% | 1 | 100.00% |
| Total | 18 | 100.00% | 1 | 100.00% |
EXPORT_SYMBOL(sched_autogroup_detach);
void sched_autogroup_fork(struct signal_struct *sig)
{
sig->autogroup = autogroup_task_get(current);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| mike galbraith | mike galbraith | 19 | 100.00% | 2 | 100.00% |
| Total | 19 | 100.00% | 2 | 100.00% |
void sched_autogroup_exit(struct signal_struct *sig)
{
autogroup_kref_put(sig->autogroup);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| mike galbraith | mike galbraith | 17 | 100.00% | 1 | 100.00% |
| Total | 17 | 100.00% | 1 | 100.00% |
static int __init setup_autogroup(char *str)
{
sysctl_sched_autogroup_enabled = 0;
return 1;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| mike galbraith | mike galbraith | 18 | 100.00% | 1 | 100.00% |
| Total | 18 | 100.00% | 1 | 100.00% |
__setup("noautogroup", setup_autogroup);
#ifdef CONFIG_PROC_FS
int proc_sched_autogroup_set_nice(struct task_struct *p, int nice)
{
static unsigned long next = INITIAL_JIFFIES;
struct autogroup *ag;
int err;
if (nice < MIN_NICE || nice > MAX_NICE)
return -EINVAL;
err = security_task_setnice(current, nice);
if (err)
return err;
if (nice < 0 && !can_nice(current, nice))
return -EPERM;
/* this is a heavy operation taking global locks.. */
if (!capable(CAP_SYS_ADMIN) && time_before(jiffies, next))
return -EAGAIN;
next = HZ / 10 + jiffies;
ag = autogroup_task_get(p);
down_write(&ag->lock);
err = sched_group_set_shares(ag->tg, sched_prio_to_weight[nice + 20]);
if (!err)
ag->nice = nice;
up_write(&ag->lock);
autogroup_kref_put(ag);
return err;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| ingo molnar | ingo molnar | 159 | 98.15% | 1 | 33.33% |
| dongsheng yang | dongsheng yang | 2 | 1.23% | 1 | 33.33% |
| andi kleen | andi kleen | 1 | 0.62% | 1 | 33.33% |
| Total | 162 | 100.00% | 3 | 100.00% |
void proc_sched_autogroup_show_task(struct task_struct *p, struct seq_file *m)
{
struct autogroup *ag = autogroup_task_get(p);
if (!task_group_is_autogroup(ag->tg))
goto out;
down_read(&ag->lock);
seq_printf(m, "/autogroup-%ld nice %d\n", ag->id, ag->nice);
up_read(&ag->lock);
out:
autogroup_kref_put(ag);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| ingo molnar | ingo molnar | 76 | 100.00% | 1 | 100.00% |
| Total | 76 | 100.00% | 1 | 100.00% |
#endif /* CONFIG_PROC_FS */
#ifdef CONFIG_SCHED_DEBUG
int autogroup_path(struct task_group *tg, char *buf, int buflen)
{
if (!task_group_is_autogroup(tg))
return 0;
return snprintf(buf, buflen, "%s-%ld", "/autogroup", tg->autogroup->id);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| mike galbraith | mike galbraith | 38 | 82.61% | 2 | 66.67% |
| bharata b rao | bharata b rao | 8 | 17.39% | 1 | 33.33% |
| Total | 46 | 100.00% | 3 | 100.00% |
#endif /* CONFIG_SCHED_DEBUG */
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| mike galbraith | mike galbraith | 701 | 69.27% | 4 | 23.53% |
| ingo molnar | ingo molnar | 255 | 25.20% | 1 | 5.88% |
| oleg nesterov | oleg nesterov | 14 | 1.38% | 1 | 5.88% |
| peter zijlstra | peter zijlstra | 11 | 1.09% | 2 | 11.76% |
| bharata b rao | bharata b rao | 8 | 0.79% | 1 | 5.88% |
| gerald schaefer | gerald schaefer | 8 | 0.79% | 1 | 5.88% |
| li zefan | li zefan | 7 | 0.69% | 1 | 5.88% |
| yong zhang | yong zhang | 3 | 0.30% | 2 | 11.76% |
| dongsheng yang | dongsheng yang | 2 | 0.20% | 1 | 5.88% |
| lucas de marchi | lucas de marchi | 1 | 0.10% | 1 | 5.88% |
| andi kleen | andi kleen | 1 | 0.10% | 1 | 5.88% |
| jason low | jason low | 1 | 0.10% | 1 | 5.88% |
| Total | 1012 | 100.00% | 17 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.