From: Tejun Heo <tj@kernel.org>
To: Andreas Herrmann <andreas.herrmann3@amd.com>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>,
linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] cpufreq, powernow-k8: Fix usage of smp_processor_id() in preemptible code
Date: Wed, 10 Oct 2012 09:18:42 +0900 [thread overview]
Message-ID: <20121010001842.GA27553@localhost> (raw)
In-Reply-To: <20121009193844.GC7724@alberich>
Hello,
On Tue, Oct 09, 2012 at 09:38:44PM +0200, Andreas Herrmann wrote:
>
> Commit 6889125b8b4e09c5e53e6ecab3433bed1ce198c9
> (cpufreq/powernow-k8: workqueue user shouldn't migrate the kworker to another CPU)
> causes powernow-k8 to trigger a preempt warning, e.g.:
>
> BUG: using smp_processor_id() in preemptible [00000000] code: cpufreq/3776
> caller is powernowk8_target+0x20/0x49
> Pid: 3776, comm: cpufreq Not tainted 3.6.0 #9
> Call Trace:
> [<ffffffff8125b447>] debug_smp_processor_id+0xc7/0xe0
> [<ffffffff814877e7>] powernowk8_target+0x20/0x49
> [<ffffffff81482b02>] __cpufreq_driver_target+0x82/0x8a
> [<ffffffff81484fc6>] cpufreq_governor_performance+0x4e/0x54
> [<ffffffff81482c50>] __cpufreq_governor+0x8c/0xc9
> [<ffffffff81482e6f>] __cpufreq_set_policy+0x1a9/0x21e
> [<ffffffff814839af>] store_scaling_governor+0x16f/0x19b
> [<ffffffff81484f16>] ? cpufreq_update_policy+0x124/0x124
> [<ffffffff8162b4a5>] ? _raw_spin_unlock_irqrestore+0x2c/0x49
> [<ffffffff81483640>] store+0x60/0x88
> [<ffffffff811708c0>] sysfs_write_file+0xf4/0x130
> [<ffffffff8111243b>] vfs_write+0xb5/0x151
> [<ffffffff811126e0>] sys_write+0x4a/0x71
> [<ffffffff816319a9>] system_call_fastpath+0x16/0x1b
...
> - /*
> - * Must run on @pol->cpu. cpufreq core is responsible for ensuring
> - * that we're bound to the current CPU and pol->cpu stays online.
> - */
Urgh... so this wasn't true? Well, the perils of the last minute
changes.
> - if (smp_processor_id() == pol->cpu)
> - return powernowk8_target_fn(&pta);
> - else
> - return work_on_cpu(pol->cpu, powernowk8_target_fn, &pta);
> + this_cpu = get_cpu();
> + if (this_cpu == pol->cpu) {
> + ret = powernowk8_target_fn(&pta);
> + put_cpu();
> + } else {
> + put_cpu();
> + ret = work_on_cpu(pol->cpu, powernowk8_target_fn, &pta);
> + }
> +
> + return ret;
Looking at the code, yes, I think the above is correct. Rafael, can
you please confirm?
Thanks.
--
tejun
next prev parent reply other threads:[~2012-10-10 0:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-09 19:38 [PATCH] cpufreq, powernow-k8: Fix usage of smp_processor_id() in preemptible code Andreas Herrmann
2012-10-10 0:18 ` Tejun Heo [this message]
2012-10-10 12:48 ` Andreas Herrmann
2012-10-10 12:51 ` Tejun Heo
2012-10-12 15:18 ` [PATCH] cpufreq, powernow-k8: Remove " Andreas Herrmann
2012-10-14 8:27 ` Rafael J. Wysocki
2012-10-14 15:40 ` Borislav Petkov
2012-10-15 5:50 ` Rafael J. Wysocki
2012-10-15 8:40 ` Borislav Petkov
2012-10-15 17:56 ` Rafael J. Wysocki
2012-10-24 21:57 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121010001842.GA27553@localhost \
--to=tj@kernel.org \
--cc=andreas.herrmann3@amd.com \
--cc=cpufreq@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rjw@sisk.pl \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).