Re: [PATCH 04/17] perf: Add ability to attach user stack dump tosample

From: Frederic Weisbecker
Date: Mon May 21 2012 - 09:19:36 EST


On Wed, May 02, 2012 at 01:37:05PM +0200, Jiri Olsa wrote:
> Introducing new sample_type bit PERF_SAMPLE_STACK. Once set,
> the sample_stack value determines the stack which is going
> to be attached.
>
> Currently only user level stack is supported, specified by
> PERF_SAMPLE_STACK_USER bit in sample_stack value. When set,
> the sample_stack_user value determines the size of the
> stack dump.
>
> Beeing able to dump parts of the user stack, starting from the
> stack pointer, will be useful to make a post mortem dwarf CFI
> based stack unwinding.
>
> Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx>
> Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> ---
> include/linux/perf_event.h | 20 ++++++++-
> kernel/events/core.c | 103 ++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 122 insertions(+), 1 deletions(-)
>
> diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
> index dcda0f16..2e5f486 100644
> --- a/include/linux/perf_event.h
> +++ b/include/linux/perf_event.h
> @@ -131,8 +131,9 @@ enum perf_event_sample_format {
> PERF_SAMPLE_RAW = 1U << 10,
> PERF_SAMPLE_BRANCH_STACK = 1U << 11,
> PERF_SAMPLE_REGS = 1U << 12,
> + PERF_SAMPLE_STACK = 1U << 13,
>
> - PERF_SAMPLE_MAX = 1U << 13, /* non-ABI */
> + PERF_SAMPLE_MAX = 1U << 14, /* non-ABI */
> };
>
> /*
> @@ -173,6 +174,15 @@ enum perf_sample_regs {
> };
>
> /*
> + * Values for sample_stack when PERF_SAMPLE_STACK is set.
> + * Defines stack dump to be attached to the sample.
> + */
> +enum perf_sample_stack {
> + PERF_SAMPLE_STACK_USER = 1U << 0, /* user stack */
> + PERF_SAMPLE_STACK_MAX = 1U << 1, /* non-ABI */

Same problem than with regs, this doesn't allow several stack dumps types
in a single sample.

> +};
> +
> +/*
> * The format of the data returned by read() on a perf event fd,
> * as specified by attr.read_format:
> *
> @@ -291,6 +301,14 @@ struct perf_event_attr {
> * See asm/perf_regs.h for details.
> */
> __u64 sample_regs_user;
> +
> + __u64 sample_stack; /* enum perf_sample_stack */
> +
> + /*
> + * Defines size of the user stack to dump on samples,
> + * for sample_stack PERF_SAMPLE_STACK_USER settings.
> + */
> + __u64 sample_stack_user;

Do we need PERF_SAMPLE_STACK when we can already set 0 in sample_stack_user?
--
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/