Skip to contentSkip to conversation

sched: CONFIG_FAIR_USER_SCHED: auto adjust users weights

PATCH New Guillaume Chazarain 1 participant 1 message Oct 31, 2007 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched: CONFIG_FAIR_USER_SCHED: auto adjust users weights

CONFIG_FAIR_USER_SCHED is great and I'm happy to see it is enabled by default but it suffers from some limitations IMHO at this time:

- on a single user system, it's useful to have root processes be given twice as CPU as user processes but I don't want nice 19 cron jobs like updatedb or rpmq to have twice as cpu as my nice -20 tasks.

- on a multi user system, a user should be able to give back its cpu share to other users. This is not possible for now with CONFIG_FAIR_USER_SCHED.

This implies that returning EPERM on nice(<0) becomes worthless, as it is equivalent to nice(>0) for every other process of the user, ignoring the limits of the nice range.

To address these problems, this patch changes the weight of the cfs_rq of each user to the maximum weight of the processes on this cfs_rq, scaled with /sys/kernel/uids/UID/cpu_share. It's possible that more elaborate mathematics than taking the max are needed, but basic testing showed the expected fairness.

---

 include/linux/sched.h |    4 ++
 kernel/sched.c        |   50 +++++++++++++++++++----
 kernel/sched_fair.c   |  108 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 154 insertions(+), 8 deletions(-)
include/linux/sched.h +4 -0
index 155d743..d6d2db9 100644
@@ -908,6 +908,10 @@ struct sched_entity {
 	/* rq "owned" by this entity/group: */
 	struct cfs_rq		*my_q;
 #endif
+#ifdef CONFIG_FAIR_USER_SCHED
+	/* used to track the max load.weight */
+	struct rb_node		max_load;
+#endif
 };
 
 struct task_struct {
kernel/sched.c +42 -8

84 lines not on this page · raw message

kernel/sched_fair.c +108 -0

126 lines not on this page · raw message