trying to identify "unused" Kconfig "config" symbols

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  I'll throw out one more possible cleanup that is a lot trickier than
it looks; I have a script from years ago that tried to do this but it
still generated tons of false positives so I'm open to anyone else
taking a crack at this (unless there is already a script that does
this somewhere).

  By "unused config symbol," I mean a config-type definition in a
Kconfig* file of the form:

  config FUBAR
      ... definition of FUBAR ...

Turning this question around, what does it mean that that symbol is
being "used" in some way? Lots of possibilities:

  1) some other symbol might depend on it
  2) some preprocessor line might test it
  3) this definition might "select" another symbol

You see what I mean -- there are a number of checks you would have to
do to confidently say, "No, nothing in the kernel source tree is
making use of the FUBAR Kconfig symbol."  So let's take a look at an
example.

  I ran my old script just on the arch/riscv/ directory and was
informed that the config symbol RISCV_SLOW_UNALIGNED_ACCESS appears to
be unused. So let's take a look at that file and some of the other
symbols surrounding it, which you can see here:

  https://github.com/torvalds/linux/blob/master/arch/riscv/Kconfig#L952

I'll reproduce some of the symbols in question (cutting out the help
content for brevity):

  config RISCV_PROBE_UNALIGNED_ACCESS
        bool "Probe for hardware unaligned access support"
        select RISCV_SCALAR_MISALIGNED

  config RISCV_EMULATED_UNALIGNED_ACCESS
        bool "Emulate unaligned access where system support is missing"
        select RISCV_SCALAR_MISALIGNED

  config RISCV_SLOW_UNALIGNED_ACCESS
        bool "Assume the system supports slow unaligned memory accesses"
        depends on NONPORTABLE

Out of those three symbols, only the third is accused of being unused.
So why are the first two "used"? Well, they "select" other stuff so
you'd have to trace that down. More to the point, if you just grep
for, say, the first one, you can see it's referenced in a number of
places:

$ grep -r RISCV_PROBE_UNALIGNED_ACCESS *
arch/riscv/include/asm/cpufeature.h:#if defined(CONFIG_RISCV_PROBE_UNALIGNED_ACCESS)
arch/riscv/Kconfig:	default RISCV_PROBE_UNALIGNED_ACCESS
arch/riscv/Kconfig:config RISCV_PROBE_UNALIGNED_ACCESS
arch/riscv/kernel/sys_hwprobe.c:#if defined(CONFIG_RISCV_PROBE_UNALIGNED_ACCESS)
arch/riscv/kernel/unaligned_access_speed.c:#ifdef CONFIG_RISCV_PROBE_UNALIGNED_ACCESS
arch/riscv/kernel/unaligned_access_speed.c:#else /* CONFIG_RISCV_PROBE_UNALIGNED_ACCESS */
... etc etc ...

and the same with the second one. But what about
RISCV_SLOW_UNALIGNED_ACCESS? Well, its definition doesn't select
anything else, and if you grep for it in the entire source tree:

$ grep -r RISCV_SLOW_UNALIGNED_ACCESS *
arch/riscv/Kconfig:config RISCV_SLOW_UNALIGNED_ACCESS
$

That's it. So is that sufficient to say that that symbol is unused?
You're invited to poke at that symbol and confirm that it does not
appear to have any *current* value or purpose.

  So that's a possibility for cleanup but, in general, identifying
allagedly "unused" Kconfig symbols is *hard*.

  Thoughts?

rday





[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux