Re: [RFC][PATCH 3/7] perf, hw_breakpoint: Fix crash inhw_breakpoint creation

From: Frederic Weisbecker
Date: Fri Oct 15 2010 - 12:44:37 EST


On Thu, Oct 14, 2010 at 10:34:07PM +0200, Peter Zijlstra wrote:
> hw_breakpoint creation needs to account stuff per-task to ensure there
> is always sufficient hardware resources to back these things due to
> ptrace.
>
> With the perf per pmu context changes the event initialization no
> longer has access to the event context, for the simple reason that we
> need to first find the pmu (result of initialization) before we can
> find the context.
>
> This makes hw_breakpoints unhappy, because it can no longer do per
> task accounting, cure this by frobbing a task pointer in the event::hw
> bits for now...
>
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
> Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
> ---
> include/linux/perf_event.h | 7 +++++++
> kernel/hw_breakpoint.c | 8 ++++----
> kernel/perf_event.c | 21 ++++++++++++++++-----
> 3 files changed, 27 insertions(+), 9 deletions(-)
>
> Index: linux-2.6/include/linux/perf_event.h
> ===================================================================
> --- linux-2.6.orig/include/linux/perf_event.h
> +++ linux-2.6/include/linux/perf_event.h
> @@ -536,6 +536,12 @@ struct hw_perf_event {
> struct { /* breakpoint */
> struct arch_hw_breakpoint info;
> struct list_head bp_list;
> + /*
> + * Crufty hack to avoid the chicken and egg
> + * problem hw_breakpoint has with context
> + * creation and event initalization.
> + */
> + struct task_struct *bp_target;
> };
> #endif
> };
> @@ -693,6 +699,7 @@ struct swevent_hlist {
>
> #define PERF_ATTACH_CONTEXT 0x01
> #define PERF_ATTACH_GROUP 0x02
> +#define PERF_ATTACH_TASK 0x04



Thanks, the patch looks good.

I'm just not sure about the point of this flag...

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/