[PATCH v2 0/6] module: avoid userspace pressure on unwanted allocations

From: Luis Chamberlain
Date: Tue Apr 04 2023 - 22:27:33 EST


This v2 series follows up on the first iteration of these patches [0].
They have the following changes made:

o Rolled in fix for an kmemleak issue reported by Jim Cromie
o Dropped from this series all the semaphore & and simplifications
on kmod.c as that should just be sent as a separate bike-shedding
opporunity patch series and it does not in any way address the
the unwanted allocations.
o The rest of the feedback was just from Greg KH and I've addressed
all his feedback. I decided to do away with the debug.c as a
separate file and leave the #ifdef CONFIG_MODULE_DEBUG eyesore
at the end of main.c. I guess it's not so bad there.
o *Tons* of fixes and enhancements to my counters, including tons
of documentation to help ensure we don't loose track of some of
the tribal knowledge and so to help ensure we have references to
what our accounting looks like. Those large wasted virtual memory
allocations on a simple qemu idle boring boot are simply rediculous, I
am quite baffled we had not spotted this before, and so it all reveals
we have quite a bit of optimizations left to do to make loading modules
an even more smoother experience at bootup.

If you'd like a tree this is on my 20230404-module-alloc-opts branch based
on modules-next [1].

[0] https://lkml.kernel.org/r/20230329053149.3976378-1-mcgrof@xxxxxxxxxx
[1] https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/log/?h=20230404-module-alloc-opts

Luis Chamberlain (6):
module: fix kmemleak annotations for non init ELF sections
module: move finished_loading()
module: extract patient module check into helper
module: avoid allocation if module is already present and ready
debugfs: add debugfs_create_atomic64_t for atomic64_t
module: add debug stats to help identify memory pressure

Documentation/core-api/kernel-api.rst | 22 +-
fs/debugfs/file.c | 36 +++
include/linux/debugfs.h | 2 +
kernel/module/Kconfig | 37 +++
kernel/module/Makefile | 1 +
kernel/module/decompress.c | 4 +
kernel/module/internal.h | 74 +++++
kernel/module/main.c | 198 ++++++++----
kernel/module/stats.c | 428 ++++++++++++++++++++++++++
kernel/module/tracking.c | 7 +-
10 files changed, 742 insertions(+), 67 deletions(-)
create mode 100644 kernel/module/stats.c

--
2.39.2