From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Hemant Kumar <hemant@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, penberg@iki.fi
Subject: Re: [PATCH v4 2/3] perf/sdt : Support perf-list to print SDT events in a single file
Date: Thu, 28 Aug 2014 19:54:07 +0900 [thread overview]
Message-ID: <53FF0A4F.3070806@hitachi.com> (raw)
In-Reply-To: <20140827214426.13454.76532.stgit@hemant-fedora>
(2014/08/28 6:50), Hemant Kumar wrote:
[...]
> +/*
> + * get_sdt_note_info(): flush the SDT notes onto stdout
> + */
> +static void get_sdt_note_info(struct list_head *start, const char *target)
> +{
> + struct sdt_note *pos;
> +
> + if (list_empty(start))
> + return;
> +
> + printf("%s :\n", target);
> + list_for_each_entry(pos, start, note_list) {
> + printf("%%%s : %s\n", pos->provider, pos->name);
Hmm, this will show
%app : marker
instead of
%app:marker
(blanks are placed around ":")
I think it should be the latter format.
> + }
> +}
> +
> +/*
> + * Error displayed in case of query of a
> + * single file for SDT markers
> + */
> +static int sdt_err(int val, const char *target)
> +{
> + switch (-val) {
> + case 0:
> + break;
> + case ENOENT:
> + /* Absence of SDT markers */
> + printf("%s : No SDT events found\n", target);
Please use pr_err or pr_warning for error messages.
> + break;
> + case EBADF:
> + printf("%s : Bad file name\n", target);
> + break;
> + default:
> + printf("%s\n", strerror(val));
> + }
And strerror_r instead of strerror (see https://lkml.org/lkml/2014/8/13/828)
> +
> + return val;
> +}
> +
> +/*
> + * cleanup_sdt_note_list() : Free the sdt note list
> + */
> +static void cleanup_sdt_note_list(struct list_head *sdt_notes)
> +{
> + struct sdt_note *tmp, *pos;
> +
> + if (list_empty(sdt_notes))
> + return;
You don't need to check this. If the list is empty list_for_each...
just skips loops.
> +
> + list_for_each_entry_safe(pos, tmp, sdt_notes, note_list) {
> + list_del(&pos->note_list);
> + free(pos->name);
> + free(pos->provider);
> + free(pos);
> + }
> +}
Thank you,
> +
> +/*
> + * filename__find_sdt() : looks for sdt markers and the list is
> + * stored in sdt_notes
> + */
> +static int filename__find_sdt(const char *target)
> +{
> + int ret;
> +
> + LIST_HEAD(sdt_notes);
> +
> + ret = get_sdt_note_list(&sdt_notes, target);
> + if (!ret)
> + get_sdt_note_info(&sdt_notes, target);
> + else
> + sdt_err(ret, target);
> +
> + cleanup_sdt_note_list(&sdt_notes);
> +
> + return ret;
> +}
> +
> +/*
> + * print_sdt_notes() : wrapper function
> + */
> +void print_sdt_events(const char *arg)
> +{
> + if (arg) {
> + filename__find_sdt(arg);
> + return;
> + }
> + pr_err("Error : File Name must be specified with \"sdt\" option!\n"
> + "Usage :\n perf list sdt <file-name>\n");
> +
> + return;
> +}
>
>
--
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com
next prev parent reply other threads:[~2014-08-28 10:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-27 21:43 [PATCH v4 0/3] perf/sdt : Support for SDT markers Hemant Kumar
2014-08-27 21:44 ` [PATCH v4 1/3] perf/sdt : Raw SDT parsing functions Hemant Kumar
2014-08-29 7:22 ` Namhyung Kim
2014-08-27 21:50 ` [PATCH v4 2/3] perf/sdt : Support perf-list to print SDT events in a single file Hemant Kumar
2014-08-28 10:54 ` Masami Hiramatsu [this message]
2014-08-28 12:23 ` Hemant Kumar
2014-08-27 21:53 ` [PATCH v4 3/3] perf/sdt : Documentation for SDT events Hemant Kumar
2014-08-29 7:26 ` Namhyung Kim
2014-09-01 6:01 ` Masami Hiramatsu
2014-08-28 11:19 ` [PATCH v4 0/3] perf/sdt : Support for SDT markers Masami Hiramatsu
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=53FF0A4F.3070806@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=hemant@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=oleg@redhat.com \
--cc=penberg@iki.fi \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.