Commit 7dfbea4c authored by Jacob Keller's avatar Jacob Keller Committed by Masahiro Yamada

scripts: remove namespace.pl

namespace.pl is intended to help locate symbols which are defined but
are not used externally. The goal is to avoid bloat of the namespace in
the resulting kernel image.

The script relies on object data, and only finds unused symbols for the
configuration used to generate that object data. This results in a lot
of false positive warnings such as symbols only used by a single
architecture, or symbols which are used externally only under certain
configurations.

Running namespace.pl using allyesconfig, allmodconfig, and
x86_64_defconfig yields the following results:

* allmodconfig
  * 11122 unique symbol names with no external reference
  * 1194 symbols listed as multiply defined
  * 214 symbols it can't resolve
* allyesconfig
  * 10997 unique symbol names with no external reference
  * 1194 symbols listed as multiply defined
  * 214 symbols it can't resolve
* x86_64_defconfig
  * 5757 unique symbol names with no external reference
  * 528 symbols listed as multiply defined
  * 154 symbols it can't resolve

The script also has no way to easily limit the scope of the checks to
a given subset of the kernel, such as only checking for symbols defined
within a module or subsystem.

Discussion on public mailing lists seems to indicate that many view the
tool output as suspect or not very useful (see discussions at [1] and
[2] for further context).

As described by Masahiro Yamada at [2], namespace.pl provides 3 types of
checks: listing multiply defined symbols, resolving external symbols,
and warnings about symbols with no reference.

The first category of issues is easily caught by the linker as any set
of multiply defined symbols should fail to link. The second category of
issues is also caught by linking, as undefined symbols would cause
issues. Even with modules, these types of issues where a module relies
on an external symbol are caught by modpost.

The remaining category of issues reported is the list of symbols with no
external reference, and is the primary motivation of this script.
However, it ought to be clear from the above examples that the output is
difficult to sort through. Even allyesconfig has ~10000 entries.

The current submit-checklist indicates that patches ought to go through
namespacecheck and fix any new issues arising. But that itself presents
problems. As described at [1], many cases of reports are due to
configuration where a function is used externally by some configuration
settings. Prominent maintainers appear to dislike changes modify code
such that symbols become static based on CONFIG_* flags ([3], and [4])

One possible solution is to adjust the advice and indicate that we only
care about the output of namespacecheck on allyesconfig or allmodconfig
builds...

However, given the discussion at [2], I suspect that few people are
actively using this tool. It doesn't have a maintainer in the
MAINTAINERS flie, and it produces so many warnings for unused symbols
that it is difficult to use effectively. Thus, I propose we simply
remove it.

[1] https://lore.kernel.org/netdev/20200708164812.384ae8ea@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com/
[2] https://lore.kernel.org/lkml/20190129204319.15238-1-jacob.e.keller@intel.com/
[3] https://lore.kernel.org/netdev/20190828.154744.2058157956381129672.davem@davemloft.net/
[4] https://lore.kernel.org/netdev/20190827210928.576c5fef@cakuba.netronome.com/Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Acked-by: default avatarRandy Dunlap <rdunlap@infradead.org>
Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
parent 76c37668
...@@ -49,8 +49,7 @@ and elsewhere regarding submitting Linux kernel patches. ...@@ -49,8 +49,7 @@ and elsewhere regarding submitting Linux kernel patches.
9) Check cleanly with sparse. 9) Check cleanly with sparse.
10) Use ``make checkstack`` and ``make namespacecheck`` and fix any problems 10) Use ``make checkstack`` and fix any problems that it finds.
that they find.
.. note:: .. note::
......
...@@ -1576,7 +1576,6 @@ help: ...@@ -1576,7 +1576,6 @@ help:
echo '' echo ''
@echo 'Static analysers:' @echo 'Static analysers:'
@echo ' checkstack - Generate a list of stack hogs' @echo ' checkstack - Generate a list of stack hogs'
@echo ' namespacecheck - Name space analysis on compiled kernel'
@echo ' versioncheck - Sanity check on version.h usage' @echo ' versioncheck - Sanity check on version.h usage'
@echo ' includecheck - Check for duplicate included header files' @echo ' includecheck - Check for duplicate included header files'
@echo ' export_report - List the usages of all exported symbols' @echo ' export_report - List the usages of all exported symbols'
...@@ -1876,7 +1875,7 @@ endif ...@@ -1876,7 +1875,7 @@ endif
# Scripts to check various things for consistency # Scripts to check various things for consistency
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
PHONY += includecheck versioncheck coccicheck namespacecheck export_report PHONY += includecheck versioncheck coccicheck export_report
includecheck: includecheck:
find $(srctree)/* $(RCS_FIND_IGNORE) \ find $(srctree)/* $(RCS_FIND_IGNORE) \
...@@ -1891,9 +1890,6 @@ versioncheck: ...@@ -1891,9 +1890,6 @@ versioncheck:
coccicheck: coccicheck:
$(Q)$(BASH) $(srctree)/scripts/$@ $(Q)$(BASH) $(srctree)/scripts/$@
namespacecheck:
$(PERL) $(srctree)/scripts/namespace.pl
export_report: export_report:
$(PERL) $(srctree)/scripts/export_report.pl $(PERL) $(srctree)/scripts/export_report.pl
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment