From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Boyd Subject: [PATCH] cpufreq: Don't use smp_processor_id() in preemptible context Date: Tue, 27 Aug 2013 15:01:24 -0700 Message-ID: <1377640884-16827-1-git-send-email-sboyd@codeaurora.org> References: <1377629249-1177-1-git-send-email-sboyd@codeaurora.org> Return-path: Received: from smtp.codeaurora.org ([198.145.11.231]:43023 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753261Ab3H0WB2 (ORCPT ); Tue, 27 Aug 2013 18:01:28 -0400 In-Reply-To: <1377629249-1177-1-git-send-email-sboyd@codeaurora.org> Sender: linux-pm-owner@vger.kernel.org List-Id: linux-pm@vger.kernel.org To: Viresh Kumar Cc: linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, "Rafael J . Wysocki" Workqueues are preemptible even if works are queued on them with queue_work_on(). Let's just use the policy->cpu argument here instead of using smp_processor_id() to silence the warning. BUG: using smp_processor_id() in preemptible [00000000] code: kworker/3:2/674 caller is gov_queue_work+0x28/0xb0 CPU: 0 PID: 674 Comm: kworker/3:2 Tainted: G W 3.10.0 #30 Workqueue: events od_dbs_timer [] (unwind_backtrace+0x0/0x11c) from [] (show_stack+0x10/0x14) [] (show_stack+0x10/0x14) from [] (debug_smp_processor_id+0xbc/0xf0) [] (debug_smp_processor_id+0xbc/0xf0) from [] (gov_queue_work+0x28/0xb0) [] (gov_queue_work+0x28/0xb0) from [] (od_dbs_timer+0x108/0x134) [] (od_dbs_timer+0x108/0x134) from [] (process_one_work+0x25c/0x444) [] (process_one_work+0x25c/0x444) from [] (worker_thread+0x200/0x344) [] (worker_thread+0x200/0x344) from [] (kthread+0xa0/0xb0) [] (kthread+0xa0/0xb0) from [] (ret_from_fork+0x14/0x3c) Signed-off-by: Stephen Boyd --- Also found this one. I'm tracking down a pretty bad hotplug/sysfs race on 3.10. I've applied all the stable patches but I'm seeing this still. I'll start another thread on this WARNING: at kernel/mutex.c:341 __mutex_lock_slowpath+0x14c/0x410() DEBUG_LOCKS_WARN_ON(l->magic != l) Modules linked in: CPU: 0 PID: 1960 Comm: sh Tainted: G W 3.10.0 #32 [] (unwind_backtrace+0x0/0x11c) from [] (show_stack+0x10/0x14) [] (show_stack+0x10/0x14) from [] (warn_slowpath_common+0x4c/0x6c) [] (warn_slowpath_common+0x4c/0x6c) from [] (warn_slowpath_fmt+0x2c/0x3c) [] (warn_slowpath_fmt+0x2c/0x3c) from [] (__mutex_lock_slowpath+0x14c/0x410) [] (__mutex_lock_slowpath+0x14c/0x410) from [] (mutex_lock+0x20/0x3c) [] (mutex_lock+0x20/0x3c) from [] (cpufreq_governor_dbs+0x568/0x5f8) [] (cpufreq_governor_dbs+0x568/0x5f8) from [] (__cpufreq_governor+0xdc/0x1a4) [] (__cpufreq_governor+0xdc/0x1a4) from [] (__cpufreq_set_policy+0x278/0x2c0) [] (__cpufreq_set_policy+0x278/0x2c0) from [] (store_scaling_min_freq+0x80/0x9c) [] (store_scaling_min_freq+0x80/0x9c) from [] (store+0x58/0x90) [] (store+0x58/0x90) from [] (sysfs_write_file+0x100/0x148) [] (sysfs_write_file+0x100/0x148) from [] (vfs_write+0xcc/0x174) [] (vfs_write+0xcc/0x174) from [] (SyS_write+0x38/0x64) [] (SyS_write+0x38/0x64) from [] (ret_fast_syscall+0x0/0x30) drivers/cpufreq/cpufreq_governor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index b9b20fd..523af48 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -137,7 +137,7 @@ void gov_queue_work(struct dbs_data *dbs_data, struct cpufreq_policy *policy, return; if (!all_cpus) { - __gov_queue_work(smp_processor_id(), dbs_data, delay); + __gov_queue_work(policy->cpu, dbs_data, delay); } else { for_each_cpu(i, policy->cpus) __gov_queue_work(i, dbs_data, delay); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation