[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <51FD0F96.4090805@intel.com>
Date: Sat, 03 Aug 2013 17:11:34 +0300
From: Adrian Hunter <adrian.hunter@...el.com>
To: Arnaldo Carvalho de Melo <acme@...stprotocols.net>
CC: linux-kernel@...r.kernel.org, David Ahern <dsahern@...il.com>,
Frederic Weisbecker <fweisbec@...il.com>,
Jiri Olsa <jolsa@...hat.com>, Mike Galbraith <efault@....de>,
Namhyung Kim <namhyung@...il.com>,
Paul Mackerras <paulus@...ba.org>,
Peter Zijlstra <peterz@...radead.org>,
Stephane Eranian <eranian@...gle.com>,
Ingo Molnar <mingo@...nel.org>
Subject: Re: [PATCH V2 1/9] perf tools: add test for reading object code
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;
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists