Message ID | 1464775486-23446-1-git-send-email-bp@alien8.de (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
On 06/01/2016 03:04 AM, Borislav Petkov wrote: > From: Borislav Petkov <bp@suse.de> > > We need to read a bunch of registers on each compute unit and possibly > on the current CPU too. Disable preemption around it. > An explanation would be helpful. Is this a bug fix ? I would like to get a confirmation from someone at AMD that this is really necessary. Thanks, Guenter > Signed-off-by: Borislav Petkov <bp@suse.de> > Cc: Rui Huang <ray.huang@amd.com> > Cc: Sherry Hurwitz <sherry.hurwitz@amd.com> > Cc: Guenter Roeck <linux@roeck-us.net> > --- > drivers/hwmon/fam15h_power.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c > index eb97a9241d17..69bb810f528b 100644 > --- a/drivers/hwmon/fam15h_power.c > +++ b/drivers/hwmon/fam15h_power.c > @@ -172,9 +172,9 @@ static void do_read_registers_on_cu(void *_data) > */ > static int read_registers(struct fam15h_power_data *data) > { > - int this_cpu, ret, cpu; > int core, this_core; > cpumask_var_t mask; > + int ret, cpu; > > ret = zalloc_cpumask_var(&mask, GFP_KERNEL); > if (!ret) > @@ -183,7 +183,6 @@ static int read_registers(struct fam15h_power_data *data) > memset(data->cu_on, 0, sizeof(int) * MAX_CUS); > > get_online_cpus(); > - this_cpu = smp_processor_id(); > > /* > * Choose the first online core of each compute unit, and then > @@ -205,10 +204,13 @@ static int read_registers(struct fam15h_power_data *data) > cpumask_set_cpu(cpumask_any(topology_sibling_cpumask(cpu)), mask); > } > > - if (cpumask_test_cpu(this_cpu, mask)) > + preempt_disable(); > + smp_call_function_many(mask, do_read_registers_on_cu, data, true); > + > + if (cpumask_test_cpu(smp_processor_id(), mask)) > do_read_registers_on_cu(data); > > - smp_call_function_many(mask, do_read_registers_on_cu, data, true); > + preempt_enable(); > put_online_cpus(); > > free_cpumask_var(mask); > -- To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Jun 01, 2016 at 06:22:59AM -0700, Guenter Roeck wrote:
> An explanation would be helpful. Is this a bug fix ?
That's a good point - yes, it is necessary. Both smp_processor_id()
*and* smp_call_function_many() need to be called with preemption
disabled.
It did fire the BUG thing in check_preemption_disabled() with 4.7-rc1
here without those fixes.
But, we need the other patch too -
"[PATCH] x86/cpu/AMD: Extend X86_FEATURE_TOPOEXT workaround to newer models"
because the cpumask generation in read_registers() doesn't work on those
Carrizo CPUs.
IINM, the breakage came in during this merge window so we don't have to
CC:stable but both should be sent to Linus as fixes for 4.7.
You could sync with Ingo who takes/acks what... but they could go
through tip and hwmon tree too, I don't see a hard dependency between
the two - they'd only need to be in 4.7-final.
Thanks.
> On Jun 1, 2016, at 9:23 PM, Guenter Roeck <linux@roeck-us.net> wrote: > >> On 06/01/2016 03:04 AM, Borislav Petkov wrote: >> From: Borislav Petkov <bp@suse.de> >> >> We need to read a bunch of registers on each compute unit and possibly >> on the current CPU too. Disable preemption around it. > > An explanation would be helpful. Is this a bug fix ? I would like to get > a confirmation from someone at AMD that this is really necessary. > This change looks good for me. But I am in office this week, I will test it on CZ platform next week. :-) Thanks, Rui > Thanks, > Guenter > >> Signed-off-by: Borislav Petkov <bp@suse.de> >> Cc: Rui Huang <ray.huang@amd.com> >> Cc: Sherry Hurwitz <sherry.hurwitz@amd.com> >> Cc: Guenter Roeck <linux@roeck-us.net> >> --- >> drivers/hwmon/fam15h_power.c | 10 ++++++---- >> 1 file changed, 6 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c >> index eb97a9241d17..69bb810f528b 100644 >> --- a/drivers/hwmon/fam15h_power.c >> +++ b/drivers/hwmon/fam15h_power.c >> @@ -172,9 +172,9 @@ static void do_read_registers_on_cu(void *_data) >> */ >> static int read_registers(struct fam15h_power_data *data) >> { >> - int this_cpu, ret, cpu; >> int core, this_core; >> cpumask_var_t mask; >> + int ret, cpu; >> >> ret = zalloc_cpumask_var(&mask, GFP_KERNEL); >> if (!ret) >> @@ -183,7 +183,6 @@ static int read_registers(struct fam15h_power_data *data) >> memset(data->cu_on, 0, sizeof(int) * MAX_CUS); >> >> get_online_cpus(); >> - this_cpu = smp_processor_id(); >> >> /* >> * Choose the first online core of each compute unit, and then >> @@ -205,10 +204,13 @@ static int read_registers(struct fam15h_power_data *data) >> cpumask_set_cpu(cpumask_any(topology_sibling_cpumask(cpu)), mask); >> } >> >> - if (cpumask_test_cpu(this_cpu, mask)) >> + preempt_disable(); >> + smp_call_function_many(mask, do_read_registers_on_cu, data, true); >> + >> + if (cpumask_test_cpu(smp_processor_id(), mask)) >> do_read_registers_on_cu(data); >> >> - smp_call_function_many(mask, do_read_registers_on_cu, data, true); >> + preempt_enable(); >> put_online_cpus(); >> >> free_cpumask_var(mask); > -- To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Sent from my iPad > On Jun 1, 2016, at 11:27 PM, Huang, Ray <Ray.Huang@amd.com> wrote: > > > >>> On Jun 1, 2016, at 9:23 PM, Guenter Roeck <linux@roeck-us.net> wrote: >>> >>> On 06/01/2016 03:04 AM, Borislav Petkov wrote: >>> From: Borislav Petkov <bp@suse.de> >>> >>> We need to read a bunch of registers on each compute unit and possibly >>> on the current CPU too. Disable preemption around it. >> >> An explanation would be helpful. Is this a bug fix ? I would like to get >> a confirmation from someone at AMD that this is really necessary. >> > > This change looks good for me. But I am in office this week, I will test it on CZ platform next week. :-) Sorry, fix typo. I am *not* in office this week. Rui-- To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Jun 01, 2016 at 03:41:26PM +0200, Borislav Petkov wrote: > On Wed, Jun 01, 2016 at 06:22:59AM -0700, Guenter Roeck wrote: > > An explanation would be helpful. Is this a bug fix ? > > That's a good point - yes, it is necessary. Both smp_processor_id() > *and* smp_call_function_many() need to be called with preemption > disabled. > > It did fire the BUG thing in check_preemption_disabled() with 4.7-rc1 > here without those fixes. > It would be great if you can add at least part of the BUG message as well as a Fixes: tag into the patch description. If you had, I would not have asked, saving both of us time ;-). > But, we need the other patch too - > > "[PATCH] x86/cpu/AMD: Extend X86_FEATURE_TOPOEXT workaround to newer models" > > because the cpumask generation in read_registers() doesn't work on those > Carrizo CPUs. > > IINM, the breakage came in during this merge window so we don't have to > CC:stable but both should be sent to Linus as fixes for 4.7. > > You could sync with Ingo who takes/acks what... but they could go > through tip and hwmon tree too, I don't see a hard dependency between > the two - they'd only need to be in 4.7-final. > Sounds like separate trees should be fine then. Thanks, Guenter -- To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c index eb97a9241d17..69bb810f528b 100644 --- a/drivers/hwmon/fam15h_power.c +++ b/drivers/hwmon/fam15h_power.c @@ -172,9 +172,9 @@ static void do_read_registers_on_cu(void *_data) */ static int read_registers(struct fam15h_power_data *data) { - int this_cpu, ret, cpu; int core, this_core; cpumask_var_t mask; + int ret, cpu; ret = zalloc_cpumask_var(&mask, GFP_KERNEL); if (!ret) @@ -183,7 +183,6 @@ static int read_registers(struct fam15h_power_data *data) memset(data->cu_on, 0, sizeof(int) * MAX_CUS); get_online_cpus(); - this_cpu = smp_processor_id(); /* * Choose the first online core of each compute unit, and then @@ -205,10 +204,13 @@ static int read_registers(struct fam15h_power_data *data) cpumask_set_cpu(cpumask_any(topology_sibling_cpumask(cpu)), mask); } - if (cpumask_test_cpu(this_cpu, mask)) + preempt_disable(); + smp_call_function_many(mask, do_read_registers_on_cu, data, true); + + if (cpumask_test_cpu(smp_processor_id(), mask)) do_read_registers_on_cu(data); - smp_call_function_many(mask, do_read_registers_on_cu, data, true); + preempt_enable(); put_online_cpus(); free_cpumask_var(mask);