From: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
To: rjw@rjwysocki.net
Cc: stewart@linux.vnet.ibm.com, viresh.kumar@linaro.org,
linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org,
linux-pm@vger.kernel.org,
Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
Subject: [PATCH] cpufreq: powernv: Export frequency throttle state of the chip through sysfs
Date: Thu, 27 Aug 2015 14:43:26 +0530 [thread overview]
Message-ID: <1440666806-11760-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com> (raw)
Create a sysfs 'throttle' attribute per-chip(per-numa-node) to reflect
the throttle state of the chip. The usersapce programs can poll on
this attribute to keep an eye on the throttle state. Currently we
print a log message to notify the user of throttling event. The
performance-sensitive applications can monitor the throttle state
using this attribute.
Following file is created in sysfs:
/sys/devices/system/node/nodeN/throttle
'throttle' attribute has the following values:
0 : frequency is unthrottled
1 : frequency is throttled
Suggested-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
---
This patch is based on top of linux-next/master
drivers/cpufreq/powernv-cpufreq.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
index 64994e1..aed6c34 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -28,6 +28,8 @@
#include <linux/of.h>
#include <linux/reboot.h>
#include <linux/slab.h>
+#include <linux/device.h>
+#include <linux/node.h>
#include <asm/cputhreads.h>
#include <asm/firmware.h>
@@ -413,6 +415,23 @@ static struct notifier_block powernv_cpufreq_reboot_nb = {
.notifier_call = powernv_cpufreq_reboot_notifier,
};
+static ssize_t throttle_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ int i;
+
+ for (i = 0; i < nr_chips; i++)
+ if (chips[i].id == dev->id) {
+ smp_call_function_any(&chips[i].mask,
+ powernv_cpufreq_throttle_check,
+ NULL, 1);
+ return sprintf(buf, "%d\n", throttled ||
+ chips[i].throttled);
+ }
+}
+
+static DEVICE_ATTR(throttle, 0400, throttle_show, NULL);
+
void powernv_cpufreq_work_fn(struct work_struct *work)
{
struct chip *chip = container_of(work, struct chip, throttle);
@@ -570,6 +589,8 @@ static int init_chip_info(void)
cpumask_copy(&chips[i].mask, cpumask_of_node(chip[i]));
INIT_WORK(&chips[i].throttle, powernv_cpufreq_work_fn);
chips[i].restore = false;
+ device_create_file(&node_devices[chip[i]]->dev,
+ &dev_attr_throttle);
}
return 0;
--
1.9.3
next reply other threads:[~2015-08-27 9:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-27 9:13 Shilpasri G Bhat [this message]
2015-08-27 9:31 ` [PATCH] cpufreq: powernv: Export frequency throttle state of the chip through sysfs Michael Ellerman
2015-08-27 10:17 ` Shilpasri G Bhat
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=1440666806-11760-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com \
--to=shilpa.bhat@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=rjw@rjwysocki.net \
--cc=stewart@linux.vnet.ibm.com \
--cc=viresh.kumar@linaro.org \
/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;
as well as URLs for NNTP newsgroup(s).