diff options
author | Oleg Nesterov <oleg@redhat.com> | 2013-06-20 11:50:13 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2013-06-20 11:58:55 -0400 |
commit | 7ab71f3244e9f970c29566c5a67e13d1fa38c387 (patch) | |
tree | a6bbb7e9893dc54edcf445c5a2fc75d5e27b2550 /kernel/events | |
parent | e1ebe86203e6532eb5a0ae8f26ccae47aca548ae (diff) |
hw_breakpoint: Simplify the "weight" usage in toggle_bp_slot() paths
Change toggle_bp_slot() to make "weight" negative if !enable.
This way we can always use "+ weight" without additional "if
(enable)" check and toggle_bp_task_slot() no longer needs this
arg.
Reported-by: Vince Weaver <vincent.weaver@maine.edu>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/r/20130620155013.GA6337@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/events')
-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) |