From nobody Sat Feb 7 22:06:46 2026 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) (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 078AC1DFD9; Wed, 20 Mar 2024 13:28:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710941301; cv=none; b=fXVyW5uFR3X4Bgsw3JzMEqg9CYFSNObdaikDEUkpgZ70OPRk+LoIrRuSbop68iFOLfqRrgMfODm3G4lKeBCYheg9ZP6YZ2LO/0lqrin7QeUNNXqXP9Mi7x12Nrm41DHV/JkVdo5tKwFyWq5CnEl1t188J084DVuTztH40iwHt8k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710941301; c=relaxed/simple; bh=4FNpVS50rI9MCJZqJZgimaLE5PgkiaIzNbqfXnfoUb0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Fx15Q4UAe4EdmUx7z+xGFo35EYwGbj6MEfb5E2hmPyY3vHyhlc32h8N+TcU/ZHpMIeGLz8y107lUjpB8HMarxw3D8ez4Uux2S+ZKITy1o9OKkpn6qwTybuSIM8NpwpSw1aE2vW8cIlttCegF5IRunlVhl64tiFa58sP7x/OM4Ug= 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.32 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.163]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4V08XD6PQLz1vx0B; Wed, 20 Mar 2024 21:27:24 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 3A4AD180060; Wed, 20 Mar 2024 21:28:11 +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; Wed, 20 Mar 2024 21:28:10 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v7 1/5] tracing/probes: support '%pd' type for print struct dentry's name Date: Wed, 20 Mar 2024 21:29:20 +0800 Message-ID: <20240320132924.2802187-2-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240320132924.2802187-1-yebin10@huawei.com> References: <20240320132924.2802187-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: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500010.china.huawei.com (7.192.105.118) Content-Type: text/plain; charset="utf-8" Support print type '%pd' for print dentry's name. Signed-off-by: Ye Bin Acked-by: Masami Hiramatsu (Google) --- kernel/trace/trace.c | 2 +- kernel/trace/trace_fprobe.c | 6 +++++ kernel/trace/trace_kprobe.c | 6 +++++ kernel/trace/trace_probe.c | 50 +++++++++++++++++++++++++++++++++++++ kernel/trace/trace_probe.h | 2 ++ 5 files changed, 65 insertions(+), 1 deletion(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index b12f8384a36a..ac26b8446337 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, \\[\\]\n" #ifdef CONFIG_HIST_TRIGGERS "\t field: ;\n" "\t stype: u8/u16/u32/u64, s8/s16/s32/s64, pid_t,\n" 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: 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: 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 22:06:46 2026 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (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 B4D6140BFD; Wed, 20 Mar 2024 13:28:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710941303; cv=none; b=VUZQ7ovE3q+SMKQSSNzZ8PwhfLbN56EfQrUcRx3Ba++wIp5xTnZLf1xkIRkENCFTZIjaVLuQa48EjhE/KlemHobzUgyVOyAR2MH96veV4sGbll6u/pmxx1hR9otHGxFhIthqbwdKX8pK+xoS+t8eWWcxANOBj7LJWM/fQTwKSns= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710941303; c=relaxed/simple; bh=gvy8zKYkHQrm2onFaLP191TLnQ4xoumRxMNImZv0AyM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qxoy7+9rkGwDtwK+EZfDReZZ/7u0K7qErKRcJuvi4XPGkx/VfcsVHBSRMmgWser4p4ordRhqsyhPfqMbIV8peeOjzxwPXdMeoVNqEvn8KkOVklgbmsYNv6z4rWVgKHYWRFIF5oCCjTRo42tIDja0vCg2h/7A3EFXWaTvckJA8s0= 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.187 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.174]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4V08VB614xzwPgR; Wed, 20 Mar 2024 21:25:38 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id A237C14040D; Wed, 20 Mar 2024 21:28:11 +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; Wed, 20 Mar 2024 21:28:11 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v7 2/5] tracing/probes: support '%pD' type for print struct file's name Date: Wed, 20 Mar 2024 21:29:21 +0800 Message-ID: <20240320132924.2802187-3-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240320132924.2802187-1-yebin10@huawei.com> References: <20240320132924.2802187-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: dggems703-chm.china.huawei.com (10.3.19.180) 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 Acked-by: Masami Hiramatsu (Google) --- kernel/trace/trace.c | 2 +- kernel/trace/trace_probe.c | 57 +++++++++++++++++++++++--------------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index ac26b8446337..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, %pd, \\[\\]\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" 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 22:06:46 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 E05D140BE5; Wed, 20 Mar 2024 13:28:19 +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=1710941301; cv=none; b=nJOzlSQgu2rp4GpUnTiJ03r9WgA/TBUYgVhRNaVoEUeMyJrMP50A4OIWfdAAnL6veYmbjxLJ0D67cOLXYzPGki+hP16az8djuC9HX8ktgNbdBJoCdELjgOizz8SwmitsVkZeYOSBhOuNU6OqEMnWb4PcyLcNgRcdYlrmhQ5RSzY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710941301; 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=egdv//vjTLv/Dnwgm5FCHtX9kgu/A4joSMg560AJ/lqf+L8Vkg7X4iraBjKnGhniEcDyY5FEBeuNKtIfCAcJQuMxVkVSdlq2s6nDg/9TxlsyyDxvNmXchwqO9tuVfIjyd+i7aKcERnxuWoOL3K4YTia164c1TQi/yRc4qdcw5JM= 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.17]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4V08VB5Qf9z1h2mb; Wed, 20 Mar 2024 21:25:38 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 1AD731A0172; Wed, 20 Mar 2024 21:28:12 +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; Wed, 20 Mar 2024 21:28:11 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v7 3/5] Documentation: tracing: add new type '%pd' and '%pD' for kprobe Date: Wed, 20 Mar 2024 21:29:22 +0800 Message-ID: <20240320132924.2802187-4-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240320132924.2802187-1-yebin10@huawei.com> References: <20240320132924.2802187-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: dggems703-chm.china.huawei.com (10.3.19.180) 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 Acked-by: Masami Hiramatsu (Google) --- 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 22:06:46 2026 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (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 D1BFC40C09; Wed, 20 Mar 2024 13:28:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710941302; cv=none; b=uqA+YnJgh3WSDvQJUl8umMsPKpl8XqHlKAXrdn/iuZIQQ5ayryTcr6KPCjXZLYcUYNK31VTdtAz09DRzFxiennEeXfWaz6XEYyYcSwTW4DY0RcTKIA8pk7kO/LIBPGPG5w1DE/C5XJfLA7szUPuoGFs/NLYpLsFM2NTDcWiIg2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710941302; c=relaxed/simple; bh=PAuV3wGybOkWPg2txqBYQgpyb2BYdYoi5e0uWKeMlW0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lTkfP24wKbTOtxboZMRvKWy4OenfC1tmxDwXRSmTPoGjElILx8jrFMCsdidL+bvGfvEQvc3GD9QhrFlxH/RQN/QGZat3L6aAWumeZJv+Xkg2BfwkBv44WFcgH6/ahSKLgJ6vRr0H2GKuuftgdbXhOOBXdxnZndQCUK+/mlZAcHU= 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.188 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 szxga02-in.huawei.com (SkyGuard) with ESMTP id 4V08XC5lKGzbdBZ; Wed, 20 Mar 2024 21:27:23 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 89F27140158; Wed, 20 Mar 2024 21:28:12 +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; Wed, 20 Mar 2024 21:28:12 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v7 4/5] selftests/ftrace: add kprobe test cases for VFS type "%pd" and "%pD" Date: Wed, 20 Mar 2024 21:29:23 +0800 Message-ID: <20240320132924.2802187-5-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240320132924.2802187-1-yebin10@huawei.com> References: <20240320132924.2802187-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: dggems703-chm.china.huawei.com (10.3.19.180) 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 Acked-by: Masami Hiramatsu (Google) --- .../ftrace/test.d/kprobe/kprobe_args_vfs.tc | 40 +++++++++++++++++++ 1 file changed, 40 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..21a54be6894c --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_vfs.tc @@ -0,0 +1,40 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Kprobe event VFS type argument +# requires: kprobe_events "%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 22:06:46 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 A94DA40BEF; Wed, 20 Mar 2024 13:28:20 +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=1710941302; cv=none; b=lG88WjDTTnv6Y7v81nSDvPJQoMs5Xb8eijRn1TTCRkv1WkLAafJGG86jCPIefgQBDysyzk10VZUsUwoXzM2pszfNqea6PfJbLYq45OGhe4WYnfBXtKCAXRCwddpnZ/gUwNhlY/em4qUEaN8GVe2aqIt2pVFYb9I/mOOrTHyfeNg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710941302; c=relaxed/simple; bh=mm/LKOibx69xdWi9kZO3FwKzMXoZWR3O/2RiRcPvCZk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=C8zvNqaoQXWfd+/+w2Y+GwDFrlnY9nph2egzIgdP6F2WzFV2Y2aRNCvO3c1awu3EqUlI5OKTt5aL89/qf0AX/4ETqC4v9xZe/iN76zNaXgh9/A7MH7u+dVB3210HsWB6yOJvKlclYklhvHWNKkh+lIcwAbDitAEnE8JvkVnozLQ= 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.88.214]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4V08VC4WF2z1h2lV; Wed, 20 Mar 2024 21:25:39 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id F1CCA1A016C; Wed, 20 Mar 2024 21:28:12 +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; Wed, 20 Mar 2024 21:28:12 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v7 5/5] selftests/ftrace: add fprobe test cases for VFS type "%pd" and "%pD" Date: Wed, 20 Mar 2024 21:29:24 +0800 Message-ID: <20240320132924.2802187-6-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240320132924.2802187-1-yebin10@huawei.com> References: <20240320132924.2802187-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: dggems703-chm.china.huawei.com (10.3.19.180) 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 Acked-by: Masami Hiramatsu (Google) --- .../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