* [PATCH -next] perf/core: fix unlock balance in perf_init_event
@ 2019-11-06 5:29 Qian Cai
2019-11-06 9:23 ` Peter Zijlstra
2019-11-13 10:56 ` [tip: perf/core] perf/core: Fix unlock balance in perf_init_event() tip-bot2 for Qian Cai
0 siblings, 2 replies; 5+ messages in thread
From: Qian Cai @ 2019-11-06 5:29 UTC (permalink / raw)
To: mingo, peterz
Cc: andi, acme, mark.rutland, jolsa, namhyung, linux-kernel, Qian Cai
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/
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)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH -next] perf/core: fix unlock balance in perf_init_event
2019-11-06 5:29 [PATCH -next] perf/core: fix unlock balance in perf_init_event Qian Cai
@ 2019-11-06 9:23 ` Peter Zijlstra
2019-11-06 10:37 ` Qian Cai
2019-11-13 10:56 ` [tip: perf/core] perf/core: Fix unlock balance in perf_init_event() tip-bot2 for Qian Cai
1 sibling, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2019-11-06 9:23 UTC (permalink / raw)
To: Qian Cai; +Cc: mingo, andi, acme, mark.rutland, jolsa, namhyung, linux-kernel
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)
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH -next] perf/core: fix unlock balance in perf_init_event
2019-11-06 9:23 ` Peter Zijlstra
@ 2019-11-06 10:37 ` Qian Cai
2019-11-06 11:06 ` Peter Zijlstra
0 siblings, 1 reply; 5+ messages in thread
From: Qian Cai @ 2019-11-06 10:37 UTC (permalink / raw)
To: Peter Zijlstra
Cc: mingo, andi, acme, mark.rutland, jolsa, namhyung, linux-kernel
> On Nov 6, 2019, at 4:23 AM, Peter Zijlstra <peterz@infradead.org> wrote:
>
> You wanted to write:
>
> Fixes: 66d258c5b048 ("perf/core: Optimize perf_init_event()")
>
> instead, right? Fixed that for you.
I was not too sure about if the hashes are stable for commits only in the -tip tree. If they remain the same even after merged into the mainline, and then yes.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH -next] perf/core: fix unlock balance in perf_init_event
2019-11-06 10:37 ` Qian Cai
@ 2019-11-06 11:06 ` Peter Zijlstra
0 siblings, 0 replies; 5+ messages in thread
From: Peter Zijlstra @ 2019-11-06 11:06 UTC (permalink / raw)
To: Qian Cai; +Cc: mingo, andi, acme, mark.rutland, jolsa, namhyung, linux-kernel
On Wed, Nov 06, 2019 at 05:37:34AM -0500, Qian Cai wrote:
>
>
> > On Nov 6, 2019, at 4:23 AM, Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > You wanted to write:
> >
> > Fixes: 66d258c5b048 ("perf/core: Optimize perf_init_event()")
> >
> > instead, right? Fixed that for you.
>
> I was not too sure about if the hashes are stable for commits only in
> the -tip tree. If they remain the same even after merged into the
> mainline, and then yes.
-tip commits are generally stable.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip: perf/core] perf/core: Fix unlock balance in perf_init_event()
2019-11-06 5:29 [PATCH -next] perf/core: fix unlock balance in perf_init_event Qian Cai
2019-11-06 9:23 ` Peter Zijlstra
@ 2019-11-13 10:56 ` tip-bot2 for Qian Cai
1 sibling, 0 replies; 5+ messages in thread
From: tip-bot2 for Qian Cai @ 2019-11-13 10:56 UTC (permalink / raw)
To: linux-tip-commits
Cc: Qian Cai, Peter Zijlstra (Intel),
Alexander Shishkin, Arnaldo Carvalho de Melo, David Ahern,
Jiri Olsa, Linus Torvalds, Mark Rutland, Namhyung Kim,
Stephane Eranian, Thomas Gleixner, Vince Weaver, Ingo Molnar,
Borislav Petkov, linux-kernel
The following commit has been merged into the perf/core branch of tip:
Commit-ID: deb0c3c29d552ab81ecd5481bb83bf2f4e41927d
Gitweb: https://git.kernel.org/tip/deb0c3c29d552ab81ecd5481bb83bf2f4e41927d
Author: Qian Cai <cai@lca.pw>
AuthorDate: Wed, 06 Nov 2019 00:29:35 -05:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 13 Nov 2019 11:06:13 +01:00
perf/core: Fix unlock balance in perf_init_event()
Commit:
66d258c5b048 ("perf/core: Optimize perf_init_event()")
introduced an unlock imbalance in perf_init_event() where it calls
"goto again" and then only repeat rcu_read_unlock().
Signed-off-by: Qian Cai <cai@lca.pw>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Fixes: 66d258c5b048 ("perf/core: Optimize perf_init_event()")
Link: https://lkml.kernel.org/r/20191106052935.8352-1-cai@lca.pw
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
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 6cb6d68..8d65e03 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) {
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-11-13 10:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-06 5:29 [PATCH -next] perf/core: fix unlock balance in perf_init_event Qian Cai
2019-11-06 9:23 ` Peter Zijlstra
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
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).