linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: linux-kernel@vger.kernel.org, tglx@linutronix.de, hpa@zytor.com,
	torvalds@linux-foundation.org, mingo@kernel.org
Cc: linux-tip-commits@vger.kernel.org
Subject: Re: [tip:locking/core] jump_label/lockdep: Assert we hold the hotplug lock for _cpuslocked() operations
Date: Tue, 11 Sep 2018 11:51:27 +0200	[thread overview]
Message-ID: <20180911095127.GT24082@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <tip-cb538267ea1e9e025ec692577c9ae75797261889@git.kernel.org>

On Mon, Sep 10, 2018 at 03:09:29AM -0700, tip-bot for Peter Zijlstra wrote:
> Commit-ID:  cb538267ea1e9e025ec692577c9ae75797261889
> Gitweb:     https://git.kernel.org/tip/cb538267ea1e9e025ec692577c9ae75797261889
> Author:     Peter Zijlstra <peterz@infradead.org>
> AuthorDate: Tue, 31 Jul 2018 14:35:32 +0200
> Committer:  Ingo Molnar <mingo@kernel.org>
> CommitDate: Mon, 10 Sep 2018 10:16:38 +0200
> 
> jump_label/lockdep: Assert we hold the hotplug lock for _cpuslocked() operations
> 
> Weirdly we seem to have forgotten this...

This of course instantly triggered a false positive :/

---
Subject: lockdep,cpu/hotplug: Annotate AP thread

Anybody trying to assert the cpu_hotplug_lock is held
(lockdep_assert_cpus_held()) from AP callbacks will fail, because the
lock is held by the BP.

Stick in an explicit annotation in cpuhp_thread_fun() to make this work.

Fixes: cb538267ea1e ("jump_label/lockdep: Assert we hold the hotplug lock for _cpuslocked() operations")
Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 kernel/cpu.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index 0097acec1c71..08c168b159da 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -616,6 +616,12 @@ static void cpuhp_thread_fun(unsigned int cpu)
 	 */
 	smp_mb();
 
+	/*
+	 * The BP holds the hotplug lock, but we're now running on the AP,
+	 * ensure that anybody asserting the lock is held, will actually find
+	 * it so.
+	 */
+	rwsem_acquire(&cpu_hotplug_lock.rw_sem.dep_map, 0, 0, _THIS_IP_);
 	cpuhp_lock_acquire(bringup);
 
 	if (st->single) {
@@ -661,6 +667,7 @@ static void cpuhp_thread_fun(unsigned int cpu)
 	}
 
 	cpuhp_lock_release(bringup);
+	rwsem_release(&cpu_hotplug_lock.rw_sem.dep_map, 1, _THIS_IP_);
 
 	if (!st->should_run)
 		complete_ap_thread(st, bringup);

       reply	other threads:[~2018-09-11  9:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <tip-cb538267ea1e9e025ec692577c9ae75797261889@git.kernel.org>
2018-09-11  9:51 ` Peter Zijlstra [this message]
2018-09-11 15:33   ` [tip:locking/core] locking/lockdep, cpu/hotplug: Annotate AP thread tip-bot for Peter Zijlstra
2018-09-11 18:03   ` tip-bot for Peter Zijlstra

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=20180911095127.GT24082@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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).