mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jay Wang <wanjay@amazon.com>
To: <bot+bpf-ci@kernel.org>, <bpf@vger.kernel.org>, <ast@kernel.org>,
	<daniel@iogearbox.net>, <andrii@kernel.org>, <eddyz87@gmail.com>,
	<memxor@gmail.com>
Cc: <alan.maguire@oracle.com>, <martin.lau@linux.dev>,
	<yonghong.song@linux.dev>, <nathan@kernel.org>, <nsc@kernel.org>,
	<linux-kbuild@vger.kernel.org>, <mcgrof@kernel.org>,
	<petr.pavlu@suse.com>, <linux-modules@vger.kernel.org>,
	<arnd@arndb.de>, <linux-kernel@vger.kernel.org>,
	<abuehaze@amazon.com>, <doebel@amazon.de>,
	<jay.wang.upstream@gmail.com>, <martin.lau@kernel.org>,
	<mason@kernel.org>, <ihor.solodrai@linux.dev>
Subject: Re: [PATCH bpf-next 5/6] bpf: defer registrations until the vmlinux BTF is available
Date: Fri, 25 Sep 2026 23:02:48 +0000	[thread overview]
Message-ID: <20260925230248.33699-1-wanjay@amazon.com> (raw)
In-Reply-To: <f0a28d1ffadcd0dbc3209da34afb902c4911ad9e31cd90a1b640d4c1592cf11d@mail.kernel.org>

Addressed since v2; the current version is v3 (patches 5-7/9):
https://lore.kernel.org/bpf/20260925224229.1850-1-wanjay@amazon.com/

Most of these are real, and btf_parse_deferred_modules() is
restructured around them:

- A module BTF is now published (btf_mod->btf set, id allocated) only
  after its queued registrations are applied, so no program can see a
  module BTF without its kfuncs, same as for vmlinux.

- Only modules that have reached MODULE_STATE_LIVE are replayed there,
  with the module pinned, so nothing registers concurrently on the same
  BTF and the module cannot go away underneath.  A module still in its
  init when the vmlinux BTF arrives is only published; the LIVE notifier
  applies what its init queued once init has returned, in the loader's
  own thread, and a failed init frees the queue at GOING.  This covers
  both the concurrent krealloc() on kfunc_set_tab and the
  try_module_get()-on-a-COMING-module lifetime issue.

- On btf_alloc_id() failure the buffer the sysfs file points at is no
  longer freed: it is handed back to the entry, which stays on the list
  as a dead entry until the module goes, and only GOING removes the file
  and then frees the data.

- Modules with a .BTF.base section: their sysfs file is still created at
  load time with the final size, but its reader loads the vmlinux BTF
  and waits until this module's BTF has been relocated and published
  before serving anything, so no unrelocated or half-relocated data is
  ever visible; modules without one are served as before, their data is
  final.  Because that reader may be the thread doing the deferred
  parsing, sysfs files are no longer removed from that path (a failed
  entry stays dead until the module goes) and MODULE_STATE_GOING removes
  the file after dropping btf_module_mutex.  Tested with an out-of-tree
  module (distilled .BTF.base, kfunc registered from init) loaded before
  the vmlinux BTF, with its own sysfs file as the first user.

- sysfs file creation failure is non-fatal in the deferred path too.

- The btf_struct_ops_register() stub is only defined when
  BTF_MODULE_NOTIFIER is; checked with BPF_JIT=n.

- Lock ordering: the vmlinux queue has its own mutex, so nothing takes
  btf_module_mutex under btf_vmlinux_lock any more (the kfunc name
  check returns early for the vmlinux BTF), and CO-RE fetches the
  vmlinux BTF before taking cand_cache_mutex, bpf_core_find_cands()
  only peeks.  That removes both new edges of the cycle.  lockdep is
  clean with CO-RE programs, module BTF and rmmod in the same boot.

- The vmlinux queue on parse failure: with =m the failure is no longer
  cached (see 3/6), so the queue is intentionally kept for the retry;
  bpf_ctx_convert.t is reset so nothing dangles.

Jay

  reply	other threads:[~2026-09-25 23:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23  5:39 [PATCH bpf-next 0/6] bpf: make the vmlinux BTF an on-demand loadable module (CONFIG_DEBUG_INFO_BTF=m) to save ~5.4 MB memory Jay Wang
2026-09-23  5:39 ` [PATCH bpf-next 1/6] bpf: pass the vmlinux BTF to btf_parse_module() and let it adopt the data Jay Wang
2026-09-23  5:39 ` [PATCH bpf-next 2/6] bpf: split the kfunc, dtor kfunc and struct_ops registration bodies Jay Wang
2026-09-23  6:16   ` bot+bpf-ci
2026-09-25 23:02     ` Jay Wang
2026-09-23  5:39 ` [PATCH bpf-next 3/6] bpf: fetch the vmlinux BTF where kernel types enter a program Jay Wang
2026-09-23  6:28   ` bot+bpf-ci
2026-09-24 11:26     ` Jiri Olsa
2026-09-25 23:02       ` Jay Wang
2026-09-25 23:02     ` Jay Wang
2026-09-23  5:39 ` [PATCH bpf-next 4/6] bpf: take the vmlinux BTF from the btf_vmlinux module Jay Wang
2026-09-23  5:39 ` [PATCH bpf-next 5/6] bpf: defer registrations until the vmlinux BTF is available Jay Wang
2026-09-23  6:41   ` bot+bpf-ci
2026-09-25 23:02     ` Jay Wang [this message]
2026-09-23  5:39 ` [PATCH bpf-next 6/6] kbuild, bpf: allow building the vmlinux BTF as a module Jay Wang
2026-09-23  8:27 ` [PATCH bpf-next 0/6] bpf: make the vmlinux BTF an on-demand loadable module (CONFIG_DEBUG_INFO_BTF=m) to save ~5.4 MB memory Alan Maguire
2026-09-25 21:23   ` Jay Wang

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=20260925230248.33699-1-wanjay@amazon.com \
    --to=wanjay@amazon.com \
    --cc=abuehaze@amazon.com \
    --cc=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=arnd@arndb.de \
    --cc=ast@kernel.org \
    --cc=bot+bpf-ci@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=doebel@amazon.de \
    --cc=eddyz87@gmail.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=jay.wang.upstream@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mason@kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=memxor@gmail.com \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    --cc=petr.pavlu@suse.com \
    --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®