All of lore.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Andi Kleen <andi@firstfloor.org>
Cc: jolsa@redhat.com, linux-kernel@vger.kernel.org, acme@kernel.org,
	mingo@kernel.org, peterz@infradead.org,
	Andi Kleen <ak@linux.intel.com>
Subject: Re: [PATCH] perf, tools: Add PERF_PID
Date: Tue, 19 Aug 2014 15:23:12 +0900	[thread overview]
Message-ID: <874mx9c81b.fsf@sejong.aot.lge.com> (raw)
In-Reply-To: <1407964337-23952-1-git-send-email-andi@firstfloor.org> (Andi Kleen's message of "Wed, 13 Aug 2014 14:12:17 -0700")

Hi Andi,

On Wed, 13 Aug 2014 14:12:17 -0700, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> It's currently difficult to filter out perf itself using a filter.
> This can give cascading effects during IO tracing when the IO
> perf does itself causes more trace output.
>
> The best way to filter is to use the pid. But it's difficult to get the pid
> of perf without using hacks.
>
> Add a PERF_PID meta variable to the perf filter that contains the current pid.
>
> With this patch the following works
>
> % perf record -e syscalls:sys_enter_write -a --filter 'common_pid != PERF_PID' ...
>
> This won't work for more complex perf pipe lines with multiple processes,
> but at least solves the problem nicely for a single perf.
>
> Signed-off-by: Andi Kleen <ak@linux.intel.com>

I like the idea, so with comments below fixed:

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung


[SNIP]
> +	/* Assume a pid has not more than 8 characters */
> +	pid = strstr(last->filter, "PERF_PID");
> +	if (pid) {
> +		char buf[9];
> +		snprintf(buf, 9, "%08d", getpid());

Why do you add zero-paddings?  I guess it'd confuse the parser as if
it's an octal digits.  What about just using "%8d"?  It seems the parser
ignores whitespaces between tokens..


> +		memcpy(pid, buf, 8);
> +	}
> +	fprintf(stderr, "filter |%s|\n", last->filter);

Isn't it a debug message?

Thanks,
Namhyung


>  	return 0;
>  }

  reply	other threads:[~2014-08-19  6:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-13 21:12 [PATCH] perf, tools: Add PERF_PID Andi Kleen
2014-08-19  6:23 ` Namhyung Kim [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-08-19 12:02 Andi Kleen
2014-08-19 15:02 ` Andi Kleen
2014-08-19 15:04 Andi Kleen
2014-09-10  0:03 Andi Kleen
2014-09-10  1:08 ` Brendan Gregg
2014-09-15 19:22 ` Arnaldo Carvalho de Melo
2014-09-15 23:17 Andi Kleen

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=874mx9c81b.fsf@sejong.aot.lge.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=andi@firstfloor.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.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 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.