From: "Vegard Nossum" <vegard.nossum@gmail.com>
To: "Sam Ravnborg" <sam@ravnborg.org>
Cc: linux-kbuild <linux-kbuild@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
"David Woodhouse" <dwmw2@infradead.org>,
"Linus Torvalds" <torvalds@linux-foundation.org>,
"Jan Engelhardt" <jengelh@computergmbh.de>
Subject: Re: [PATCH] Speed up "make headers_*"
Date: Sun, 8 Jun 2008 12:12:35 +0200 [thread overview]
Message-ID: <19f34abd0806080312j2b09179cpa384a0460af5874e@mail.gmail.com> (raw)
In-Reply-To: <20080608094730.GA30098@uranus.ravnborg.org>
On Sun, Jun 8, 2008 at 11:47 AM, Sam Ravnborg <sam@ravnborg.org> wrote:
> This is just a heads up patch if anyone is interested.
> I finally took the time needed to optimize the
> make headers_* targets.
>
> On my box it now takes less than 10 seconds to run
> the full install + check cycle.
> And it generates roughtly one screen full of output.
>
> Compare that to ~31 seconds and output filling up
> my scroll back buffer.
Nice :-)
> Comments (especially to the perl scripts) are welcome.
Will do! Some of my comments are a bit on the pedantic side, so you
choose yourself which ones you want to heed!
> diff --git a/scripts/headers_check.pl b/scripts/headers_check.pl
> new file mode 100644
> index 0000000..dfb2ec7
> --- /dev/null
> +++ b/scripts/headers_check.pl
> @@ -0,0 +1,48 @@
> +#!/usr/bin/perl
> +#
> +# headers_check.pl execute a number of trivial consistency checks
> +#
> +# Usage: headers_check.pl dir [files...]
> +# dir..: dir to look for included files
> +# files: list of files to check
> +#
> +# The script reads the supplied files line by line and:
> +#
> +# 1) for each include statement it checks if the
> +# included file actually exists.
> +# Only include files located in asm* and linux* are checked.
> +# The rest are assumed to be system include files.
> +#
> +# 2) TODO
'use strict' and 'use warnings' is recommended. You have "my" on the
variables anyway (which is a good thing!).
> +
> +my ($dir, @files) = @ARGV;
> +
> +my $ret = 0;
> +my $lineno = 0;
> +my $filename;
> +
> +foreach $file (@files) {
> + $filename = $file;
> + open(FILE, "< $filename") or die "$filename: $!\n";
I personally prefer to put '<', $filename here instead of mashing them
together as one string. I don't know if it really matters.
If you want to compile with strict/warnings here, you should replace
FILE with "my $fh" here
> + $lineno = 0;
> + while ($line = <FILE>) {
...and use <$fh> here.
> + $lineno++;
> + &check_include();
The & should be gone (see perldoc -q 'calling a function')
> + }
> + close(FILE);
> +}
> +exit($ret);
The parentheses are not needed for most of the built-in functions.
> +
> +my $includere = qr/^\s*#\s*include\s+<(.*)>/;
What seems to be the purpose of this, also what's up with the funny name? :-D
> +sub check_include()
The parentheses should be gone. This has something to do with
prototypes and should normally not be used.
> +{
> + if ($line =~ m/^\s*#\s*include\s+<(.*)>/) {
> + my $inc = $1;
This could also be written as if (my($inc) = $line =~ ...), and you
bypass the use of $1, which is often error-prone... but it's correct
in this case and is simply a matter of taste.
> + if ($inc =~ m/^asm/ || $inc =~ m/^linux/) {
> + if (!(stat($dir . "/" . $inc))) {
May use unless() instead of if(!()) here. But that's just perl pedantry.
> + printf STDERR "$filename:$lineno: included file '$inc' is not exported\n";
> + $ret = 1;
> + }
> + }
> + }
> +}
More or less the same comments would apply to the next script as well.
> diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
> new file mode 100644
> index 0000000..8aa66af
> --- /dev/null
> +++ b/scripts/headers_install.pl
...
> + $line =~ s/([\s(])__user\s/\1/g;
...
Use of $1 instead of \1 is recommended, see perldoc perlre ("Warning
on \1 vs $1").
Vegard
--
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
-- E. W. Dijkstra, EWD1036
next prev parent reply other threads:[~2008-06-08 10:12 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-08 9:47 Sam Ravnborg
2008-06-08 10:12 ` Vegard Nossum [this message]
2008-06-08 10:41 ` Sam Ravnborg
2008-06-08 10:49 ` David Woodhouse
2008-06-08 11:17 ` Sam Ravnborg
2008-06-08 12:23 ` Oleg Verych
2008-06-08 13:17 ` David Woodhouse
2008-06-08 17:06 ` Segher Boessenkool
2008-06-08 17:34 ` Andreas Schwab
2008-06-08 19:45 ` Segher Boessenkool
2008-06-08 20:36 ` Geert Uytterhoeven
2008-06-08 11:01 ` WANG Cong
2008-06-08 11:18 ` Sam Ravnborg
2008-06-08 11:06 ` Vegard Nossum
2008-06-08 11:20 ` Sam Ravnborg
2008-06-08 11:20 ` David Woodhouse
2008-06-08 11:30 ` Sam Ravnborg
2008-06-08 11:47 ` David Woodhouse
2008-06-08 12:14 ` David Woodhouse
2008-06-08 12:29 ` David Woodhouse
2008-06-08 20:07 ` Sam Ravnborg
2008-06-08 20:58 ` David Woodhouse
2008-06-08 21:13 ` Sam Ravnborg
2008-06-09 6:23 ` Sam Ravnborg
2008-06-08 20:07 ` [PATCH 1/6] kbuild: refactor headers_* targets in Makefile Sam Ravnborg
2008-06-08 20:07 ` [PATCH 2/6] kbuild: always unifdef files in headers_install* Sam Ravnborg
2008-06-08 20:07 ` [PATCH 3/6] kbuild: drop support of ALTARCH for headers_* Sam Ravnborg
2008-06-08 20:07 ` [PATCH 4/6] kbuild: code refactoring in Makefile.headerinst Sam Ravnborg
2008-06-08 20:07 ` [PATCH 5/6] kbuild: error out early in make headers_install Sam Ravnborg
2008-06-09 10:19 ` David Woodhouse
2008-06-08 20:07 ` [PATCH 6/6] kbuild: optimize headers_* targets Sam Ravnborg
2008-06-08 20:37 ` Vegard Nossum
2008-06-08 21:15 ` Sam Ravnborg
2008-06-26 1:59 [PATCH] Speed up "make headers_*" Tim Schmielau
2008-06-26 7:11 ` Adrian Bunk
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=19f34abd0806080312j2b09179cpa384a0460af5874e@mail.gmail.com \
--to=vegard.nossum@gmail.com \
--cc=dwmw2@infradead.org \
--cc=jengelh@computergmbh.de \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sam@ravnborg.org \
--cc=torvalds@linux-foundation.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®