mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-14 06:24:53 +08:00
b8cbc0855a
This is part of the general push to deprecate register_sysctl_paths and register_sysctl_table. After removing all the calling functions, we remove both the register_sysctl_table function and the documentation check that appeared in check-sysctl-docs awk script. We save 595 bytes with this change: ./scripts/bloat-o-meter vmlinux.1.refactor-base-paths vmlinux.2.remove-sysctl-table add/remove: 2/8 grow/shrink: 1/0 up/down: 1154/-1749 (-595) Function old new delta count_subheaders - 983 +983 unregister_sysctl_table 29 184 +155 __pfx_count_subheaders - 16 +16 __pfx_unregister_sysctl_table.part 16 - -16 __pfx_register_leaf_sysctl_tables.constprop 16 - -16 __pfx_count_subheaders.part 16 - -16 __pfx___register_sysctl_base 16 - -16 unregister_sysctl_table.part 136 - -136 __register_sysctl_base 478 - -478 register_leaf_sysctl_tables.constprop 524 - -524 count_subheaders.part 547 - -547 Total: Before=21257652, After=21257057, chg -0.00% [mcgrof: remove register_leaf_sysctl_tables and append_path too and add bloat-o-meter stats] Signed-off-by: Joel Granados <j.granados@samsung.com> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> Acked-by: Christian Brauner <brauner@kernel.org>
156 lines
3.7 KiB
Awk
Executable File
156 lines
3.7 KiB
Awk
Executable File
#!/usr/bin/gawk -f
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
# Script to check sysctl documentation against source files
|
|
#
|
|
# Copyright (c) 2020 Stephen Kitt
|
|
|
|
# Example invocation:
|
|
# scripts/check-sysctl-docs -vtable="kernel" \
|
|
# Documentation/admin-guide/sysctl/kernel.rst \
|
|
# $(git grep -l register_sysctl_)
|
|
#
|
|
# Specify -vdebug=1 to see debugging information
|
|
|
|
BEGIN {
|
|
if (!table) {
|
|
print "Please specify the table to look for using the table variable" > "/dev/stderr"
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
# The following globals are used:
|
|
# children: maps ctl_table names and procnames to child ctl_table names
|
|
# documented: maps documented entries (each key is an entry)
|
|
# entries: maps ctl_table names and procnames to counts (so
|
|
# enumerating the subkeys for a given ctl_table lists its
|
|
# procnames)
|
|
# files: maps procnames to source file names
|
|
# paths: maps ctl_path names to paths
|
|
# curpath: the name of the current ctl_path struct
|
|
# curtable: the name of the current ctl_table struct
|
|
# curentry: the name of the current proc entry (procname when parsing
|
|
# a ctl_table, constructed path when parsing a ctl_path)
|
|
|
|
|
|
# Remove punctuation from the given value
|
|
function trimpunct(value) {
|
|
while (value ~ /^["&]/) {
|
|
value = substr(value, 2)
|
|
}
|
|
while (value ~ /[]["&,}]$/) {
|
|
value = substr(value, 1, length(value) - 1)
|
|
}
|
|
return value
|
|
}
|
|
|
|
# Print the information for the given entry
|
|
function printentry(entry) {
|
|
seen[entry]++
|
|
printf "* %s from %s", entry, file[entry]
|
|
if (documented[entry]) {
|
|
printf " (documented)"
|
|
}
|
|
print ""
|
|
}
|
|
|
|
|
|
# Stage 1: build the list of documented entries
|
|
FNR == NR && /^=+$/ {
|
|
if (prevline ~ /Documentation for/) {
|
|
# This is the main title
|
|
next
|
|
}
|
|
|
|
# The previous line is a section title, parse it
|
|
$0 = prevline
|
|
if (debug) print "Parsing " $0
|
|
inbrackets = 0
|
|
for (i = 1; i <= NF; i++) {
|
|
if (length($i) == 0) {
|
|
continue
|
|
}
|
|
if (!inbrackets && substr($i, 1, 1) == "(") {
|
|
inbrackets = 1
|
|
}
|
|
if (!inbrackets) {
|
|
token = trimpunct($i)
|
|
if (length(token) > 0 && token != "and") {
|
|
if (debug) print trimpunct($i)
|
|
documented[trimpunct($i)]++
|
|
}
|
|
}
|
|
if (inbrackets && substr($i, length($i), 1) == ")") {
|
|
inbrackets = 0
|
|
}
|
|
}
|
|
}
|
|
|
|
FNR == NR {
|
|
prevline = $0
|
|
next
|
|
}
|
|
|
|
|
|
# Stage 2: process each file and find all sysctl tables
|
|
BEGINFILE {
|
|
delete children
|
|
delete entries
|
|
delete paths
|
|
curpath = ""
|
|
curtable = ""
|
|
curentry = ""
|
|
if (debug) print "Processing file " FILENAME
|
|
}
|
|
|
|
/^static struct ctl_path/ {
|
|
match($0, /static struct ctl_path ([^][]+)/, tables)
|
|
curpath = tables[1]
|
|
if (debug) print "Processing path " curpath
|
|
}
|
|
|
|
/^static struct ctl_table/ {
|
|
match($0, /static struct ctl_table ([^][]+)/, tables)
|
|
curtable = tables[1]
|
|
if (debug) print "Processing table " curtable
|
|
}
|
|
|
|
/^};$/ {
|
|
curpath = ""
|
|
curtable = ""
|
|
curentry = ""
|
|
}
|
|
|
|
curpath && /\.procname[\t ]*=[\t ]*".+"/ {
|
|
match($0, /.procname[\t ]*=[\t ]*"([^"]+)"/, names)
|
|
if (curentry) {
|
|
curentry = curentry "/" names[1]
|
|
} else {
|
|
curentry = names[1]
|
|
}
|
|
if (debug) print "Setting path " curpath " to " curentry
|
|
paths[curpath] = curentry
|
|
}
|
|
|
|
curtable && /\.procname[\t ]*=[\t ]*".+"/ {
|
|
match($0, /.procname[\t ]*=[\t ]*"([^"]+)"/, names)
|
|
curentry = names[1]
|
|
if (debug) print "Adding entry " curentry " to table " curtable
|
|
entries[curtable][curentry]++
|
|
file[curentry] = FILENAME
|
|
}
|
|
|
|
/\.child[\t ]*=/ {
|
|
child = trimpunct($NF)
|
|
if (debug) print "Linking child " child " to table " curtable " entry " curentry
|
|
children[curtable][curentry] = child
|
|
}
|
|
|
|
END {
|
|
for (entry in documented) {
|
|
if (!seen[entry]) {
|
|
print "No implementation for " entry
|
|
}
|
|
}
|
|
}
|