From nobody Wed Dec 24 21:30:33 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 5844358134; Tue, 23 Jan 2024 09:19:14 +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=1706001556; cv=none; b=pk7Q8aNUZ+MPpk8C+/tmpi9pCr6FwzsMcaiU5clVcr9w1LIVE6SYtJuUWZKcKo6RyfjKRsm6Jx3HWq061p0IuBpqVvRtFlYVEg6wnY/BD8gUY2mBNtsJUzLALYxu6s9xADfDINQ42kXhFG6RRE7j5B7gUB+a7KyQx5z8yRjSz5o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706001556; c=relaxed/simple; bh=SiWtbyNZNzEz2T7i5SIjV//aX/niwPXUWmBVnXoNsP4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HIAR2wTADuePdmXaxQu6uwhOePOiA/O7dVTOaHzGi9njSgxegiuQVW9vxMMnHsxwvhQXICLCDbWyT/JuedkxiafMgbh0lviVigy6+oNLIfsJqELjFPHZ0A7mbxSQ1qVBJ3aXicmAlmqWH/Ymo+bX6lBmlJxgHspSo0YUJ4QZWMM= 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.88.194]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4TK1hK5R6nzvVDK; Tue, 23 Jan 2024 17:17:37 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id D7D851404FE; Tue, 23 Jan 2024 17:19:08 +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; Tue, 23 Jan 2024 17:19:03 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v4 1/7] string.h: add str_has_suffix() helper for test string ends with specify string Date: Tue, 23 Jan 2024 17:21:33 +0800 Message-ID: <20240123092139.3698375-2-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240123092139.3698375-1-yebin10@huawei.com> References: <20240123092139.3698375-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" str_has_suffix() is test string if ends with specify string, and also this API may return the index of where the suffix was found. Signed-off-by: Ye Bin --- include/linux/string.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/linux/string.h b/include/linux/string.h index 433c207a01da..2fb0f22237fe 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -405,4 +405,32 @@ static __always_inline size_t str_has_prefix(const cha= r *str, const char *prefix return strncmp(str, prefix, len) =3D=3D 0 ? len : 0; } =20 +/** + * str_has_suffix - Test if a string has a given suffix + * @str: The string to test + * @suffix: The string to see if @str ends with + * @index: The index into @str of where @suffix is if found (NULL to ignor= e) + * + * Returns: + * * strlen(@suffix) if @str ends with @suffix + * * 0 if @str does not end with @suffix + */ +static __always_inline size_t str_has_suffix(const char *str, const char *= suffix, + size_t *index) +{ + size_t len =3D strlen(suffix); + size_t str_len =3D strlen(str); + + if (len > str_len) + return 0; + + if (strncmp(str + str_len - len, suffix, len)) + return 0; + + if (index) + *index =3D str_len - len; + + return len; +} + #endif /* _LINUX_STRING_H_ */ --=20 2.31.1 From nobody Wed Dec 24 21:30:33 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 00F1758212; Tue, 23 Jan 2024 09:19:13 +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=1706001556; cv=none; b=EyUUfEbjVhSO1wnjGtnF7NhFtxL4EZT+gj7vW8Sb93m0EdzoGK6P5FBkSaWdpmFFDRfQWYL83/JOGS2S0Oq6Ph+5m1BG0trzoQsmWLGZykhzip0sCdo0IO2RAFM3Uetl2IFaANP4pO6H4eYQ6Rh+0QKDoI+NXGllgqqXFkBb0yA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706001556; c=relaxed/simple; bh=kYEzP77hAItk65iHZF+3d1AGqaHOMtv6LJ964mV0QIM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HYt3KvD8CfU4UUJOtC3Qe4NCE3jik+BtdVh2xx6NOVjvE4+JIxyQHoRYbestF9dptas+oEsV/wpRtTi/LsIEEOTMQFHcZESVTmLjWcMkPLzY4xCjE7jz55YwolHSsGBFClhXgg62jKKT87Fn0KVHBy3otkNYZbvZ0UZNxN2/XLM= 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.194]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4TK1hv44lmz18LMp; Tue, 23 Jan 2024 17:18:07 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id DC21E140578; Tue, 23 Jan 2024 17:19:08 +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; Tue, 23 Jan 2024 17:19:04 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v4 2/7] tracing/probes: add traceprobe_expand_dentry_args() helper Date: Tue, 23 Jan 2024 17:21:34 +0800 Message-ID: <20240123092139.3698375-3-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240123092139.3698375-1-yebin10@huawei.com> References: <20240123092139.3698375-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 | 36 ++++++++++++++++++++++++++++++++++++ kernel/trace/trace_probe.h | 2 ++ 2 files changed, 38 insertions(+) diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index 4dc74d73fc1d..cc8bd7ea5341 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -1565,6 +1565,42 @@ const char **traceprobe_expand_meta_args(int argc, c= onst char *argv[], return ERR_PTR(ret); } =20 +int traceprobe_expand_dentry_args(int argc, const char *argv[], char *buf, + int bufsize) +{ + int i, used, ret; + + used =3D 0; + for (i =3D 0; i < argc; i++) { + size_t idx; + + if (str_has_suffix(argv[i], ":%pd", &idx)) { + char *tmp =3D kstrdup(argv[i], GFP_KERNEL); + char *equal; + + if (!tmp) + return -ENOMEM; + + equal =3D strchr(tmp, '=3D'); + if (equal) + *equal =3D '\0'; + tmp[idx] =3D '\0'; + ret =3D snprintf(buf + 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) + return -ENOMEM; + argv[i] =3D buf + used; + used +=3D ret + 1; + } + } + + return 0; +} + 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..553371a4e0b1 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -402,6 +402,8 @@ 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, + int bufsize); =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 21:30:33 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 5873F58215; Tue, 23 Jan 2024 09:19:14 +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=1706001556; cv=none; b=O7RD0u/yY7vrH89CYP6kBT8mQR/jwtSJkTK6LBA9Bx1Qtb22sleCCrxqFj8Vs/V3PPKVQNwW7zZnUpmOdIQWpwJCJbAEjlrf0aLXnoVX5eoTLCXC2Bt8wPLTkduSSY26WAmL1/dxR88gGLCGoISdSsIIu89pXHnTcAqhtI7B/lY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706001556; c=relaxed/simple; bh=R+0EqFIiGaBBpGCVcH0I4eW51HMRsop2Clw0T8UHkPY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CQZzSmogPnSo3wOCNRDE83FSz9OszksRUMAgiQPgTGbLRgVEDRuBagrdxwA4066arvzEq2rGe9k0RxVw/hyzxXQXw582sW85jzgnUBQxVaveBCIhBMlSa4pwVd96fRdvczUu57y0+Zm3k5ZX41gtdX5dLsivLmLVwWnZHjFrWNw= 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.88.194]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4TK1hv2tr9zsVBl; Tue, 23 Jan 2024 17:18:07 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id E04E8140410; Tue, 23 Jan 2024 17:19:08 +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; Tue, 23 Jan 2024 17:19:04 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v4 3/7] tracing/probes: support '%pd' type for print struct dentry's name Date: Tue, 23 Jan 2024 17:21:35 +0800 Message-ID: <20240123092139.3698375-4-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240123092139.3698375-1-yebin10@huawei.com> References: <20240123092139.3698375-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 ++++++ kernel/trace/trace_probe.h | 1 + 2 files changed, 7 insertions(+) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index c4c6e0e0068b..00b74530fbad 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[MAX_DENTRY_ARGS_LEN]; struct traceprobe_parse_context ctx =3D { .flags =3D TPARG_FL_KERNEL }; =20 switch (argv[0][0]) { @@ -930,6 +931,11 @@ static int __trace_kprobe_create(int argc, const char = *argv[]) argv =3D new_argv; } =20 + ret =3D traceprobe_expand_dentry_args(argc, argv, dbuf, + MAX_DENTRY_ARGS_LEN); + if (ret) + goto out; + /* setup a probe */ tk =3D alloc_trace_kprobe(group, event, addr, symbol, offset, maxactive, argc, is_return); diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index 553371a4e0b1..d9c053824975 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 --=20 2.31.1 From nobody Wed Dec 24 21:30:33 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 5878058218; Tue, 23 Jan 2024 09:19:14 +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=1706001556; cv=none; b=hwBul+U3ePXlCJ9RS91cfjFKf92qUmiiEOWnXb9ylYOiCy/u9Jp5yHRmzQk5i2/vp1/ao8U/0nkgp4XuyqMXlbSqxwC/5gSKYZ2dFtPi8cZwQ3JFwCQv8fI4oVIHrg/bJXaS2V+63jzsp+mSXN50JNfBScqov+6mNr+Du91fPJc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706001556; c=relaxed/simple; bh=pw2vTIuQmODbxC808VglRRN13BkaI7LvfeN3506+b+k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mcgWNbWgtL4NOauva2Sf1gk6UGad5a4UcwnpqPhtZJr7TIG716XpjSmw62oUSgQF2dX4SMG9n8VRvPZDYUs9a7UHJlPFM3dxIko8e1AlTcr7phN7qLSnU0jORv0YLgZIcJY1R71U1NqEURVibTH3GU86nJACsaegYVWiRlNyxvg= 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.88.194]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4TK1hv31hXzsWMZ; Tue, 23 Jan 2024 17:18:07 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id E479C1404FD; Tue, 23 Jan 2024 17:19:08 +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; Tue, 23 Jan 2024 17:19:05 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v4 4/7] tracing/probes: support '%pD' type for print struct file's name Date: Tue, 23 Jan 2024 17:21:36 +0800 Message-ID: <20240123092139.3698375-5-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240123092139.3698375-1-yebin10@huawei.com> References: <20240123092139.3698375-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 | 41 ++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index cc8bd7ea5341..a664633137a0 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" @@ -1574,28 +1575,38 @@ int traceprobe_expand_dentry_args(int argc, const c= har *argv[], char *buf, for (i =3D 0; i < argc; i++) { size_t idx; =20 - if (str_has_suffix(argv[i], ":%pd", &idx)) { - char *tmp =3D kstrdup(argv[i], GFP_KERNEL); - char *equal; + if (!str_has_suffix(argv[i], ":%pd", &idx) && + !str_has_suffix(argv[i], ":%pD", &idx)) + continue; =20 - if (!tmp) - return -ENOMEM; + char *tmp =3D kstrdup(argv[i], GFP_KERNEL); + char *equal; + + if (!tmp) + return -ENOMEM; =20 - equal =3D strchr(tmp, '=3D'); - if (equal) - *equal =3D '\0'; - tmp[idx] =3D '\0'; + equal =3D strchr(tmp, '=3D'); + if (equal) + *equal =3D '\0'; + tmp[idx] =3D '\0'; + if (argv[i][idx + 3] =3D=3D 'd') ret =3D snprintf(buf + 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) - return -ENOMEM; - argv[i] =3D buf + used; - used +=3D ret + 1; - } + else + ret =3D snprintf(buf + 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) + return -ENOMEM; + argv[i] =3D buf + used; + used +=3D ret + 1; } =20 return 0; --=20 2.31.1 From nobody Wed Dec 24 21:30:33 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 88BEF58209; Tue, 23 Jan 2024 09:19:13 +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=1706001555; cv=none; b=SJ71NUc6FDq60LRbc+O3MTSE7+SxrzaCDuM46yMnEuuU9zPpNBQEedOyFCczMMvTI/67HLwHkrw7iySIDLTWk9dESLyMomgEkJ1CGPGtTlmcpvfXo6muHBq6fxs+sg9RFyCprtmI/p2Q6AY+riw2jnqC7+l8sczC1a82rsYsCYk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706001555; c=relaxed/simple; bh=ASkvNL+WBKTxbaQNMIjBmg1cXddIy1p77kjdfuRrvQo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rQzUycTcymEisBX0zjk6GhQY0UomjQBkhR0m0YxUnSg7iPNF5sNbjPyu4S8uCFmRNW5Cqfl4fWe/ZUhCTr3TCQDnpcych1fOdJHIb8UHT5UqYN5cLuOuCvkrhYWrNxaQZ85+cV2IhIhbmqji/xBnGW1CwXMfCbymlk0Tk9drtNA= 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.88.194]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4TK1j51JZkzNlSH; Tue, 23 Jan 2024 17:18:17 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id E8AED140631; Tue, 23 Jan 2024 17:19:08 +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; Tue, 23 Jan 2024 17:19:05 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v4 5/7] tracing: add new type "%pd/%pD" in readme_msg[] Date: Tue, 23 Jan 2024 17:21:37 +0800 Message-ID: <20240123092139.3698375-6-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240123092139.3698375-1-yebin10@huawei.com> References: <20240123092139.3698375-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 21:30:33 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 656DF5C60D; Tue, 23 Jan 2024 09:19:35 +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=1706001576; cv=none; b=Tp2Rdwv0q7epr1Q6Qd+RvyyoRpjuK7O0dKLfrKglIWdtDysruU3QLxHs++LNLwh2RTCjh35OfhDngpGnfRDDejMbBmyZUYYhOvZJwi+uff4Y6Gt7u2g0pc/HyLCvyjbXDsmDZfyTetvB4mlZ5cfW9ZRGN1mGqPql0iy4xiMX5pM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706001576; c=relaxed/simple; bh=IZ2ztT+g8180deg7EL3rrFcIgg1N/vQXRmntkTF7fOc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jtSYB9ae66ZsJKTBY2vqJEZdae2Tq9LD4+jBJmCx4or2XeGKiyLijZBmYzOO9dVHF01MURY70H/oqTVFq+hQ7Zt6pUqJTaHGdg7TMm31ABvPVZqB5R8ic8holzYgoNmHMoX02/nmLcyCWnwJtebhLMn/WEUOhYgPzbYB0Py8/jY= 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 4TK1jY39PYzNlQ6; Tue, 23 Jan 2024 17:18:41 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 31CEE180089; Tue, 23 Jan 2024 17:19: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; Tue, 23 Jan 2024 17:19:06 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v4 6/7] Documentation: tracing: add new type '%pd' and '%pD' for kprobe Date: Tue, 23 Jan 2024 17:21:38 +0800 Message-ID: <20240123092139.3698375-7-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240123092139.3698375-1-yebin10@huawei.com> References: <20240123092139.3698375-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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Documentation/trace/kprobetrace.rst b/Documentation/trace/kpro= betrace.rst index bf9cecb69fc9..a1d12d65a8dc 100644 --- a/Documentation/trace/kprobetrace.rst +++ b/Documentation/trace/kprobetrace.rst @@ -58,7 +58,8 @@ 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" + (x8/x16/x32/x64), VFS layer common type(%pd/%pD) for print + file name, "char", "string", "ustring", "symbol", "symst= r" and bitfield are supported. =20 (\*1) only for the probe on function entry (offs =3D=3D 0). Note, this a= rgument access @@ -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 pointer or struct file's pointer. + .. _user_mem_access: =20 User Memory Access --=20 2.31.1 From nobody Wed Dec 24 21:30:33 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 2E7405914C; Tue, 23 Jan 2024 09:19:50 +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=1706001591; cv=none; b=o75whJJPO+UxQxmSYmXaZ9SNY/Bs9VqdOucXseOatNOuzQYXdSW0TBcAqqJT1rZprrPDLnsKrjjibOzT74WFn4Wr5jKDlyA+00UMavEbLDwXpEIEPLFGDdSMqoe3ZsWe4VksE8cyulvIFRmXj+Np08UbmEiuCdgybpYY9ojHiaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706001591; c=relaxed/simple; bh=wqD3BcIyhEmryJcEFaCD5uVA14nzmG5cK5v0iik8hsM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HfWtv8hwHPhFTGnnNiZ8GxiFVxkXhHs+RorN3pB7B74q8ChvYcxZUDj36tEobDpfHRlvq3fJRW7Zjns87+xUEc/WQVBKHozQdZ4LtNnNr+3XluSSBOM1RpwcsoFK049ZbBOcw5XEM6R75nWwOgD0KfVLGOADmv6WYuikT/1dtfg= 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 4TK1j50k71zvVDK; Tue, 23 Jan 2024 17:18:17 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 3693E18007C; Tue, 23 Jan 2024 17:19:33 +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; Tue, 23 Jan 2024 17:19:06 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v4 7/7] selftests/ftrace: add test cases for VFS type "%pd" and "%pD" Date: Tue, 23 Jan 2024 17:21:39 +0800 Message-ID: <20240123092139.3698375-8-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240123092139.3698375-1-yebin10@huawei.com> References: <20240123092139.3698375-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(); Signed-off-by: Ye Bin --- .../ftrace/test.d/kprobe/kprobe_args_vfs.tc | 79 +++++++++++++++++++ 1 file changed, 79 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..1d8edd294dd6 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_vfs.tc @@ -0,0 +1,79 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Kprobe event VFS type argument +# requires: kprobe_events + +case `uname -m` in +x86_64) + ARG1=3D%di +;; +i[3456]86) + ARG1=3D%ax +;; +aarch64) + ARG1=3D%x0 +;; +arm*) + ARG1=3D%r0 +;; +ppc64*) + ARG1=3D%r3 +;; +ppc*) + ARG1=3D%r3 +;; +s390*) + ARG1=3D%r2 +;; +mips*) + ARG1=3D%r4 +;; +loongarch*) + ARG1=3D%r4 +;; +riscv*) + ARG1=3D%a0 +;; +*) + echo "Please implement other architecture here" + exit_untested +esac + +: "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