Thread (8 messages) flat view 8 messages, 3 authors, 2016-11-08

Re: [PATCH v2] ppc: cpufreq: disable preemption while checking CPU throttling state

From: Denis Kirjanov <hidden>
Date: 2016-11-07 05:15:27

On Monday, November 7, 2016, Gautham R Shenoy [off-list ref]
wrote:
Hi Denis,

On Fri, Nov 04, 2016 at 07:08:38AM -0400, Denis Kirjanov wrote:

You can provide the config option with which this bug was found in the
change log. I suppose you had enabled CONFIG_DEBUG_PREEMPT.
that's why I put the comment

quoted
    [   67.700897] BUG: using smp_processor_id() in preemptible
[00000000] code: cat/7343
quoted
    [   67.700988] caller is .powernv_cpufreq_throttle_check+0x2c/0x710
    [   67.700998] CPU: 13 PID: 7343 Comm: cat Not tainted
4.8.0-rc5-dirty #1
quoted
    [   67.701038] Call Trace:
    [   67.701066] [c0000007d25b75b0] [c000000000971378]
.dump_stack+0xe4/0x150 (unreliable)
quoted
    [   67.701153] [c0000007d25b7640] [c0000000005162e4]
.check_preemption_disabled+0x134/0x150
quoted
    [   67.701238] [c0000007d25b76e0] [c0000000007b63ac]
.powernv_cpufreq_throttle_check+0x2c/0x710
quoted
    [   67.701322] [c0000007d25b7790] [c0000000007b6d18]
.powernv_cpufreq_target_index+0x288/0x360
quoted
    [   67.701407] [c0000007d25b7870] [c0000000007acee4]
.__cpufreq_driver_target+0x394/0x8c0
quoted
    [   67.701491] [c0000007d25b7920] [c0000000007b22ac]
.cpufreq_set+0x7c/0xd0
quoted
    [   67.701565] [c0000007d25b79b0] [c0000000007adf50]
.store_scaling_setspeed+0x80/0xc0
quoted
    [   67.701650] [c0000007d25b7a40] [c0000000007ae270]
.store+0xa0/0x100
quoted
    [   67.701723] [c0000007d25b7ae0] [c0000000003566e8]
.sysfs_kf_write+0x88/0xb0
quoted
    [   67.701796] [c0000007d25b7b70] [c0000000003553b8]
.kernfs_fop_write+0x178/0x260
quoted
    [   67.701881] [c0000007d25b7c10] [c0000000002ac3cc]
.__vfs_write+0x3c/0x1c0
quoted
    [   67.701954] [c0000007d25b7cf0] [c0000000002ad584]
.vfs_write+0xc4/0x230
quoted
    [   67.702027] [c0000007d25b7d90] [c0000000002aeef8]
.SyS_write+0x58/0x100
quoted
    [   67.702101] [c0000007d25b7e30] [c00000000000bfec]
system_call+0x38/0xfc
quoted
Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org <javascript:;>>

v2:  wrap powernv_cpufreq_throttle_check()
as suggested by Gautham R Shenoy
Looks good otherwise.

Reviewed-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com <javascript:;>>
quoted
---
 drivers/cpufreq/powernv-cpufreq.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/cpufreq/powernv-cpufreq.c
b/drivers/cpufreq/powernv-cpufreq.c
quoted
index d3ffde8..112e0e2 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -647,8 +647,15 @@ static int powernv_cpufreq_target_index(struct
cpufreq_policy *policy,
quoted
      if (unlikely(rebooting) && new_index != get_nominal_index())
              return 0;

-     if (!throttled)
+     if (!throttled) {
+             /*
+              * we don't want to be preempted while
+              * checking if the CPU frequency has been throttled
+              */
+             preempt_disable();
              powernv_cpufreq_throttle_check(NULL);
+             preempt_enable();
+    }

      cur_msec = jiffies_to_msecs(get_jiffies_64());

--
1.8.3.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help