Skip to content

RFC initramfs: reduce buffer footprint

David Disseldorp linux-fsdevel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest6 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6vsprintf: add simple_strntoulinclude/linux/kstrtox.h lib/vsprintf.c+8 -00 replies
2/6initramfs: avoid memcpy for hex header fieldsinit/initramfs.c+3 -60 replies
3/6initramfs: remove extra symlink path bufferinit/initramfs.c+5 -70 replies
4/6initramfs: merge header_buf and name_bufinit/initramfs.c+13 -100 replies
5/6initramfs: reuse buf for built-in and bootloader initramfsinit/initramfs.c+14 -120 replies
6/6initramfs: avoid static buffer for error messageinit/initramfs.c+5 -30 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/6] initramfs: reduce buffer footprint

There are a number of stack, heap and data-segment buffers which are unnecessary for initramfs unpacking. This patchset attempts to remove them by:
- parsing cpio hex strings in place, instead of copying them for nul-termination. (Patches 1 & 2).
- reusing a single heap buffer for cpio header, file and symlink paths, instead of three separate buffers. (Patches 3 & 4).
- reusing the heap-allocated cpio buffer across both builtin and bootloader-provided unpack attempts. (Patch 5).
- reusing the heap-allocated cpio buffer for error messages on FSM-exit, instead of a data-segment buffer. (Patch 6).

I've flagged this as an RFC as I'd like to improve the commit messages and also provide more thorough testing, likely via kunit / kselftest integration.

Feedback appreciated.

David Disseldorp (6):
vsprintf: add simple_strntoul
initramfs: avoid memcpy for hex header fields
initramfs: remove extra symlink path buffer
initramfs: merge header_buf and name_buf
initramfs: reuse buf for built-in and bootloader initramfs
initramfs: avoid static buffer for error message

 include/linux/kstrtox.h |  1 +
 init/initramfs.c        | 50 +++++++++++++++++++++--------------------
 lib/vsprintf.c          |  7 ++++++
 3 files changed, 34 insertions(+), 24 deletions(-)