Re: [PATCH 12/11] sched: rt-group: uid-group interface

Previous thread: [PATCH 01/11] sched: rt throttling vs no_hz by Peter Zijlstra on Sunday, January 6, 2008 - 9:11 am. (1 message)

Next thread: [PATCH 03/11] hrtimer: clean up cpu->base locking tricks by Peter Zijlstra on Sunday, January 6, 2008 - 9:11 am. (1 message)
From: Peter Zijlstra
Date: Sunday, January 6, 2008 - 9:11 am

this time compile tested on all 16 combinations of:

  CONFIG_SMP
  CONFIG_FAIR_GROUP_SCHED
  CONFIG_HIGH_RES_TIMERS
  CONFIG_NO_HZ

ran some but not all combinations
--

--

From: Peter Zijlstra
Date: Monday, January 7, 2008 - 3:51 am

The list of open points and issues for this work:

 - review/testing

 - handle the PI case better

   The only thing I can come up with currently is to basically have two
   priority arrays one for boosted and one for non boosted tasks, and
   normally run the highest of either array, but in the case of a
   throttled group, only pick from the boosted array.

   Not sure I like that for its space overhead, Steven?

 - I occasionally see a weird lockup on iterating the task_groups list
   on smp machines. - I failed to see anything wrong, but hey, this
   stack of used brown paper bags is steadily growing.

 - figure out what to do for UID based group scheduling, the current
   implementation leaves it impossible for !root users to execute
   real time tasks by setting rt_runtime_us to 0, and it has no way
   to change it.

   Srivatsa, what happened to the per uid weight patches?, Perhaps we
   can extend that interface to allow changing this.

 - I guess documentation needs to be written ;-)
From: Srivatsa Vaddagiri
Date: Monday, January 7, 2008 - 5:23 am

Hi Peter,
	The sysfs interface for tweaking each user's share should be in
mainline already (sysfs_create_file() in user_kobject_create()). This
could be extended for your purpose, hopefully in a straightforward
manner (you never know that with sysfs :(

-- 
Regards,
vatsa
--

From: Peter Zijlstra
Date: Monday, January 7, 2008 - 5:12 am

Ah, I missed that going in. Thanks, I'll give it a go.
From: Peter Zijlstra
Date: Monday, January 7, 2008 - 9:57 am

Subject: sched: rt-group: add uid-group interface

Extend the /sys/kernel/uids/<uid>/ interface to allow setting
the group's rt_period and rt_runtime.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 include/linux/sched.h |    4 +-
 kernel/user.c         |   93 +++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 84 insertions(+), 13 deletions(-)

Index: linux-2.6/include/linux/sched.h
===================================================================
--- linux-2.6.orig/include/linux/sched.h
+++ linux-2.6/include/linux/sched.h
@@ -559,7 +559,9 @@ struct user_struct {
 	struct task_group *tg;
 #ifdef CONFIG_SYSFS
 	struct kset kset;
-	struct subsys_attribute user_attr;
+	struct subsys_attribute share_attr;
+	struct subsys_attribute rt_period_attr;
+	struct subsys_attribute rt_runtime_attr;
 	struct work_struct work;
 #endif
 #endif
Index: linux-2.6/kernel/user.c
===================================================================
--- linux-2.6.orig/kernel/user.c
+++ linux-2.6/kernel/user.c
@@ -129,7 +129,7 @@ static inline void uids_mutex_unlock(voi
 }
 
 /* return cpu shares held by the user */
-static ssize_t cpu_shares_show(struct kset *kset, char *buffer)
+static ssize_t cpu_share_show(struct kset *kset, char *buffer)
 {
 	struct user_struct *up = container_of(kset, struct user_struct, kset);
 
@@ -137,8 +137,8 @@ static ssize_t cpu_shares_show(struct ks
 }
 
 /* modify cpu shares held by the user */
-static ssize_t cpu_shares_store(struct kset *kset, const char *buffer,
-				size_t size)
+static ssize_t cpu_share_store(struct kset *kset, const char *buffer,
+			       size_t size)
 {
 	struct user_struct *up = container_of(kset, struct user_struct, kset);
 	unsigned long shares;
@@ -151,12 +151,67 @@ static ssize_t cpu_shares_store(struct k
 	return (rc ? rc : size);
 }
 
-static void user_attr_init(struct subsys_attribute *sa, char *name, int mode)
+static ssize_t cpu_rt_period_show(struct kset *kset, char *buffer)
 ...
From: Ingo Molnar
Date: Tuesday, January 8, 2008 - 3:33 am

thanks, applied.

	Ingo
--

From: Peter Zijlstra
Date: Tuesday, January 8, 2008 - 4:02 am

I already have documentation on the todo list, I'll add this file to
that list :-)
From: Kay Sievers
Date: Tuesday, January 8, 2008 - 7:31 am

Care to rebase the patch against -mm, we fixed the mixed-up usage
of ksets and kobjects, and this can not apply anymore:
  http://git.kernel.org/?p=linux/kernel/git/gregkh/patches.git;a=blob;f=driver/struct-us...

There is also an attribute group now which makes it much easier to add
new files.

Thanks,
Kay
--

From: Peter Zijlstra
Date: Tuesday, January 8, 2008 - 4:35 pm

Ingo, Greg,

What would be the easiest way to carry this forward? sched-devel and
greg's tree would intersect at this point and leave poor akpm with the
resulting mess. Should I just make an incremental patch akpm can carry
and push? Or can we base one tree off the other?



--

From: Greg KH
Date: Tuesday, January 8, 2008 - 4:58 pm

[Empty message]
From: Ingo Molnar
Date: Tuesday, January 8, 2008 - 4:57 pm

hm, i'd really like to see this tested and go through sched.git. It's 
only the few sysfs bits which interfere, right?

	Ingo
--

From: Greg KH
Date: Wednesday, January 9, 2008 - 5:05 pm

[Empty message]
From: Dhaval Giani
Date: Wednesday, February 6, 2008 - 9:17 pm

Hi,

I was wondering where these changes are right now. I don't see the sysfs
interface for rt-group-sched in mainline right now.

Thanks,
-- 
regards,
Dhaval
--

From: Greg KH
Date: Wednesday, February 6, 2008 - 10:42 pm

All of the sysfs changes I had are in Linus's tree, so you don't need me
anymore :)

thanks,

greg k-h
--

From: Peter Zijlstra
Date: Tuesday, January 8, 2008 - 4:26 pm

compile tested only attempt at finalizing the interface

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
Index: linux-2.6/include/linux/sched.h
===================================================================
--- linux-2.6.orig/include/linux/sched.h
+++ linux-2.6/include/linux/sched.h
@@ -1519,8 +1519,6 @@ extern unsigned int sysctl_sched_child_r
 extern unsigned int sysctl_sched_features;
 extern unsigned int sysctl_sched_migration_cost;
 extern unsigned int sysctl_sched_nr_migrate;
-extern unsigned int sysctl_sched_rt_period;
-extern unsigned int sysctl_sched_rt_runtime;
 #if defined(CONFIG_FAIR_GROUP_SCHED) && defined(CONFIG_SMP)
 extern unsigned int sysctl_sched_min_bal_int_shares;
 extern unsigned int sysctl_sched_max_bal_int_shares;
@@ -1530,6 +1528,8 @@ int sched_nr_latency_handler(struct ctl_
 		struct file *file, void __user *buffer, size_t *length,
 		loff_t *ppos);
 #endif
+extern unsigned int sysctl_sched_rt_period;
+extern int sysctl_sched_rt_runtime;
 
 extern unsigned int sysctl_sched_compat_yield;
 
@@ -2017,8 +2017,8 @@ extern void sched_move_task(struct task_
 extern int sched_group_set_shares(struct task_group *tg, unsigned long shares);
 extern unsigned long sched_group_shares(struct task_group *tg);
 extern int sched_group_set_rt_runtime(struct task_group *tg,
-				      unsigned long rt_runtime_us);
-extern unsigned long sched_group_rt_runtime(struct task_group *tg);
+				      long rt_runtime_us);
+extern long sched_group_rt_runtime(struct task_group *tg);
 extern int sched_group_set_rt_period(struct task_group *tg,
 				     unsigned long rt_runtime_us);
 extern unsigned long sched_group_rt_period(struct task_group *tg);
Index: linux-2.6/kernel/sched.c
===================================================================
--- linux-2.6.orig/kernel/sched.c
+++ linux-2.6/kernel/sched.c
@@ -649,13 +649,18 @@ const_debug unsigned int sysctl_sched_nr
  * period over which we measure rt task cpu usage in us.
  * default: 1s
  ...
From: Ingo Molnar
Date: Monday, January 7, 2008 - 4:17 am

thanks, applied. This is a really big step forwards in terms of making 
RT task CPU usage more flexible and more manageable.

	Ingo
--

Previous thread: [PATCH 01/11] sched: rt throttling vs no_hz by Peter Zijlstra on Sunday, January 6, 2008 - 9:11 am. (1 message)

Next thread: [PATCH 03/11] hrtimer: clean up cpu->base locking tricks by Peter Zijlstra on Sunday, January 6, 2008 - 9:11 am. (1 message)