From: Prarit Bhargava <prarit@redhat.com>
To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Prarit Bhargava <prarit@redhat.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Radivoje Jovanovic <radivoje.jovanovic@intel.com>,
Seiichi Ikarashi <s.ikarashi@jp.fujitsu.com>,
Mathias Krause <minipli@googlemail.com>,
Ajay Thomas <ajay.thomas.david.rajamanickam@intel.com>
Subject: [PATCH 2/3 v4] powercap, intel_rapl, implement check for minimum time window
Date: Mon, 21 Mar 2016 08:27:15 -0400 [thread overview]
Message-ID: <1458563236-19269-3-git-send-email-prarit@redhat.com> (raw)
In-Reply-To: <1458563236-19269-1-git-send-email-prarit@redhat.com>
Using an small value for the time window results in a
bogus value for the time window. For example,
[root@intel-chiefriver-03 linux]# echo 950 >
/sys/devices/virtual/powercap/intel-rapl/intel-rapl\:0/constraint_0_time_window_us;
egrep ^ /sys/devices/virtual/powercap/intel-rapl/intel-rapl\:0/constraint_0_time_window_us
-bash: echo: write error: Invalid argument
/sys/devices/virtual/powercap/intel-rapl/intel-rapl:0/constraint_0_time_window_us:1:4501502475370496
The Intel ASDM doesn't explicitly define a minimum time window.
The MSR_RAPL_POWER_UNIT register, read during initialization, does
specify a minimum time window unit so that can be used as a lower
bound for error checking.
After this change the minimum time window is properly clamped:
[root@intel-chiefriver-03 linux]# echo 950 >
/sys/devices/virtual/powercap/intel-rapl/intel-rapl\:0/constraint_0_time_window_us;
egrep ^ /sys/devices/virtual/powercap/intel-rapl/intel-rapl\:0/constraint_0_time_window_us
-bash: echo: write error: Invalid argument
/sys/devices/virtual/powercap/intel-rapl/intel-rapl:0/constraint_0_time_window_us:1:976
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Radivoje Jovanovic <radivoje.jovanovic@intel.com>
Cc: Seiichi Ikarashi <s.ikarashi@jp.fujitsu.com>
Cc: Mathias Krause <minipli@googlemail.com>
Cc: Ajay Thomas <ajay.thomas.david.rajamanickam@intel.com>
Signed-off-by: Prarit Bhargava <prarit@redhat.com>
---
drivers/powercap/intel_rapl.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/powercap/intel_rapl.c b/drivers/powercap/intel_rapl.c
index feb063d..cf89b3d 100644
--- a/drivers/powercap/intel_rapl.c
+++ b/drivers/powercap/intel_rapl.c
@@ -516,6 +516,7 @@ static int set_time_window(struct powercap_zone *power_zone, int id,
u64 window)
{
struct rapl_domain *rd;
+ struct rapl_package *rp;
int ret = 0;
u64 max_window;
@@ -524,12 +525,18 @@ static int set_time_window(struct powercap_zone *power_zone, int id,
if (ret < 0)
goto out;
- if (window > max_window) {
+ rd = power_zone_to_rapl_domain(power_zone);
+ rp = find_package_by_id(rd->package_id);
+ /*
+ * The Intel ASDM doesn't explicitly define a minimum time window.
+ * The MSR_RAPL_POWER_UNIT register, read during initialization,
+ * does contain the smallest unit of time that can be measured.
+ */
+ if ((window > max_window) || (window < rp->time_unit)) {
ret = -EINVAL;
goto out;
}
- rd = power_zone_to_rapl_domain(power_zone);
switch (rd->rpl[id].prim_id) {
case PL1_ENABLE:
rapl_write_data_raw(rd, TIME_WINDOW1, window);
--
1.7.9.3
next prev parent reply other threads:[~2016-03-21 12:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-21 12:27 [RESEND PATCH 0/3 v4] powercap, intel_rapl, implement time window checks Prarit Bhargava
2016-03-21 12:27 ` [PATCH 1/3 v4] powercap, intel_rapl, implement get_max_time_window Prarit Bhargava
2016-03-31 18:28 ` Pandruvada, Srinivas
2016-04-05 13:14 ` Prarit Bhargava
2016-04-11 11:33 ` Prarit Bhargava
2016-04-11 14:11 ` Pandruvada, Srinivas
2016-03-21 12:27 ` Prarit Bhargava [this message]
2016-03-21 12:27 ` [PATCH 3/3 v3] powercap, intel_rapl, Add ignore_max_time_window_check module parameter for broken BIOSes Prarit Bhargava
2016-03-28 18:07 ` [RESEND PATCH 0/3 v4] powercap, intel_rapl, implement time window checks Pandruvada, Srinivas
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=1458563236-19269-3-git-send-email-prarit@redhat.com \
--to=prarit@redhat.com \
--cc=ajay.thomas.david.rajamanickam@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=minipli@googlemail.com \
--cc=radivoje.jovanovic@intel.com \
--cc=rafael.j.wysocki@intel.com \
--cc=s.ikarashi@jp.fujitsu.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 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).