diff mbox

[v5,1/5] cpufreq: powernv: Hot-plug safe the kworker thread

Message ID 1453369139-10203-2-git-send-email-shilpa.bhat@linux.vnet.ibm.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Shilpasri G Bhat Jan. 21, 2016, 9:38 a.m. UTC
In the kworker_thread powernv_cpufreq_work_fn(), we can end up
sending an IPI to a cpu going offline. This is a rare corner case
which is fixed using {get/put}_online_cpus(). Along with this fix,
this patch adds changes to do oneshot cpumask_{clear/and} operation.

Suggested-by: Shreyas B Prabhu <shreyas@linux.vnet.ibm.com>
Suggested-by: Gautham R Shenoy <ego@linux.vnet.ibm.com>
Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
Reviewed-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
---
 drivers/cpufreq/powernv-cpufreq.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

Comments

kernel test robot Jan. 21, 2016, 10:20 a.m. UTC | #1
Hi Shilpasri,

[auto build test ERROR on pm/linux-next]
[also build test ERROR on v4.4 next-20160121]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Shilpasri-G-Bhat/cpufreq-powernv-Redesign-the-presentation-of-throttle-notification-and-solve-bug-fixes-in-the-driver/20160121-174402
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: powerpc-allyesconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=powerpc 

Note: the linux-review/Shilpasri-G-Bhat/cpufreq-powernv-Redesign-the-presentation-of-throttle-notification-and-solve-bug-fixes-in-the-driver/20160121-174402 HEAD 9aca97b0876d0d182772832e0447a9bf58a967f7 builds fine.
      It only hurts bisectibility.

All errors (new ones prefixed by >>):

   drivers/cpufreq/powernv-cpufreq.c: In function 'powernv_cpufreq_work_fn':
>> drivers/cpufreq/powernv-cpufreq.c:428:2: error: implicit declaration of function 'get_online_cpus' [-Werror=implicit-function-declaration]
     get_online_cpus();
     ^
>> drivers/cpufreq/powernv-cpufreq.c:449:2: error: implicit declaration of function 'put_online_cpus' [-Werror=implicit-function-declaration]
     put_online_cpus();
     ^
   cc1: some warnings being treated as errors

vim +/get_online_cpus +428 drivers/cpufreq/powernv-cpufreq.c

   422	void powernv_cpufreq_work_fn(struct work_struct *work)
   423	{
   424		struct chip *chip = container_of(work, struct chip, throttle);
   425		unsigned int cpu;
   426		cpumask_t mask;
   427	
 > 428		get_online_cpus();
   429		cpumask_and(&mask, &chip->mask, cpu_online_mask);
   430		smp_call_function_any(&mask,
   431				      powernv_cpufreq_throttle_check, NULL, 0);
   432	
   433		if (!chip->restore)
   434			goto out;
   435	
   436		chip->restore = false;
   437		for_each_cpu(cpu, &mask) {
   438			int index;
   439			struct cpufreq_policy policy;
   440	
   441			cpufreq_get_policy(&policy, cpu);
   442			cpufreq_frequency_table_target(&policy, policy.freq_table,
   443						       policy.cur,
   444						       CPUFREQ_RELATION_C, &index);
   445			powernv_cpufreq_target_index(&policy, index);
   446			cpumask_andnot(&mask, &mask, policy.cpus);
   447		}
   448	out:
 > 449		put_online_cpus();
   450	}
   451	
   452	static char throttle_reason[][30] = {

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
index 547890f..50a5b21 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -423,18 +423,19 @@  void powernv_cpufreq_work_fn(struct work_struct *work)
 {
 	struct chip *chip = container_of(work, struct chip, throttle);
 	unsigned int cpu;
-	cpumask_var_t mask;
+	cpumask_t mask;
 
-	smp_call_function_any(&chip->mask,
+	get_online_cpus();
+	cpumask_and(&mask, &chip->mask, cpu_online_mask);
+	smp_call_function_any(&mask,
 			      powernv_cpufreq_throttle_check, NULL, 0);
 
 	if (!chip->restore)
-		return;
+		goto out;
 
 	chip->restore = false;
-	cpumask_copy(mask, &chip->mask);
-	for_each_cpu_and(cpu, mask, cpu_online_mask) {
-		int index, tcpu;
+	for_each_cpu(cpu, &mask) {
+		int index;
 		struct cpufreq_policy policy;
 
 		cpufreq_get_policy(&policy, cpu);
@@ -442,9 +443,10 @@  void powernv_cpufreq_work_fn(struct work_struct *work)
 					       policy.cur,
 					       CPUFREQ_RELATION_C, &index);
 		powernv_cpufreq_target_index(&policy, index);
-		for_each_cpu(tcpu, policy.cpus)
-			cpumask_clear_cpu(tcpu, mask);
+		cpumask_andnot(&mask, &mask, policy.cpus);
 	}
+out:
+	put_online_cpus();
 }
 
 static char throttle_reason[][30] = {