All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: vatsa@linux.vnet.ibm.com
Cc: LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
	Balbir Singh <balbir@linux.vnet.ibm.com>,
	dmitry.adamushko@gmail.com, Steven Rostedt <rostedt@goodmis.org>,
	Gregory Haskins <ghaskins@novell.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH 12/11] sched: rt-group: uid-group interface
Date: Mon, 07 Jan 2008 17:57:42 +0100	[thread overview]
Message-ID: <1199725063.31975.53.camel@lappy> (raw)
In-Reply-To: <20080107122330.GB25945@linux.vnet.ibm.com>


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)
 {
-	sa->attr.name = name;
-	sa->attr.mode = mode;
-	sa->show = cpu_shares_show;
-	sa->store = cpu_shares_store;
+	struct user_struct *up = container_of(kset, struct user_struct, kset);
+
+	return sprintf(buffer, "%lu\n", sched_group_rt_period(up->tg));
+}
+
+static ssize_t cpu_rt_period_store(struct kset *kset, const char *buffer,
+				   size_t size)
+{
+	struct user_struct *up = container_of(kset, struct user_struct, kset);
+	unsigned long rt_period_us;
+	int rc;
+
+	sscanf(buffer, "%lu", &rt_period_us);
+	rc = sched_group_set_rt_period(up->tg, rt_period_us);
+
+	return (rc ?: size);
+}
+
+static ssize_t cpu_rt_runtime_show(struct kset *kset, char *buffer)
+{
+	struct user_struct *up = container_of(kset, struct user_struct, kset);
+
+	return sprintf(buffer, "%lu\n", sched_group_rt_runtime(up->tg));
+}
+
+static ssize_t cpu_rt_runtime_store(struct kset *kset, const char *buffer,
+				    size_t size)
+{
+	struct user_struct *up = container_of(kset, struct user_struct, kset);
+	unsigned long rt_runtime_us;
+	int rc;
+
+	sscanf(buffer, "%lu", &rt_runtime_us);
+	rc = sched_group_set_rt_runtime(up->tg, rt_runtime_us);
+
+	return (rc ?: size);
+}
+
+static void user_attr_init(struct user_struct *up)
+{
+	struct subsys_attribute *sa;
+
+	sa = &up->share_attr;
+	sa->attr.name = "cpu_share";
+	sa->attr.mode = 0644;
+	sa->show = cpu_share_show;
+	sa->store = cpu_share_store;
+
+	sa = &up->rt_period_attr;
+	sa->attr.name = "cpu_rt_period_us";
+	sa->attr.mode = 0644;
+	sa->show = cpu_rt_period_show;
+	sa->store = cpu_rt_period_store;
+
+	sa = &up->rt_runtime_attr;
+	sa->attr.name = "cpu_rt_runtime_us";
+	sa->attr.mode = 0644;
+	sa->show = cpu_rt_runtime_show;
+	sa->store = cpu_rt_runtime_store;
 }
 
 /* Create "/sys/kernel/uids/<uid>" directory and
@@ -172,15 +227,27 @@ static int user_kobject_create(struct us
 	kobj->parent = &uids_kobject;	/* create under /sys/kernel/uids dir */
 	kobject_set_name(kobj, "%d", up->uid);
 	kset_init(kset);
-	user_attr_init(&up->user_attr, "cpu_share", 0644);
+	user_attr_init(up);
 
 	error = kobject_add(kobj);
 	if (error)
 		goto done;
 
-	error = sysfs_create_file(kobj, &up->user_attr.attr);
+	error = sysfs_create_file(kobj, &up->share_attr.attr);
+	if (error)
+		goto error1;
+	error = sysfs_create_file(kobj, &up->rt_period_attr.attr);
 	if (error)
-		kobject_del(kobj);
+		goto error2;
+	error = sysfs_create_file(kobj, &up->rt_runtime_attr.attr);
+	if (error)
+		goto error3;
+
+	if (0) {
+error3:		sysfs_remove_file(kobj, &up->rt_period_attr.attr);
+error2: 	sysfs_remove_file(kobj, &up->share_attr.attr);
+error1: 	kobject_del(kobj);
+	}
 
 	kobject_uevent(kobj, KOBJ_ADD);
 
@@ -238,7 +305,9 @@ static void remove_user_sysfs_dir(struct
 	if (!remove_user)
 		goto done;
 
-	sysfs_remove_file(kobj, &up->user_attr.attr);
+	sysfs_remove_file(kobj, &up->share_attr.attr);
+	sysfs_remove_file(kobj, &up->rt_period_attr.attr);
+	sysfs_remove_file(kobj, &up->rt_runtime_attr.attr);
 	kobject_uevent(kobj, KOBJ_REMOVE);
 	kobject_del(kobj);
 



  parent reply	other threads:[~2008-01-07 16:58 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-06 16:11 [PATCH 00/11] another rt group sched update Peter Zijlstra
2008-01-06 16:11 ` [PATCH 01/11] sched: rt throttling vs no_hz Peter Zijlstra
2008-01-06 16:11 ` [PATCH 02/11] sched: load_balance_monitor rename Peter Zijlstra
2008-01-06 16:11 ` [PATCH 03/11] hrtimer: clean up cpu->base locking tricks Peter Zijlstra
2008-01-06 16:11 ` [PATCH 04/11] hrtimer: fixup the HRTIMER_CB_IRQSAFE_NO_SOFTIRQ fallback Peter Zijlstra
2008-01-07 11:56   ` Peter Zijlstra
2008-01-08 11:16     ` Ingo Molnar
2008-01-06 16:11 ` [PATCH 05/11] hrtimer: unlock hrtimer_wakeup Peter Zijlstra
2008-01-06 16:11 ` [PATCH 06/11] sched: rt-group: reduce rescheduling Peter Zijlstra
2008-01-06 16:11 ` [PATCH 07/11] sched: rt-group: per group period Peter Zijlstra
2008-01-06 16:11 ` [PATCH 08/11] sched: rt-group: deal with PI Peter Zijlstra
2008-01-06 16:11 ` [PATCH 09/11] sched: rt-group: dynamic period ticks Peter Zijlstra
2008-01-06 16:11 ` [PATCH 10/11] sched: rt-group: EDF Peter Zijlstra
2008-01-06 16:11 ` [PATCH 11/11] sched: rt-group: interface Peter Zijlstra
2008-01-07 10:51 ` [PATCH 00/11] another rt group sched update Peter Zijlstra
2008-01-07 11:24   ` Peter Zijlstra
2008-01-07 12:23   ` Srivatsa Vaddagiri
2008-01-07 12:12     ` Peter Zijlstra
2008-01-07 16:57     ` Peter Zijlstra [this message]
2008-01-08 10:33       ` [PATCH 12/11] sched: rt-group: uid-group interface Ingo Molnar
2008-01-08 10:57       ` Dhaval Giani
2008-01-08 11:02         ` Peter Zijlstra
2008-01-08 14:31           ` Kay Sievers
2008-01-08 23:35             ` Peter Zijlstra
2008-01-08 23:58               ` Greg KH
2008-01-08 23:57                 ` Ingo Molnar
2008-01-10  0:05                   ` Greg KH
2008-02-07  4:17                     ` Dhaval Giani
2008-02-07  5:42                       ` Greg KH
2008-01-08 23:26         ` Peter Zijlstra
2008-01-07 11:17 ` [PATCH 00/11] another rt group sched update Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1199725063.31975.53.camel@lappy \
    --to=a.p.zijlstra@chello.nl \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=dmitry.adamushko@gmail.com \
    --cc=ghaskins@novell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=vatsa@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.