Skip to content

Commit 0d85535

Browse files
mikeyIngo Molnar
authored andcommitted
perf, powerpc: Fix hw breakpoints returning -ENOSPC
I've been trying to get hardware breakpoints with perf to work on POWER7 but I'm getting the following: % perf record -e mem:0x10000000 true Error: sys_perf_event_open() syscall returned with 28 (No space left on device). /bin/dmesg may provide additional information. Fatal: No CONFIG_PERF_EVENTS=y kernel support configured? true: Terminated (FWIW adding -a and it works fine) Debugging it seems that __reserve_bp_slot() is returning ENOSPC because it thinks there are no free breakpoint slots on this CPU. I have a 2 CPUs, so perf userspace is doing two perf_event_open syscalls to add a counter to each CPU [1]. The first syscall succeeds but the second is failing. On this second syscall, fetch_bp_busy_slots() sets slots.pinned to be 1, despite there being no breakpoint on this CPU. This is because the call the task_bp_pinned, checks all CPUs, rather than just the current CPU. POWER7 only has one hardware breakpoint per CPU (ie. HBP_NUM=1), so we return ENOSPC. The following patch fixes this by checking the associated CPU for each breakpoint in task_bp_pinned. I'm not familiar with this code, so it's provided as a reference to the above issue. Signed-off-by: Michael Neuling <mikey@neuling.org> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Michael Ellerman <michael@ellerman.id.au> Cc: Jovi Zhang <bookjovi@gmail.com> Cc: K Prasad <prasad@linux.vnet.ibm.com> Link: http://lkml.kernel.org/r/1351268936-2956-1-git-send-email-fweisbec@gmail.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 35fd3dc commit 0d85535

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

kernel/events/hw_breakpoint.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,16 @@ static unsigned int max_task_bp_pinned(int cpu, enum bp_type_idx type)
111111
* Count the number of breakpoints of the same type and same task.
112112
* The given event must be not on the list.
113113
*/
114-
static int task_bp_pinned(struct perf_event *bp, enum bp_type_idx type)
114+
static int task_bp_pinned(int cpu, struct perf_event *bp, enum bp_type_idx type)
115115
{
116116
struct task_struct *tsk = bp->hw.bp_target;
117117
struct perf_event *iter;
118118
int count = 0;
119119

120120
list_for_each_entry(iter, &bp_task_head, hw.bp_list) {
121-
if (iter->hw.bp_target == tsk && find_slot_idx(iter) == type)
121+
if (iter->hw.bp_target == tsk &&
122+
find_slot_idx(iter) == type &&
123+
cpu == iter->cpu)
122124
count += hw_breakpoint_weight(iter);
123125
}
124126

@@ -141,7 +143,7 @@ fetch_bp_busy_slots(struct bp_busy_slots *slots, struct perf_event *bp,
141143
if (!tsk)
142144
slots->pinned += max_task_bp_pinned(cpu, type);
143145
else
144-
slots->pinned += task_bp_pinned(bp, type);
146+
slots->pinned += task_bp_pinned(cpu, bp, type);
145147
slots->flexible = per_cpu(nr_bp_flexible[type], cpu);
146148

147149
return;
@@ -154,7 +156,7 @@ fetch_bp_busy_slots(struct bp_busy_slots *slots, struct perf_event *bp,
154156
if (!tsk)
155157
nr += max_task_bp_pinned(cpu, type);
156158
else
157-
nr += task_bp_pinned(bp, type);
159+
nr += task_bp_pinned(cpu, bp, type);
158160

159161
if (nr > slots->pinned)
160162
slots->pinned = nr;
@@ -188,7 +190,7 @@ static void toggle_bp_task_slot(struct perf_event *bp, int cpu, bool enable,
188190
int old_idx = 0;
189191
int idx = 0;
190192

191-
old_count = task_bp_pinned(bp, type);
193+
old_count = task_bp_pinned(cpu, bp, type);
192194
old_idx = old_count - 1;
193195
idx = old_idx + weight;
194196

0 commit comments

Comments
 (0)