[PATCH 0/2] module: avoid all memory pressure due to duplicates

Luis Chamberlain
2023-05-24T21:36:39Z

We now know that duplicate kernel module loading can incur considerable
vmalloc memory pressure on boot. Module loading uses vmalloc space 3 times
in the worst case. Detecting duplicates early before processing the module
name was the last mile we had to go and we recently were debating if userspace
should fix this or the kernel should fix this. We decided to punt the problem
to userspace.

At LSFMM 2023 in Vancouver this year I talked to Lennart Poettering about this
and described the issue with udev. Fixing this in userspace would be complex,
and it was preferable if we could resolve this in-kernel. And indeed it is
possible to resolve it relatively easily in-kernel with just the inode. So
let's do that and be done with the issue.

Patch #2 has the details on the savings on a 255 CPU system.

With this we get 0 bytes wasted incurred due to duplicates.

Luis Chamberlain (2):
fs/kernel_read_file: add support for duplicate detection
module: add support to avoid duplicates early on load

fs/Kconfig | 3 +
fs/kernel_read_file.c | 124 +++++++++++++++++++++++++++++++
include/linux/kernel_read_file.h | 14 ++++
include/linux/module.h | 1 +
kernel/module/Kconfig | 20 +++++
kernel/module/internal.h | 1 +
kernel/module/main.c | 19 +++--
7 files changed, 175 insertions(+), 7 deletions(-)

--
2.39.2