From nobody Wed Dec 24 16:03:28 2025 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.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 1F29312B78; Thu, 25 Jan 2024 07:38:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706168329; cv=none; b=M3hFYQhIC9v4nEUtB+xtkQ5T/3jiNoXejO7545ODtJaad6V0mdsYaH4D5Jpwi04adxY6UynoyqqYVLYuZkfnBk3teCY8/CFaaetegEswQCB+Zr1foNtB+tsN40lty6zHwI8Uhqy+UK0BuVFNI9hZsH6fcFnO2u1uB34CvfiwKfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706168329; c=relaxed/simple; bh=3fYlcljHcBza41tVnauOAqAFF6vQGvbVdY4Eygygshc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CyYbNKo/v5RjE3ZQrZlGoXM4kk9aRYHc8qle2+ZFBYDWC8+9uysz7x0aTWTqkXs5JOh5WxbkIpB3wMnYVtNksDq+qSb8dDWk7b0Nb/xkTkI6z8DgNJFQ0f/mBEd6/x1dR9aQqG2gGNGOQcdAYtEBSJGEtSbJjD5Ht/0X6NpnLNg= 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.189 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.254]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4TLCNG38WKzNlXN; Thu, 25 Jan 2024 15:37:50 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 417AD180079; Thu, 25 Jan 2024 15:38:29 +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_128_GCM_SHA256) id 15.1.2507.35; Thu, 25 Jan 2024 15:36:50 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v5 1/8] tracing/probes: add traceprobe_expand_dentry_args() helper Date: Thu, 25 Jan 2024 15:39:16 +0800 Message-ID: <20240125073923.2252057-2-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240125073923.2252057-1-yebin10@huawei.com> References: <20240125073923.2252057-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 4dc74d73fc1d..0c1caf0f474a 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -1565,6 +1565,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; + 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 850d9ecb6765..5800513439f3 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 Wed Dec 24 16:03:28 2025 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 9C558134B4; Thu, 25 Jan 2024 07:39:21 +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=1706168363; cv=none; b=Y6Cjqp92kvKvH5uknOVrU2kfrQazKETjo524QBLh+o5c1BC+qX5JexM4JyO2XNW+lawZhCmZMD60Cgev11BRUHc97R938SX2x2muHGNB76c/oyHBg/ow6dQbVrjONqY3EKh/ktNqBD99jF37TOKhlVt+jqNB1qScb7fncp09geo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706168363; c=relaxed/simple; bh=DTWWED3utzA+ZuMoccKiNwpAtso/EWOE5CANqtTsna8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CvkfkcVdki2uTkx0SizxDeIC9xsIKrvZEzR5ky7ouPDTzzFxxrBsACNoHxo8Nuh6P6oI0Vk48sr1/BAeirL9LEMolTGMJ0N/kQTIcO/v/m6JStP++5rKvyXgiN/KDPjHpgZabns6IiRir6il7iZUNzxPsLl4KLaI8LZ70DRY3GY= 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.162.112]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4TLCPR1NHNz1vsVX; Thu, 25 Jan 2024 15:38:51 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id A086E140667; Thu, 25 Jan 2024 15:38:58 +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_128_GCM_SHA256) id 15.1.2507.35; Thu, 25 Jan 2024 15:36:51 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v5 2/8] tracing/probes: support '%pd' type for print struct dentry's name Date: Thu, 25 Jan 2024 15:39:17 +0800 Message-ID: <20240125073923.2252057-3-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240125073923.2252057-1-yebin10@huawei.com> References: <20240125073923.2252057-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 Wed Dec 24 16:03:28 2025 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.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 6A8B012B72; Thu, 25 Jan 2024 07:39:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706168358; cv=none; b=GbO3EVAAvEpdgnqdZ4dhYspmBhGgXeCNolhMUgBCJjCXN010AHwgTH5BUmMJXsFha1wZ7PMymCsasPG4JI9x9j5An3L0m9Kez2DbhseqLFp24jXdnYaqowIfy4XiulUxBdDvglY2FLD6VEg4uA0dz4MKyWSnidym03nIbwNTioY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706168358; c=relaxed/simple; bh=ZJw2waAhRAaGjGS/x8pJBAD09jJFzOLc+6SEuva6ITo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uUHPkiBF/jjSW6Uv7m13QgaTtO8dou1aT8BmGihJAl6YfvW0wA4Q3f0Ox7ZsvYxDCcZn2Xrgl/VBI+PuFw++Vign/csophVpHO62tJMBLGsAMPgw2juZKzSPlMHrRMHE/UexI9cOL5W3KVyNls4dXF5ELIR7/auv/pTZ7RqeDUU= 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.189 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.254]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4TLCNr3R49zNlTV; Thu, 25 Jan 2024 15:38:20 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 4AADE18001A; Thu, 25 Jan 2024 15:38:59 +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_128_GCM_SHA256) id 15.1.2507.35; Thu, 25 Jan 2024 15:36:51 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v5 3/8] tracing/probes: support '%pD' type for print struct file's name Date: Thu, 25 Jan 2024 15:39:18 +0800 Message-ID: <20240125073923.2252057-4-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240125073923.2252057-1-yebin10@huawei.com> References: <20240125073923.2252057-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 0c1caf0f474a..5ac7b0193dd8 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" @@ -1577,35 +1578,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 Wed Dec 24 16:03:28 2025 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 5B1E2171AC; Thu, 25 Jan 2024 07:39:31 +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=1706168374; cv=none; b=X7sW7TjcoWqn4MuQt5w8nDcknvHpSVPkLSjr1+FxLzQXOsGnpqshXt5PE8esZo+DkRhCaQnoUBvExqLKaTYnIDfOlEBtYMHZnieer1JO1K/htuw45kCmqDhupnbhxF+4RdyP/BD7gW8SNB6EPJ9YNzvs0bmMi+qkraE2YpPzdm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706168374; c=relaxed/simple; bh=fL+61EE8VfS7TSQ3fjCfD78Ystne/UYrNzobZfLfpQ0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Z7ssflh9J/LTKlZ0FTBUuatS0ppFW60ivAk/+EToq3Fnnzk4YhukQJ05LGtNbMQifEdIMMdHXJ5z2pHvPmF/IDLemtoMnC4isSUs+G28NslxMpJkaNewTD5do0dgNd3YRRNXhB9JhxswBC9+28O9O44jzpVIu5GtkOgpuiiT46k= 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.162.254]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4TLCNx2BYvzsWJS; Thu, 25 Jan 2024 15:38:25 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 4ED5E180080; Thu, 25 Jan 2024 15:39:14 +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_128_GCM_SHA256) id 15.1.2507.35; Thu, 25 Jan 2024 15:36:52 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v5 4/8] tracing/probes: support '%pd/%pD' type for fprobe Date: Thu, 25 Jan 2024 15:39:19 +0800 Message-ID: <20240125073923.2252057-5-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240125073923.2252057-1-yebin10@huawei.com> References: <20240125073923.2252057-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/%pD' for print dentry's or file's name. Signed-off-by: Ye Bin Acked-by: Masami Hiramatsu (Google) --- 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 Wed Dec 24 16:03:28 2025 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 E7FEF17552; Thu, 25 Jan 2024 07:39:35 +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=1706168377; cv=none; b=FYHpMrECzVNk5R1lg+ooUjWBp12y61FPY5Jalcl/62heWEbMXPpfr+cG6PLUE0lPQXBL92PzW4Fj19qwW7MW5ozLZ02a0yq0PIaLuJ6ILmIcWXC9CDS3AkKVKalwYpuS6jDxH75qMCOKvHO6daBy8CmH0Gse+R/UoszKuA3Cm+U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706168377; c=relaxed/simple; bh=ASkvNL+WBKTxbaQNMIjBmg1cXddIy1p77kjdfuRrvQo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NUrZLxdzzHXn6tSug2rn+vZqs3Lj923BfCns1YVnHK7LSvVzn0vyOS1UPQsHRgQyE3SJx1rOJF/VujGtx2yq1RPMja7PlvLwmJ7Ai4PFuyhCVpfs5W/NyDCtBJuX3lPxICFl3MrF7ZmyNiGlzplXeCI34FFnlAfvViQcF8KauP0= 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.162.254]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4TLCP16fsQz18LrN; Thu, 25 Jan 2024 15:38:29 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id BE1A1180081; Thu, 25 Jan 2024 15:39: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_128_GCM_SHA256) id 15.1.2507.35; Thu, 25 Jan 2024 15:36:52 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v5 5/8] tracing: add new type "%pd/%pD" in readme_msg[] Date: Thu, 25 Jan 2024 15:39:20 +0800 Message-ID: <20240125073923.2252057-6-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240125073923.2252057-1-yebin10@huawei.com> References: <20240125073923.2252057-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 2a7c6fd934e9..13197d3b86bd 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -5745,7 +5745,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 Wed Dec 24 16:03:28 2025 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (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 8810E175A6; Thu, 25 Jan 2024 07:39:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.35 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706168387; cv=none; b=PRKQbkN6Ex8uEZo7U3LS/zeDgwsOOvVnJ1arDtg65M6aLRwu1STI2d6rEx1JLX55o3eyVL81nx3lAi7maiMl6O1zlKFEOuAQ6oRdmgH2FW7nTrznhxGKG+QXU0rjQogfubB7Z+G8TWeFlu1hE4WSGc1KBzTCqtE1sF7KGbgYie4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706168387; 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=qOM7MssELzKjE54BJC6PGSNb2I18pCe7dKnD4RCiuvghNL7kD+b5Pv1/aQ/s/NZBaS1OHyg2nyfJNEZOIrqL0SVjNaZL/PLhGt8fwHT4sru3nH7zgPKKcGnhkklNRiJSxEmfka+RKBN485nwCZ0OT94KTMd0oNK9EW0DPSJnlmA= 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.35 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 szxga07-in.huawei.com (SkyGuard) with ESMTP id 4TLCNQ20Vyz1Q8D9; Thu, 25 Jan 2024 15:37:58 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id A73DD1404F7; Thu, 25 Jan 2024 15:39:28 +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_128_GCM_SHA256) id 15.1.2507.35; Thu, 25 Jan 2024 15:36:53 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v5 6/8] Documentation: tracing: add new type '%pd' and '%pD' for kprobe Date: Thu, 25 Jan 2024 15:39:21 +0800 Message-ID: <20240125073923.2252057-7-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240125073923.2252057-1-yebin10@huawei.com> References: <20240125073923.2252057-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 Wed Dec 24 16:03:28 2025 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 48A41175AD; Thu, 25 Jan 2024 07:39:46 +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=1706168387; cv=none; b=uzYYvpYrYfeuSYVAvNpTFJOLhNcj3QQswPo7KE8/cQ0xXYdRBEMbFvxhAA1KyRfcl9pYalMULoafKsRIdeMCnWb1uGfE422MYeuAIPbTJ4lRXIOtqXnixFE8c+YvbFvt3GA/LbEJIPFbQiZ7RpFfJ3Xa1/tNPPP9INlNprsGw4c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706168387; c=relaxed/simple; bh=kbdMpe4IqkGBetn5w0E/SJbJ+UhnYagZ5GDUcfBAmB8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HzNngnDFxOOAz4lZtm8Pxrf3Pnd00T9lEh8jNVIcDMKkWSqwFyQ5FPA/MUOPHtJoerw8JKxjF3gSqFH4HD3XREHqb5R0x3Dk/5iiiXBX/WJE0/yalbq56zqEK96eAY/HnjQloShRn+YhDSRlroPQjDXCP8xg5L3pdrh55gwgem8= 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.162.254]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4TLCPD3X0cz18Lnb; Thu, 25 Jan 2024 15:38:40 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 5326818006C; Thu, 25 Jan 2024 15:39:29 +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_128_GCM_SHA256) id 15.1.2507.35; Thu, 25 Jan 2024 15:36:53 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v5 7/8] selftests/ftrace: add kprobe test cases for VFS type "%pd" and "%pD" Date: Thu, 25 Jan 2024 15:39:22 +0800 Message-ID: <20240125073923.2252057-8-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240125073923.2252057-1-yebin10@huawei.com> References: <20240125073923.2252057-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..cf0599b90f1a --- /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 + +: "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 Wed Dec 24 16:03:28 2025 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 CEF3F17BAE; Thu, 25 Jan 2024 07:40:01 +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=1706168403; cv=none; b=SR2jdrvqLnpOa+FuolKyKvhdSKmIJUBX6bmlCDPE8AAIsUGRwBLhMhPm5wZl63wwGy/tI7KD2skm+m47ci8g3/LRmtCWPIlZeMyb0qVt2++o807EXx3OfjYGn1IagMQK8Jg/HybUNKjccErrcJBUJ5NuBfBZ0byPreTvfrzoj+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706168403; c=relaxed/simple; bh=Di5QFTkBZO4/CVl9f+evbhAXhnNNLRMry/k3VXo5/Hs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LysK3lS9382xpMooisgpX0iBbGXV1Ubh00tMNXws7aPLGA58acAp2UjlwHAwksqXYyS69ufiaxGniEaHx7YGUlggQMWcYGxNjhFV5EKY4av8KibGfVe9GlxcDbeDOzf6OHoVw2xrw7qRb+/vXAOkPG9i0gwDN+iF/u8IdyAST8k= 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.162.254]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4TLCNy19qwzhZPy; Thu, 25 Jan 2024 15:38:26 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 575A9180083; Thu, 25 Jan 2024 15:39:44 +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_128_GCM_SHA256) id 15.1.2507.35; Thu, 25 Jan 2024 15:36:53 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v5 8/8] selftests/ftrace: add fprobe test cases for VFS type "%pd" and "%pD" Date: Thu, 25 Jan 2024 15:39:23 +0800 Message-ID: <20240125073923.2252057-9-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240125073923.2252057-1-yebin10@huawei.com> References: <20240125073923.2252057-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..0a5baaffc137 --- /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 + +: "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