From nobody Sat Feb 7 10:08:27 2026 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 9DCA68BEA; Fri, 15 Mar 2024 06:54:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710485662; cv=none; b=Ouch9V04tP2lgfhMyF+oxo5JeZWX6ju1ZwQiBEu7nTJUQPWESIBCSQoF95pbWKobeaK5j8a6MWOEznkIII8d02EqXfVVwQW5JfNr1/8U4E9beV3NZ9a/7/Y35nlXY5xrDw3bgxq+0yrzW78pGSniZgy79vpdhYbr8+LaQXsRSAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710485662; c=relaxed/simple; bh=vrLjDY7iYTglWbIF9byAN3ZdVSQfDDmsDWsXScSYCLA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qCMVi1a5crw5A23MmwBvvC52v7rpa9E2alQ4zfuYikFCUykNvDC3IUTkygulFAkxmEfDWdx1fG1olcSyguwL1FyDxx9Z7hcF41nfQ2jaCvsGg21o6JWSd6qgQUaL9y6n7n7pwH0dyxxKoKwBzUtRzbCaS+CIBicR91n7LSosUus= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Tww0v14KZz1xqfr; Fri, 15 Mar 2024 14:52:31 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 6CD5D1A016F; Fri, 15 Mar 2024 14:54:18 +0800 (CST) Received: from huawei.com (10.175.127.227) by canpemm500010.china.huawei.com (7.192.105.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 15 Mar 2024 14:54:17 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v6 1/8] tracing/probes: add traceprobe_expand_dentry_args() helper Date: Fri, 15 Mar 2024 14:55:33 +0800 Message-ID: <20240315065540.1181879-2-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240315065540.1181879-1-yebin10@huawei.com> References: <20240315065540.1181879-1-yebin10@huawei.com> 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-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500010.china.huawei.com (7.192.105.118) Content-Type: text/plain; charset="utf-8" Add traceprobe_expand_dentry_args() to expand dentry args. this API is prepare to support "%pd" print format for kprobe. Signed-off-by: Ye Bin --- kernel/trace/trace_probe.c | 50 ++++++++++++++++++++++++++++++++++++++ kernel/trace/trace_probe.h | 2 ++ 2 files changed, 52 insertions(+) diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index 34289f9c6707..a27567e16c36 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -1569,6 +1569,56 @@ const char **traceprobe_expand_meta_args(int argc, c= onst char *argv[], return ERR_PTR(ret); } =20 +/* @buf: *buf must be equal to NULL. Caller must to free *buf */ +int traceprobe_expand_dentry_args(int argc, const char *argv[], char **buf) +{ + int i, used, ret; + const int bufsize =3D MAX_DENTRY_ARGS_LEN; + char *tmpbuf =3D NULL; + + if (*buf) + return -EINVAL; + + used =3D 0; + for (i =3D 0; i < argc; i++) { + if (glob_match("*:%pd", argv[i])) { + char *tmp; + char *equal; + + if (!tmpbuf) { + tmpbuf =3D kmalloc(bufsize, GFP_KERNEL); + if (!tmpbuf) + return -ENOMEM; + } + + tmp =3D kstrdup(argv[i], GFP_KERNEL); + if (!tmp) + goto nomem; + + equal =3D strchr(tmp, '=3D'); + if (equal) + *equal =3D '\0'; + tmp[strlen(argv[i]) - 4] =3D '\0'; + ret =3D snprintf(tmpbuf + used, bufsize - used, + "%s%s+0x0(+0x%zx(%s)):string", + equal ? tmp : "", equal ? "=3D" : "", + offsetof(struct dentry, d_name.name), + equal ? equal + 1 : tmp); + kfree(tmp); + if (ret >=3D bufsize - used) + goto nomem; + argv[i] =3D tmpbuf + used; + used +=3D ret + 1; + } + } + + *buf =3D tmpbuf; + return 0; +nomem: + kfree(tmpbuf); + return -ENOMEM; +} + void traceprobe_finish_parse(struct traceprobe_parse_context *ctx) { clear_btf_context(ctx); diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index c1877d018269..3d22fba4b63f 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -34,6 +34,7 @@ #define MAX_ARRAY_LEN 64 #define MAX_ARG_NAME_LEN 32 #define MAX_BTF_ARGS_LEN 128 +#define MAX_DENTRY_ARGS_LEN 256 #define MAX_STRING_SIZE PATH_MAX #define MAX_ARG_BUF_LEN (MAX_TRACE_ARGS * MAX_ARG_NAME_LEN) =20 @@ -402,6 +403,7 @@ extern int traceprobe_parse_probe_arg(struct trace_prob= e *tp, int i, const char **traceprobe_expand_meta_args(int argc, const char *argv[], int *new_argc, char *buf, int bufsize, struct traceprobe_parse_context *ctx); +extern int traceprobe_expand_dentry_args(int argc, const char *argv[], cha= r **buf); =20 extern int traceprobe_update_arg(struct probe_arg *arg); extern void traceprobe_free_probe_arg(struct probe_arg *arg); --=20 2.31.1 From nobody Sat Feb 7 10:08:27 2026 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 9DCD01A38EF; Fri, 15 Mar 2024 06:54:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710485662; cv=none; b=KMs/CD/md3pz3Vs/3rgTJHbsj/CtvkzjM7tflYUyPC/QvcCjYco3XfuIvdJIzjPlQHb1sNB8QE03hjv3GRftuGby+rTWjmkGVjGC7frAij8UGSc0umcx/a2pPHD886Wumu2YVIzLPxjSWzjNVniEYhbdsqHBtWjEFlrG41jwado= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710485662; c=relaxed/simple; bh=DTWWED3utzA+ZuMoccKiNwpAtso/EWOE5CANqtTsna8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LEoShVyUt9ML3EH5iC8scVvTAIBN22pT2Hc/f9NC94xmu1te+4cICWF7zDb28EJl0WSmmx782fJAi+9V8lHnlEEIFEgSXjoueaI3EwRRdUItWyQuVh5PNS2+dmloPZ7Xr4650Ulki/3VVGI4Ezs2OWtyq5CwtpGfkHr/E8j8V0o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Tww056p5Hz2BgNG; Fri, 15 Mar 2024 14:51:49 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id D366A140157; Fri, 15 Mar 2024 14:54:18 +0800 (CST) Received: from huawei.com (10.175.127.227) by canpemm500010.china.huawei.com (7.192.105.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 15 Mar 2024 14:54:18 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v6 2/8] tracing/probes: support '%pd' type for print struct dentry's name Date: Fri, 15 Mar 2024 14:55:34 +0800 Message-ID: <20240315065540.1181879-3-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240315065540.1181879-1-yebin10@huawei.com> References: <20240315065540.1181879-1-yebin10@huawei.com> 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-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500010.china.huawei.com (7.192.105.118) Content-Type: text/plain; charset="utf-8" Similar to '%pd' for printk, use '%pd' for print struct dentry's name. Signed-off-by: Ye Bin --- kernel/trace/trace_kprobe.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index c4c6e0e0068b..7cbb43740b4f 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -779,6 +779,7 @@ static int __trace_kprobe_create(int argc, const char *= argv[]) char buf[MAX_EVENT_NAME_LEN]; char gbuf[MAX_EVENT_NAME_LEN]; char abuf[MAX_BTF_ARGS_LEN]; + char *dbuf =3D NULL; struct traceprobe_parse_context ctx =3D { .flags =3D TPARG_FL_KERNEL }; =20 switch (argv[0][0]) { @@ -930,6 +931,10 @@ static int __trace_kprobe_create(int argc, const char = *argv[]) argv =3D new_argv; } =20 + ret =3D traceprobe_expand_dentry_args(argc, argv, &dbuf); + if (ret) + goto out; + /* setup a probe */ tk =3D alloc_trace_kprobe(group, event, addr, symbol, offset, maxactive, argc, is_return); @@ -971,6 +976,7 @@ static int __trace_kprobe_create(int argc, const char *= argv[]) trace_probe_log_clear(); kfree(new_argv); kfree(symbol); + kfree(dbuf); return ret; =20 parse_error: --=20 2.31.1 From nobody Sat Feb 7 10:08:27 2026 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) (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 5C42118637; Fri, 15 Mar 2024 06:54:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.255 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710485668; cv=none; b=AwxyT6X1hcKRNkQ3vJyWP0oOgiyGjl+typHq0JxrLTcxgpXf2/tuXYyM3MscX2nnPCa3CYX9aOItVKjW8WRUSFfLxfk0s6StPrsrInTk4SnfPTkq2BLGUBtwG7Xz5q/ddxCU9EvxjHKWGnHH5mKGOe01elEQyuvfLJhucQGGZq4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710485668; c=relaxed/simple; bh=WuzOu1pbLK1l4Mw333eghX00jBYu4yVSy2f2BXI6kRU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cO091kP9nJZmBy1tBtU88VEQss6p2YGvZYYFlh7vUjNSpdXWWvaMStOnVOMz7fpvoyictAYyTxZimXFW/TF01dm3CwqON23tUOeioejvNB9f8qX3l4qcwqYDF8HnJow9dleZzWk/bJCKljst/6U9LlJIjETyASmHjBCFfITcl/4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.255 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Tww0T74fLz1Q9gW; Fri, 15 Mar 2024 14:52:09 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 4858F1404F3; Fri, 15 Mar 2024 14:54:19 +0800 (CST) Received: from huawei.com (10.175.127.227) by canpemm500010.china.huawei.com (7.192.105.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 15 Mar 2024 14:54:18 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v6 3/8] tracing/probes: support '%pd' type for fprobe Date: Fri, 15 Mar 2024 14:55:35 +0800 Message-ID: <20240315065540.1181879-4-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240315065540.1181879-1-yebin10@huawei.com> References: <20240315065540.1181879-1-yebin10@huawei.com> 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-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500010.china.huawei.com (7.192.105.118) Content-Type: text/plain; charset="utf-8" Support print type '%pd' for print dentry's or file's name. Signed-off-by: Ye Bin --- kernel/trace/trace_fprobe.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/trace/trace_fprobe.c b/kernel/trace/trace_fprobe.c index 7d2ddbcfa377..988d68e906ad 100644 --- a/kernel/trace/trace_fprobe.c +++ b/kernel/trace/trace_fprobe.c @@ -976,6 +976,7 @@ static int __trace_fprobe_create(int argc, const char *= argv[]) char gbuf[MAX_EVENT_NAME_LEN]; char sbuf[KSYM_NAME_LEN]; char abuf[MAX_BTF_ARGS_LEN]; + char *dbuf =3D NULL; bool is_tracepoint =3D false; struct tracepoint *tpoint =3D NULL; struct traceprobe_parse_context ctx =3D { @@ -1086,6 +1087,10 @@ static int __trace_fprobe_create(int argc, const cha= r *argv[]) argv =3D new_argv; } =20 + ret =3D traceprobe_expand_dentry_args(argc, argv, &dbuf); + if (ret) + goto out; + /* setup a probe */ tf =3D alloc_trace_fprobe(group, event, symbol, tpoint, maxactive, argc, is_return); @@ -1131,6 +1136,7 @@ static int __trace_fprobe_create(int argc, const char= *argv[]) trace_probe_log_clear(); kfree(new_argv); kfree(symbol); + kfree(dbuf); return ret; =20 parse_error: --=20 2.31.1 From nobody Sat Feb 7 10:08:27 2026 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 E254DDDA6; Fri, 15 Mar 2024 06:54:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710485663; cv=none; b=VctCWhAMSgZHglGT1dG3Jap7SRc113sROt+0YcCdt644mzDB/dDbV1s08X1HAV5tgCe6xlcqeQDYMQGCxJ/GLscSGDg9UtQ9LXmLM7nHB9WpCySyMBHxAOxwPiNxMk3Ds/yavUqEWai5qGJQo68nf0ciRzGgkStpriSvchlGWi4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710485663; c=relaxed/simple; bh=GjRxippzJ1yVsG3/oTdISeBTK/MJfco3wGa3k6U3Uco=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OoAvUaMGpxGd1STkCPjBrZetKPx3PuX3XWERWNPaYLZEWmGo85MZT83zW515Wsft16FK483spZbkOH0aVnt2N2rhABhVAcv+wTkRq+nzNh7B4+aeDaBCUp0UsAMVpGCfTuN98orbwBXVvWcMUW68cI936qyhxbyOali+7l1KRXE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Tww065wvKz2BgNP; Fri, 15 Mar 2024 14:51:50 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id B524B140485; Fri, 15 Mar 2024 14:54:19 +0800 (CST) Received: from huawei.com (10.175.127.227) by canpemm500010.china.huawei.com (7.192.105.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 15 Mar 2024 14:54:19 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v6 4/8] tracing/probes: support '%pD' type for print struct file's name Date: Fri, 15 Mar 2024 14:55:36 +0800 Message-ID: <20240315065540.1181879-5-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240315065540.1181879-1-yebin10@huawei.com> References: <20240315065540.1181879-1-yebin10@huawei.com> 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-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500010.china.huawei.com (7.192.105.118) Content-Type: text/plain; charset="utf-8" Similar to '%pD' for printk, use '%pD' for print struct file's name. Signed-off-by: Ye Bin --- kernel/trace/trace_probe.c | 57 +++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index a27567e16c36..7bfc6c0d5436 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -12,6 +12,7 @@ #define pr_fmt(fmt) "trace_probe: " fmt =20 #include +#include #include "trace_btf.h" =20 #include "trace_probe.h" @@ -1581,35 +1582,47 @@ int traceprobe_expand_dentry_args(int argc, const c= har *argv[], char **buf) =20 used =3D 0; for (i =3D 0; i < argc; i++) { - if (glob_match("*:%pd", argv[i])) { - char *tmp; - char *equal; - - if (!tmpbuf) { - tmpbuf =3D kmalloc(bufsize, GFP_KERNEL); - if (!tmpbuf) - return -ENOMEM; - } + char *tmp; + char *equal; + size_t arg_len; =20 - tmp =3D kstrdup(argv[i], GFP_KERNEL); - if (!tmp) - goto nomem; + if (!glob_match("*:%p[dD]", argv[i])) + continue; =20 - equal =3D strchr(tmp, '=3D'); - if (equal) - *equal =3D '\0'; - tmp[strlen(argv[i]) - 4] =3D '\0'; + if (!tmpbuf) { + tmpbuf =3D kmalloc(bufsize, GFP_KERNEL); + if (!tmpbuf) + return -ENOMEM; + } + + tmp =3D kstrdup(argv[i], GFP_KERNEL); + if (!tmp) + goto nomem; + + equal =3D strchr(tmp, '=3D'); + if (equal) + *equal =3D '\0'; + arg_len =3D strlen(argv[i]); + tmp[arg_len - 4] =3D '\0'; + if (argv[i][arg_len - 1] =3D=3D 'd') ret =3D snprintf(tmpbuf + used, bufsize - used, "%s%s+0x0(+0x%zx(%s)):string", equal ? tmp : "", equal ? "=3D" : "", offsetof(struct dentry, d_name.name), equal ? equal + 1 : tmp); - kfree(tmp); - if (ret >=3D bufsize - used) - goto nomem; - argv[i] =3D tmpbuf + used; - used +=3D ret + 1; - } + else + ret =3D snprintf(tmpbuf + used, bufsize - used, + "%s%s+0x0(+0x%zx(+0x%zx(%s))):string", + equal ? tmp : "", equal ? "=3D" : "", + offsetof(struct dentry, d_name.name), + offsetof(struct file, f_path.dentry), + equal ? equal + 1 : tmp); + + kfree(tmp); + if (ret >=3D bufsize - used) + goto nomem; + argv[i] =3D tmpbuf + used; + used +=3D ret + 1; } =20 *buf =3D tmpbuf; --=20 2.31.1 From nobody Sat Feb 7 10:08:27 2026 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (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 D084713AE2; Fri, 15 Mar 2024 06:54:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710485664; cv=none; b=B2foDgLtlngckAM0HG6GuC2bGiWruAEPH+mdlgxNc/I6XRuuWf72v7pTjBJ3MAOMX+Qu16ATKOxXurL9bHjxDXtGWe81x4lf8n9VnLRv5zIWikCJ7VtoBZ4xNgNWry0d6Qk3votuuZJWNRrdFixZ6xc3Yq5Ogh4uU3Q3VCQNLcg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710485664; c=relaxed/simple; bh=QEHYEKZn/nfC/bCEp7pLWNVR586Kb/4ue5St/ROhyu4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hTa2ARUjDBVOwy5XS+f5YAkebGTTDLh2hMK+1IWzv1zAszttQbR3eZiY7dxMYpBYb+bq/tNelf/wczNYV0jqkucnYseK5IC2o2ZnUDWp1M2dbmvKyPgbHI/hkf9Cs5ORP4RyxOrD8R0zKP271NDnKwLpsKTZZzyOGMzMY8SKP0E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Tww2f3Q2nz1FMLf; Fri, 15 Mar 2024 14:54:02 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 2B946140157; Fri, 15 Mar 2024 14:54:20 +0800 (CST) Received: from huawei.com (10.175.127.227) by canpemm500010.china.huawei.com (7.192.105.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 15 Mar 2024 14:54:19 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v6 5/8] tracing: add new type "%pd/%pD" in readme_msg[] Date: Fri, 15 Mar 2024 14:55:37 +0800 Message-ID: <20240315065540.1181879-6-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240315065540.1181879-1-yebin10@huawei.com> References: <20240315065540.1181879-1-yebin10@huawei.com> 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-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500010.china.huawei.com (7.192.105.118) Content-Type: text/plain; charset="utf-8" Signed-off-by: Ye Bin --- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index b12f8384a36a..831dfd0773a4 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -5510,7 +5510,7 @@ static const char readme_msg[] =3D "\t +|-[u](), \\imm-value, \\\"imm-string\"\n" "\t type: s8/16/32/64, u8/16/32/64, x8/16/32/64, char, string, symbol= ,\n" "\t b@/, ustring,\n" - "\t symstr, \\[\\]\n" + "\t symstr, %pd/%pD, \\[\\]\n" #ifdef CONFIG_HIST_TRIGGERS "\t field: ;\n" "\t stype: u8/u16/u32/u64, s8/s16/s32/s64, pid_t,\n" --=20 2.31.1 From nobody Sat Feb 7 10:08:27 2026 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) (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 C99D918C1A; Fri, 15 Mar 2024 06:54:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.255 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710485670; cv=none; b=cb7OEMGu9BmdVpaFYSf16VCVNHOF9ny5HuzsXd4U9P5ZwWyxts6/6gj37hQTvHmCoxmnqJEv0AMDD/DyqO7XhjJq9Dp57ygMuLAvwwdR3Dod597o2WkNUIKoxdpDMSANzlsCD0rMRQ/UO9WSCHa43VU3kAHX8UDx/+jY6qojGd4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710485670; c=relaxed/simple; bh=erOBzZetGQeOc5+oyau5RI5nfAQAu9VK/IeB1+EeIo4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g7KS1PM1on3NYrnjE3fuOr78pXtURBqKjE0O0ElJvTNDiPng90NiYrBNQ62U1oi7uD+DdeZySExi94AkZUAd34Rn08KRVB09RzIuknZhBOYuDbuxe5YWSb16UKXzzniJu8ahefsQncAhp2NibiG2+LOm+yZXmjpwPvyjR1z95PI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.255 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Tww0W2CXnz1Q9kS; Fri, 15 Mar 2024 14:52:11 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 9516118007C; Fri, 15 Mar 2024 14:54:20 +0800 (CST) Received: from huawei.com (10.175.127.227) by canpemm500010.china.huawei.com (7.192.105.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 15 Mar 2024 14:54:20 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v6 6/8] Documentation: tracing: add new type '%pd' and '%pD' for kprobe Date: Fri, 15 Mar 2024 14:55:38 +0800 Message-ID: <20240315065540.1181879-7-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240315065540.1181879-1-yebin10@huawei.com> References: <20240315065540.1181879-1-yebin10@huawei.com> 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-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500010.china.huawei.com (7.192.105.118) Content-Type: text/plain; charset="utf-8" Similar to printk() '%pd' is for fetch dentry's name from struct dentry's pointer, and '%pD' is for fetch file's name from struct file's pointer. Signed-off-by: Ye Bin --- Documentation/trace/kprobetrace.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Documentation/trace/kprobetrace.rst b/Documentation/trace/kpro= betrace.rst index bf9cecb69fc9..f13f0fc11251 100644 --- a/Documentation/trace/kprobetrace.rst +++ b/Documentation/trace/kprobetrace.rst @@ -58,8 +58,9 @@ Synopsis of kprobe_events NAME=3DFETCHARG : Set NAME as the argument name of FETCHARG. FETCHARG:TYPE : Set TYPE as the type of FETCHARG. Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal types - (x8/x16/x32/x64), "char", "string", "ustring", "symbol", "symstr" - and bitfield are supported. + (x8/x16/x32/x64), VFS layer common type(%pd/%pD), "char", + "string", "ustring", "symbol", "symstr" and bitfield are + supported. =20 (\*1) only for the probe on function entry (offs =3D=3D 0). Note, this a= rgument access is best effort, because depending on the argument type, it may be = passed on @@ -113,6 +114,9 @@ With 'symstr' type, you can filter the event with wildc= ard pattern of the symbols, and you don't need to solve symbol name by yourself. For $comm, the default type is "string"; any other type is invalid. =20 +VFS layer common type(%pd/%pD) is a special type, which fetches dentry's or +file's name from struct dentry's address or struct file's address. + .. _user_mem_access: =20 User Memory Access --=20 2.31.1 From nobody Sat Feb 7 10:08:27 2026 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (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 20B9314012; Fri, 15 Mar 2024 06:54:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710485665; cv=none; b=DNAdjZJ8Vjsh90bHWrDRMbDIsmrJfnVojAFUtSdcyjKKG01494RjFdnFC9Khm8yfdyyfFvG0+sYVF3OPwyYSCLq1iEolQww+CrrEPfTnh8z6y7RxNUr5rz3bN/Y3p/PoBRG33cRqZE+gVzexH64W2QOPugykaRRdpDRx09/tWoM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710485665; c=relaxed/simple; bh=0/WV/6Kb3iC5gYSeZVx26GoOUUshmVEdVz9ZIolb0aA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Y8dWxQDg3UA20vCmHMN2dZiakXOdctVVpbiBfoXx45mREQur9eVjNz4QpjhNYAPpIF1neqfN87RoIihSf1z9NPJDyAC615D2bbm+wb+WMupOB4bKIQCYw15y+tuBRCndLpWeGyvTDghFiiYnkuEr1k6vUmxgo9lVAQkNPGp51jQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Tww2g2ZJzz1FMW1; Fri, 15 Mar 2024 14:54:03 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 0F13814040F; Fri, 15 Mar 2024 14:54:21 +0800 (CST) Received: from huawei.com (10.175.127.227) by canpemm500010.china.huawei.com (7.192.105.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 15 Mar 2024 14:54:20 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v6 7/8] selftests/ftrace: add kprobe test cases for VFS type "%pd" and "%pD" Date: Fri, 15 Mar 2024 14:55:39 +0800 Message-ID: <20240315065540.1181879-8-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240315065540.1181879-1-yebin10@huawei.com> References: <20240315065540.1181879-1-yebin10@huawei.com> 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-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500010.china.huawei.com (7.192.105.118) Content-Type: text/plain; charset="utf-8" This patch adds test cases for new print format type "%pd/%pD".The test cas= es test the following items: 1. Test README if add "%pd/%pD" type; 2. Test "%pd" type for dput(); 3. Test "%pD" type for vfs_read(); This test case require enable CONFIG_HAVE_FUNCTION_ARG_ACCESS_API configura= tion. Signed-off-by: Ye Bin --- .../ftrace/test.d/kprobe/kprobe_args_vfs.tc | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_arg= s_vfs.tc diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_vfs.t= c b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_vfs.tc new file mode 100644 index 000000000000..8bea9a75a331 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_vfs.tc @@ -0,0 +1,43 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Kprobe event VFS type argument +# requires: kprobe_events "%pd/%pD":README + +: "Test argument %pd/%pD in README" +grep -q "%pd/%pD" README + +: "Test argument %pd with name" +echo 'p:testprobe dput name=3D$arg1:%pd' > kprobe_events +echo 1 > events/kprobes/testprobe/enable +grep -q "1" events/kprobes/testprobe/enable +echo 0 > events/kprobes/testprobe/enable +grep "dput" trace | grep -q "enable" +echo "" > kprobe_events +echo "" > trace + +: "Test argument %pd without name" +echo 'p:testprobe dput $arg1:%pd' > kprobe_events +echo 1 > events/kprobes/testprobe/enable +grep -q "1" events/kprobes/testprobe/enable +echo 0 > events/kprobes/testprobe/enable +grep "dput" trace | grep -q "enable" +echo "" > kprobe_events +echo "" > trace + +: "Test argument %pD with name" +echo 'p:testprobe vfs_read name=3D$arg1:%pD' > kprobe_events +echo 1 > events/kprobes/testprobe/enable +grep -q "1" events/kprobes/testprobe/enable +echo 0 > events/kprobes/testprobe/enable +grep "vfs_read" trace | grep -q "enable" +echo "" > kprobe_events +echo "" > trace + +: "Test argument %pD without name" +echo 'p:testprobe vfs_read $arg1:%pD' > kprobe_events +echo 1 > events/kprobes/testprobe/enable +grep -q "1" events/kprobes/testprobe/enable +echo 0 > events/kprobes/testprobe/enable +grep "vfs_read" trace | grep -q "enable" +echo "" > kprobe_events +echo "" > trace --=20 2.31.1 From nobody Sat Feb 7 10:08:27 2026 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 462A514A85; Fri, 15 Mar 2024 06:54:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710485664; cv=none; b=mTm2MqGjPXoSfpI8MT0jVAxQfgJfgJzSpcAv4YKRiXZBvmKkLV4NHpHmdttOA6C+MhW7WWEjPT5gXr+186dOFVxSs/dR/1uzWbravmXxnr7CKUUL9LJwd/iybcNdyrzFS2RYqxiQl3tjEPUNxyo/VLzpaajbTlLeYgMia5nFffU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710485664; c=relaxed/simple; bh=mm/LKOibx69xdWi9kZO3FwKzMXoZWR3O/2RiRcPvCZk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ACnZ5z+N//vWOvf5IbCcuY6SHTLNXQPdv0fDBhtDw8AYUCd09PWHL1nxFk0AvEANMRWq+GZVVNGy03N5cgZ5aJJnVDOwM5bFva3tg213dDo9CL2FFttTvd3FQKmJsU2jVB2PYgq+J9PZ6U/wkqn0VJzM+DbQmtxbFaod7rt2A48= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Tww0y1KZ5z1xr44; Fri, 15 Mar 2024 14:52:34 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 763A61A0187; Fri, 15 Mar 2024 14:54:21 +0800 (CST) Received: from huawei.com (10.175.127.227) by canpemm500010.china.huawei.com (7.192.105.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 15 Mar 2024 14:54:21 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v6 8/8] selftests/ftrace: add fprobe test cases for VFS type "%pd" and "%pD" Date: Fri, 15 Mar 2024 14:55:40 +0800 Message-ID: <20240315065540.1181879-9-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240315065540.1181879-1-yebin10@huawei.com> References: <20240315065540.1181879-1-yebin10@huawei.com> 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-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500010.china.huawei.com (7.192.105.118) Content-Type: text/plain; charset="utf-8" This patch adds fprobe test cases for new print format type "%pd/%pD".The test cases test the following items: 1. Test "%pd" type for dput(); 2. Test "%pD" type for vfs_read(); This test case require enable CONFIG_HAVE_FUNCTION_ARG_ACCESS_API configura= tion. Signed-off-by: Ye Bin --- .../ftrace/test.d/dynevent/fprobe_args_vfs.tc | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/dynevent/fprobe_a= rgs_vfs.tc diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/fprobe_args_vfs= .tc b/tools/testing/selftests/ftrace/test.d/dynevent/fprobe_args_vfs.tc new file mode 100644 index 000000000000..49a833bf334c --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/dynevent/fprobe_args_vfs.tc @@ -0,0 +1,40 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Fprobe event VFS type argument +# requires: kprobe_events "%pd/%pD":README + +: "Test argument %pd with name for fprobe" +echo 'f:testprobe dput name=3D$arg1:%pd' > dynamic_events +echo 1 > events/fprobes/testprobe/enable +grep -q "1" events/fprobes/testprobe/enable +echo 0 > events/fprobes/testprobe/enable +grep "dput" trace | grep -q "enable" +echo "" > dynamic_events +echo "" > trace + +: "Test argument %pd without name for fprobe" +echo 'f:testprobe dput $arg1:%pd' > dynamic_events +echo 1 > events/fprobes/testprobe/enable +grep -q "1" events/fprobes/testprobe/enable +echo 0 > events/fprobes/testprobe/enable +grep "dput" trace | grep -q "enable" +echo "" > dynamic_events +echo "" > trace + +: "Test argument %pD with name for fprobe" +echo 'f:testprobe vfs_read name=3D$arg1:%pD' > dynamic_events +echo 1 > events/fprobes/testprobe/enable +grep -q "1" events/fprobes/testprobe/enable +echo 0 > events/fprobes/testprobe/enable +grep "vfs_read" trace | grep -q "enable" +echo "" > dynamic_events +echo "" > trace + +: "Test argument %pD without name for fprobe" +echo 'f:testprobe vfs_read $arg1:%pD' > dynamic_events +echo 1 > events/fprobes/testprobe/enable +grep -q "1" events/fprobes/testprobe/enable +echo 0 > events/fprobes/testprobe/enable +grep "vfs_read" trace | grep -q "enable" +echo "" > dynamic_events +echo "" > trace --=20 2.31.1