[PATCH/RFC] of: Shrink struct of_device_id
Rasmus Villemoes
rasmus.villemoes at prevas.dk
Wed Nov 10 08:51:41 PST 2021
On 10/11/2021 17.23, Geert Uytterhoeven wrote:
> Currently struct of_device_id is 196 (32-bit) or 200 (64-bit) bytes
> large. It contains fixed-size strings for a name, a type, and a
> compatible value, but the first two are barely used.
> OF device ID tables contain multiple entries, plus an empty sentinel
> entry.
>
> Statistics for my current kernel source tree:
> - 4487 tables with 16836 entries (3367200 bytes)
> - 176 names (average 6.7 max 23 chars)
> - 66 types (average 5.1 max 21 chars)
> - 12192 compatible values (average 18.0 max 45 chars)
> Taking into account the minimum needed size to store the strings, only
> 6.9% of the allocated space is used...
>
> Reduce kernel size by reducing the sizes of the fixed strings by one
> half.
Tried something like this 2.5 years ago:
https://lore.kernel.org/lkml/20190425203101.9403-1-linux@rasmusvillemoes.dk/
I think that there might be some not-in-tree code that relies on the
existing layout. I considered adding a CONFIG_ knob, either for these
sizes in particular, or more generally a def_bool y "CONFIG_LEGACY"
which embedded folks that build the entire distro from source and don't
have any legacy things can turn off, and then get more sensible defaults
all around.
Including fx in the TCP stack where some CVE fix required changing some
parameter, but the kernel itself couldn't ship a sane default because
no-regressions, so userspace had to learn to set yet another sysctl
properly.
Rasmus
More information about the linux-riscv
mailing list