public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: linux-kernel@vger.kernel.org, David Ahern <dsahern@gmail.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jiri Olsa <jolsa@redhat.com>, Mike Galbraith <efault@gmx.de>,
	Namhyung Kim <namhyung@gmail.com>,
	Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Stephane Eranian <eranian@google.com>,
	Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH V2 1/9] perf tools: add test for reading object code
Date: Sat, 03 Aug 2013 17:11:34 +0300	[thread overview]
Message-ID: <51FD0F96.4090805@intel.com> (raw)
In-Reply-To: <20130731172833.GH3614@ghostprotocols.net>

On 31/07/2013 8:28 p.m., Arnaldo Carvalho de Melo wrote:
> Em Wed, Jul 31, 2013 at 11:58:20AM -0300, Arnaldo Carvalho de Melo escreveu:
>> >  Em Wed, Jul 31, 2013 at 12:13:50AM +0300, Adrian Hunter escreveu:
>>> >  >  Using the information in mmap events, perf tools can read object
>>> >  >  code associated with sampled addresses.  A test is added that
>>> >  >  compares bytes read by perf with the same bytes read using
>>> >  >  objdump.
>> >
>> >  investigating...
>> >
>> >  (gdb) run test 21
>> >  Starting program: /root/bin/perf test 21
>> >  [Thread debugging using libthread_db enabled]
>> >  Using host libthread_db library "/lib64/libthread_db.so.1".
>> >  21: Test object code reading                               :
>> >  Program received signal SIGSEGV, Segmentation fault.
>> >  0x000000000045a2d3 in xyarray__entry (xy=0x0, x=0, y=0) at util/xyarray.h:17
>> >  17		return&xy->contents[x * xy->row_size + y * xy->entry_size];
>
> Still investigating, but the attached patch is needed to handle such
> failure cases:

I removed the offending perf_evlist__disable() since it was not needed 
anyway.  Otherwise the existing error path was simpler so I kept it in V3.

>
> [root@zoo ~]# perf test 21
> 21: Test object code reading                               : FAILED!
> [root@zoo ~]# perf test -v 21
> 21: Test object code reading                               :
> --- start ---
> Looking at the vmlinux_path (6 entries long)
> symsrc__init: cannot get elf header.
> Using /lib/modules/3.11.0-rc2+/build/vmlinux for symbols
> Parsing event 'cycles'
> Parsing event 'cycles:u'
> perf_evlist__open failed
> ---- end ----
> Test object code reading: FAILED!
> [root@zoo ~]#
>
> - Arnaldo
>
>
> error_path.patch
>
>
> diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
> index 7c9437d..9d9b6b5 100644
> --- a/tools/perf/tests/code-reading.c
> +++ b/tools/perf/tests/code-reading.c
> @@ -357,7 +357,7 @@ static int do_test_code_reading(void)
>   	ret = machine__create_kernel_maps(machine);
>   	if (ret<  0) {
>   		pr_debug("machine__create_kernel_maps failed\n");
> -		goto out_err;
> +		goto out_machine_exit;
>   	}
>
>   	/* Load kernel map */
> @@ -365,7 +365,7 @@ static int do_test_code_reading(void)
>   	ret = map__load(map, NULL);
>   	if (ret<  0) {
>   		pr_debug("map__load failed\n");
> -		goto out_err;
> +		goto out_destroy_kernel_maps;
>   	}
>   	have_vmlinux = map->dso->symtab_type == DSO_BINARY_TYPE__VMLINUX;
>   	/* No point getting kernel events if there is no vmlinux */
> @@ -375,26 +375,26 @@ static int do_test_code_reading(void)
>   	threads = thread_map__new_by_tid(pid);
>   	if (!threads) {
>   		pr_debug("thread_map__new_by_tid failed\n");
> -		goto out_err;
> +		goto out_destroy_kernel_maps;
>   	}
>
>   	ret = perf_event__synthesize_thread_map(NULL, threads,
>   						perf_event__process, machine);
>   	if (ret<  0) {
>   		pr_debug("perf_event__synthesize_thread_map failed\n");
> -		goto out_err;
> +		goto out_thread_map_delete;
>   	}
>
>   	thread = machine__findnew_thread(machine, pid);
>   	if (!thread) {
>   		pr_debug("machine__findnew_thread failed\n");
> -		goto out_err;
> +		goto out_thread_map_delete;
>   	}
>
>   	cpus = cpu_map__new(NULL);
>   	if (!cpus) {
>   		pr_debug("cpu_map__new failed\n");
> -		goto out_err;
> +		goto out_thread_map_delete;
>   	}
>
>   	while (1) {
> @@ -403,7 +403,7 @@ static int do_test_code_reading(void)
>   		evlist = perf_evlist__new();
>   		if (!evlist) {
>   			pr_debug("perf_evlist__new failed\n");
> -			goto out_err;
> +			goto out_cpu_map_delete;
>   		}
>
>   		perf_evlist__set_maps(evlist, cpus, threads);
> @@ -416,7 +416,7 @@ static int do_test_code_reading(void)
>   		ret = parse_events(evlist, str);
>   		if (ret<  0) {
>   			pr_debug("parse_events failed\n");
> -			goto out_err;
> +			goto out_evlist_delete;
>   		}
>
>   		perf_evlist__config(evlist,&opts);
> @@ -435,7 +435,7 @@ static int do_test_code_reading(void)
>   				continue;
>   			}
>   			pr_debug("perf_evlist__open failed\n");
> -			goto out_err;
> +			goto out_evlist_delete;
>   		}
>   		break;
>   	}
> @@ -443,7 +443,7 @@ static int do_test_code_reading(void)
>   	ret = perf_evlist__mmap(evlist, UINT_MAX, false);
>   	if (ret<  0) {
>   		pr_debug("perf_evlist__mmap failed\n");
> -		goto out_err;
> +		goto out_evlist_close;
>   	}
>
>   	perf_evlist__enable(evlist);
> @@ -454,7 +454,7 @@ static int do_test_code_reading(void)
>
>   	ret = process_events(machine, evlist);
>   	if (ret<  0)
> -		goto out_err;
> +		goto out_evlist_munmap;
>
>   	if (!have_vmlinux)
>   		err = TEST_CODE_READING_NO_VMLINUX;
> @@ -462,19 +462,21 @@ static int do_test_code_reading(void)
>   		err = TEST_CODE_READING_NO_ACCESS;
>   	else
>   		err = TEST_CODE_READING_OK;
> -out_err:
> -	if (evlist) {
> -		perf_evlist__disable(evlist);
> -		perf_evlist__munmap(evlist);
> -		perf_evlist__close(evlist);
> -		perf_evlist__delete(evlist);
> -	}
> -	if (cpus)
> -		cpu_map__delete(cpus);
> -	if (threads)
> -		thread_map__delete(threads);
> +
> +out_evlist_munmap:
> +	perf_evlist__munmap(evlist);
> +out_evlist_close:
> +	perf_evlist__close(evlist);
> +out_evlist_delete:
> +	perf_evlist__delete(evlist);
> +out_cpu_map_delete:
> +	cpu_map__delete(cpus);
> +out_thread_map_delete:
> +	thread_map__delete(threads);
> +out_destroy_kernel_maps:
>   	machines__destroy_kernel_maps(&machines);
>   	machine__delete_threads(machine);
> +out_machine_exit:
>   	machines__exit(&machines);
>
>   	return err;
>


  parent reply	other threads:[~2013-08-03 14:11 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-30 21:13 [PATCH V2 0/9] perf tools: add support for reading object code Adrian Hunter
2013-07-30 21:13 ` [PATCH V2 1/9] perf tools: add test " Adrian Hunter
2013-07-31 14:17   ` Arnaldo Carvalho de Melo
2013-07-31 14:24     ` Peter Zijlstra
2013-08-01  2:32       ` Namhyung Kim
2013-08-03 13:45     ` Adrian Hunter
2013-08-05 16:32       ` Arnaldo Carvalho de Melo
2013-07-31 14:58   ` Arnaldo Carvalho de Melo
2013-07-31 17:28     ` Arnaldo Carvalho de Melo
2013-07-31 17:46       ` Arnaldo Carvalho de Melo
2013-08-03 19:37         ` Adrian Hunter
2013-08-03 14:11       ` Adrian Hunter [this message]
2013-07-30 21:13 ` [PATCH V2 2/9] perf tools: load kernel maps before using Adrian Hunter
2013-07-31 14:35   ` Arnaldo Carvalho de Melo
2013-07-30 21:13 ` [PATCH V2 3/9] perf tools: make it possible to read object code from vmlinux Adrian Hunter
2013-07-30 21:13 ` [PATCH V2 4/9] perf tools: adjust the vmlinux symtab matches kallsyms test Adrian Hunter
2013-07-30 21:13 ` [PATCH V2 5/9] perf tools: avoid SyS kernel syscall aliases Adrian Hunter
2013-07-30 21:13 ` [PATCH V2 6/9] perf tools: make it possible to read object code from kernel modules Adrian Hunter
2013-07-30 21:13 ` [PATCH V2 7/9] perf tools: add support for reading from /proc/kcore Adrian Hunter
2013-07-30 21:13 ` [PATCH V2 8/9] perf tools: add kcore to the object code reading test Adrian Hunter
2013-07-30 21:13 ` [PATCH V2 9/9] perf tools: allow annotation using /proc/kcore Adrian Hunter

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=51FD0F96.4090805@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=acme@ghostprotocols.net \
    --cc=dsahern@gmail.com \
    --cc=efault@gmx.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@gmail.com \
    --cc=paulus@samba.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