Skip to content

RFC vmalloc_exec for modules and BPF programs

Song Liu linux-mm lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 RFC Latest4 patches 24 repliesIn review
  2. v1 RFC5 patches 14 repliesSuperseded

Changes in v2 from the cover letter

1. Major rewrite of the logic of vmalloc_exec and vfree_exec. They now work fine with BPF programs (patch 1, 2, 4). But module side (patch 3) still need some work.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4vmalloc: introduce vmalloc_exec and vfree_execinclude/linux/vmalloc.h mm/nommu.c mm/vmalloc.c+278 -03 replies
2/4bpf: use vmalloc_execkernel/bpf/core.c+10 -1450 replies
3/4modules, x86: use vmalloc_exec for module corearch/x86/Kconfig arch/x86/kernel/alternative.c arch/x86/kernel/module.c +3 more+41 -205 replies
4/4vmalloc_exec: share a huge page with kernel textarch/x86/mm/init_64.c mm/vmalloc.c+26 -18 replies

Reviews trailers per patch

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

Read the v2 thread

Cover letter [RFC v2 0/4] vmalloc_exec for modules and BPF programs

Changes RFC v1 => RFC v2:
1. Major rewrite of the logic of vmalloc_exec and vfree_exec. They now work fine with BPF programs (patch 1, 2, 4). But module side (patch 3) still need some work.

This set is a prototype that allows dynamic kernel text (modules, bpf programs, various trampolines, etc.) to share huge pages. The idea is similar to Peter's suggestion in [1]. Please refer to each patch for more detais.

The ultimate goal is to only host kernel text in 2MB pages (for x86_64).

Please share your comments on this.

Thanks!

[1] https://lore.kernel.org/bpf/[email protected]/
[2] RFC v1: https://lore.kernel.org/linux-mm/[email protected]/T/

Song Liu (4):
vmalloc: introduce vmalloc_exec and vfree_exec
bpf: use vmalloc_exec
modules, x86: use vmalloc_exec for module core
vmalloc_exec: share a huge page with kernel text

 arch/x86/Kconfig              |   1 +
 arch/x86/kernel/alternative.c |  30 +++-
 arch/x86/kernel/module.c      |   1 +
 arch/x86/mm/init_64.c         |   3 +-
 include/linux/vmalloc.h       |   2 +
 kernel/bpf/core.c             | 155 ++----------------
 kernel/module/main.c          |  23 +--
 kernel/module/strict_rwx.c    |   3 -
 kernel/trace/ftrace.c         |   3 +-
 mm/nommu.c                    |   7 +
 mm/vmalloc.c                  | 296 ++++++++++++++++++++++++++++++++++
 11 files changed, 358 insertions(+), 166 deletions(-)

--
2.30.2