From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Jacob Pan <jacob.jun.pan@linux.intel.com>,
LKML <linux-kernel@vger.kernel.org>, Borislav Petkov <bp@suse.de>,
Ingo Molnar <mingo@kernel.org>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
"ego@linux.vnet.ibm.com" <ego@linux.vnet.ibm.com>,
Oleg Nesterov <oleg@redhat.com>
Subject: Re: [PATCH] intel_rapl: Correct hotplug correction
Date: Fri, 23 May 2014 03:01:11 +0530 [thread overview]
Message-ID: <537E6C9F.5060406@linux.vnet.ibm.com> (raw)
In-Reply-To: <20140522123251.GU30445@twins.programming.kicks-ass.net>
On 05/22/2014 06:02 PM, Peter Zijlstra wrote:
> On Thu, May 22, 2014 at 05:24:33PM +0530, Srivatsa S. Bhat wrote:
>> Yeah, its complicated and perhaps we can do much better than that. But I'll
>> try to explain why there are so many different locks in the existing code.
>>
[...]
>
> So I think we can reduce it to just the one rwsem (with recursion) if we
> shoot CPU_POST_DEAD in the head.
>
Ok, I'll take a look at the cpufreq core and see how we can get rid of the
POST_DEAD case there. I myself had added that (sorry!) to solve a complicated
deadlock involving a race between CPU offline and a task writing to one of
the cpufreq sysfs files. The sysfs writer task would increment the kobject
refcount and call get_online_cpus(), whereas the CPU offline task would wait
for the kobj refcount to drop to zero, while still holding the hotplug lock.
Thus the 2 tasks would end up waiting on each other indefinitely.
So using POST_DEAD had enabled us to wait for the refcount to drop to zero
without holding the hotplug lock, which allowed the sysfs writer to get
past get_online_cpus(), finish its job and finally drop the refcount.
Anyway, I'll take a fresh look to see if we can overcome that problem in
some other way.
> Because currently we cannot take the rwsem in exclusive mode over the
> whole thing because of POST_DEAD.
>
> Once we kill that, the hotplug lock's exclusive mode can cover the
> entire hotplug operation.
>
> For (un)registrer we can also use the exclusive lock, (un)register of
> notifiers should not happen often and should equally not be performance
> critical, so using the exclusive lock should be just fine.
>
> That means we can then remove cpu_add_remove_lock from both the register
> and hotplug ops proper. (un)register_cpu_notifier() should get an
> assertion that we hold the hotplug lock in exclusive mode.
>
> That leaves the non-exclusive lock to guard against hotplug happening.
>
> Now, last time Linus said he would like that to be a non-lock, and have
> it weakly serialized, RCU style. Not sure we can fully pull that off,
> haven't throught that through yet.
Thank you for explanation!
>
>> I think Oleg had a proposed patch to use per-cpu rwsem in CPU hotplug to
>> drastically simplify this whole locking scheme. I think we could look at
>> that again.
>
> I don't think that was to simplify things, the hotplug lock is basically
> an open coded rw lock already, so that was to make it reuse the per-cpu
> rwsem code.
>
Ah, ok!
Regards,
Srivatsa S. Bhat
prev parent reply other threads:[~2014-05-22 21:32 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-22 9:23 [PATCH] intel_rapl: Correct hotplug correction Borislav Petkov
2014-05-22 9:43 ` Srivatsa S. Bhat
2014-05-22 10:08 ` Borislav Petkov
2014-05-22 11:54 ` Srivatsa S. Bhat
2014-05-22 12:13 ` Borislav Petkov
2014-05-22 12:32 ` Peter Zijlstra
2014-05-22 15:30 ` [PATCH] x86, MCE: Kill CPU_POST_DEAD Borislav Petkov
2014-05-22 15:50 ` Luck, Tony
2014-05-22 19:55 ` Borislav Petkov
2014-05-22 21:13 ` Srivatsa S. Bhat
2014-05-22 21:31 ` Borislav Petkov
2014-05-22 21:40 ` Srivatsa S. Bhat
2014-05-22 21:43 ` Srivatsa S. Bhat
2014-05-26 20:01 ` Borislav Petkov
2014-05-22 21:31 ` Srivatsa S. Bhat [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=537E6C9F.5060406@linux.vnet.ibm.com \
--to=srivatsa.bhat@linux.vnet.ibm.com \
--cc=bp@alien8.de \
--cc=bp@suse.de \
--cc=ego@linux.vnet.ibm.com \
--cc=jacob.jun.pan@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rafael.j.wysocki@intel.com \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=tglx@linutronix.de \
/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