diff options
-rw-r--r-- | kernel/events/hw_breakpoint.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c index dee0148dcf54..5cd4f6d9652c 100644 --- a/kernel/events/hw_breakpoint.c +++ b/kernel/events/hw_breakpoint.c | |||
@@ -182,7 +182,7 @@ fetch_this_slot(struct bp_busy_slots *slots, int weight) | |||
182 | /* | 182 | /* |
183 | * Add a pinned breakpoint for the given task in our constraint table | 183 | * Add a pinned breakpoint for the given task in our constraint table |
184 | */ | 184 | */ |
185 | static void toggle_bp_task_slot(struct perf_event *bp, int cpu, bool enable, | 185 | static void toggle_bp_task_slot(struct perf_event *bp, int cpu, |
186 | enum bp_type_idx type, int weight) | 186 | enum bp_type_idx type, int weight) |
187 | { | 187 | { |
188 | /* tsk_pinned[n-1] is the number of tasks having n>0 breakpoints */ | 188 | /* tsk_pinned[n-1] is the number of tasks having n>0 breakpoints */ |
@@ -190,10 +190,7 @@ static void toggle_bp_task_slot(struct perf_event *bp, int cpu, bool enable, | |||
190 | int old_idx, new_idx; | 190 | int old_idx, new_idx; |
191 | 191 | ||
192 | old_idx = task_bp_pinned(cpu, bp, type) - 1; | 192 | old_idx = task_bp_pinned(cpu, bp, type) - 1; |
193 | if (enable) | 193 | new_idx = old_idx + weight; |
194 | new_idx = old_idx + weight; | ||
195 | else | ||
196 | new_idx = old_idx - weight; | ||
197 | 194 | ||
198 | if (old_idx >= 0) | 195 | if (old_idx >= 0) |
199 | tsk_pinned[old_idx]--; | 196 | tsk_pinned[old_idx]--; |
@@ -211,22 +208,21 @@ toggle_bp_slot(struct perf_event *bp, bool enable, enum bp_type_idx type, | |||
211 | int cpu = bp->cpu; | 208 | int cpu = bp->cpu; |
212 | struct task_struct *tsk = bp->hw.bp_target; | 209 | struct task_struct *tsk = bp->hw.bp_target; |
213 | 210 | ||
211 | if (!enable) | ||
212 | weight = -weight; | ||
213 | |||
214 | /* Pinned counter cpu profiling */ | 214 | /* Pinned counter cpu profiling */ |
215 | if (!tsk) { | 215 | if (!tsk) { |
216 | 216 | per_cpu(nr_cpu_bp_pinned[type], cpu) += weight; | |
217 | if (enable) | ||
218 | per_cpu(nr_cpu_bp_pinned[type], bp->cpu) += weight; | ||
219 | else | ||
220 | per_cpu(nr_cpu_bp_pinned[type], bp->cpu) -= weight; | ||
221 | return; | 217 | return; |
222 | } | 218 | } |
223 | 219 | ||
224 | /* Pinned counter task profiling */ | 220 | /* Pinned counter task profiling */ |
225 | if (cpu >= 0) { | 221 | if (cpu >= 0) { |
226 | toggle_bp_task_slot(bp, cpu, enable, type, weight); | 222 | toggle_bp_task_slot(bp, cpu, type, weight); |
227 | } else { | 223 | } else { |
228 | for_each_possible_cpu(cpu) | 224 | for_each_possible_cpu(cpu) |
229 | toggle_bp_task_slot(bp, cpu, enable, type, weight); | 225 | toggle_bp_task_slot(bp, cpu, type, weight); |
230 | } | 226 | } |
231 | 227 | ||
232 | if (enable) | 228 | if (enable) |