mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Will Hawkins <hawkinsw@borlaugic.com>
Cc: linux-kernel@vger.kernel.org, hawkinsw@gmail.com
Subject: Re: [PATCH] trace-cmd record: Fix syntax in make_pid_filter
Date: Fri, 13 Oct 2017 14:24:49 -0400	[thread overview]
Message-ID: <20171013142449.27f84c42@gandalf.local.home> (raw)
In-Reply-To: <1507917432-8110-1-git-send-email-hawkinsw@borlaugic.com>

On Fri, 13 Oct 2017 13:57:12 -0400
Will Hawkins <hawkinsw@borlaugic.com> wrote:

> In older versions of the kernel, event filtering by
> pid does not use the set_event_pid file. Instead,
> ftrace uses a common filter (created in make_pid_filter)
> to filter events based on PID.
> 
> The syntax of the filter generated by this function is
> overly permissive. When filtering by pid, || is used
> where && should be (in certain cases) which means that
> unrelated events are captured.
> 

Thanks for sending this.

> Signed-off-by: Will Hawkins <hawkinsw@borlaugic.com>
> ---
>  trace-record.c | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/trace-record.c b/trace-record.c
> index a0b6541..d9c2959 100644
> --- a/trace-record.c
> +++ b/trace-record.c
> @@ -935,14 +935,19 @@ static char *make_pid_filter(char *curr_filter, const char *field)
>  	str = filter + curr_len;
>  
>  	for (p = filter_pids; p; p = p->next) {
> -		if (p == filter_pids)
> -			orit = "";
> -		else
> -			orit = "||";
> -		if (p->exclude)
> +		if (p->exclude) {
>  			match = "!=";
> -		else
> +			if (p == filter_pids)
> +				orit = "";
> +			else
> +				orit = "&&";
> +		} else {
>  			match = "==";
> +			if (p == filter_pids)
> +				orit = "";
> +			else
> +				orit = "||";
> +		}

A little nicer way of doing this is:


	if (p->exclude) {
		match = "!=";
		orit = "&&";
	} else {
		match = "==";
		orit = "||";
	}
	if (p == filter_pids)
		orit = "";

Care to send a v2?

-- Steve

>  		len = sprintf(str, "%s(%s%s%d)", orit, field, match, p->pid);
>  		str += len;
>  	}

  reply	other threads:[~2017-10-13 18:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-13 17:57 Will Hawkins
2017-10-13 18:24 ` Steven Rostedt [this message]
2017-10-13 18:32   ` Will Hawkins

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=20171013142449.27f84c42@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=hawkinsw@borlaugic.com \
    --cc=hawkinsw@gmail.com \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®