From nobody Sun Oct 5 10:45:25 2025 Received: from out-180.mta0.migadu.com (out-180.mta0.migadu.com [91.218.175.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C07424E4B4 for ; Tue, 5 Aug 2025 12:23:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754396623; cv=none; b=k/aHXIGZBZcmOC3WfYrUzfWyZrYXPns+OSwVgoxsplRhQBxjKfQ+IVoZRunSIGT8rdj87tLxj8xRQgj9XVwFkELuLlG3ly5j0gOeYHPoShUapFOyGYetWixMaAq8Sh+VZiBtnjWXUosfsdRJ6+a2W58ovo/jj/KhGxMtTL9M67Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754396623; c=relaxed/simple; bh=xFnGQAK+SCGpQM5L461SVbPvgeMBSoj1Z0emM/2Xm3s=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=clCdCVrl3e04oM62qhc3XnmAUMr1NxE0ra+BUvNqpBZ6RIm9uojxnL4QLNZ7U1zV6/ciIAO2gt546JWc/x04g1XC04EvhhW+WNQPzFL+0ZtXzx1b4+DOLCPBLi17/14gu9wemDYzy4DhcIuw4qxo1Z8Fh5V4HRHuqUe9eU7nZwA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=uSmESP7A; arc=none smtp.client-ip=91.218.175.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="uSmESP7A" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1754396608; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Fnd61Z9ADig6IYqnJnuJZzpg/ZV/PVSlvhbbeJhiw5U=; b=uSmESP7A11Q8dLzDlEkGxgxwqM5Lt4O0TrpSTubFDOCdSgWNT5U1pJjsNqWazpiMW3bPyS IRj+z05WLaa+ZVPZnQYpRQFf7OXWXIQXiSIR3HYGcDtc1BeobT8A7Uvgn8yzcRCJTPlQTE vr2pdoYWhKZ6v9QNJrwIkHdomxEOOtY= From: Tao Chen To: song@kernel.org, jolsa@kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com, mattbobrowski@google.com, rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Tao Chen Subject: [PATCH bpf-next] bpf: Remove migrate_disable in kprobe_multi_link_prog_run Date: Tue, 5 Aug 2025 20:23:12 +0800 Message-ID: <20250805122312.1890951-1-chen.dylane@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" bpf program should run under migration disabled, kprobe_multi_link_prog_run called the way from graph tracer, which disables preemption in function_graph_enter_regs, as Jiri and Yonghong suggested, there is no need to use migrate_disable. As a result, some overhead maybe will be reduced. Fixes: 0dcac2725406 ("bpf: Add multi kprobe link") Signed-off-by: Tao Chen Acked-by: Jiri Olsa Acked-by: Yonghong Song --- kernel/trace/bpf_trace.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 3ae52978cae..1993fc62539 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -2734,14 +2734,19 @@ kprobe_multi_link_prog_run(struct bpf_kprobe_multi_= link *link, goto out; } =20 - migrate_disable(); + /* + * bpf program should run under migration disabled, kprobe_multi_link_pro= g_run + * called the way from graph tracer, which disables preemption in + * function_graph_enter_regs, so there is no need to use migrate_disable. + * Accessing the above percpu data bpf_prog_active is also safe for the s= ame + * reason. + */ rcu_read_lock(); regs =3D ftrace_partial_regs(fregs, bpf_kprobe_multi_pt_regs_ptr()); old_run_ctx =3D bpf_set_run_ctx(&run_ctx.session_ctx.run_ctx); err =3D bpf_prog_run(link->link.prog, regs); bpf_reset_run_ctx(old_run_ctx); rcu_read_unlock(); - migrate_enable(); =20 out: __this_cpu_dec(bpf_prog_active); --=20 2.48.1