mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Henrik Austad <henrik@austad.us>
To: LKML <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@linuxtronix.de>
Cc: Henrik Austad <haustad@cisco.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	John Stultz <john.stultz@linaro.org>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: [PATCH 6/6] Expose tick_set_forced_cpu() via sysfs
Date: Tue, 25 Feb 2014 13:34:01 +0100	[thread overview]
Message-ID: <1393331641-14016-7-git-send-email-henrik@austad.us> (raw)
In-Reply-To: <1393331641-14016-1-git-send-email-henrik@austad.us>

From: Henrik Austad <haustad@cisco.com>

This allows userspace to set the forced CPU via sysfs in
/sys/kernel/timekeeping/forced_cpu.

CC: Thomas Gleixner <tglx@linutronix.de>
CC: Peter Zijlstra <peterz@infradead.org>
CC: Frederic Weisbecker <fweisbec@gmail.com>
CC: John Stultz <john.stultz@linaro.org>
CC: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Henrik Austad <haustad@cisco.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[] = {
 	&current_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


  parent reply	other threads:[~2014-02-25 12:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-25 12:33 [PATCH 0/6 v2] Expose do_timer CPU as RW to userspace Henrik Austad
2014-02-25 12:33 ` [PATCH 1/6] Expose do_timer CPU from tick-common Henrik Austad
2014-02-25 12:33 ` [PATCH 2/6] Add sysfs RO interface to tick_do_timer_cpu Henrik Austad
2014-02-25 12:33 ` [PATCH 3/6] Expose do_timer CPU as RO variable to userspace via sysctl Henrik Austad
2014-02-25 12:33 ` [PATCH 4/6] Force a specific CPU to handle all do_timer() events Henrik Austad
2014-02-25 12:34 ` [PATCH 5/6] Expose the forced_timer_cpu to userspace via sysctl as R/W Henrik Austad
2014-02-25 12:34 ` Henrik Austad [this message]
2014-02-25 14:19 ` [PATCH 0/6 v2] Expose do_timer CPU as RW to userspace Frederic Weisbecker
2014-02-26  8:16   ` Henrik Austad
2014-02-26 13:02     ` Frederic Weisbecker
2014-02-27  8:37       ` Henrik Austad
2014-02-27 13:56         ` Frederic Weisbecker
2014-02-28  9:40           ` Henrik Austad
2014-02-28 23:08             ` Frederic Weisbecker
2014-03-03 10:42               ` Henrik Austad

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=1393331641-14016-7-git-send-email-henrik@austad.us \
    --to=henrik@austad.us \
    --cc=fweisbec@gmail.com \
    --cc=haustad@cisco.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tglx@linuxtronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®