Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1210355 > unrolled thread
| Started by | Rasmus Villemoes <linux@rasmusvillemoes.dk> |
|---|---|
| First post | 2015-08-20 12:00 +0200 |
| Last post | 2015-08-28 17:10 +0200 |
| Articles | 5 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v3 0/4] scripts: add stack{usage,delta} scripts Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-08-20 12:00 +0200
[PATCH v3 3/4] kbuild: remove *.su files generated by -fstack-usage Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-08-20 12:00 +0200
[PATCH v3 2/4] .gitignore: add *.su pattern Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-08-20 12:00 +0200
[PATCH v3 4/4] scripts: add stackdelta script Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-08-20 12:00 +0200
Re: [PATCH v3 0/4] scripts: add stack{usage,delta} scripts Michal Marek <mmarek@suse.cz> - 2015-08-28 17:10 +0200
| From | Rasmus Villemoes <linux@rasmusvillemoes.dk> |
|---|---|
| Date | 2015-08-20 12:00 +0200 |
| Subject | [PATCH v3 0/4] scripts: add stack{usage,delta} scripts |
| Message-ID | <pZuNA-1gR-5@gated-at.bofh.it> |
On Wed, Aug 19 2015, Michal Marek <mmarek@suse.cz> wrote: > Do you plan any new iterations, or is this final despite the [RFC]? > If it's final, I will apply it. It's final, modulo a few typos I spotted. I took the opportunity to fix those and send with a PATCH prefix. === The current checkstack.pl script has a few problems, stemming from the overly simplistic attempt at parsing objdump output with regular expressions. Since gcc 4.6 introduced the -fstack-usage option, we can now get the exact stack use instead of resorting to ad hoc methods. This introduces two small scripts. One for running make with KCFLAGS set to -fstack-usage, followed by collecting the generated .su files in a single output file. Another for taking two such output files and computing the changes in stack use. 2/4 and 3/4 may be too small by themselves; they can easily be squashed into 1/4. v2: Use KCFLAGS instead of EXTRA_CFLAGS. A few more details in commit messages. Simpler option handling in stackusage. Removed accidental leftover debug prints. v3: Fix a few typos. Rasmus Villemoes (4): scripts: add stackusage script .gitignore: add *.su pattern kbuild: remove *.su files generated by -fstack-usage scripts: add stackdelta script .gitignore | 1 + Makefile | 1 + scripts/stackdelta | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/stackusage | 33 ++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100755 scripts/stackdelta create mode 100755 scripts/stackusage -- 2.1.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Rasmus Villemoes <linux@rasmusvillemoes.dk> |
|---|---|
| Date | 2015-08-20 12:00 +0200 |
| Subject | [PATCH v3 3/4] kbuild: remove *.su files generated by -fstack-usage |
| Message-ID | <pZuNB-1gR-27@gated-at.bofh.it> |
| In reply to | #1210355 |
Make sure 'make clean' removes *.su files generated by the gcc option -fstack-usage. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 6e88c371b32f..a3b3499f94e5 100644 --- a/Makefile +++ b/Makefile @@ -1433,6 +1433,7 @@ clean: $(clean-dirs) \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ -o -name '*.ko.*' \ -o -name '*.dwo' \ + -o -name '*.su' \ -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ -o -name '*.symtypes' -o -name 'modules.order' \ -o -name modules.builtin -o -name '.tmp_*.o.*' \ -- 2.1.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Rasmus Villemoes <linux@rasmusvillemoes.dk> |
|---|---|
| Date | 2015-08-20 12:00 +0200 |
| Subject | [PATCH v3 2/4] .gitignore: add *.su pattern |
| Message-ID | <pZuND-1gR-57@gated-at.bofh.it> |
| In reply to | #1210355 |
Ignore the *.su files generated by using the gcc option -fstack-usage. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4ad4a98b884b..9e51ead66a55 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ modules.builtin Module.symvers *.dwo +*.su # # Top-level generic files -- 2.1.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Rasmus Villemoes <linux@rasmusvillemoes.dk> |
|---|---|
| Date | 2015-08-20 12:00 +0200 |
| Subject | [PATCH v3 4/4] scripts: add stackdelta script |
| Message-ID | <pZuND-1gR-71@gated-at.bofh.it> |
| In reply to | #1210355 |
This adds a simple perl script for reading two files as produced by
the stackusage script and computing the changes in stack usage. For
example:
$ scripts/stackusage -o /tmp/old.su CC=gcc-4.7 -j8 fs/ext4/
$ scripts/stackusage -o /tmp/new.su CC=gcc-5.0 -j8 fs/ext4/
$ scripts/stackdelta /tmp/{old,new}.su | sort -k5,5g
shows that gcc 5.0 generally produces less stack-hungry code than gcc
4.7. Obviously, the script can also be used for measuring the effect
of commits, .config tweaks or whatnot.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
scripts/stackdelta | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
create mode 100755 scripts/stackdelta
diff --git a/scripts/stackdelta b/scripts/stackdelta
new file mode 100755
index 000000000000..48eabf2f48f8
--- /dev/null
+++ b/scripts/stackdelta
@@ -0,0 +1,59 @@
+#!/usr/bin/perl
+
+# Read two files produced by the stackusage script, and show the
+# delta between them.
+#
+# Currently, only shows changes for functions listed in both files. We
+# could add an option to show also functions which have vanished or
+# appeared (which would often be due to gcc making other inlining
+# decisions).
+#
+# Another possible option would be a minimum absolute value for the
+# delta.
+#
+# A third possibility is for sorting by delta, but that can be
+# achieved by piping to sort -k5,5g.
+
+sub read_stack_usage_file {
+ my %su;
+ my $f = shift;
+ open(my $fh, '<', $f)
+ or die "cannot open $f: $!";
+ while (<$fh>) {
+ chomp;
+ my ($file, $func, $size, $type) = split;
+ # Old versions of gcc (at least 4.7) have an annoying quirk in
+ # that a (static) function whose name has been changed into
+ # for example ext4_find_unwritten_pgoff.isra.11 will show up
+ # in the .su file with a name of just "11". Since such a
+ # numeric suffix is likely to change across different
+ # commits/compilers/.configs or whatever else we're trying to
+ # tweak, we can't really track those functions, so we just
+ # silently skip them.
+ #
+ # Newer gcc (at least 5.0) report the full name, so again,
+ # since the suffix is likely to change, we strip it.
+ next if $func =~ m/^[0-9]+$/;
+ $func =~ s/\..*$//;
+ # Line numbers are likely to change; strip those.
+ $file =~ s/:[0-9]+$//;
+ $su{"${file}\t${func}"} = {size => $size, type => $type};
+ }
+ close($fh);
+ return \%su;
+}
+
+@ARGV == 2
+ or die "usage: $0 <old> <new>";
+
+my $old = read_stack_usage_file($ARGV[0]);
+my $new = read_stack_usage_file($ARGV[1]);
+my @common = sort grep {exists $new->{$_}} keys %$old;
+for (@common) {
+ my $x = $old->{$_}{size};
+ my $y = $new->{$_}{size};
+ my $delta = $y - $x;
+ if ($delta) {
+ printf "%s\t%d\t%d\t%+d\n", $_, $x, $y, $delta;
+ }
+}
--
2.1.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Michal Marek <mmarek@suse.cz> |
|---|---|
| Date | 2015-08-28 17:10 +0200 |
| Message-ID | <q2trY-6Qn-23@gated-at.bofh.it> |
| In reply to | #1210355 |
On 2015-08-20 11:53, Rasmus Villemoes wrote: > On Wed, Aug 19 2015, Michal Marek <mmarek@suse.cz> wrote: > >> Do you plan any new iterations, or is this final despite the [RFC]? >> If it's final, I will apply it. > > It's final, modulo a few typos I spotted. I took the opportunity to > fix those and send with a PATCH prefix. Thanks. I applied the series to kbuild.git#misc now. Michal -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web