mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Jiri Olsa <jolsa@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
	David Ahern <dsahern@gmail.com>, Andi Kleen <andi@firstfloor.org>
Subject: Re: [PATCH 2/5] perf tools: Fix segfault on dynamic entries
Date: Sun, 21 Feb 2016 18:37:46 +0100	[thread overview]
Message-ID: <20160221173746.GG10701@krava.homerouter.cpe> (raw)
In-Reply-To: <1456064558-13086-2-git-send-email-namhyung@kernel.org>

On Sun, Feb 21, 2016 at 11:22:35PM +0900, Namhyung Kim wrote:
> The dynamic entry is created for each tracepoint event.  When it sets up
> the sort key, it checks with existing keys using ->equal() callback.
> But it missed to set the ->equal for dynamic entries.  The following
> segfault was due to the missing ->equal() callback.
> 
>   (gdb) bt
>   #0  0x0000000000140003 in ?? ()
>   #1  0x0000000000537769 in fmt_equal (b=0x2106980, a=0x21067a0) at ui/hist.c:548
>   #2  perf_hpp__setup_output_field (list=0x8c6d80 <perf_hpp_list>) at ui/hist.c:560
>   #3  0x00000000004e927e in setup_sorting (evlist=<optimized out>) at util/sort.c:2642
>   #4  0x000000000043cf50 in cmd_report (argc=<optimized out>, argv=<optimized out>, prefix=<optimized out>)
>       at builtin-report.c:932
>   #5  0x00000000004865a1 in run_builtin (p=p@entry=0x8bbce0 <commands+192>, argc=argc@entry=7,
>       argv=argv@entry=0x7ffd24d56ce0) at perf.c:390
>   #6  0x000000000042dc1f in handle_internal_command (argv=0x7ffd24d56ce0, argc=7) at perf.c:451
>   #7  run_argv (argv=0x7ffd24d56a70, argcp=0x7ffd24d56a7c) at perf.c:495
>   #8  main (argc=7, argv=0x7ffd24d56ce0) at perf.c:620
> 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

> ---
>  tools/perf/util/sort.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index de715756f281..7daea71691df 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -1835,6 +1835,20 @@ bool perf_hpp__is_dynamic_entry(struct perf_hpp_fmt *fmt)
>  	return fmt->cmp == __sort__hde_cmp;
>  }
>  
> +static bool __sort__hde_equal(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b)
> +{
> +	struct hpp_dynamic_entry *hde_a;
> +	struct hpp_dynamic_entry *hde_b;
> +
> +	if (!perf_hpp__is_dynamic_entry(a) || !perf_hpp__is_dynamic_entry(b))
> +		return false;
> +
> +	hde_a = container_of(a, struct hpp_dynamic_entry, hpp);
> +	hde_b = container_of(b, struct hpp_dynamic_entry, hpp);
> +
> +	return hde_a->field == hde_b->field;
> +}
> +
>  static void hde_free(struct perf_hpp_fmt *fmt)
>  {
>  	struct hpp_dynamic_entry *hde;
> @@ -1867,6 +1881,7 @@ __alloc_dynamic_entry(struct perf_evsel *evsel, struct format_field *field)
>  	hde->hpp.cmp = __sort__hde_cmp;
>  	hde->hpp.collapse = __sort__hde_cmp;
>  	hde->hpp.sort = __sort__hde_cmp;
> +	hde->hpp.equal = __sort__hde_equal;
>  	hde->hpp.free = hde_free;
>  
>  	INIT_LIST_HEAD(&hde->hpp.list);
> -- 
> 2.7.1
> 

  reply	other threads:[~2016-02-21 17:37 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-21 14:22 [PATCH 1/5] perf tools: Fix assertion failure on dynamic entry Namhyung Kim
2016-02-21 14:22 ` [PATCH 2/5] perf tools: Fix segfault on dynamic entries Namhyung Kim
2016-02-21 17:37   ` Jiri Olsa [this message]
2016-02-25  5:37   ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-21 14:22 ` [PATCH 3/5] perf tools: Update srcline/file if needed Namhyung Kim
2016-02-21 17:39   ` Jiri Olsa
2016-02-22  0:31     ` [PATCH v2 " Namhyung Kim
2016-02-22  6:49       ` Jiri Olsa
2016-02-25  5:37       ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-21 14:22 ` [PATCH 4/5] perf tools: Fix alignment on some sort keys Namhyung Kim
2016-02-21 17:40   ` Jiri Olsa
2016-02-22  0:32     ` [PATCH v2 " Namhyung Kim
2016-02-25  5:38       ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-21 14:22 ` [PATCH 5/5] perf tools: Fix column width setting on 'trace' sort key Namhyung Kim
2016-02-21 17:41   ` Jiri Olsa
2016-02-25  5:38   ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-21 17:37 ` [PATCH 1/5] perf tools: Fix assertion failure on dynamic entry Jiri Olsa
2016-02-22 15:08   ` Arnaldo Carvalho de Melo
2016-02-25  5:38 ` [tip:perf/core] " tip-bot for Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160221173746.GG10701@krava.homerouter.cpe \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=andi@firstfloor.org \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®