From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Hemant Kumar <hkshaw@linux.vnet.ibm.com>
Cc: linux-kernel@vger.kernel.org, srikar@linux.vnet.ibm.com,
peterz@infradead.org, oleg@redhat.com,
hegdevasant@linux.vnet.ibm.com, mingo@redhat.com,
anton@redhat.com, systemtap@sourceware.org, namhyung@kernel.org,
aravinda@linux.vnet.ibm.com
Subject: Re: [PATCH v4 2/3] Support for perf to probe into SDT markers:
Date: Thu, 24 Oct 2013 14:45:18 +0900 [thread overview]
Message-ID: <5268B3EE.5060603@hitachi.com> (raw)
In-Reply-To: <20131023050502.1886.15779.stgit@hemant-fedora>
(2013/10/23 14:05), Hemant Kumar wrote:
> This allows perf to probe into the sdt markers/notes present in
> the libraries and executables. We try to find the associated location
> and handle prelinking (since, stapsdt notes section is not allocated
> during runtime). Prelinking is handled with the help of base
> section which is allocated during runtime. This address can be compared
> with the address retrieved from the notes' description. If its different,
> we can take this difference and then add to the note's location.
>
> We can use existing '-a/--add' option to add events for sdt markers.
> Also, we can add multiple events at once using the same '-a' option.
>
> Usage:
> perf probe -x /lib64/libc.so.6 -a 'my_event=%libc:setjmp'
>
> Output:
> Added new event:
> libc:my_event (on 0x35981)
>
> You can now use it in all perf tools, such as:
>
> perf record -e libc:my_event -aR sleep 1
>
>
> Signed-off-by: Hemant Kumar Shaw <hkshaw@linux.vnet.ibm.com>
Almost! please check below comments :)
> static int convert_to_probe_trace_events(struct perf_probe_event *pev,
> struct probe_trace_event **tevs,
> int max_tevs, const char *target)
> @@ -1916,11 +1975,23 @@ static int convert_to_probe_trace_events(struct perf_probe_event *pev,
> struct symbol *sym;
> int ret = 0, i;
> struct probe_trace_event *tev;
> + char *buf;
> + unsigned long long addr;
>
> - /* Convert perf_probe_event with debuginfo */
> - ret = try_to_find_probe_trace_events(pev, tevs, max_tevs, target);
> - if (ret != 0)
> - return ret; /* Found in debuginfo or got an error */
> + if (pev->sdt) {
> + ret = -EBADF;
> + if (pev->uprobes)
> + ret = try_to_find_sdt_notes(pev, target);
> + if (ret)
> + return ret;
> + } else {
> + /* Convert perf_probe_event with debuginfo */
> + ret = try_to_find_probe_trace_events(pev, tevs, max_tevs,
> + target);
> + /* Found in debuginfo or got an error */
> + if (ret != 0)
> + return ret;
These "ret != 0" checkers can be merged.
[...]
> +int search_sdt_note(struct sdt_note *key, const char *target)
> +{
> + Elf *elf;
> + int fd, ret;
> + bool found = false;
> + struct sdt_note *pos = NULL;
> + LIST_HEAD(sdt_notes);
> +
> + fd = open(target, O_RDONLY);
> + if (fd < 0) {
> + pr_err("%s : %s\n", target, strerror(errno));
> + return -errno;
> + }
> +
> + symbol__elf_init();
> + elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
> + if (!elf) {
> + ret = -EBADF;
> + pr_debug("Can't read the elf of %s\n", target);
> + goto out_close;
> + }
> +
> + ret = construct_sdt_notes_list(elf, &sdt_notes);
> + if (ret)
> + goto out_end;
> +
> + /* Iterate through the notes and retrieve the required note */
> + list_for_each_entry(pos, &sdt_notes, note_list) {
> + if (!strcmp(key->name, pos->name) &&
> + !strcmp(key->provider, pos->provider)) {
> + adjust_note_addr(pos, key, elf);
> + found = true;
> + break;
> + }
> + }
> + if (!found) {
> + printf("%%%s:%s not found in %s!\n", key->provider, key->name,
> + target);
> + return -ENOENT;
Here, you skipped the closing process. maybe ret = -ENOENT is enough here.
> + }
> +
> +out_end:
> + elf_end(elf);
> +out_close:
> + close(fd);
> + ret = sdt_err(ret, target);
It seems the sdt_err is only for the return value of contruct_sdt_notes_list(),
thus it is better to integrate it.
> + if (!ret && list_empty(&sdt_notes))
> + ret = -ENOENT;
I think this can be removed, because it always be false (caught by previous !found).
> + cleanup_sdt_note_list(&sdt_notes);
> + return ret;
> +}
Thank you,
--
Masami HIRAMATSU
IT Management Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com
next prev parent reply other threads:[~2013-10-24 5:45 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-23 5:04 [PATCH v4 0/3] perf support to SDT markers Hemant Kumar
2013-10-23 5:04 ` [PATCH v4 1/3] SDT markers listing by perf: Hemant Kumar
2013-10-23 5:05 ` [PATCH v4 2/3] Support for perf to probe into SDT markers: Hemant Kumar
2013-10-24 5:45 ` Masami Hiramatsu [this message]
2013-10-24 10:25 ` Hemant Kumar
2013-10-25 12:38 ` Pekka Enberg
2013-10-25 12:59 ` Srikar Dronamraju
2013-10-25 14:20 ` Pekka Enberg
2013-10-25 15:20 ` David Ahern
2013-10-28 8:48 ` Pekka Enberg
2013-10-28 16:59 ` David Ahern
2013-10-28 18:45 ` Pekka Enberg
2013-10-29 9:55 ` Hemant Kumar
2013-10-29 14:05 ` Pekka Enberg
2013-10-29 19:41 ` Hemant Kumar
2013-10-30 10:22 ` Masami Hiramatsu
2013-10-26 9:50 ` Ingo Molnar
2013-10-28 8:56 ` Pekka Enberg
2013-10-28 10:57 ` Masami Hiramatsu
2013-10-29 5:50 ` Namhyung Kim
2013-10-26 11:16 ` Frank Ch. Eigler
2013-10-28 8:40 ` Pekka Enberg
2013-10-28 10:34 ` Ingo Molnar
2013-10-30 10:05 ` Masami Hiramatsu
2013-10-30 11:51 ` Pekka Enberg
2013-10-31 9:59 ` Ingo Molnar
2013-10-31 10:54 ` Mark Wielaard
2013-10-31 10:57 ` Ingo Molnar
2013-10-31 13:12 ` Peter Zijlstra
2013-10-31 13:23 ` Mark Wielaard
2013-10-30 13:30 ` Hemant Kumar
2013-10-28 11:23 ` Masami Hiramatsu
2013-10-28 12:42 ` Pekka Enberg
2013-10-28 14:11 ` Srikar Dronamraju
2013-10-28 14:21 ` Pekka Enberg
2013-10-28 17:31 ` Srikar Dronamraju
2013-10-28 17:48 ` Pekka Enberg
2013-10-29 3:19 ` Masami Hiramatsu
2013-10-29 5:31 ` Namhyung Kim
2013-10-29 14:51 ` Mark Wielaard
2013-10-29 19:54 ` Pekka Enberg
2013-10-29 2:51 ` Masami Hiramatsu
2013-10-23 5:05 ` [PATCH v4 3/3] Documentation regarding perf/sdt Hemant Kumar
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=5268B3EE.5060603@hitachi.com \
--to=masami.hiramatsu.pt@hitachi.com \
--cc=anton@redhat.com \
--cc=aravinda@linux.vnet.ibm.com \
--cc=hegdevasant@linux.vnet.ibm.com \
--cc=hkshaw@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=srikar@linux.vnet.ibm.com \
--cc=systemtap@sourceware.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
Powered by JetHome