From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) (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 EEEBC246BC9 for ; Mon, 23 Jun 2025 13:45:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.189 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750686302; cv=none; b=tb+hkBJll11soQ443ROtgHezPifuDHX0Pbf18Whir8oxiczmV3pNOlpOWGVj5D07otO/R6PWorMxYtzFVtJvQSyV6MrjMdYjpQszbg5KX+80/c+s+eobWOTTKgK+q4u1nQzmbcTvDdYBfTfy4MA/4WwoADxBZGJbq7TevDJ/27k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750686302; c=relaxed/simple; bh=suvc5WbRVa5rRmFJhLgfpPlDChH0civ6Huy/T17A58w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=My2u6ZWhAu+vmGAZi2zQLF7auAsAClgmZdCDYMU6AXeFJqzb607aeF5XCgO0tUox9IwYlzA5lo+M6sO1CWPTUVI3CVzInlsVQQjQ6qSnB+6HJ5cQzvIqtvu6B7jI80lJL1df9T4bTDN01ZSvjyzFxgfn0iZUPGyalLziuFHaIgM= 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=kxyjpUq9; arc=none smtp.client-ip=95.215.58.189 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="kxyjpUq9" 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=1750686298; 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: in-reply-to:in-reply-to:references:references; bh=VXlnijRMaGhbbsaduEiRQFEzyVj0NFtPqTR2WJA2Fhg=; b=kxyjpUq9lIC6m4D7oUtct4BRuR5tKkDB+HQFgdax0UpiwGKzFKneqGTX98W7KjiUFP879T QbUaIFD2V8xED1MheM4mcXeoPx20N6B40qhlT1REEVl+5hz8gTV95eROz0df5faRBHH62p LdE8vXVZuvSGSC9OM9QnOsaZr5g0C5w= From: Tao Chen To: kpsingh@kernel.org, mattbobrowski@google.com, 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, sdf@fomichev.me, haoluo@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 v5 2/3] bpf: Add show_fdinfo for uprobe_multi Date: Mon, 23 Jun 2025 21:43:41 +0800 Message-ID: <20250623134342.227347-2-chen.dylane@linux.dev> In-Reply-To: <20250623134342.227347-1-chen.dylane@linux.dev> References: <20250623134342.227347-1-chen.dylane@linux.dev> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Show uprobe_multi link info with fdinfo, the info as follows: link_type: uprobe_multi link_id: 10 prog_tag: 7db356c03e61a4d4 prog_id: 42 uprobe_cnt: 3 pid: 0 path: /home/dylane/bpf/tools/testing/selftests/bpf/test_progs offset ref_ctr_offset cookie 0xa69f13 0x0 2 0xa69f1e 0x0 3 0xa69f29 0x0 1 Signed-off-by: Tao Chen --- kernel/trace/bpf_trace.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 8ecb1a9f85d..90209dda819 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -3171,10 +3171,54 @@ static int bpf_uprobe_multi_link_fill_link_info(const struct bpf_link *link, return err; } +#ifdef CONFIG_PROC_FS +static void bpf_uprobe_multi_show_fdinfo(const struct bpf_link *link, + struct seq_file *seq) +{ + struct bpf_uprobe_multi_link *umulti_link; + char *p, *buf; + + umulti_link = container_of(link, struct bpf_uprobe_multi_link, link); + + buf = kmalloc(PATH_MAX, GFP_KERNEL); + if (!buf) + return; + + p = d_path(&umulti_link->path, buf, PATH_MAX); + if (IS_ERR(p)) { + kfree(buf); + return; + } + + seq_printf(seq, + "uprobe_cnt:\t%u\n" + "pid:\t%u\n" + "path:\t%s\n", + umulti_link->cnt, + umulti_link->task ? task_pid_nr_ns(umulti_link->task, + task_active_pid_ns(current)) : 0, + p); + + seq_printf(seq, "%-16s %-16s %-16s\n", "offset", "ref_ctr_offset", "cookie"); + for (int i = 0; i < umulti_link->cnt; i++) { + seq_printf(seq, + "%#-16llx %#-16lx %-16llu\n", + umulti_link->uprobes[i].offset, + umulti_link->uprobes[i].ref_ctr_offset, + umulti_link->uprobes[i].cookie); + } + + kfree(buf); +} +#endif + static const struct bpf_link_ops bpf_uprobe_multi_link_lops = { .release = bpf_uprobe_multi_link_release, .dealloc_deferred = bpf_uprobe_multi_link_dealloc, .fill_link_info = bpf_uprobe_multi_link_fill_link_info, +#ifdef CONFIG_PROC_FS + .show_fdinfo = bpf_uprobe_multi_show_fdinfo, +#endif }; static int uprobe_prog_run(struct bpf_uprobe *uprobe, -- 2.48.1