Commit 7ab71f32 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Ingo Molnar

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: default avatarVince Weaver <vincent.weaver@maine.edu>
Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Acked-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/r/20130620155013.GA6337@redhat.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent e1ebe862
...@@ -182,7 +182,7 @@ fetch_this_slot(struct bp_busy_slots *slots, int weight) ...@@ -182,7 +182,7 @@ fetch_this_slot(struct bp_busy_slots *slots, int weight)
/* /*
* Add a pinned breakpoint for the given task in our constraint table * Add a pinned breakpoint for the given task in our constraint table
*/ */
static void toggle_bp_task_slot(struct perf_event *bp, int cpu, bool enable, static void toggle_bp_task_slot(struct perf_event *bp, int cpu,
enum bp_type_idx type, int weight) enum bp_type_idx type, int weight)
{ {
/* tsk_pinned[n-1] is the number of tasks having n>0 breakpoints */ /* 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,10 +190,7 @@ static void toggle_bp_task_slot(struct perf_event *bp, int cpu, bool enable,
int old_idx, new_idx; int old_idx, new_idx;
old_idx = task_bp_pinned(cpu, bp, type) - 1; old_idx = task_bp_pinned(cpu, bp, type) - 1;
if (enable) new_idx = old_idx + weight;
new_idx = old_idx + weight;
else
new_idx = old_idx - weight;
if (old_idx >= 0) if (old_idx >= 0)
tsk_pinned[old_idx]--; tsk_pinned[old_idx]--;
...@@ -211,22 +208,21 @@ toggle_bp_slot(struct perf_event *bp, bool enable, enum bp_type_idx type, ...@@ -211,22 +208,21 @@ toggle_bp_slot(struct perf_event *bp, bool enable, enum bp_type_idx type,
int cpu = bp->cpu; int cpu = bp->cpu;
struct task_struct *tsk = bp->hw.bp_target; struct task_struct *tsk = bp->hw.bp_target;
if (!enable)
weight = -weight;
/* Pinned counter cpu profiling */ /* Pinned counter cpu profiling */
if (!tsk) { if (!tsk) {
per_cpu(nr_cpu_bp_pinned[type], cpu) += weight;
if (enable)
per_cpu(nr_cpu_bp_pinned[type], bp->cpu) += weight;
else
per_cpu(nr_cpu_bp_pinned[type], bp->cpu) -= weight;
return; return;
} }
/* Pinned counter task profiling */ /* Pinned counter task profiling */
if (cpu >= 0) { if (cpu >= 0) {
toggle_bp_task_slot(bp, cpu, enable, type, weight); toggle_bp_task_slot(bp, cpu, type, weight);
} else { } else {
for_each_possible_cpu(cpu) for_each_possible_cpu(cpu)
toggle_bp_task_slot(bp, cpu, enable, type, weight); toggle_bp_task_slot(bp, cpu, type, weight);
} }
if (enable) if (enable)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment