Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1350473 > unrolled thread
| Started by | Borislav Petkov <bp@alien8.de> |
|---|---|
| First post | 2016-03-04 18:50 +0100 |
| Last post | 2016-03-08 18:40 +0100 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [tip:perf/core] perf/x86/intel/rapl: Sanitize the quirk handling Borislav Petkov <bp@alien8.de> - 2016-03-04 18:50 +0100
Re: [tip:perf/core] perf/x86/intel/rapl: Sanitize the quirk handling Ingo Molnar <mingo@kernel.org> - 2016-03-08 17:10 +0100
[PATCH] perf/x86/intel/rapl: Simplify quirk handling even more Borislav Petkov <bp@alien8.de> - 2016-03-08 17:50 +0100
[tip:perf/core] perf/x86/intel/rapl: Simplify quirk handling even more tip-bot for Borislav Petkov <tipbot@zytor.com> - 2016-03-08 18:40 +0100
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2016-03-04 18:50 +0100 |
| Subject | Re: [tip:perf/core] perf/x86/intel/rapl: Sanitize the quirk handling |
| Message-ID | <r921s-1Re-15@gated-at.bofh.it> |
On Mon, Feb 29, 2016 at 03:10:28AM -0800, tip-bot for Thomas Gleixner wrote:
> Commit-ID: b8b3319a471b2df35ae0a8fe94223638468e9ca4
> Gitweb: http://git.kernel.org/tip/b8b3319a471b2df35ae0a8fe94223638468e9ca4
> Author: Thomas Gleixner <tglx@linutronix.de>
> AuthorDate: Mon, 22 Feb 2016 22:19:22 +0000
> Committer: Ingo Molnar <mingo@kernel.org>
> CommitDate: Mon, 29 Feb 2016 09:35:22 +0100
>
> perf/x86/intel/rapl: Sanitize the quirk handling
>
> There is no point in having a quirk machinery for a single possible
> function. Get rid of it and move the quirk to a place where it actually
> makes sense.
I guess you can simplify this even more by even getting rid of that
quirk function pointer funkyness and simply tell rapl_check_hw_unit() to
apply the quirk.
Diff ontop of yours:
---
diff --git a/arch/x86/events/intel/rapl.c b/arch/x86/events/intel/rapl.c
index 019e541fa988..0b72976bab35 100644
--- a/arch/x86/events/intel/rapl.c
+++ b/arch/x86/events/intel/rapl.c
@@ -592,18 +592,7 @@ static int rapl_cpu_notifier(struct notifier_block *self,
return NOTIFY_OK;
}
-static __init void rapl_hsw_server_quirk(void)
-{
- /*
- * DRAM domain on HSW server has fixed energy unit which can be
- * different than the unit from power unit MSR.
- * "Intel Xeon Processor E5-1600 and E5-2600 v3 Product Families, V2
- * of 2. Datasheet, September 2014, Reference Number: 330784-001 "
- */
- rapl_hw_unit[RAPL_IDX_RAM_NRG_STAT] = 16;
-}
-
-static int rapl_check_hw_unit(void (*quirk)(void))
+static int rapl_check_hw_unit(bool apply_quirk)
{
u64 msr_rapl_power_unit_bits;
int i;
@@ -614,9 +603,14 @@ static int rapl_check_hw_unit(void (*quirk)(void))
for (i = 0; i < NR_RAPL_DOMAINS; i++)
rapl_hw_unit[i] = (msr_rapl_power_unit_bits >> 8) & 0x1FULL;
- /* Apply cpu model quirk */
- if (quirk)
- quirk();
+ /*
+ * DRAM domain on HSW server has fixed energy unit which can be
+ * different than the unit from power unit MSR.
+ * "Intel Xeon Processor E5-1600 and E5-2600 v3 Product Families, V2
+ * of 2. Datasheet, September 2014, Reference Number: 330784-001 "
+ */
+ if (apply_quirk)
+ rapl_hw_unit[RAPL_IDX_RAM_NRG_STAT] = 16;
/*
* Calculate the timer rate:
@@ -704,7 +698,7 @@ static const struct x86_cpu_id rapl_cpu_match[] __initconst = {
static int __init rapl_pmu_init(void)
{
- void (*quirk)(void) = NULL;
+ bool apply_quirk = false;
int ret;
if (!x86_match_cpu(rapl_cpu_match))
@@ -717,7 +711,7 @@ static int __init rapl_pmu_init(void)
rapl_pmu_events_group.attrs = rapl_events_cln_attr;
break;
case 63: /* Haswell-Server */
- quirk = rapl_hsw_server_quirk;
+ apply_quirk = true;
rapl_cntr_mask = RAPL_IDX_SRV;
rapl_pmu_events_group.attrs = rapl_events_srv_attr;
break;
@@ -733,7 +727,7 @@ static int __init rapl_pmu_init(void)
rapl_pmu_events_group.attrs = rapl_events_srv_attr;
break;
case 87: /* Knights Landing */
- quirk = rapl_hsw_server_quirk;
+ apply_quirk = true;
rapl_cntr_mask = RAPL_IDX_KNL;
rapl_pmu_events_group.attrs = rapl_events_knl_attr;
break;
@@ -741,7 +735,7 @@ static int __init rapl_pmu_init(void)
return -ENODEV;
}
- ret = rapl_check_hw_unit(quirk);
+ ret = rapl_check_hw_unit(apply_quirk);
if (ret)
return ret;
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
[toc] | [next] | [standalone]
| From | Ingo Molnar <mingo@kernel.org> |
|---|---|
| Date | 2016-03-08 17:10 +0100 |
| Message-ID | <rasmR-37R-5@gated-at.bofh.it> |
| In reply to | #1350473 |
* Borislav Petkov <bp@alien8.de> wrote:
> On Mon, Feb 29, 2016 at 03:10:28AM -0800, tip-bot for Thomas Gleixner wrote:
> > Commit-ID: b8b3319a471b2df35ae0a8fe94223638468e9ca4
> > Gitweb: http://git.kernel.org/tip/b8b3319a471b2df35ae0a8fe94223638468e9ca4
> > Author: Thomas Gleixner <tglx@linutronix.de>
> > AuthorDate: Mon, 22 Feb 2016 22:19:22 +0000
> > Committer: Ingo Molnar <mingo@kernel.org>
> > CommitDate: Mon, 29 Feb 2016 09:35:22 +0100
> >
> > perf/x86/intel/rapl: Sanitize the quirk handling
> >
> > There is no point in having a quirk machinery for a single possible
> > function. Get rid of it and move the quirk to a place where it actually
> > makes sense.
>
> I guess you can simplify this even more by even getting rid of that
> quirk function pointer funkyness and simply tell rapl_check_hw_unit() to
> apply the quirk.
>
> Diff ontop of yours:
>
> ---
> diff --git a/arch/x86/events/intel/rapl.c b/arch/x86/events/intel/rapl.c
> index 019e541fa988..0b72976bab35 100644
> --- a/arch/x86/events/intel/rapl.c
> +++ b/arch/x86/events/intel/rapl.c
> @@ -592,18 +592,7 @@ static int rapl_cpu_notifier(struct notifier_block *self,
> return NOTIFY_OK;
> }
>
> -static __init void rapl_hsw_server_quirk(void)
> -{
> - /*
> - * DRAM domain on HSW server has fixed energy unit which can be
> - * different than the unit from power unit MSR.
> - * "Intel Xeon Processor E5-1600 and E5-2600 v3 Product Families, V2
> - * of 2. Datasheet, September 2014, Reference Number: 330784-001 "
> - */
> - rapl_hw_unit[RAPL_IDX_RAM_NRG_STAT] = 16;
> -}
> -
> -static int rapl_check_hw_unit(void (*quirk)(void))
> +static int rapl_check_hw_unit(bool apply_quirk)
> {
> u64 msr_rapl_power_unit_bits;
> int i;
> @@ -614,9 +603,14 @@ static int rapl_check_hw_unit(void (*quirk)(void))
> for (i = 0; i < NR_RAPL_DOMAINS; i++)
> rapl_hw_unit[i] = (msr_rapl_power_unit_bits >> 8) & 0x1FULL;
>
> - /* Apply cpu model quirk */
> - if (quirk)
> - quirk();
> + /*
> + * DRAM domain on HSW server has fixed energy unit which can be
> + * different than the unit from power unit MSR.
> + * "Intel Xeon Processor E5-1600 and E5-2600 v3 Product Families, V2
> + * of 2. Datasheet, September 2014, Reference Number: 330784-001 "
> + */
> + if (apply_quirk)
> + rapl_hw_unit[RAPL_IDX_RAM_NRG_STAT] = 16;
>
> /*
> * Calculate the timer rate:
> @@ -704,7 +698,7 @@ static const struct x86_cpu_id rapl_cpu_match[] __initconst = {
>
> static int __init rapl_pmu_init(void)
> {
> - void (*quirk)(void) = NULL;
> + bool apply_quirk = false;
> int ret;
>
> if (!x86_match_cpu(rapl_cpu_match))
> @@ -717,7 +711,7 @@ static int __init rapl_pmu_init(void)
> rapl_pmu_events_group.attrs = rapl_events_cln_attr;
> break;
> case 63: /* Haswell-Server */
> - quirk = rapl_hsw_server_quirk;
> + apply_quirk = true;
> rapl_cntr_mask = RAPL_IDX_SRV;
> rapl_pmu_events_group.attrs = rapl_events_srv_attr;
> break;
> @@ -733,7 +727,7 @@ static int __init rapl_pmu_init(void)
> rapl_pmu_events_group.attrs = rapl_events_srv_attr;
> break;
> case 87: /* Knights Landing */
> - quirk = rapl_hsw_server_quirk;
> + apply_quirk = true;
> rapl_cntr_mask = RAPL_IDX_KNL;
> rapl_pmu_events_group.attrs = rapl_events_knl_attr;
> break;
> @@ -741,7 +735,7 @@ static int __init rapl_pmu_init(void)
> return -ENODEV;
> }
>
> - ret = rapl_check_hw_unit(quirk);
> + ret = rapl_check_hw_unit(apply_quirk);
> if (ret)
> return ret;
Please send a patch with a changelog so it can be applied.
Thanks!
Ingo
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2016-03-08 17:50 +0100 |
| Subject | [PATCH] perf/x86/intel/rapl: Simplify quirk handling even more |
| Message-ID | <rasZA-3on-15@gated-at.bofh.it> |
| In reply to | #1353176 |
Drop the quirk() function pointer in favor of a simple boolean which
says whether the quirk should be applied or not. Update comment while at
it.
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andi Kleen <andi.kleen@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Harish Chegondi <harish.chegondi@intel.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
---
arch/x86/events/intel/rapl.c | 32 +++++++++++++-------------------
1 file changed, 13 insertions(+), 19 deletions(-)
diff --git a/arch/x86/events/intel/rapl.c b/arch/x86/events/intel/rapl.c
index 019e541fa988..b834a3f55a01 100644
--- a/arch/x86/events/intel/rapl.c
+++ b/arch/x86/events/intel/rapl.c
@@ -592,18 +592,7 @@ static int rapl_cpu_notifier(struct notifier_block *self,
return NOTIFY_OK;
}
-static __init void rapl_hsw_server_quirk(void)
-{
- /*
- * DRAM domain on HSW server has fixed energy unit which can be
- * different than the unit from power unit MSR.
- * "Intel Xeon Processor E5-1600 and E5-2600 v3 Product Families, V2
- * of 2. Datasheet, September 2014, Reference Number: 330784-001 "
- */
- rapl_hw_unit[RAPL_IDX_RAM_NRG_STAT] = 16;
-}
-
-static int rapl_check_hw_unit(void (*quirk)(void))
+static int rapl_check_hw_unit(bool apply_quirk)
{
u64 msr_rapl_power_unit_bits;
int i;
@@ -614,9 +603,14 @@ static int rapl_check_hw_unit(void (*quirk)(void))
for (i = 0; i < NR_RAPL_DOMAINS; i++)
rapl_hw_unit[i] = (msr_rapl_power_unit_bits >> 8) & 0x1FULL;
- /* Apply cpu model quirk */
- if (quirk)
- quirk();
+ /*
+ * DRAM domain on HSW server and KNL has fixed energy unit which can be
+ * different than the unit from power unit MSR. See
+ * "Intel Xeon Processor E5-1600 and E5-2600 v3 Product Families, V2
+ * of 2. Datasheet, September 2014, Reference Number: 330784-001 "
+ */
+ if (apply_quirk)
+ rapl_hw_unit[RAPL_IDX_RAM_NRG_STAT] = 16;
/*
* Calculate the timer rate:
@@ -704,7 +698,7 @@ static const struct x86_cpu_id rapl_cpu_match[] __initconst = {
static int __init rapl_pmu_init(void)
{
- void (*quirk)(void) = NULL;
+ bool apply_quirk = false;
int ret;
if (!x86_match_cpu(rapl_cpu_match))
@@ -717,7 +711,7 @@ static int __init rapl_pmu_init(void)
rapl_pmu_events_group.attrs = rapl_events_cln_attr;
break;
case 63: /* Haswell-Server */
- quirk = rapl_hsw_server_quirk;
+ apply_quirk = true;
rapl_cntr_mask = RAPL_IDX_SRV;
rapl_pmu_events_group.attrs = rapl_events_srv_attr;
break;
@@ -733,7 +727,7 @@ static int __init rapl_pmu_init(void)
rapl_pmu_events_group.attrs = rapl_events_srv_attr;
break;
case 87: /* Knights Landing */
- quirk = rapl_hsw_server_quirk;
+ apply_quirk = true;
rapl_cntr_mask = RAPL_IDX_KNL;
rapl_pmu_events_group.attrs = rapl_events_knl_attr;
break;
@@ -741,7 +735,7 @@ static int __init rapl_pmu_init(void)
return -ENODEV;
}
- ret = rapl_check_hw_unit(quirk);
+ ret = rapl_check_hw_unit(apply_quirk);
if (ret)
return ret;
--
2.3.5
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Borislav Petkov <tipbot@zytor.com> |
|---|---|
| Date | 2016-03-08 18:40 +0100 |
| Subject | [tip:perf/core] perf/x86/intel/rapl: Simplify quirk handling even more |
| Message-ID | <ratM4-40W-161@gated-at.bofh.it> |
| In reply to | #1353209 |
Commit-ID: 7a8698058ae493ae53b1a8a2fa23d2e37000d73e
Gitweb: http://git.kernel.org/tip/7a8698058ae493ae53b1a8a2fa23d2e37000d73e
Author: Borislav Petkov <bp@alien8.de>
AuthorDate: Tue, 8 Mar 2016 17:40:41 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 8 Mar 2016 17:49:52 +0100
perf/x86/intel/rapl: Simplify quirk handling even more
Drop the quirk() function pointer in favor of a simple boolean which
says whether the quirk should be applied or not. Update comment while at
it.
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <andi.kleen@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Harish Chegondi <harish.chegondi@intel.com>
Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: linux-tip-commits@vger.kernel.org
Link: http://lkml.kernel.org/r/20160308164041.GF16568@pd.tnic
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/events/intel/rapl.c | 32 +++++++++++++-------------------
1 file changed, 13 insertions(+), 19 deletions(-)
diff --git a/arch/x86/events/intel/rapl.c b/arch/x86/events/intel/rapl.c
index 019e541..b834a3f 100644
--- a/arch/x86/events/intel/rapl.c
+++ b/arch/x86/events/intel/rapl.c
@@ -592,18 +592,7 @@ static int rapl_cpu_notifier(struct notifier_block *self,
return NOTIFY_OK;
}
-static __init void rapl_hsw_server_quirk(void)
-{
- /*
- * DRAM domain on HSW server has fixed energy unit which can be
- * different than the unit from power unit MSR.
- * "Intel Xeon Processor E5-1600 and E5-2600 v3 Product Families, V2
- * of 2. Datasheet, September 2014, Reference Number: 330784-001 "
- */
- rapl_hw_unit[RAPL_IDX_RAM_NRG_STAT] = 16;
-}
-
-static int rapl_check_hw_unit(void (*quirk)(void))
+static int rapl_check_hw_unit(bool apply_quirk)
{
u64 msr_rapl_power_unit_bits;
int i;
@@ -614,9 +603,14 @@ static int rapl_check_hw_unit(void (*quirk)(void))
for (i = 0; i < NR_RAPL_DOMAINS; i++)
rapl_hw_unit[i] = (msr_rapl_power_unit_bits >> 8) & 0x1FULL;
- /* Apply cpu model quirk */
- if (quirk)
- quirk();
+ /*
+ * DRAM domain on HSW server and KNL has fixed energy unit which can be
+ * different than the unit from power unit MSR. See
+ * "Intel Xeon Processor E5-1600 and E5-2600 v3 Product Families, V2
+ * of 2. Datasheet, September 2014, Reference Number: 330784-001 "
+ */
+ if (apply_quirk)
+ rapl_hw_unit[RAPL_IDX_RAM_NRG_STAT] = 16;
/*
* Calculate the timer rate:
@@ -704,7 +698,7 @@ static const struct x86_cpu_id rapl_cpu_match[] __initconst = {
static int __init rapl_pmu_init(void)
{
- void (*quirk)(void) = NULL;
+ bool apply_quirk = false;
int ret;
if (!x86_match_cpu(rapl_cpu_match))
@@ -717,7 +711,7 @@ static int __init rapl_pmu_init(void)
rapl_pmu_events_group.attrs = rapl_events_cln_attr;
break;
case 63: /* Haswell-Server */
- quirk = rapl_hsw_server_quirk;
+ apply_quirk = true;
rapl_cntr_mask = RAPL_IDX_SRV;
rapl_pmu_events_group.attrs = rapl_events_srv_attr;
break;
@@ -733,7 +727,7 @@ static int __init rapl_pmu_init(void)
rapl_pmu_events_group.attrs = rapl_events_srv_attr;
break;
case 87: /* Knights Landing */
- quirk = rapl_hsw_server_quirk;
+ apply_quirk = true;
rapl_cntr_mask = RAPL_IDX_KNL;
rapl_pmu_events_group.attrs = rapl_events_knl_attr;
break;
@@ -741,7 +735,7 @@ static int __init rapl_pmu_init(void)
return -ENODEV;
}
- ret = rapl_check_hw_unit(quirk);
+ ret = rapl_check_hw_unit(apply_quirk);
if (ret)
return ret;
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web