Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) #!/usr/bin/env perl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) # Read two files produced by the stackusage script, and show the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) # delta between them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) # Currently, only shows changes for functions listed in both files. We
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) # could add an option to show also functions which have vanished or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) # appeared (which would often be due to gcc making other inlining
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) # decisions).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) # Another possible option would be a minimum absolute value for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) # delta.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) # A third possibility is for sorting by delta, but that can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) # achieved by piping to sort -k5,5g.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) sub read_stack_usage_file {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)     my %su;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)     my $f = shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)     open(my $fh, '<', $f)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	or die "cannot open $f: $!";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)     while (<$fh>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	chomp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	my ($file, $func, $size, $type) = split;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	# Old versions of gcc (at least 4.7) have an annoying quirk in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	# that a (static) function whose name has been changed into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	# for example ext4_find_unwritten_pgoff.isra.11 will show up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	# in the .su file with a name of just "11". Since such a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	# numeric suffix is likely to change across different
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	# commits/compilers/.configs or whatever else we're trying to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	# tweak, we can't really track those functions, so we just
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	# silently skip them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	# Newer gcc (at least 5.0) report the full name, so again,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	# since the suffix is likely to change, we strip it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	next if $func =~ m/^[0-9]+$/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	$func =~ s/\..*$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	# Line numbers are likely to change; strip those.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	$file =~ s/:[0-9]+$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	$su{"${file}\t${func}"} = {size => $size, type => $type};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)     close($fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)     return \%su;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) @ARGV == 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)     or die "usage: $0 <old> <new>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) my $old = read_stack_usage_file($ARGV[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) my $new = read_stack_usage_file($ARGV[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) my @common = sort grep {exists $new->{$_}} keys %$old;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) for (@common) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)     my $x = $old->{$_}{size};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)     my $y = $new->{$_}{size};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)     my $delta = $y - $x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)     if ($delta) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	printf "%s\t%d\t%d\t%+d\n", $_, $x, $y, $delta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }