mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jay Wang <wanjay@amazon.com>
To: <bpf@vger.kernel.org>, <ast@kernel.org>, <daniel@iogearbox.net>,
	<andrii@kernel.org>
Cc: <yonghong.song@linux.dev>, <catalin.marinas@arm.com>,
	<will@kernel.org>, <x86@kernel.org>,
	<dave.hansen@linux.intel.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<abuehaze@amazon.com>, <doebel@amazon.de>,
	<jay.wang.upstream@gmail.com>
Subject: [PATCH bpf-next 0/1] bpf: btf: make vmlinux BTF disposable at boot to save ~5 MiB
Date: Thu, 17 Sep 2026 00:02:00 +0000	[thread overview]
Message-ID: <20260917000201.25581-1-wanjay@amazon.com> (raw)

Based on and tested against mainline commit 9b87fdc9af2f ("Merge tag
'sched_ext-for-7.3-rc3-fixes' of
git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext").

This patch adds a "btf=off" boot parameter that disables the vmlinux BTF
and frees the pages backing it, recovering ~5 MiB.  The reasons for making
it a boot-time choice are below.

A distribution ships one kernel binary to every user, so each CONFIG_*
choice applies to all of them.  CONFIG_DEBUG_INFO_BTF is one where that
hurts: the vmlinux .BTF section stays in rodata for the whole boot,
5.2 MiB on x86-64 and 5.3 MiB on arm64 with a distribution config.  On a
1 GiB VM, a common cloud instance size, that is a visible part of total
memory.  Off takes BTF away from the users who need it; on charges the
users who never touch it.

Letting the user decide at boot follows the existing
CONFIG_SECURITY_SELINUX_BOOTPARAM, which does the same for selinux=0.
With btf=off the kernel behaves as if CONFIG_DEBUG_INFO_BTF were not set,
so nothing can reach the section and its pages are freed.  BPF features
needing kernel type information then fail program load cleanly, exactly as
on a config-off kernel.  By default the parameter is not set and nothing
changes.

The freeing implementation is architecture-specific, and btf=off is
currently supported on x86-64 and arm64.

Testing: x86-64 and arm64 boot with and without btf=off.  With btf=off,
/sys/kernel/btf is absent and ~5 MiB is returned to the page allocator.

Jay Wang (1):
  bpf: btf: add btf=off boot parameter to disable and free vmlinux BTF

 .../admin-guide/kernel-parameters.txt         |  14 +++
 arch/arm64/mm/mmu.c                           | 108 +++++++++++++++++-
 arch/x86/mm/init_64.c                         |  30 +++++
 arch/x86/mm/pat/set_memory.c                  |  28 ++++-
 include/linux/btf.h                           |   9 ++
 kernel/bpf/btf.c                              |  51 ++++++++-
 kernel/bpf/sysfs_btf.c                        |   7 ++
 kernel/bpf/verifier.c                         |   2 +-
 8 files changed, 241 insertions(+), 8 deletions(-)


base-commit: 9b87fdc9af2fbfcdb5c24a64139685ef80f6573f
-- 
2.47.3


             reply	other threads:[~2026-09-17  0:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17  0:02 Jay Wang [this message]
2026-09-17  0:02 ` [PATCH bpf-next 1/1] bpf: btf: add btf=off boot parameter to disable and free vmlinux BTF Jay Wang
2026-09-17  1:56   ` Alexei Starovoitov
2026-09-17  4:07     ` Wang, Jay
2026-09-17  7:10       ` Alan Maguire

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260917000201.25581-1-wanjay@amazon.com \
    --to=wanjay@amazon.com \
    --cc=abuehaze@amazon.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=daniel@iogearbox.net \
    --cc=dave.hansen@linux.intel.com \
    --cc=doebel@amazon.de \
    --cc=jay.wang.upstream@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®