From: Peter Zijlstra <peterz@infradead.org>
To: Qian Cai <cai@lca.pw>
Cc: mingo@redhat.com, andi@firstfloor.org, acme@kernel.org,
mark.rutland@arm.com, jolsa@redhat.com, namhyung@kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH -next] perf/core: fix unlock balance in perf_init_event
Date: Wed, 6 Nov 2019 10:23:52 +0100 [thread overview]
Message-ID: <20191106092352.GU4131@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20191106052935.8352-1-cai@lca.pw>
On Wed, Nov 06, 2019 at 12:29:35AM -0500, Qian Cai wrote:
> The -next commit "perf/core: Optimize perf_init_event()" [1] introduced
> an unlock imbalance in perf_init_event() where it calls "goto again" and
> then only repeat rcu_read_unlock().
>
> WARNING: bad unlock balance detected!
> perf_event_open/6185 is trying to release lock (rcu_read_lock) at:
> [<ffffffffb5eb4039>] perf_event_alloc+0xbb9/0x17f0
> but there are no more locks to release!
> other info that might help us debug this:
> 2 locks held by perf_event_open/6185:
> #0: ffff888526780b50 (&sig->cred_guard_mutex){+.+.}, at: __do_sys_perf_event_open+0x6ee/0x1460
> #1: ffffffffb866b4e8 (&pmus_srcu){....}, at: perf_event_alloc+0xab8/0x17f0
> Call Trace:
> dump_stack+0xa0/0xea
> print_unlock_imbalance_bug.cold.40+0xb1/0xb6
> lock_release+0x349/0x4b0
> perf_event_alloc+0xbcf/0x17f0
> __do_sys_perf_event_open+0x1e2/0x1460
> __x64_sys_perf_event_open+0x62/0x70
> do_syscall_64+0xcc/0xaec
> entry_SYSCALL_64_after_hwframe+0x49/0xbe
>
> [1] https://lore.kernel.org/lkml/20191022092307.425783389@infradead.org/
You wanted to write:
Fixes: 66d258c5b048 ("perf/core: Optimize perf_init_event()")
instead, right? Fixed that for you.
> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
> kernel/events/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index cfd89b4a02d8..8226d6ecdb86 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -10307,7 +10307,6 @@ static struct pmu *perf_init_event(struct perf_event *event)
> goto unlock;
> }
>
> - rcu_read_lock();
> /*
> * PERF_TYPE_HARDWARE and PERF_TYPE_HW_CACHE
> * are often aliases for PERF_TYPE_RAW.
> @@ -10317,6 +10316,7 @@ static struct pmu *perf_init_event(struct perf_event *event)
> type = PERF_TYPE_RAW;
>
> again:
> + rcu_read_lock();
> pmu = idr_find(&pmu_idr, type);
> rcu_read_unlock();
> if (pmu) {
> --
> 2.21.0 (Apple Git-122)
>
next prev parent reply other threads:[~2019-11-06 9:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-06 5:29 Qian Cai
2019-11-06 9:23 ` Peter Zijlstra [this message]
2019-11-06 10:37 ` Qian Cai
2019-11-06 11:06 ` Peter Zijlstra
2019-11-13 10:56 ` [tip: perf/core] perf/core: Fix unlock balance in perf_init_event() tip-bot2 for Qian Cai
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=20191106092352.GU4131@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=andi@firstfloor.org \
--cc=cai@lca.pw \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@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
all inboxes | Powered by JetHome®