The patch titled KBUILD: export-symbol usage report generator (upadte) has been added to the -mm tree. Its filename is kbuild-export-symbol-usage-report-generator-update.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: KBUILD: export-symbol usage report generator (upadte) From: Ram Pai <linuxram@xxxxxxxxxx> Provide the ability to generate a report of (1) All the exported symbols and their in-kernel-module usage count (2) For each module, lists the modules and their exported symbols, on which it depends. the report can be generated by executing: perl scripts/export_report The tool warns if the modules are not built using MODVERSIONING. Signed-off-by: Ram Pai <linuxram@xxxxxxxxxx> Cc: Sam Ravnborg <sam@xxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- scripts/export_report.pl | 51 ++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 15 deletions(-) diff -puN scripts/export_report.pl~kbuild-export-symbol-usage-report-generator-update scripts/export_report.pl --- a/scripts/export_report.pl~kbuild-export-symbol-usage-report-generator-update +++ a/scripts/export_report.pl @@ -4,7 +4,7 @@ # Released under GPL v2. # Author : Ram Pai (linuxram@xxxxxxxxxx) # -# Usage: export_report.pl -k Module.symvers [-o report_file ] *.mod.c +# Usage: export_report.pl -k Module.symvers [-o report_file ] -f *.mod.c # use Getopt::Std; @@ -38,12 +38,20 @@ sub print_depends_on { } sub usage { - die "Usage: @_ -h -k Module.symvers [ -o outputfile ] -f all the .mod.c files \n"; + print "Usage: @_ -h -k Module.symvers [ -o outputfile ] \n", + "\t-f: treat all the non-option argument as .mod.c files. ", + "Recommend using this as the last option\n", + "\t-h: print detailed help\n", + "\t-k: the path to Module.symvers file. By default uses ", + "the file from the current directory\n", + "\t-o outputfile: output the report to outputfile\n"; + exit 0; } sub collectcfiles { my @file = `cat .tmp_versions/*.mod | grep '.*\.ko\$'`; @file = grep {s/\.ko/.mod.c/} @file; + chomp @file; return @file; } @@ -67,7 +75,6 @@ unless (open(MODULE_SYMVERS, $opt{'k'})) die "Sorry, cannot open $opt{'k'}: $!\n"; } - if (defined $opt{'o'}) { unless (open(OUTPUT_HANDLE, ">$opt{'o'}")) { die "Sorry, cannot open $opt{'o'} $!\n"; @@ -93,29 +100,43 @@ foreach my $thismod (@allcfiles) { print "Sorry, cannot open $thismod: $!\n"; next; } + my $state=0; while ( <MODULE_MODULE> ) { chomp; - if ( $_ !~ /0x[0-9a-f]{7,8},/ ) { + if ($state eq 0) { + $state = 1 if ($_ =~ /static const struct modversion_info/); + next; + } + if ($state eq 1) { + $state = 2 if ($_ =~ /__attribute__\(\(section\("__versions"\)\)\)/); next; } - my $sym = (split /([,"])/,)[4]; - my ($module, $value, $symbol, $gpl) = @{$SYMBOL{$sym}}; - $SYMBOL{ $sym } = [ $module, $value+1, $symbol, $gpl]; - push(@{$MODULE{$thismod}} , $sym); + if ($state eq 2) { + if ( $_ !~ /0x[0-9a-f]{7,8},/ ) { + next; + } + my $sym = (split /([,"])/,)[4]; + my ($module, $value, $symbol, $gpl) = @{$SYMBOL{$sym}}; + $SYMBOL{ $sym } = [ $module, $value+1, $symbol, $gpl]; + push(@{$MODULE{$thismod}} , $sym); + } + } + if ($state ne 2) { + print "WARNING:$thismod is not built with CONFIG_MODVERSION enabled\n"; } close(MODULE_MODULE); } -print "\tTHIS FILE REPORTS THE USAGE PATTERNS OF EXPORTED SYMBOLS BY IN_TREE\n"; -print "\t\t\t\tMODULES\n"; +print "\tThis file reports the exported symbols usage patterns by in-tree\n", + "\t\t\t\tmodules\n"; printf("%s\n\n\n","x"x80); printf("\t\t\t\tINDEX\n\n\n"); -printf("SECTION 1: USAGE COUNTS OF ALL EXPORTED SYMBOLS\n"); -printf("SECTION 2: LIST OF MODULES AND THE EXPORTED SYMBOLS THEY USE\n"); +printf("SECTION 1: Usage counts of all exported symbols\n"); +printf("SECTION 2: List of modules and the exported symbols they use\n"); printf("%s\n\n\n","x"x80); -printf("SECTION 1:\tTHE EXPORTED SYMBOLS AND THEIR USAGE COUNT\n\n"); -printf("%-25s\t%-25s\t%-5s\t%-25s\n", "SYMBOL", "MODULE", "USAGE COUNT", - "EXPORT TYPE"); +printf("SECTION 1:\tThe exported symbols and their usage count\n\n"); +printf("%-25s\t%-25s\t%-5s\t%-25s\n", "Symbol", "Module", "Usage count", + "export type"); # # print the list of unused exported symbols _ Patches currently in -mm which might be from linuxram@xxxxxxxxxx are git-kbuild.patch kbuild-export-symbol-usage-report-generator.patch kbuild-export-symbol-usage-report-generator-update.patch core-use-list_move.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html