perf/core: fix unlock balance in perf_init_event
PATCH 1/1 perf/core: fix unlock balance in perf_init_event
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/[email protected]/
--- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/core.c +1 -1
@@ -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) {
Signature · 1 line
2.21.0 (Apple Git-122)
Peter Zijlstra
maintainerQuoted 22 lines · Qian Cai
The -next commit "perf/core: Optimize
perf_init_event()" [1] introduced an unlock imbalance inperf_init_event()where it calls "goto again" and then only repeatrcu_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
Quoted 1 line
You wanted to write:
instead, right? Fixed that for you.
Quoted 28 lines
Signed-off-by Qian Cai <[email protected]>--- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/events/core.c +1
-1@@ -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) {Signature · 1 line
2.21.0 (Apple Git-122)
Quoted 9 lines · Peter Zijlstra
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.
Peter Zijlstra
maintainerQuoted 6 lines · Qian Cai
Quoted 6 lines · Peter Zijlstra
You wanted to write:
Quoted 7 lines
Quoted 3 lines
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.
[tip: perf/core] perf/core: Fix unlock balance in perf_init_event()
In reply to Qian CaiThe following commit has been merged into the perf/core branch of tip:
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 <[email protected]> AuthorDate: Wed, 06 Nov 2019 00:29:35 -05:00 Committer: Ingo Molnar <[email protected]> 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().
--- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/core.c +1 -1
@@ -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) {