BPF List
 help / color / mirror / Atom feed
From: Xu Kuohai <xukuohai@huaweicloud.com>
To: bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	John Fastabend <john.fastabend@gmail.com>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	Jiri Olsa <jolsa@kernel.org>,
	Emil Tsalapatis <emil@etsalapatis.com>,
	Puranjay Mohan <puranjay@kernel.org>,
	Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Subject: [PATCH bpf-next v2 0/2] bpf: Move IPIs out of pack_mutex and reduce IBPB flushes
Date: Thu,  3 Dec 2026 14:09:20 +0000	[thread overview]
Message-ID: <cover.1796304466.git.xukuohai@huawei.com> (raw)

From: Xu Kuohai <xukuohai@huawei.com>

BPF JIT memory is allocated through the BPF program pack allocator,
which uses a global pack_mutex to protect its packs. While holding this
lock, the allocator currently sends IPI to all CPUs on two paths: IBPB
flush on the x86 alloc path and CPU pipeline flush on the arm64 free
path. Because the caller can be preempted while waiting for the IPI
completion, the lock can be held for a long time, causing heavy lock
contention on busy systems.

This series moves both IPIs out of pack_mutex and tracks dirty state per
chunk instead of per pack to reduce IBPB flushes.

v2:
- Switch to Puranjay's patch to move bpf_arch_text_invalidate out of
  pack_mutex
- Switch to a new approach suggested by Alexei to move the IBPB flush
  out of pack_mutex

v1: https://lore.kernel.org/bpf/cover.1796223449.git.xukuohai@huawei.com/

Puranjay Mohan (1):
  bpf: Invalidate freed prog pack memory without holding pack_mutex

Xu Kuohai (1):
  bpf: Reduce branch predictor flush and move it out of pack_mutex

 kernel/bpf/core.c | 101 +++++++++++++++++++++++++---------------------
 1 file changed, 56 insertions(+), 45 deletions(-)

-- 
2.47.3


             reply	other threads:[~2026-12-03 14:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 14:09 Xu Kuohai [this message]
2026-12-03 14:09 ` [PATCH bpf-next v2 1/2] bpf: Invalidate freed prog pack memory without holding pack_mutex Xu Kuohai
2026-12-03 14:09 ` [PATCH bpf-next v2 2/2] bpf: Reduce branch predictor flush and move it out of pack_mutex Xu Kuohai

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=cover.1796304466.git.xukuohai@huawei.com \
    --to=xukuohai@huaweicloud.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=memxor@gmail.com \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=puranjay@kernel.org \
    --cc=song@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