From: Xiaotian Feng <xtfeng@gmail.com>
To: Amerigo Wang <amwang@redhat.com>
Cc: linux-kernel@vger.kernel.org,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Dave Jones <davej@redhat.com>,
cpufreq@vger.kernel.org, Prarit Bhargava <prarit@redhat.com>,
Thomas Renninger <trenn@suse.de>,
akpm@linux-foundation.org,
Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Subject: Re: [Patch] cpufreq: fix a deadlock during shutting down
Date: Tue, 9 Feb 2010 17:23:11 +0800 [thread overview]
Message-ID: <7b6bb4a51002090123v2bdf1582ua0b78bc99dceeb81@mail.gmail.com> (raw)
In-Reply-To: <20100209091408.29971.63921.sendpatchset@localhost.localdomain>
On Tue, Feb 9, 2010 at 5:10 PM, Amerigo Wang <amwang@redhat.com> wrote:
>
> Benjamin reported that, the machine deadlocks right after printing the
> following when doing a shutdown:
>
> halt/4071 is trying to acquire lock:
> (s_active){++++.+}, at: [<c0000000001ef868>] .sysfs_addrm_finish+0x58/0xc0
>
> but task is already holding lock:
> (&per_cpu(cpu_policy_rwsem, cpu)){+.+.+.}, at: [<c0000000004cd6ac>] .lock_policy_rwsem_write+0x84/0xf4
>
> which lock already depends on the new lock.
>
> the existing dependency chain (in reverse order) is:
>
> <nothing else ... machine deadlocked here>
>
>
> This is because we are trying to kobject_put() a kobject while
> we are holding cpu policy rwsem. So just move kobject_put()
> down after releasing the rwsem.
>
> Totally untested.
>
> Reported-by: Xiaotian Feng <xtfeng@gmail.com>
> Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Signed-off-by: WANG Cong <amwang@redhat.com>
> Cc: Dave Jones <davej@redhat.com>
> Cc: Thomas Renninger <trenn@suse.de>
> Cc: Prarit Bhargava <prarit@redhat.com>
> Cc: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
>
> ---
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 67bc2ec..222b35f 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1113,6 +1113,7 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
> unsigned int cpu = sys_dev->id;
> unsigned long flags;
> struct cpufreq_policy *data;
> + struct kobject *kobj;
> #ifdef CONFIG_SMP
> struct sys_device *cpu_sys_dev;
> unsigned int j;
> @@ -1192,7 +1193,7 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
> if (cpufreq_driver->target)
> __cpufreq_governor(data, CPUFREQ_GOV_STOP);
>
> - kobject_put(&data->kobj);
> + kobj = &data->kobj;
>
> /* we need to make sure that the underlying kobj is actually
> * not referenced anymore by anybody before we proceed with
Then kernel will wait_for_completion(&data->kobj_unregister); forever.....
> @@ -1207,6 +1208,7 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
>
> unlock_policy_rwsem_write(cpu);
>
> + kobject_put(kobj);
> free_cpumask_var(data->related_cpus);
> free_cpumask_var(data->cpus);
> kfree(data);
>
prev parent reply other threads:[~2010-02-09 9:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-09 9:10 Amerigo Wang
2010-02-09 9:22 ` David Rientjes
2010-02-10 6:56 ` Cong Wang
2010-02-09 9:23 ` Xiaotian Feng [this message]
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=7b6bb4a51002090123v2bdf1582ua0b78bc99dceeb81@mail.gmail.com \
--to=xtfeng@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=amwang@redhat.com \
--cc=benh@kernel.crashing.org \
--cc=cpufreq@vger.kernel.org \
--cc=davej@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=prarit@redhat.com \
--cc=trenn@suse.de \
--cc=venkatesh.pallipadi@intel.com \
/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
all inboxes | Powered by JetHome®