All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] platform/x86: intel_pmc_core: transform Pkg C-state residency from TSC ticks into microseconds
@ 2019-05-27 13:08 Harry Pan
  2019-05-28  2:53 ` Harry Pan
  2019-05-28  2:57 ` [PATCH v2] " Harry Pan
  0 siblings, 2 replies; 5+ messages in thread
From: Harry Pan @ 2019-05-27 13:08 UTC (permalink / raw)
  To: LKML
  Cc: gs0622, Harry Pan, Vishwanath Somayaji, Andy Shevchenko,
	platform-driver-x86, Rajneesh Bhardwaj, Darren Hart

Refer to the Intel SDM Vol.4, the package C-state residency counters
of modern IA micro-architecture are all ticking in TSC frequency,
hence we can apply simple math to transform the ticks into microseconds.
i.e.,
residency (ms) = count / tsc_khz
residency (us) = count / tsc_khz * 1000

This also aligns to other sysfs debug entries of residency counter in
the same metric in microseconds, benefits reading and scripting.

Signed-off-by: Harry Pan <harry.pan@intel.com>

---

 drivers/platform/x86/intel_pmc_core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c
index f2c621b55f49..20e0843ebfb4 100644
--- a/drivers/platform/x86/intel_pmc_core.c
+++ b/drivers/platform/x86/intel_pmc_core.c
@@ -24,6 +24,7 @@
 #include <asm/cpu_device_id.h>
 #include <asm/intel-family.h>
 #include <asm/msr.h>
+#include <asm/tsc.h>
 
 #include "intel_pmc_core.h"
 
@@ -726,7 +727,6 @@ static int pmc_core_ltr_show(struct seq_file *s, void *unused)
 	return 0;
 }
 DEFINE_SHOW_ATTRIBUTE(pmc_core_ltr);
-
 static int pmc_core_pkgc_show(struct seq_file *s, void *unused)
 {
 	struct pmc_dev *pmcdev = s->private;
@@ -738,8 +738,8 @@ static int pmc_core_pkgc_show(struct seq_file *s, void *unused)
 		if (rdmsrl_safe(map[index].bit_mask, &pcstate_count))
 			continue;
 
-		seq_printf(s, "%-8s : 0x%llx\n", map[index].name,
-			   pcstate_count);
+		seq_printf(s, "%-8s : %llu\n", map[index].name,
+			   pcstate_count * 1000 / tsc_khz);
 	}
 
 	return 0;
-- 
2.20.1


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

* [PATCH] platform/x86: intel_pmc_core: transform Pkg C-state residency from TSC ticks into microseconds
  2019-05-27 13:08 [PATCH] platform/x86: intel_pmc_core: transform Pkg C-state residency from TSC ticks into microseconds Harry Pan
@ 2019-05-28  2:53 ` Harry Pan
  2019-05-28  2:57 ` [PATCH v2] " Harry Pan
  1 sibling, 0 replies; 5+ messages in thread
From: Harry Pan @ 2019-05-28  2:53 UTC (permalink / raw)
  To: LKML
  Cc: gs0622, Harry Pan, Vishwanath Somayaji, Andy Shevchenko,
	platform-driver-x86, Rajneesh Bhardwaj, Darren Hart

Refer to the Intel SDM Vol.4, the package C-state residency counters
of modern IA micro-architecture are all ticking in TSC frequency,
hence we can apply simple math to transform the ticks into microseconds.
i.e.,
residency (ms) = count / tsc_khz
residency (us) = count / tsc_khz * 1000

This also aligns to other sysfs debug entries of residency counter in
the same metric in microseconds, benefits reading and scripting.

v2: restore the accidentally deleted newline, no function change.

Signed-off-by: Harry Pan <harry.pan@intel.com>

---

 drivers/platform/x86/intel_pmc_core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c
index f2c621b55f49..c78918a7e731 100644
--- a/drivers/platform/x86/intel_pmc_core.c
+++ b/drivers/platform/x86/intel_pmc_core.c
@@ -24,6 +24,7 @@
 #include <asm/cpu_device_id.h>
 #include <asm/intel-family.h>
 #include <asm/msr.h>
+#include <asm/tsc.h>
 
 #include "intel_pmc_core.h"
 
@@ -738,8 +739,8 @@ static int pmc_core_pkgc_show(struct seq_file *s, void *unused)
 		if (rdmsrl_safe(map[index].bit_mask, &pcstate_count))
 			continue;
 
-		seq_printf(s, "%-8s : 0x%llx\n", map[index].name,
-			   pcstate_count);
+		seq_printf(s, "%-8s : %llu\n", map[index].name,
+			   pcstate_count * 1000 / tsc_khz);
 	}
 
 	return 0;
-- 
2.20.1


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

* [PATCH v2] platform/x86: intel_pmc_core: transform Pkg C-state residency from TSC ticks into microseconds
  2019-05-27 13:08 [PATCH] platform/x86: intel_pmc_core: transform Pkg C-state residency from TSC ticks into microseconds Harry Pan
  2019-05-28  2:53 ` Harry Pan
@ 2019-05-28  2:57 ` Harry Pan
  2019-06-19  8:28   ` [PATCH v3] " Harry Pan
  1 sibling, 1 reply; 5+ messages in thread
From: Harry Pan @ 2019-05-28  2:57 UTC (permalink / raw)
  To: LKML
  Cc: gs0622, Harry Pan, Vishwanath Somayaji, Andy Shevchenko,
	platform-driver-x86, Rajneesh Bhardwaj, Darren Hart

Refer to the Intel SDM Vol.4, the package C-state residency counters
of modern IA micro-architecture are all ticking in TSC frequency,
hence we can apply simple math to transform the ticks into microseconds.
i.e.,
residency (ms) = count / tsc_khz
residency (us) = count / tsc_khz * 1000

This also aligns to other sysfs debug entries of residency counter in
the same metric in microseconds, benefits reading and scripting.

v2: restore the accidentally deleted newline, no function change.

Signed-off-by: Harry Pan <harry.pan@intel.com>

---

 drivers/platform/x86/intel_pmc_core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c
index f2c621b55f49..c78918a7e731 100644
--- a/drivers/platform/x86/intel_pmc_core.c
+++ b/drivers/platform/x86/intel_pmc_core.c
@@ -24,6 +24,7 @@
 #include <asm/cpu_device_id.h>
 #include <asm/intel-family.h>
 #include <asm/msr.h>
+#include <asm/tsc.h>
 
 #include "intel_pmc_core.h"
 
@@ -738,8 +739,8 @@ static int pmc_core_pkgc_show(struct seq_file *s, void *unused)
 		if (rdmsrl_safe(map[index].bit_mask, &pcstate_count))
 			continue;
 
-		seq_printf(s, "%-8s : 0x%llx\n", map[index].name,
-			   pcstate_count);
+		seq_printf(s, "%-8s : %llu\n", map[index].name,
+			   pcstate_count * 1000 / tsc_khz);
 	}
 
 	return 0;
-- 
2.20.1


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

* [PATCH v3] platform/x86: intel_pmc_core: transform Pkg C-state residency from TSC ticks into microseconds
  2019-05-28  2:57 ` [PATCH v2] " Harry Pan
@ 2019-06-19  8:28   ` Harry Pan
  2019-06-29 13:24     ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Harry Pan @ 2019-06-19  8:28 UTC (permalink / raw)
  To: LKML
  Cc: gs0622, Harry Pan, Vishwanath Somayaji, Andy Shevchenko,
	platform-driver-x86, Rajneesh Bhardwaj, Darren Hart

Refer to the Intel SDM Vol.4, the package C-state residency counters
of modern IA micro-architecture are all ticking in TSC frequency,
hence we can apply simple math to transform the ticks into microseconds.
i.e.,
residency (ms) = count / tsc_khz
residency (us) = count / tsc_khz * 1000

This also aligns to other sysfs debug entries of residency counter in
the same metric in microseconds, benefits reading and scripting.

v2: restore the accidentally deleted newline, no function change.
v3: apply kernel do_div() macro to calculate division

Signed-off-by: Harry Pan <harry.pan@intel.com>

---

 drivers/platform/x86/intel_pmc_core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c
index f2c621b55f49..ab798efacc85 100644
--- a/drivers/platform/x86/intel_pmc_core.c
+++ b/drivers/platform/x86/intel_pmc_core.c
@@ -24,6 +24,7 @@
 #include <asm/cpu_device_id.h>
 #include <asm/intel-family.h>
 #include <asm/msr.h>
+#include <asm/tsc.h>
 
 #include "intel_pmc_core.h"
 
@@ -738,7 +739,9 @@ static int pmc_core_pkgc_show(struct seq_file *s, void *unused)
 		if (rdmsrl_safe(map[index].bit_mask, &pcstate_count))
 			continue;
 
-		seq_printf(s, "%-8s : 0x%llx\n", map[index].name,
+		pcstate_count *= 1000;
+		do_div(pcstate_count, tsc_khz);
+		seq_printf(s, "%-8s : %llu\n", map[index].name,
 			   pcstate_count);
 	}
 
-- 
2.20.1


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

* Re: [PATCH v3] platform/x86: intel_pmc_core: transform Pkg C-state residency from TSC ticks into microseconds
  2019-06-19  8:28   ` [PATCH v3] " Harry Pan
@ 2019-06-29 13:24     ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2019-06-29 13:24 UTC (permalink / raw)
  To: Harry Pan
  Cc: LKML, gs0622, Vishwanath Somayaji, Andy Shevchenko,
	Platform Driver, Rajneesh Bhardwaj, Darren Hart

On Wed, Jun 19, 2019 at 11:29 AM Harry Pan <harry.pan@intel.com> wrote:
>
> Refer to the Intel SDM Vol.4, the package C-state residency counters
> of modern IA micro-architecture are all ticking in TSC frequency,
> hence we can apply simple math to transform the ticks into microseconds.
> i.e.,
> residency (ms) = count / tsc_khz
> residency (us) = count / tsc_khz * 1000
>
> This also aligns to other sysfs debug entries of residency counter in
> the same metric in microseconds, benefits reading and scripting.
>
> v2: restore the accidentally deleted newline, no function change.
> v3: apply kernel do_div() macro to calculate division
>
> Signed-off-by: Harry Pan <harry.pan@intel.com>
>

Pushed to my review and testing queue, thanks!

> ---
>
>  drivers/platform/x86/intel_pmc_core.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c
> index f2c621b55f49..ab798efacc85 100644
> --- a/drivers/platform/x86/intel_pmc_core.c
> +++ b/drivers/platform/x86/intel_pmc_core.c
> @@ -24,6 +24,7 @@
>  #include <asm/cpu_device_id.h>
>  #include <asm/intel-family.h>
>  #include <asm/msr.h>
> +#include <asm/tsc.h>
>
>  #include "intel_pmc_core.h"
>
> @@ -738,7 +739,9 @@ static int pmc_core_pkgc_show(struct seq_file *s, void *unused)
>                 if (rdmsrl_safe(map[index].bit_mask, &pcstate_count))
>                         continue;
>
> -               seq_printf(s, "%-8s : 0x%llx\n", map[index].name,
> +               pcstate_count *= 1000;
> +               do_div(pcstate_count, tsc_khz);
> +               seq_printf(s, "%-8s : %llu\n", map[index].name,
>                            pcstate_count);
>         }
>
> --
> 2.20.1
>


-- 
With Best Regards,
Andy Shevchenko

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

end of thread, other threads:[~2019-06-29 13:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-27 13:08 [PATCH] platform/x86: intel_pmc_core: transform Pkg C-state residency from TSC ticks into microseconds Harry Pan
2019-05-28  2:53 ` Harry Pan
2019-05-28  2:57 ` [PATCH v2] " Harry Pan
2019-06-19  8:28   ` [PATCH v3] " Harry Pan
2019-06-29 13:24     ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.