<br><br>On Thursday, November 3, 2016, Gautham R Shenoy <<a href="mailto:ego@linux.vnet.ibm.com">ego@linux.vnet.ibm.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Denis,<br>
<br>
On Thu, Nov 03, 2016 at 07:20:41AM -0400, Denis Kirjanov wrote:<br>
> [   67.700897] BUG: using smp_processor_id() in preemptible [00000000] code: cat/7343<br>
> [   67.700988] caller is .powernv_cpufreq_throttle_<wbr>check+0x2c/0x710<br>
> [   67.700998] CPU: 13 PID: 7343 Comm: cat Not tainted 4.8.0-rc5-dirty #1<br>
> [   67.701038] Call Trace:<br>
> [   67.701066] [c0000007d25b75b0] [c000000000971378] .dump_stack+0xe4/0x150 (unreliable)<br>
> [   67.701153] [c0000007d25b7640] [c0000000005162e4] .check_preemption_disabled+<wbr>0x134/0x150<br>
> [   67.701238] [c0000007d25b76e0] [c0000000007b63ac] .powernv_cpufreq_throttle_<wbr>check+0x2c/0x710<br>
> [   67.701322] [c0000007d25b7790] [c0000000007b6d18] .powernv_cpufreq_target_index+<wbr>0x288/0x360<br>
> [   67.701407] [c0000007d25b7870] [c0000000007acee4] .__cpufreq_driver_target+<wbr>0x394/0x8c0<br>
> [   67.701491] [c0000007d25b7920] [c0000000007b22ac] .cpufreq_set+0x7c/0xd0<br>
> [   67.701565] [c0000007d25b79b0] [c0000000007adf50] .store_scaling_setspeed+0x80/<wbr>0xc0<br>
> [   67.701650] [c0000007d25b7a40] [c0000000007ae270] .store+0xa0/0x100<br>
> [   67.701723] [c0000007d25b7ae0] [c0000000003566e8] .sysfs_kf_write+0x88/0xb0<br>
> [   67.701796] [c0000007d25b7b70] [c0000000003553b8] .kernfs_fop_write+0x178/0x260<br>
> [   67.701881] [c0000007d25b7c10] [c0000000002ac3cc] .__vfs_write+0x3c/0x1c0<br>
> [   67.701954] [c0000007d25b7cf0] [c0000000002ad584] .vfs_write+0xc4/0x230<br>
> [   67.702027] [c0000007d25b7d90] [c0000000002aeef8] .SyS_write+0x58/0x100<br>
> [   67.702101] [c0000007d25b7e30] [c00000000000bfec] system_call+0x38/0xfc<br>
><br>
> Signed-off-by: Denis Kirjanov <<a href="javascript:;" onclick="_e(event, 'cvml', 'kda@linux-powerpc.org')">kda@linux-powerpc.org</a>><br>
<br>
<br>
Thanks for looking into this!<br>
> ---<br>
>  drivers/cpufreq/powernv-<wbr>cpufreq.c | 4 +++-<br>
>  1 file changed, 3 insertions(+), 1 deletion(-)<br>
><br>
> diff --git a/drivers/cpufreq/powernv-<wbr>cpufreq.c b/drivers/cpufreq/powernv-<wbr>cpufreq.c<br>
> index d3ffde8..4cd91a3 100644<br>
> --- a/drivers/cpufreq/powernv-<wbr>cpufreq.c<br>
> +++ b/drivers/cpufreq/powernv-<wbr>cpufreq.c<br>
> @@ -475,7 +475,7 @@ static inline unsigned int get_nominal_index(void)<br>
>  static void powernv_cpufreq_throttle_<wbr>check(void *data)<br>
<br>
The powernv_cpufreq_throttle_<wbr>check() checks if the frequency on any of<br>
the CPUs on this chip has been throttled. Hence it needs to be<br>
executed without preemption on a CPU on the particular chip.<br>
<br>
It is called in two places currently:<br>
<br>
a) powernv_cpufreq_work_fn where<br>
it is called via smp_call_function_any() which will ensure that the<br>
function will be executed without preempted.<br>
<br>
b) from powernv_cpufreq_target_index: Here it should be nested within<br>
the preempt_disable() preempt_enable() calls. It currently is not.<br>
<br>
So, I would suggest fixing b) instead of locally fixing<br>
smp_processor_id() to get_cpu()/put_cpu().</blockquote><div><br></div><div>Ok, I'll send the v2 then.</div><div><br></div><div>Thanks! </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
>  {<br>
>       struct chip *chip;<br>
> -     unsigned int cpu = smp_processor_id();<br>
> +     int cpu;<br>
>       unsigned long pmsr;<br>
>       int pmsr_pmax;<br>
>       unsigned int pmsr_pmax_idx;<br>
> @@ -491,9 +491,11 @@ static void powernv_cpufreq_throttle_<wbr>check(void *data)<br>
>                       goto next;<br>
>               chip->throttled = true;<br>
>               if (pmsr_pmax_idx > powernv_pstate_info.nominal) {<br>
> +                     cpu = get_cpu();<br>
>                       pr_warn_once("CPU %d on Chip %u has Pmax(%d) reduced below nominal frequency(%d)\n",<br>
>                                    cpu, chip->id, pmsr_pmax,<br>
>                                    idx_to_pstate(powernv_pstate_<wbr>info.nominal));<br>
> +                     put_cpu();<br>
>                       chip->throttle_sub_turbo++;<br>
>               } else {<br>
>                       chip->throttle_turbo++;<br>
> --<br>
> 1.8.3.1<br>
><br>
<br>
--<br>
Thanks and Regards<br>
gautham.<br>
<br>
</blockquote><br><br>-- <br>Regards / Mit besten Grüßen,<br>Denis<br><br>