linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mel Gorman <mel@csn.ul.ie>
To: "Li, Ming Chun" <macli@brc.ubc.ca>
Cc: LKML <linux-kernel@vger.kernel.org>, linux-mm@kvack.org
Subject: Re: [PATCH 4/6] tracing, page-allocator: Add a postprocessing script for page-allocator-related ftrace events
Date: Mon, 10 Aug 2009 08:41:46 +0100	[thread overview]
Message-ID: <20090810074145.GA1933@csn.ul.ie> (raw)
In-Reply-To: <alpine.DEB.1.00.0908071228310.14726@mail.selltech.ca>

On Fri, Aug 07, 2009 at 12:32:34PM -0700, Li, Ming Chun wrote:
> On Fri, 7 Aug 2009, Li, Ming Chun wrote:
> 
> > On Fri, 7 Aug 2009, Mel Gorman wrote:
> > 
> > > +sub generate_traceevent_regex {
> > > +	my $event = shift;
> > > +	my $default = shift;
> > > +	my @fields = @_;
> > > +	my $regex;
> > 
> > You are using shift to retrieve parameters below, @fields is not used 
> > anywhere.
> > 

Correct, this can be removed. Initially, I was going to use an array but
shift was far neater. Forgot to cleanup afterwards.

> > > +
> > > +	# Read the event format or use the default
> > > +	if (!open (FORMAT, "/sys/kernel/debug/tracing/events/$event/format")) {
> > > +		$regex = $default;
> > > +	} else {
> > > +		my $line;
> > > +		while (!eof(FORMAT)) {
> > > +			$line = <FORMAT>;
> > > +			if ($line =~ /^print fmt:\s"(.*)",.*/) {
> > > +				$regex = $1;
> > > +				$regex =~ s/%p/\([0-9a-f]*\)/g;
> > > +				$regex =~ s/%d/\([-0-9]*\)/g;
> > > +				$regex =~ s/%lu/\([0-9]*\)/g;
> > > +			}
> > > +		}
> > > +	}
> > > +
> > > +	# Verify fields are in the right order
> > > +	my $tuple;
> > > +	foreach $tuple (split /\s/, $regex) {
> > > +		my ($key, $value) = split(/=/, $tuple);
> > > +		my $expected = shift;
> > > +		if ($key ne $expected) {
> > > +			print("WARNING: Format not as expected '$key' != '$expected'");
> > > +			$regex =~ s/$key=\((.*)\)/$key=$1/;
> > > +		}
> > > +	}
> > > +	if (defined $_) {
> > > +		die("Fewer fields than expected in format");
> > > +	}
> > > +
> > 
> > How about:
> > 	if (defined shift) {
> > 		die("Fewer fields than expected in format");
> > 	}
> > ? 
> > 
> > I don't know, just ask if it is clear.
> 
> Ah, I think it should be:
> 	if (@_) {
> 		die("Fewer fields than expected in format");
> 	}
> 
> ? Sorry for the noise :)
> 

It's not noise at all, you're right to point out something was wrong
here. It needed to be either

if (defined shift)
if (defined $_[0])

I went with your first suggestion of "if (defined shift)"

Thanks

==== CUT HERE ====
tracing, page-allocator: Fix sanity check of TP_printk format for mm_page_alloc_extfrag

The trace-pagealloc-postprocess.pl script sanity checks the TP_printk
format for mm_page_alloc_extfrag to ensure all expected fields are in
the output format. Ming Chun Li pointed out that the check for all
expected fields is checking the wrong scalar and that there was a
unused @fields declared. This patch deletes the unused variable and
fixes the check.

Reported-by: Ming Chun Li <macli@brc.ubc.ca>
Signed-off-by: Mel Gorman <mel@csn.ul.ie>
---
 Documentation/trace/postprocess/trace-pagealloc-postprocess.pl |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/trace/postprocess/trace-pagealloc-postprocess.pl b/Documentation/trace/postprocess/trace-pagealloc-postprocess.pl
index 1a8a408..7df50e8 100755
--- a/Documentation/trace/postprocess/trace-pagealloc-postprocess.pl
+++ b/Documentation/trace/postprocess/trace-pagealloc-postprocess.pl
@@ -91,7 +91,6 @@ my $regex_statppid = '[-0-9]*\s\(.*\)\s[A-Za-z]\s([0-9]*).*';
 sub generate_traceevent_regex {
 	my $event = shift;
 	my $default = shift;
-	my @fields = @_;
 	my $regex;
 
 	# Read the event format or use the default
@@ -120,7 +119,8 @@ sub generate_traceevent_regex {
 			$regex =~ s/$key=\((.*)\)/$key=$1/;
 		}
 	}
-	if (defined $_) {
+
+	if (defined shift) {
 		die("Fewer fields than expected in format");
 	}
 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2009-08-10  7:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-07 17:40 [PATCH 0/6] Add some trace events for the page allocator v5 Mel Gorman
2009-08-07 17:40 ` [PATCH 1/6] tracing, page-allocator: Add trace events for page allocation and page freeing Mel Gorman
2009-08-08  5:47   ` KOSAKI Motohiro
2009-08-07 17:40 ` [PATCH 2/6] tracing, page-allocator: Add trace events for anti-fragmentation falling back to other migratetypes Mel Gorman
2009-08-07 17:40 ` [PATCH 3/6] tracing, page-allocator: Add trace event for page traffic related to the buddy lists Mel Gorman
2009-08-07 17:40 ` [PATCH 4/6] tracing, page-allocator: Add a postprocessing script for page-allocator-related ftrace events Mel Gorman
2009-08-07 19:10   ` Li, Ming Chun
2009-08-07 19:32     ` Li, Ming Chun
2009-08-10  7:41       ` Mel Gorman [this message]
2009-08-07 17:40 ` [PATCH 5/6] tracing, documentation: Add a document describing how to do some performance analysis with tracepoints Mel Gorman
2009-08-07 17:40 ` [PATCH 6/6] tracing, documentation: Add a document on the kmem tracepoints Mel Gorman
  -- strict thread matches above, loose matches on Subject: below --
2009-08-10 15:41 [PATCH 0/6] Add some trace events for the page allocator v6 Mel Gorman
2009-08-10 15:41 ` [PATCH 4/6] tracing, page-allocator: Add a postprocessing script for page-allocator-related ftrace events Mel Gorman
2009-08-06 16:07 [PATCH 0/4] Add some trace events for the page allocator v4 Mel Gorman
2009-08-06 16:07 ` [PATCH 4/6] tracing, page-allocator: Add a postprocessing script for page-allocator-related ftrace events Mel Gorman
2009-08-06 21:07   ` Li, Ming Chun
2009-08-07 11:13     ` Mel Gorman
2009-08-07  8:00   ` Ingo Molnar
2009-08-07 14:16     ` Mel Gorman

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=20090810074145.GA1933@csn.ul.ie \
    --to=mel@csn.ul.ie \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=macli@brc.ubc.ca \
    /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