sched: group scheduling, sysfs tunables
Add tunables in sysfs to modify a user's cpu share. A directory is created in sysfs for each new user in the system. /sys/kernel/uids/<uid>/cpu_share Reading this file returns the cpu shares granted for the user. Writing into this file modifies the cpu share for the user. Only an administrator is allowed to modify a user's cpu share. Ex: # cd /sys/kernel/uids/ # cat 512/cpu_share 1024 # echo 2048 > 512/cpu_share # cat 512/cpu_share 2048 # Signed-off-by: Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
committed by
Ingo Molnar
parent
8ca0e14ffb
commit
5cb350baf5
@@ -162,6 +162,8 @@ struct task_group {
|
||||
/* runqueue "owned" by this group on each cpu */
|
||||
struct cfs_rq **cfs_rq;
|
||||
unsigned long shares;
|
||||
/* spinlock to serialize modification to shares */
|
||||
spinlock_t lock;
|
||||
};
|
||||
|
||||
/* Default task group's sched entity on each cpu */
|
||||
@@ -6533,6 +6535,7 @@ void __init sched_init(void)
|
||||
se->parent = NULL;
|
||||
}
|
||||
init_task_group.shares = init_task_group_load;
|
||||
spin_lock_init(&init_task_group.lock);
|
||||
#endif
|
||||
|
||||
for (j = 0; j < CPU_LOAD_IDX_MAX; j++)
|
||||
@@ -6777,6 +6780,7 @@ struct task_group *sched_create_group(void)
|
||||
}
|
||||
|
||||
tg->shares = NICE_0_LOAD;
|
||||
spin_lock_init(&tg->lock);
|
||||
|
||||
return tg;
|
||||
|
||||
@@ -6897,8 +6901,9 @@ int sched_group_set_shares(struct task_group *tg, unsigned long shares)
|
||||
{
|
||||
int i;
|
||||
|
||||
spin_lock(&tg->lock);
|
||||
if (tg->shares == shares)
|
||||
return 0;
|
||||
goto done;
|
||||
|
||||
/* return -EINVAL if the new value is not sane */
|
||||
|
||||
@@ -6906,7 +6911,14 @@ int sched_group_set_shares(struct task_group *tg, unsigned long shares)
|
||||
for_each_possible_cpu(i)
|
||||
set_se_shares(tg->se[i], shares);
|
||||
|
||||
done:
|
||||
spin_unlock(&tg->lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long sched_group_shares(struct task_group *tg)
|
||||
{
|
||||
return tg->shares;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_FAIR_GROUP_SCHED */
|
||||
|
Reference in New Issue
Block a user