hw_breakpoint: Pass bp_type argument to __reserve_bp_slot|__release_bp_slot()
Passing bp_type argument to __reserve_bp_slot() and __release_bp_slot() functions, so we can pass another bp_type than the one defined in bp->attr.bp_type. This will be handy in following change that fixes breakpoint slot counts during its modification. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Hari Bathini <hbathini@linux.vnet.ibm.com> Cc: Jin Yao <yao.jin@linux.intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Kan Liang <kan.liang@intel.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Milind Chabbi <chabbi.milind@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Oleg Nesterov <onestero@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Will Deacon <will.deacon@arm.com> Link: http://lkml.kernel.org/r/20180312134548.31532-3-jolsa@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
@ -277,7 +277,7 @@ __weak void arch_unregister_hw_breakpoint(struct perf_event *bp)
|
|||||||
* ((per_cpu(info->flexible, *) > 1) + max(per_cpu(info->cpu_pinned, *))
|
* ((per_cpu(info->flexible, *) > 1) + max(per_cpu(info->cpu_pinned, *))
|
||||||
* + max(per_cpu(info->tsk_pinned, *))) < HBP_NUM
|
* + max(per_cpu(info->tsk_pinned, *))) < HBP_NUM
|
||||||
*/
|
*/
|
||||||
static int __reserve_bp_slot(struct perf_event *bp)
|
static int __reserve_bp_slot(struct perf_event *bp, u64 bp_type)
|
||||||
{
|
{
|
||||||
struct bp_busy_slots slots = {0};
|
struct bp_busy_slots slots = {0};
|
||||||
enum bp_type_idx type;
|
enum bp_type_idx type;
|
||||||
@ -288,11 +288,11 @@ static int __reserve_bp_slot(struct perf_event *bp)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
/* Basic checks */
|
/* Basic checks */
|
||||||
if (bp->attr.bp_type == HW_BREAKPOINT_EMPTY ||
|
if (bp_type == HW_BREAKPOINT_EMPTY ||
|
||||||
bp->attr.bp_type == HW_BREAKPOINT_INVALID)
|
bp_type == HW_BREAKPOINT_INVALID)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
type = find_slot_idx(bp->attr.bp_type);
|
type = find_slot_idx(bp_type);
|
||||||
weight = hw_breakpoint_weight(bp);
|
weight = hw_breakpoint_weight(bp);
|
||||||
|
|
||||||
fetch_bp_busy_slots(&slots, bp, type);
|
fetch_bp_busy_slots(&slots, bp, type);
|
||||||
@ -317,19 +317,19 @@ int reserve_bp_slot(struct perf_event *bp)
|
|||||||
|
|
||||||
mutex_lock(&nr_bp_mutex);
|
mutex_lock(&nr_bp_mutex);
|
||||||
|
|
||||||
ret = __reserve_bp_slot(bp);
|
ret = __reserve_bp_slot(bp, bp->attr.bp_type);
|
||||||
|
|
||||||
mutex_unlock(&nr_bp_mutex);
|
mutex_unlock(&nr_bp_mutex);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __release_bp_slot(struct perf_event *bp)
|
static void __release_bp_slot(struct perf_event *bp, u64 bp_type)
|
||||||
{
|
{
|
||||||
enum bp_type_idx type;
|
enum bp_type_idx type;
|
||||||
int weight;
|
int weight;
|
||||||
|
|
||||||
type = find_slot_idx(bp->attr.bp_type);
|
type = find_slot_idx(bp_type);
|
||||||
weight = hw_breakpoint_weight(bp);
|
weight = hw_breakpoint_weight(bp);
|
||||||
toggle_bp_slot(bp, false, type, weight);
|
toggle_bp_slot(bp, false, type, weight);
|
||||||
}
|
}
|
||||||
@ -339,7 +339,7 @@ void release_bp_slot(struct perf_event *bp)
|
|||||||
mutex_lock(&nr_bp_mutex);
|
mutex_lock(&nr_bp_mutex);
|
||||||
|
|
||||||
arch_unregister_hw_breakpoint(bp);
|
arch_unregister_hw_breakpoint(bp);
|
||||||
__release_bp_slot(bp);
|
__release_bp_slot(bp, bp->attr.bp_type);
|
||||||
|
|
||||||
mutex_unlock(&nr_bp_mutex);
|
mutex_unlock(&nr_bp_mutex);
|
||||||
}
|
}
|
||||||
@ -354,7 +354,7 @@ int dbg_reserve_bp_slot(struct perf_event *bp)
|
|||||||
if (mutex_is_locked(&nr_bp_mutex))
|
if (mutex_is_locked(&nr_bp_mutex))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return __reserve_bp_slot(bp);
|
return __reserve_bp_slot(bp, bp->attr.bp_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
int dbg_release_bp_slot(struct perf_event *bp)
|
int dbg_release_bp_slot(struct perf_event *bp)
|
||||||
@ -362,7 +362,7 @@ int dbg_release_bp_slot(struct perf_event *bp)
|
|||||||
if (mutex_is_locked(&nr_bp_mutex))
|
if (mutex_is_locked(&nr_bp_mutex))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
__release_bp_slot(bp);
|
__release_bp_slot(bp, bp->attr.bp_type);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user