e9a7729008
Provide infrastructure to auto-configure to enum and API changes in the global page stats used for our free memory calculations. arc_free_memory has been broken since an API change in Linux v3.14: 2016-07-28 v4.8 599d0c95 mm, vmscan: move LRU lists to node 2016-07-28 v4.8 75ef7184 mm, vmstat: add infrastructure for per-node vmstats These commits moved some of global_page_state() into global_node_page_state(). The API change was particularly egregious as, instead of breaking the old code, it silently did the wrong thing and we continued using global_page_state() where we should have been using global_node_page_state(), thus indexing into the wrong array via NR_SLAB_RECLAIMABLE et al. There have been further API changes along the way: 2017-07-06 v4.13 385386cf mm: vmstat: move slab statistics from zone to node counters 2017-09-06 v4.14 c41f012a mm: rename global_page_state to global_zone_page_state ...and various (incomplete, as it turns out) attempts to accomodate these changes in ZoL: 2017-08-242209e409
Linux 4.8+ compatibility fix for vm stats 2017-09-16787acae0
Linux 3.14 compat: IO acct, global_page_state, etc 2017-09-19 661907e6 Linux 4.14 compat: IO acct, global_page_state, etc The config infrastructure provided here resolves these issues going back to the original API change in v3.14 and is robust against further Linux changes in this area. Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: George Melikov <mail@gmelikov.ru> Signed-off-by: Chris Dunlop <chris@onthe.net.au> Closes #7170
59 lines
955 B
Perl
Executable File
59 lines
955 B
Perl
Executable File
#!/usr/bin/perl -w
|
|
|
|
my $usage = <<EOT;
|
|
usage: config-enum enum [file ...]
|
|
|
|
Returns the elements from an enum declaration.
|
|
|
|
"Best effort": we're not building an entire C interpreter here!
|
|
EOT
|
|
|
|
use warnings;
|
|
use strict;
|
|
use Getopt::Std;
|
|
|
|
my %opts;
|
|
|
|
if (!getopts("", \%opts) || @ARGV < 1) {
|
|
print $usage;
|
|
exit 2;
|
|
}
|
|
|
|
my $enum = shift;
|
|
|
|
my $in_enum = 0;
|
|
|
|
while (<>) {
|
|
# comments
|
|
s/\/\*.*\*\///;
|
|
if (m/\/\*/) {
|
|
while ($_ .= <>) {
|
|
last if s/\/\*.*\*\///s;
|
|
}
|
|
}
|
|
|
|
# preprocessor stuff
|
|
next if /^#/;
|
|
|
|
# find our enum
|
|
$in_enum = 1 if s/^\s*enum\s+${enum}(?:\s|$)//;
|
|
next unless $in_enum;
|
|
|
|
# remove explicit values
|
|
s/\s*=[^,]+,/,/g;
|
|
|
|
# extract each identifier
|
|
while (m/\b([a-z_][a-z0-9_]*)\b/ig) {
|
|
print $1, "\n";
|
|
}
|
|
|
|
#
|
|
# don't exit: there may be multiple versions of the same enum, e.g.
|
|
# inside different #ifdef blocks. Let's explicitly return all of
|
|
# them and let external tooling deal with it.
|
|
#
|
|
$in_enum = 0 if m/}\s*;/;
|
|
}
|
|
|
|
exit 0;
|