From: Arnaldo Carvalho de Melo <acme@redhat.com>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Mike Galbraith <efault@gmx.de>
Subject: Re: [PATCH 1/4] perf tools: callchain: Warn only once in empty node detection
Date: Fri, 7 Aug 2009 22:06:48 -0300 [thread overview]
Message-ID: <20090808010648.GL4339@ghostprotocols.net> (raw)
In-Reply-To: <1249690585-9145-1-git-send-email-fweisbec@gmail.com>
Em Sat, Aug 08, 2009 at 02:16:22AM +0200, Frederic Weisbecker escreveu:
> When we fill a new node that is found to be empty (sign of a bug),
> we print a message each time that happens. Sometimes we reach thousands
> of lines printed.
>
> Just warn only once in that case (and use stderr instead of stdout).
Wouldn't this be better done with a macro so that the every message is
print once instead of any fprintf_once message?
I think it would even be nice to just use the same thing the kernel
uses... WARN_ON_ONCE, and also using asm/bug.h, etc, just add it to
tools/perf/util/include/asm, etc.
That way one can even forget that this is not kernel programming... :-)
- Arnaldo
> Reported-by: Ingo Molnar <mingo@elte.hu>
> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Mike Galbraith <efault@gmx.de>
> ---
> tools/perf/util/callchain.c | 3 ++-
> tools/perf/util/util.h | 3 +++
> tools/perf/util/wrapper.c | 16 ++++++++++++++++
> 3 files changed, 21 insertions(+), 1 deletions(-)
>
> diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
> index 98c5627..ce0c6d4 100644
> --- a/tools/perf/util/callchain.c
> +++ b/tools/perf/util/callchain.c
> @@ -13,6 +13,7 @@
> #include <stdio.h>
> #include <stdbool.h>
> #include <errno.h>
> +#include "util.h"
>
> #include "callchain.h"
>
> @@ -203,7 +204,7 @@ fill_node(struct callchain_node *node, struct ip_callchain *chain,
> }
> node->val_nr = chain->nr - start;
> if (!node->val_nr)
> - printf("Warning: empty node in callchain tree\n");
> + fprintf_once(stderr, "Warning: empty node in callchain tree\n");
> }
>
> static void
> diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
> index 68fe157..386ea40 100644
> --- a/tools/perf/util/util.h
> +++ b/tools/perf/util/util.h
> @@ -148,6 +148,9 @@ static inline const char *skip_prefix(const char *str, const char *prefix)
> return strncmp(str, prefix, len) ? NULL : str + len;
> }
>
> +extern int fprintf_once(FILE *fp, const char *fmt, ...)
> + __attribute__((format (printf, 2, 3)));
> +
> #if defined(NO_MMAP) || defined(USE_WIN32_MMAP)
>
> #ifndef PROT_READ
> diff --git a/tools/perf/util/wrapper.c b/tools/perf/util/wrapper.c
> index 4574ac2..026c87c 100644
> --- a/tools/perf/util/wrapper.c
> +++ b/tools/perf/util/wrapper.c
> @@ -205,3 +205,19 @@ int xmkstemp(char *template)
> die("Unable to create temporary file: %s", strerror(errno));
> return fd;
> }
> +
> +int fprintf_once(FILE *fp, const char *fmt, ...)
> +{
> + va_list args;
> + int ret;
> + static int once;
> +
> + if (once++)
> + return 1;
> +
> + va_start(args, fmt);
> + ret = vfprintf(fp, fmt, args);
> + va_end(args);
> +
> + return ret;
> +}
> --
> 1.6.2.3
next prev parent reply other threads:[~2009-08-08 1:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-08 0:16 [PATCH 1/4] perf tools: callchain: Warn only once in empty node detection Frederic Weisbecker
2009-08-08 0:16 ` [PATCH 2/4] perf tools: callchain: Ignore empty callchains Frederic Weisbecker
2009-08-08 11:51 ` [tip:perfcounters/core] perf tools: callchain: Fix spurious 'perf report' warnings: ignore " tip-bot for Frederic Weisbecker
2009-08-09 11:09 ` tip-bot for Frederic Weisbecker
2009-08-08 0:16 ` [PATCH 3/4] perf tools: callchain: Default display callchain from report if recorded with -g Frederic Weisbecker
2009-08-08 11:51 ` [tip:perfcounters/core] perf tools: callchain: Fix 'perf report' display to be callchain by default tip-bot for Frederic Weisbecker
2009-08-09 11:09 ` tip-bot for Frederic Weisbecker
2009-08-08 0:16 ` [PATCH 4/4] perf tools: callchain: Display amount of ignored chains in fractal mode Frederic Weisbecker
2009-08-08 11:52 ` [tip:perfcounters/core] perf tools: callchain: Fix sum of percentages to be 100% by displaying " tip-bot for Frederic Weisbecker
2009-08-08 12:29 ` Ingo Molnar
2009-08-09 2:42 ` Frederic Weisbecker
2009-08-09 11:12 ` [tip:perfcounters/urgent] perf tools: callchain: Fix bad rounding of minimum rate tip-bot for Frederic Weisbecker
2009-08-09 11:10 ` [tip:perfcounters/core] perf tools: callchain: Fix sum of percentages to be 100% by displaying amount of ignored chains in fractal mode tip-bot for Frederic Weisbecker
2009-08-08 1:06 ` Arnaldo Carvalho de Melo [this message]
2009-08-08 1:10 ` [PATCH 1/4] perf tools: callchain: Warn only once in empty node detection Frederic Weisbecker
-- strict thread matches above, loose matches on Subject: below --
2009-08-08 2:26 Frederic Weisbecker
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=20090808010648.GL4339@ghostprotocols.net \
--to=acme@redhat.com \
--cc=efault@gmx.de \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--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