From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>,
Michael Wang <wangyun@linux.vnet.ibm.com>,
Jiri Kosina <jkosina@suse.cz>, Borislav Petkov <bp@alien8.de>,
"Rafael J. Wysocki" <rjw@sisk.pl>,
linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org,
linux-pm@vger.kernel.org
Subject: Re: [RFC PATCH] cpu hotplug: rework cpu_hotplug locking (was [LOCKDEP] cpufreq: possible circular locking dependency detected)
Date: Fri, 28 Jun 2013 15:01:34 +0530 [thread overview]
Message-ID: <51CD57F6.9050906@linux.vnet.ibm.com> (raw)
In-Reply-To: <20130628074403.GA2201@swordfish>
On 06/28/2013 01:14 PM, Sergey Senozhatsky wrote:
> On (06/28/13 10:13), Viresh Kumar wrote:
>> On 26 June 2013 02:45, Sergey Senozhatsky <sergey.senozhatsky@gmail.com> wrote:
>>>
>>> [ 60.277396] ======================================================
>>> [ 60.277400] [ INFO: possible circular locking dependency detected ]
>>> [ 60.277407] 3.10.0-rc7-dbg-01385-g241fd04-dirty #1744 Not tainted
>>> [ 60.277411] -------------------------------------------------------
>>> [ 60.277417] bash/2225 is trying to acquire lock:
>>> [ 60.277422] ((&(&j_cdbs->work)->work)){+.+...}, at: [<ffffffff810621b5>] flush_work+0x5/0x280
>>> [ 60.277444]
>>> but task is already holding lock:
>>> [ 60.277449] (cpu_hotplug.lock){+.+.+.}, at: [<ffffffff81042d8b>] cpu_hotplug_begin+0x2b/0x60
>>> [ 60.277465]
>>> which lock already depends on the new lock.
>>
>> Hi Sergey,
>>
>> Can you try reverting this patch?
>>
>> commit 2f7021a815f20f3481c10884fe9735ce2a56db35
>> Author: Michael Wang <wangyun@linux.vnet.ibm.com>
>> Date: Wed Jun 5 08:49:37 2013 +0000
>>
>> cpufreq: protect 'policy->cpus' from offlining during __gov_queue_work()
>>
>
> Hello,
> Yes, this helps, of course, but at the same time it returns the previous
> problem -- preventing cpu_hotplug in some places.
>
>
> I have a bit different (perhaps naive) RFC patch and would like to hear
> comments.
>
>
>
> The idead is to brake existing lock dependency chain by not holding
> cpu_hotplug lock mutex across the calls. In order to detect active
> refcount readers or active writer, refcount now may have the following
> values:
>
> -1: active writer -- only one writer may be active, readers are blocked
> 0: no readers/writer
>> 0: active readers -- many readers may be active, writer is blocked
>
> "blocked" reader or writer goes to wait_queue. as soon as writer finishes
> (refcount becomes 0), it wakeups all existing processes in a wait_queue.
> reader perform wakeup call only when it sees that pending writer is present
> (active_writer is not NULL).
>
> cpu_hotplug lock now only required to protect refcount cmp, inc, dec
> operations so it can be changed to spinlock.
>
Its best to avoid changing the core infrastructure in order to fix some
call-site, unless that scenario is really impossible to handle with the
current infrastructure.
I have a couple of suggestions below, to solve this issue, without touching
the core hotplug code:
You can perhaps try cancelling the work item in two steps:
a. using cancel_delayed_work() under CPU_DOWN_PREPARE
b. using cancel_delayed_work_sync() under CPU_POST_DEAD
And of course, destroy the resources associated with that work (like
the timer_mutex) only after the full tear-down.
Or perhaps you might find a way to perform the tear-down in just one step
at the CPU_POST_DEAD stage. Whatever works correctly.
The key point here is that the core CPU hotplug code provides us with the
CPU_POST_DEAD stage, where the hotplug lock is _not_ held. Which is exactly
what you want in solving the issue with cpufreq.
Regards,
Srivatsa S. Bhat
next prev parent reply other threads:[~2013-06-28 9:31 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-25 21:15 [LOCKDEP] cpufreq: possible circular locking dependency detected Sergey Senozhatsky
2013-06-28 4:43 ` Viresh Kumar
2013-06-28 7:44 ` [RFC PATCH] cpu hotplug: rework cpu_hotplug locking (was [LOCKDEP] cpufreq: possible circular locking dependency detected) Sergey Senozhatsky
2013-06-28 9:31 ` Srivatsa S. Bhat [this message]
2013-06-28 10:04 ` Sergey Senozhatsky
2013-06-28 14:13 ` Srivatsa S. Bhat
2013-06-29 7:35 ` Sergey Senozhatsky
2013-07-01 4:42 ` [LOCKDEP] cpufreq: possible circular locking dependency detected Michael Wang
2013-07-10 23:13 ` Sergey Senozhatsky
2013-07-11 2:43 ` Michael Wang
2013-07-11 8:22 ` Sergey Senozhatsky
2013-07-11 8:47 ` Michael Wang
2013-07-11 8:48 ` Michael Wang
2013-07-11 11:47 ` Bartlomiej Zolnierkiewicz
2013-07-12 2:19 ` Michael Wang
2013-07-11 9:01 ` Sergey Senozhatsky
2013-07-14 11:47 ` Sergey Senozhatsky
2013-07-14 12:06 ` Sergey Senozhatsky
2013-07-15 3:50 ` Michael Wang
2013-07-15 7:52 ` Michael Wang
2013-07-15 8:29 ` Sergey Senozhatsky
2013-07-15 13:19 ` Srivatsa S. Bhat
2013-07-15 13:32 ` Srivatsa S. Bhat
2013-07-15 20:49 ` Peter Wu
2013-07-16 8:29 ` Srivatsa S. Bhat
2013-07-15 23:20 ` Sergey Senozhatsky
2013-07-16 8:33 ` Srivatsa S. Bhat
2013-07-16 10:44 ` Sergey Senozhatsky
2013-07-16 15:19 ` Srivatsa S. Bhat
2013-07-16 21:29 ` Rafael J. Wysocki
2013-07-16 2:19 ` Michael Wang
2013-07-15 2:42 ` Michael Wang
2013-07-14 15:56 ` Rafael J. Wysocki
2013-07-15 2:46 ` Michael Wang
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=51CD57F6.9050906@linux.vnet.ibm.com \
--to=srivatsa.bhat@linux.vnet.ibm.com \
--cc=bp@alien8.de \
--cc=cpufreq@vger.kernel.org \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@sisk.pl \
--cc=sergey.senozhatsky@gmail.com \
--cc=viresh.kumar@linaro.org \
--cc=wangyun@linux.vnet.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.