linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* turbostat update to version 20.03.19
@ 2020-03-20  5:22 Len Brown
  2020-03-20  5:22 ` [PATCH 01/10] tools/power turbostat: Support Cometlake Len Brown
  0 siblings, 1 reply; 15+ messages in thread
From: Len Brown @ 2020-03-20  5:22 UTC (permalink / raw)
  To: linux-pm

Please let me know if you see any issues with these patches.

thanks!
-Len

[PATCH 01/10] tools/power turbostat: Support Cometlake
[PATCH 02/10] tools/power turbostat: Fix gcc build warnings
[PATCH 03/10] tools/power turbostat: Support Tiger Lake
[PATCH 04/10] tools/power turbostat: Support Ice Lake server
[PATCH 05/10] tools/power turbostat: Support Jasper Lake
[PATCH 06/10] tools/power turbostat: Support Elkhart Lake
[PATCH 07/10] tools/power turbostat: Fix missing SYS_LPI counter on
[PATCH 08/10] tools/power turbostat: Fix 32-bit capabilities warning
[PATCH 09/10] tools/power turbostat: Print cpuidle information
[PATCH 10/10] turbostat: update version



^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 01/10] tools/power turbostat: Support Cometlake
  2020-03-20  5:22 turbostat update to version 20.03.19 Len Brown
@ 2020-03-20  5:22 ` Len Brown
  2020-03-20  5:22   ` [PATCH 02/10] tools/power turbostat: Fix gcc build warnings Len Brown
                     ` (8 more replies)
  0 siblings, 9 replies; 15+ messages in thread
From: Len Brown @ 2020-03-20  5:22 UTC (permalink / raw)
  To: linux-pm; +Cc: Chen Yu, Rui Zhang, Len Brown

From: Chen Yu <yu.c.chen@intel.com>

From a turbostat point of view, Cometlake is like Kabylake.

Suggested-by: Rui Zhang <rui.zhang@intel.com>
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
---
 tools/power/x86/turbostat/turbostat.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 31c1ca0bb3ee..dd5ac9f52ac5 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -4610,6 +4610,8 @@ unsigned int intel_model_duplicates(unsigned int model)
 	case INTEL_FAM6_SKYLAKE:
 	case INTEL_FAM6_KABYLAKE_L:
 	case INTEL_FAM6_KABYLAKE:
+	case INTEL_FAM6_COMETLAKE_L:
+	case INTEL_FAM6_COMETLAKE:
 		return INTEL_FAM6_SKYLAKE_L;
 
 	case INTEL_FAM6_ICELAKE_L:
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 02/10] tools/power turbostat: Fix gcc build warnings
  2020-03-20  5:22 ` [PATCH 01/10] tools/power turbostat: Support Cometlake Len Brown
@ 2020-03-20  5:22   ` Len Brown
  2020-03-20  5:22   ` [PATCH 03/10] tools/power turbostat: Support Tiger Lake Len Brown
                     ` (7 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Len Brown @ 2020-03-20  5:22 UTC (permalink / raw)
  To: linux-pm; +Cc: Len Brown

From: Len Brown <len.brown@intel.com>

Warning: ‘__builtin_strncpy’ specified bound 20 equals destination size
	[-Wstringop-truncation]

reduce param to strncpy, to guarantee that a null byte is always copied
into destination buffer.

Signed-off-by: Len Brown <len.brown@intel.com>
---
 tools/power/x86/turbostat/turbostat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index dd5ac9f52ac5..fa95a8ca5565 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -5325,9 +5325,9 @@ int add_counter(unsigned int msr_num, char *path, char *name,
 	}
 
 	msrp->msr_num = msr_num;
-	strncpy(msrp->name, name, NAME_BYTES);
+	strncpy(msrp->name, name, NAME_BYTES - 1);
 	if (path)
-		strncpy(msrp->path, path, PATH_BYTES);
+		strncpy(msrp->path, path, PATH_BYTES - 1);
 	msrp->width = width;
 	msrp->type = type;
 	msrp->format = format;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 03/10] tools/power turbostat: Support Tiger Lake
  2020-03-20  5:22 ` [PATCH 01/10] tools/power turbostat: Support Cometlake Len Brown
  2020-03-20  5:22   ` [PATCH 02/10] tools/power turbostat: Fix gcc build warnings Len Brown
@ 2020-03-20  5:22   ` Len Brown
  2020-03-20  5:22   ` [PATCH 04/10] tools/power turbostat: Support Ice Lake server Len Brown
                     ` (6 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Len Brown @ 2020-03-20  5:22 UTC (permalink / raw)
  To: linux-pm; +Cc: Chen Yu, Len Brown

From: Chen Yu <yu.c.chen@intel.com>

From a turbostat point of view, Tiger Lake looks like Ice Lake.

Signed-off-by: Chen Yu <yu.c.chen@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
---
 tools/power/x86/turbostat/turbostat.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index fa95a8ca5565..d2c3f294da2d 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -4616,6 +4616,8 @@ unsigned int intel_model_duplicates(unsigned int model)
 
 	case INTEL_FAM6_ICELAKE_L:
 	case INTEL_FAM6_ICELAKE_NNPI:
+	case INTEL_FAM6_TIGERLAKE_L:
+	case INTEL_FAM6_TIGERLAKE:
 		return INTEL_FAM6_CANNONLAKE_L;
 
 	case INTEL_FAM6_ATOM_TREMONT_D:
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 04/10] tools/power turbostat: Support Ice Lake server
  2020-03-20  5:22 ` [PATCH 01/10] tools/power turbostat: Support Cometlake Len Brown
  2020-03-20  5:22   ` [PATCH 02/10] tools/power turbostat: Fix gcc build warnings Len Brown
  2020-03-20  5:22   ` [PATCH 03/10] tools/power turbostat: Support Tiger Lake Len Brown
@ 2020-03-20  5:22   ` Len Brown
  2020-03-20  5:22   ` [PATCH 05/10] tools/power turbostat: Support Jasper Lake Len Brown
                     ` (5 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Len Brown @ 2020-03-20  5:22 UTC (permalink / raw)
  To: linux-pm; +Cc: Chen Yu, Len Brown

From: Chen Yu <yu.c.chen@intel.com>

From a turbostat point of view, Ice Lake server looks like Sky Lake server.

Signed-off-by: Chen Yu <yu.c.chen@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
---
 tools/power/x86/turbostat/turbostat.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index d2c3f294da2d..26088b2a27cc 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -4622,6 +4622,9 @@ unsigned int intel_model_duplicates(unsigned int model)
 
 	case INTEL_FAM6_ATOM_TREMONT_D:
 		return INTEL_FAM6_ATOM_GOLDMONT_D;
+
+	case INTEL_FAM6_ICELAKE_X:
+		return INTEL_FAM6_SKYLAKE_X;
 	}
 	return model;
 }
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 05/10] tools/power turbostat: Support Jasper Lake
  2020-03-20  5:22 ` [PATCH 01/10] tools/power turbostat: Support Cometlake Len Brown
                     ` (2 preceding siblings ...)
  2020-03-20  5:22   ` [PATCH 04/10] tools/power turbostat: Support Ice Lake server Len Brown
@ 2020-03-20  5:22   ` Len Brown
  2020-03-20  5:22   ` [PATCH 06/10] tools/power turbostat: Support Elkhart Lake Len Brown
                     ` (4 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Len Brown @ 2020-03-20  5:22 UTC (permalink / raw)
  To: linux-pm; +Cc: Chen Yu, Len Brown

From: Chen Yu <yu.c.chen@intel.com>

Jasper Lake, like Elkhart Lake, uses a Tremont CPU.
So reuse the code.

Signed-off-by: Chen Yu <yu.c.chen@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
---
 tools/power/x86/turbostat/turbostat.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 26088b2a27cc..e953afb2e7a1 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -4623,6 +4623,9 @@ unsigned int intel_model_duplicates(unsigned int model)
 	case INTEL_FAM6_ATOM_TREMONT_D:
 		return INTEL_FAM6_ATOM_GOLDMONT_D;
 
+	case INTEL_FAM6_ATOM_TREMONT_L:
+		return INTEL_FAM6_ATOM_TREMONT;
+
 	case INTEL_FAM6_ICELAKE_X:
 		return INTEL_FAM6_SKYLAKE_X;
 	}
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 06/10] tools/power turbostat: Support Elkhart Lake
  2020-03-20  5:22 ` [PATCH 01/10] tools/power turbostat: Support Cometlake Len Brown
                     ` (3 preceding siblings ...)
  2020-03-20  5:22   ` [PATCH 05/10] tools/power turbostat: Support Jasper Lake Len Brown
@ 2020-03-20  5:22   ` Len Brown
  2020-03-20  5:22   ` [PATCH 07/10] tools/power turbostat: Fix missing SYS_LPI counter on some Chromebooks Len Brown
                     ` (3 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Len Brown @ 2020-03-20  5:22 UTC (permalink / raw)
  To: linux-pm; +Cc: Chen Yu, Len Brown

From: Chen Yu <yu.c.chen@intel.com>

From a turbostat point of view the Tremont-based Elkhart Lake
is very similar to Goldmont, reuse the code of Goldmont.

Elkhart Lake does not support 'group turbo limit counter'
nor C3, adjust the code accordingly.

Signed-off-by: Chen Yu <yu.c.chen@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
---
 tools/power/x86/turbostat/turbostat.c | 31 ++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index e953afb2e7a1..761146c4f9bc 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -3265,6 +3265,7 @@ int probe_nhm_msrs(unsigned int family, unsigned int model)
 	case INTEL_FAM6_ATOM_GOLDMONT:	/* BXT */
 	case INTEL_FAM6_ATOM_GOLDMONT_PLUS:
 	case INTEL_FAM6_ATOM_GOLDMONT_D:	/* DNV */
+	case INTEL_FAM6_ATOM_TREMONT:	/* EHL */
 		pkg_cstate_limits = glm_pkg_cstate_limits;
 		break;
 	default:
@@ -3336,6 +3337,17 @@ int is_skx(unsigned int family, unsigned int model)
 	}
 	return 0;
 }
+int is_ehl(unsigned int family, unsigned int model)
+{
+	if (!genuine_intel)
+		return 0;
+
+	switch (model) {
+	case INTEL_FAM6_ATOM_TREMONT:
+		return 1;
+	}
+	return 0;
+}
 
 int has_turbo_ratio_limit(unsigned int family, unsigned int model)
 {
@@ -3894,6 +3906,20 @@ void rapl_probe_intel(unsigned int family, unsigned int model)
 		else
 			BIC_PRESENT(BIC_PkgWatt);
 		break;
+	case INTEL_FAM6_ATOM_TREMONT:	/* EHL */
+		do_rapl = RAPL_PKG | RAPL_CORES | RAPL_CORE_POLICY | RAPL_DRAM | RAPL_DRAM_PERF_STATUS | RAPL_PKG_PERF_STATUS | RAPL_GFX | RAPL_PKG_POWER_INFO;
+		if (rapl_joules) {
+			BIC_PRESENT(BIC_Pkg_J);
+			BIC_PRESENT(BIC_Cor_J);
+			BIC_PRESENT(BIC_RAM_J);
+			BIC_PRESENT(BIC_GFX_J);
+		} else {
+			BIC_PRESENT(BIC_PkgWatt);
+			BIC_PRESENT(BIC_CorWatt);
+			BIC_PRESENT(BIC_RAMWatt);
+			BIC_PRESENT(BIC_GFXWatt);
+		}
+		break;
 	case INTEL_FAM6_SKYLAKE_L:	/* SKL */
 	case INTEL_FAM6_CANNONLAKE_L:	/* CNL */
 		do_rapl = RAPL_PKG | RAPL_CORES | RAPL_CORE_POLICY | RAPL_DRAM | RAPL_DRAM_PERF_STATUS | RAPL_PKG_PERF_STATUS | RAPL_GFX | RAPL_PKG_POWER_INFO;
@@ -4295,6 +4321,7 @@ int has_snb_msrs(unsigned int family, unsigned int model)
 	case INTEL_FAM6_ATOM_GOLDMONT:		/* BXT */
 	case INTEL_FAM6_ATOM_GOLDMONT_PLUS:
 	case INTEL_FAM6_ATOM_GOLDMONT_D:	/* DNV */
+	case INTEL_FAM6_ATOM_TREMONT:		/* EHL */
 		return 1;
 	}
 	return 0;
@@ -4324,6 +4351,7 @@ int has_c8910_msrs(unsigned int family, unsigned int model)
 	case INTEL_FAM6_CANNONLAKE_L:	/* CNL */
 	case INTEL_FAM6_ATOM_GOLDMONT:	/* BXT */
 	case INTEL_FAM6_ATOM_GOLDMONT_PLUS:
+	case INTEL_FAM6_ATOM_TREMONT:	/* EHL */
 		return 1;
 	}
 	return 0;
@@ -4882,7 +4910,8 @@ void process_cpuid()
 	do_slm_cstates = is_slm(family, model);
 	do_knl_cstates  = is_knl(family, model);
 
-	if (do_slm_cstates || do_knl_cstates || is_cnl(family, model))
+	if (do_slm_cstates || do_knl_cstates || is_cnl(family, model) ||
+	    is_ehl(family, model))
 		BIC_NOT_PRESENT(BIC_CPU_c3);
 
 	if (!quiet)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 07/10] tools/power turbostat: Fix missing SYS_LPI counter on some Chromebooks
  2020-03-20  5:22 ` [PATCH 01/10] tools/power turbostat: Support Cometlake Len Brown
                     ` (4 preceding siblings ...)
  2020-03-20  5:22   ` [PATCH 06/10] tools/power turbostat: Support Elkhart Lake Len Brown
@ 2020-03-20  5:22   ` Len Brown
  2020-03-20  5:22   ` [PATCH 08/10] tools/power turbostat: Fix 32-bit capabilities warning Len Brown
                     ` (2 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Len Brown @ 2020-03-20  5:22 UTC (permalink / raw)
  To: linux-pm; +Cc: Len Brown

From: Len Brown <len.brown@intel.com>

Some Chromebook BIOS' do not export an ACPI LPIT, which is how
Linux finds the residency counter for CPU and SYSTEM low power states,
that is exports in /sys/devices/system/cpu/cpuidle/*residency_us

When these sysfs attributes are missing, check the debugfs attrubte
from the pmc_core driver, which accesses the same counter value.

Signed-off-by: Len Brown <len.brown@intel.com>
---
 tools/power/x86/turbostat/turbostat.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 761146c4f9bc..3ecbf709a48c 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -304,6 +304,10 @@ int *irqs_per_cpu;		/* indexed by cpu_num */
 
 void setup_all_buffers(void);
 
+char *sys_lpi_file;
+char *sys_lpi_file_sysfs = "/sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us";
+char *sys_lpi_file_debugfs = "/sys/kernel/debug/pmc_core/slp_s0_residency_usec";
+
 int cpu_is_not_present(int cpu)
 {
 	return !CPU_ISSET_S(cpu, cpu_present_setsize, cpu_present_set);
@@ -2916,8 +2920,6 @@ int snapshot_gfx_mhz(void)
  *
  * record snapshot of
  * /sys/devices/system/cpu/cpuidle/low_power_idle_cpu_residency_us
- *
- * return 1 if config change requires a restart, else return 0
  */
 int snapshot_cpu_lpi_us(void)
 {
@@ -2941,17 +2943,14 @@ int snapshot_cpu_lpi_us(void)
 /*
  * snapshot_sys_lpi()
  *
- * record snapshot of
- * /sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us
- *
- * return 1 if config change requires a restart, else return 0
+ * record snapshot of sys_lpi_file
  */
 int snapshot_sys_lpi_us(void)
 {
 	FILE *fp;
 	int retval;
 
-	fp = fopen_or_die("/sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us", "r");
+	fp = fopen_or_die(sys_lpi_file, "r");
 
 	retval = fscanf(fp, "%lld", &cpuidle_cur_sys_lpi_us);
 	if (retval != 1) {
@@ -4946,10 +4945,16 @@ void process_cpuid()
 	else
 		BIC_NOT_PRESENT(BIC_CPU_LPI);
 
-	if (!access("/sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us", R_OK))
+	if (!access(sys_lpi_file_sysfs, R_OK)) {
+		sys_lpi_file = sys_lpi_file_sysfs;
 		BIC_PRESENT(BIC_SYS_LPI);
-	else
+	} else if (!access(sys_lpi_file_debugfs, R_OK)) {
+		sys_lpi_file = sys_lpi_file_debugfs;
+		BIC_PRESENT(BIC_SYS_LPI);
+	} else {
+		sys_lpi_file_sysfs = NULL;
 		BIC_NOT_PRESENT(BIC_SYS_LPI);
+	}
 
 	if (!quiet)
 		decode_misc_feature_control();
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 08/10] tools/power turbostat: Fix 32-bit capabilities warning
  2020-03-20  5:22 ` [PATCH 01/10] tools/power turbostat: Support Cometlake Len Brown
                     ` (5 preceding siblings ...)
  2020-03-20  5:22   ` [PATCH 07/10] tools/power turbostat: Fix missing SYS_LPI counter on some Chromebooks Len Brown
@ 2020-03-20  5:22   ` Len Brown
  2020-03-25  0:50     ` Doug Smythies
  2020-03-20  5:22   ` [PATCH 09/10] tools/power turbostat: Print cpuidle information Len Brown
  2020-03-20  5:22   ` [PATCH 10/10] turbostat: update version Len Brown
  8 siblings, 1 reply; 15+ messages in thread
From: Len Brown @ 2020-03-20  5:22 UTC (permalink / raw)
  To: linux-pm; +Cc: Len Brown

From: Len Brown <len.brown@intel.com>

warning: `turbostat' uses 32-bit capabilities (legacy support in use)

Signed-off-by: Len Brown <len.brown@intel.com>
---
 tools/power/x86/turbostat/Makefile    |  2 +-
 tools/power/x86/turbostat/turbostat.c | 46 +++++++++++++++++----------
 2 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/tools/power/x86/turbostat/Makefile b/tools/power/x86/turbostat/Makefile
index 13f1e8b9ac52..2b6551269e43 100644
--- a/tools/power/x86/turbostat/Makefile
+++ b/tools/power/x86/turbostat/Makefile
@@ -16,7 +16,7 @@ override CFLAGS +=	-D_FORTIFY_SOURCE=2
 
 %: %.c
 	@mkdir -p $(BUILD_OUTPUT)
-	$(CC) $(CFLAGS) $< -o $(BUILD_OUTPUT)/$@ $(LDFLAGS)
+	$(CC) $(CFLAGS) $< -o $(BUILD_OUTPUT)/$@ $(LDFLAGS) -lcap
 
 .PHONY : clean
 clean :
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 3ecbf709a48c..77f89371ec5f 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -30,7 +30,7 @@
 #include <sched.h>
 #include <time.h>
 #include <cpuid.h>
-#include <linux/capability.h>
+#include <sys/capability.h>
 #include <errno.h>
 #include <math.h>
 
@@ -3150,28 +3150,42 @@ void check_dev_msr()
 			err(-5, "no /dev/cpu/0/msr, Try \"# modprobe msr\" ");
 }
 
-void check_permissions()
+/*
+ * check for CAP_SYS_RAWIO
+ * return 0 on success
+ * return 1 on fail
+ */
+int check_for_cap_sys_rawio(void)
 {
-	struct __user_cap_header_struct cap_header_data;
-	cap_user_header_t cap_header = &cap_header_data;
-	struct __user_cap_data_struct cap_data_data;
-	cap_user_data_t cap_data = &cap_data_data;
-	extern int capget(cap_user_header_t hdrp, cap_user_data_t datap);
-	int do_exit = 0;
-	char pathname[32];
+	cap_t caps;
+	cap_flag_value_t cap_flag_value;
 
-	/* check for CAP_SYS_RAWIO */
-	cap_header->pid = getpid();
-	cap_header->version = _LINUX_CAPABILITY_VERSION;
-	if (capget(cap_header, cap_data) < 0)
-		err(-6, "capget(2) failed");
+	caps = cap_get_proc();
+	if (caps == NULL)
+		err(-6, "cap_get_proc\n");
 
-	if ((cap_data->effective & (1 << CAP_SYS_RAWIO)) == 0) {
-		do_exit++;
+	if (cap_get_flag(caps, CAP_SYS_RAWIO, CAP_EFFECTIVE, &cap_flag_value))
+		err(-6, "cap_get\n");
+
+	if (cap_flag_value != CAP_SET) {
 		warnx("capget(CAP_SYS_RAWIO) failed,"
 			" try \"# setcap cap_sys_rawio=ep %s\"", progname);
+		return 1;
 	}
 
+	if (cap_free(caps) == -1)
+		err(-6, "cap_free\n");
+
+	return 0;
+}
+void check_permissions(void)
+{
+	int do_exit = 0;
+	char pathname[32];
+
+	/* check for CAP_SYS_RAWIO */
+	do_exit += check_for_cap_sys_rawio();
+
 	/* test file permissions */
 	sprintf(pathname, "/dev/cpu/%d/msr", base_cpu);
 	if (euidaccess(pathname, R_OK)) {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 09/10] tools/power turbostat: Print cpuidle information
  2020-03-20  5:22 ` [PATCH 01/10] tools/power turbostat: Support Cometlake Len Brown
                     ` (6 preceding siblings ...)
  2020-03-20  5:22   ` [PATCH 08/10] tools/power turbostat: Fix 32-bit capabilities warning Len Brown
@ 2020-03-20  5:22   ` Len Brown
  2020-03-20 15:22     ` Doug Smythies
  2020-03-20  5:22   ` [PATCH 10/10] turbostat: update version Len Brown
  8 siblings, 1 reply; 15+ messages in thread
From: Len Brown @ 2020-03-20  5:22 UTC (permalink / raw)
  To: linux-pm; +Cc: Antti Laakso, Len Brown

From: Antti Laakso <antti.laakso@linux.intel.com>

Print cpuidle driver and governor.

Signed-off-by: Antti Laakso <antti.laakso@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
---
 tools/power/x86/turbostat/turbostat.c | 30 +++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 77f89371ec5f..c9e299e99c2f 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -3509,6 +3509,7 @@ dump_sysfs_cstate_config(void)
 	char path[64];
 	char name_buf[16];
 	char desc[64];
+	char cpuidle_buf[64];
 	FILE *input;
 	int state;
 	char *sp;
@@ -3516,6 +3517,35 @@ dump_sysfs_cstate_config(void)
 	if (!DO_BIC(BIC_sysfs))
 		return;
 
+	if (access("/sys/devices/system/cpu/cpuidle", R_OK)) {
+		fprintf(outf, "cpuidle not loaded\n");
+		return;
+	}
+
+	sprintf(path, "/sys/devices/system/cpu/cpuidle/current_driver");
+	input = fopen(path, "r");
+	if (input == NULL) {
+		fprintf(outf, "NSFOD %s\n", path);
+		return;
+	}
+	if (!fgets(cpuidle_buf, sizeof(cpuidle_buf), input))
+		err(1, "%s: failed to read file", path);
+	fclose(input);
+
+	fprintf(outf, "cpuidle driver: %s", cpuidle_buf);
+
+	sprintf(path, "/sys/devices/system/cpu/cpuidle/current_governor_ro");
+	input = fopen(path, "r");
+	if (input == NULL) {
+		fprintf(outf, "NSFOD %s\n", path);
+		return;
+	}
+	if (!fgets(cpuidle_buf, sizeof(cpuidle_buf), input))
+		err(1, "%s: failed to read file", path);
+	fclose(input);
+
+	fprintf(outf, "cpuidle governor: %s", cpuidle_buf);
+
 	for (state = 0; state < 10; ++state) {
 
 		sprintf(path, "/sys/devices/system/cpu/cpu%d/cpuidle/state%d/name",
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 10/10] turbostat: update version
  2020-03-20  5:22 ` [PATCH 01/10] tools/power turbostat: Support Cometlake Len Brown
                     ` (7 preceding siblings ...)
  2020-03-20  5:22   ` [PATCH 09/10] tools/power turbostat: Print cpuidle information Len Brown
@ 2020-03-20  5:22   ` Len Brown
  8 siblings, 0 replies; 15+ messages in thread
From: Len Brown @ 2020-03-20  5:22 UTC (permalink / raw)
  To: linux-pm; +Cc: Len Brown

From: Len Brown <len.brown@intel.com>

A stitch in time saves nine.

Signed-off-by: Len Brown <len.brown@intel.com>
---
 tools/power/x86/turbostat/turbostat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index c9e299e99c2f..399b2c3b095c 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -5394,7 +5394,7 @@ int get_and_dump_counters(void)
 }
 
 void print_version() {
-	fprintf(outf, "turbostat version 19.08.31"
+	fprintf(outf, "turbostat version 20.03.19"
 		" - Len Brown <lenb@kernel.org>\n");
 }
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* RE: [PATCH 09/10] tools/power turbostat: Print cpuidle information
  2020-03-20  5:22   ` [PATCH 09/10] tools/power turbostat: Print cpuidle information Len Brown
@ 2020-03-20 15:22     ` Doug Smythies
  2020-03-21  4:52       ` Len Brown
  0 siblings, 1 reply; 15+ messages in thread
From: Doug Smythies @ 2020-03-20 15:22 UTC (permalink / raw)
  To: 'Len Brown', 'Antti Laakso'
  Cc: 'Len Brown',
	linux-pm, Doug Smythies, 'Rafael J. Wysocki'

Hi Len, Antti,

I didn't actually try it yet.
This reply is just from reading the patches.

On 2020.03.19 22:23 Len Brown wrote:

> From: Antti Laakso <antti.laakso@linux.intel.com>
>
> Print cpuidle driver and governor.
>
> Signed-off-by: Antti Laakso <antti.laakso@linux.intel.com>
> Signed-off-by: Len Brown <len.brown@intel.com>

...

> +	sprintf(path, "/sys/devices/system/cpu/cpuidle/current_governor_ro");
> +	input = fopen(path, "r");
> +	if (input == NULL) {
> +		fprintf(outf, "NSFOD %s\n", path);
> +		return;
> +	}
> +	if (!fgets(cpuidle_buf, sizeof(cpuidle_buf), input))
> +		err(1, "%s: failed to read file", path);
> +	fclose(input);
> +
> +	fprintf(outf, "cpuidle governor: %s", cpuidle_buf);
> +

There is a problem here if one has the 'cpuidle_sysfs_switch'
in the kernel command line (which I do always), because that
(not) variable name changes as a function of the switch [2].

I have:

$ grep . /sys/devices/system/cpu/cpuidle/*
/sys/devices/system/cpu/cpuidle/available_governors:ladder menu teo
/sys/devices/system/cpu/cpuidle/current_driver:intel_idle
/sys/devices/system/cpu/cpuidle/current_governor:teo

And in grub:

GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1 consoleblank=300 intel_pstate=passive cpuidle_sysfs_switch cpuidle.governor=teo"

Note that there was talk of getting rid of the command line switch [1 at the end], which would be great.
Copied below:

On 2019.09.02 14:59 Rafael wrote:

> FWIW, I've been thinking about getting rid of the cpuidle_sysfs_switch
> command line option and always allowing user space to switch cpuidle
> governors at run time.  At least I see no reason why that would not
> work ATM.

[1] https://marc.info/?l=linux-pm&m=156746153919195&w=2
[2] Documentation/admin-guide/pm/cpuidle.rst (search for 'current_governor_ro')

... Doug



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 09/10] tools/power turbostat: Print cpuidle information
  2020-03-20 15:22     ` Doug Smythies
@ 2020-03-21  4:52       ` Len Brown
  0 siblings, 0 replies; 15+ messages in thread
From: Len Brown @ 2020-03-21  4:52 UTC (permalink / raw)
  To: Doug Smythies; +Cc: Antti Laakso, Len Brown, Linux PM list, Rafael J. Wysocki

Thanks, Doug, for reviewing the patch!

I'll send a replacement that is more flexible.

cheers,
-Len

^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: [PATCH 08/10] tools/power turbostat: Fix 32-bit capabilities warning
  2020-03-20  5:22   ` [PATCH 08/10] tools/power turbostat: Fix 32-bit capabilities warning Len Brown
@ 2020-03-25  0:50     ` Doug Smythies
  2020-03-25  0:54       ` Brown, Len
  0 siblings, 1 reply; 15+ messages in thread
From: Doug Smythies @ 2020-03-25  0:50 UTC (permalink / raw)
  To: 'Len Brown'; +Cc: 'Len Brown', linux-pm

Hi Len,

On 2020.03.24 22:23 Len Brown wrote:

> From: Len Brown <len.brown@intel.com>
>
> warning: `turbostat' uses 32-bit capabilities (legacy support in use)
>
> Signed-off-by: Len Brown <len.brown@intel.com>
> ---
>  tools/power/x86/turbostat/Makefile    |  2 +-
>  tools/power/x86/turbostat/turbostat.c | 46 +++++++++++++++++----------
>  2 files changed, 31 insertions(+), 17 deletions(-)

...

> +#include <sys/capability.h>


This seems to require a package, libcap-dev, to be installed.
I never needed it before.
Just F.Y.I.

... Doug



^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: [PATCH 08/10] tools/power turbostat: Fix 32-bit capabilities warning
  2020-03-25  0:50     ` Doug Smythies
@ 2020-03-25  0:54       ` Brown, Len
  0 siblings, 0 replies; 15+ messages in thread
From: Brown, Len @ 2020-03-25  0:54 UTC (permalink / raw)
  To: Doug Smythies, 'Len Brown'; +Cc: linux-pm

> +#include <sys/capability.h>

> This seems to require a package, libcap-dev, to be installed.

Yeah, sort of annoying that libcap-dev isn't installed by default.
I've added it to the list of stuff that I install on new machines before they are usable...



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2020-03-25  0:55 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-20  5:22 turbostat update to version 20.03.19 Len Brown
2020-03-20  5:22 ` [PATCH 01/10] tools/power turbostat: Support Cometlake Len Brown
2020-03-20  5:22   ` [PATCH 02/10] tools/power turbostat: Fix gcc build warnings Len Brown
2020-03-20  5:22   ` [PATCH 03/10] tools/power turbostat: Support Tiger Lake Len Brown
2020-03-20  5:22   ` [PATCH 04/10] tools/power turbostat: Support Ice Lake server Len Brown
2020-03-20  5:22   ` [PATCH 05/10] tools/power turbostat: Support Jasper Lake Len Brown
2020-03-20  5:22   ` [PATCH 06/10] tools/power turbostat: Support Elkhart Lake Len Brown
2020-03-20  5:22   ` [PATCH 07/10] tools/power turbostat: Fix missing SYS_LPI counter on some Chromebooks Len Brown
2020-03-20  5:22   ` [PATCH 08/10] tools/power turbostat: Fix 32-bit capabilities warning Len Brown
2020-03-25  0:50     ` Doug Smythies
2020-03-25  0:54       ` Brown, Len
2020-03-20  5:22   ` [PATCH 09/10] tools/power turbostat: Print cpuidle information Len Brown
2020-03-20 15:22     ` Doug Smythies
2020-03-21  4:52       ` Len Brown
2020-03-20  5:22   ` [PATCH 10/10] turbostat: update version Len Brown

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).