[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1393331641-14016-7-git-send-email-henrik@austad.us>
Date: Tue, 25 Feb 2014 13:34:01 +0100
From: Henrik Austad <henrik@...tad.us>
To: LKML <linux-kernel@...r.kernel.org>,
Thomas Gleixner <tglx@...uxtronix.de>
Cc: Henrik Austad <haustad@...co.com>,
Thomas Gleixner <tglx@...utronix.de>,
Peter Zijlstra <peterz@...radead.org>,
Frederic Weisbecker <fweisbec@...il.com>,
John Stultz <john.stultz@...aro.org>,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
Subject: [PATCH 6/6] Expose tick_set_forced_cpu() via sysfs
From: Henrik Austad <haustad@...co.com>
This allows userspace to set the forced CPU via sysfs in
/sys/kernel/timekeeping/forced_cpu.
CC: Thomas Gleixner <tglx@...utronix.de>
CC: Peter Zijlstra <peterz@...radead.org>
CC: Frederic Weisbecker <fweisbec@...il.com>
CC: John Stultz <john.stultz@...aro.org>
CC: Paul E. McKenney <paulmck@...ux.vnet.ibm.com>
Signed-off-by: Henrik Austad <haustad@...co.com>
---
kernel/time/timekeeping.c | 36 ++++++++++++++++++++++++++++++------
1 file changed, 30 insertions(+), 6 deletions(-)
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 4bdfa11..b148062 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -44,23 +44,47 @@ int expose_tick_forced_timer_cpu = -1;
/*
* sysfs interface to timer-cpu
*/
-static ssize_t current_cpu_show(struct kobject *kobj,
- struct kobj_attribute *attr,
- char *buf)
-{
- return sprintf(buf, "%d\n", tick_expose_cpu());
+static ssize_t cpu_show(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ char *buf)
+{
+ int var = -EINVAL;
+ if (strcmp(attr->attr.name, "current_cpu") == 0)
+ var = sprintf(buf, "%d\n", tick_expose_cpu());
+ else if (strcmp(attr->attr.name, "forced_cpu") == 0)
+ var = sprintf(buf, "%d\n", tick_get_forced_cpu());
+ return var;
+}
+
+static ssize_t cpu_store(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ const char * buf,
+ size_t count)
+{
+ int var = 0;
+ if (strcmp(attr->attr.name, "forced_cpu") == 0) {
+ sscanf(buf, "%du", &var);
+ if ((var = tick_set_forced_cpu(var)) != 0) {
+ pr_err("trouble setting forced CPU (%d)\n", var);
+ }
+ }
+ return count;
}
static struct kobj_attribute current_cpu_attribute =
- __ATTR_RO(current_cpu);
+ __ATTR(current_cpu, 0444, cpu_show, NULL);
+static struct kobj_attribute forced_cpu_attribute =
+ __ATTR(forced_cpu, 0644, cpu_show, cpu_store);
static struct attribute *timekeeping_attrs[] = {
¤t_cpu_attribute.attr,
+ &forced_cpu_attribute.attr,
NULL,
};
static struct attribute_group timekeeping_ag = {
.attrs = timekeeping_attrs,
};
+
static struct kobject *timekeeping_kobj;
static __init int timekeeping_sysfs_init(void)
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists