OpenVZ Forum


Home » Mailing lists » Devel » [PATCH 2/2] CGroups _s64 files: Use read_s64/write_s64 in CFS cgroup for rt_runtime file
[PATCH 2/2] CGroups _s64 files: Use read_s64/write_s64 in CFS cgroup for rt_runtime file [message #27998] Wed, 05 March 2008 10:20
Paul Menage is currently offline  Paul Menage
Messages: 642
Registered: September 2006
Senior Member
This removes some filesystem boilerplate from the CFS cgroup subsystem.

Signed-off-by: Paul Menage <menage@google.com>

---
 kernel/sched.c |   52 +++++++++-------------------------------------------
 1 file changed, 9 insertions(+), 43 deletions(-)

Index: read_s64-2.6.25-rc3-mm1/kernel/sched.c
===================================================================
--- read_s64-2.6.25-rc3-mm1.orig/kernel/sched.c
+++ read_s64-2.6.25-rc3-mm1/kernel/sched.c
@@ -8081,48 +8081,14 @@ static u64 cpu_shares_read_u64(struct cg
 
 #ifdef CONFIG_RT_GROUP_SCHED
 static int cpu_rt_runtime_write(struct cgroup *cgrp, struct cftype *cft,
-				struct file *file,
-				const char __user *userbuf,
-				size_t nbytes, loff_t *unused_ppos)
-{
-	char buffer[64];
-	int retval = 0;
-	s64 val;
-	char *end;
-
-	if (!nbytes)
-		return -EINVAL;
-	if (nbytes >= sizeof(buffer))
-		return -E2BIG;
-	if (copy_from_user(buffer, userbuf, nbytes))
-		return -EFAULT;
-
-	buffer[nbytes] = 0;     /* nul-terminate */
-
-	/* strip newline if necessary */
-	if (nbytes && (buffer[nbytes-1] == '\n'))
-		buffer[nbytes-1] = 0;
-	val = simple_strtoll(buffer, &end, 0);
-	if (*end)
-		return -EINVAL;
-
-	/* Pass to subsystem */
-	retval = sched_group_set_rt_runtime(cgroup_tg(cgrp), val);
-	if (!retval)
-		retval = nbytes;
-	return retval;
-}
-
-static ssize_t cpu_rt_runtime_read(struct cgroup *cgrp, struct cftype *cft,
-				   struct file *file,
-				   char __user *buf, size_t nbytes,
-				   loff_t *ppos)
-{
-	char tmp[64];
-	long val = sched_group_rt_runtime(cgroup_tg(cgrp));
-	int len = sprintf(tmp, "%ld\n", val);
+				s64 val)
+{
+	return sched_group_set_rt_runtime(cgroup_tg(cgrp), val);
+}
 
-	return simple_read_from_buffer(buf, nbytes, ppos, tmp, len);
+static s64 cpu_rt_runtime_read(struct cgroup *cgrp, struct cftype *cft)
+{
+	return sched_group_rt_runtime(cgroup_tg(cgrp));
 }
 #endif
 
@@ -8137,8 +8103,8 @@ static struct cftype cpu_files[] = {
 #ifdef CONFIG_RT_GROUP_SCHED
 	{
 		.name = "rt_runtime_us",
-		.read = cpu_rt_runtime_read,
-		.write = cpu_rt_runtime_write,
+		.read_s64 = cpu_rt_runtime_read,
+		.write_s64 = cpu_rt_runtime_write,
 	},
 #endif
 };

--
_______________________________________________
Containers mailing list
Containers@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
Previous Topic: [PATCH 1/2] CGroups _s64 files: Add cgroups read_s64/write_s64 file methods
Next Topic: [PATCH 0/2] CGroups _s64 files: Intro
Goto Forum:
  


Current Time: Sun Jul 21 11:20:07 GMT 2024

Total time taken to generate the page: 0.02356 seconds