From nobody Sun Oct 5 10:45:22 2025 Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [95.215.58.171]) (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 6DAB672630 for ; Tue, 5 Aug 2025 16:27:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754411280; cv=none; b=aU4L0+P4+xi+phbvKiASxNXalF74LGIbY4x1vfa6WbeSbdaF3qA/Yolt0PW8RUvPhL4DF2zWya1papb97pc3vWF846yzWGe5CVl45dYZK38c6pgoHKfEHnIlQtbskIVwsk0DZ7hb6mHqqmS6rdS6NNKHUv4bZq9erWokka8Otg8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754411280; c=relaxed/simple; bh=0THvNMFdfFhOxdvVstvFWtM+3I1dikuGop1BGeqltLE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ISqlRHXQuTq+Sn27ISNtvz92CF5kaK7l/em3ur3G3e2eL94+Wf9fv2wYuh1KUrjEEW/JNkB4+nmucIm3+yH9OFYQ7QQbusFLm/VHakguljwH6OBf5p/LYr4frLR0JOFCLcEHUa1+/8NrkvlMuowvrFCHFodMEVaxEMuk5QHEUT8= 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=ot62REN9; arc=none smtp.client-ip=95.215.58.171 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="ot62REN9" 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=1754411276; 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=/Z7pYFfWoLH1aXLvPg1vJ4VkW5EEtjCy8xcya4QuHqA=; b=ot62REN9lJLUGMUhPDjXjgTP+uLp3mM3Db4gCSkY2RqjkRUfLZV0puuIP/Bho6hsSGO8A6 H/FE3iatZ/u503Z47D6V/MbWu89/sPL0z0j3LKxmn4KFzTw1R6m16es9txHzcRdMKKUzEk D1KujsxdypwmivC2GlxbwvX+ujsN490= From: Tao Chen To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com, jolsa@kernel.org, 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 v2] bpf: Remove migrate_disable in kprobe_multi_link_prog_run Date: Wed, 6 Aug 2025 00:27:32 +0800 Message-ID: <20250805162732.1896687-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 all 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") Acked-by: Yonghong Song Acked-by: Jiri Olsa Signed-off-by: Tao Chen --- kernel/trace/bpf_trace.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) Change list: v1 -> v2: - s/called the way/called all the way/.(Jiri) v1: https://lore.kernel.org/bpf/f7acfd22-bcf3-4dff-9a87-7c1e6f84ce9c@linux= .dev diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 3ae52978cae..5701791e3cb 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 all 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