Message ID | 20240119013848.3111364-1-yebin10@huawei.com |
---|---|
Headers |
Return-Path: <linux-kernel+bounces-30685-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp734197dyb; Thu, 18 Jan 2024 17:37:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IElXvAvCdly7U5VTsXx1rfCDWESewGkigqWol9LlXc7/+RWg0MKU0tXrmnUcy+65Y88BRy+ X-Received: by 2002:a05:6a21:3998:b0:19a:f7de:3af3 with SMTP id ad24-20020a056a21399800b0019af7de3af3mr2010776pzc.71.1705628229634; Thu, 18 Jan 2024 17:37:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705628229; cv=pass; d=google.com; s=arc-20160816; b=OifNw/lzEaPEnl7Adgx8LRPOXfuXTN2nNvTs8adW7Xde/GHEBkkDK3nBpheNJ2CLJ5 hPKWvDd8rs0fMP016TCkYYsFW859jTaatvgBd4/kc86T0KSJjuvhfDjZ4kx8yWm0JK46 MGELo67BFqOd1qWKzMS0Ibi6j6WMder99Zn4APlMA3v9QqVY9vuZ1qVPh28jLFYmUFGx nO+k+2jPiT5Y/zlcWb62etlIEO9IVdPqcHyQT3d7P/sa9NpkfBCan7kDVA0nVb1MH+7A lb7QzzBxS4rexkxagTTyyT3wRXS7TlphchYqBdxgzU3TjBtLRFcUPHNurIQCiFa+waSa HHDQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=aoW+HGbkhi5CDcSVUfkZWvf4yMUxv/U+gVBDimaFXdQ=; fh=Us/DORbzHj5XmgnBeJW+VlCBdo2pSXKHAejHonylCvY=; b=Xe5l9lhkuIu+LzRkhUOqAl5EP+/WAC1F1h00AdTfouZrXo8SEUZLgt0N2hMdGrBNCw ZUdqLmRU8VMX3GsvEXlvc1A097hQb1JaOpw+xlie6ZIcLnCQKdOc1QxSIlQV+w/X1AHF 3q0nRDLCKUFztAbtYzgH5iSlfypfqujWWtoRc1UZY7KKjsHRax7K9w3gQPxrjOYkvPCb HjeBp1tkR/jyMB5MiYmOCYt0p8Kp3dn/zwiffALDlashLdNU6ITLo0sUFmNgNLqri9zi nvhbc7wqhJ7q6B2MLBjtS6USDQAj10JgkfyjaXuIsU+6B767q+1u4UZfFDHyIZE56ud/ qhmA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-30685-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30685-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h4-20020a170902f7c400b001d720fe91basi45552plw.389.2024.01.18.17.37.09 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 17:37:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30685-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-30685-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30685-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7C6902834DB for <ouuuleilei@gmail.com>; Fri, 19 Jan 2024 01:36:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CFF0A4A15; Fri, 19 Jan 2024 01:36:21 +0000 (UTC) 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 BFA66EC7; Fri, 19 Jan 2024 01:36:17 +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=1705628180; cv=none; b=pMmxCD3VupRCAkMNrdXYq/suZuyIP4nbfRRLtxmzYZB0gyXsqVUu+/2A0h/k2p6jJJPpLMOe0tkP7E7UEHz2gH0cLPLDBCVkSAAn36+x6y4faOCF806Vm6PUNY+8Kfqz775NSMv4dI8ckSVZEVHnByZsnYejWr3wfjlxovtI3oM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705628180; c=relaxed/simple; bh=FuC0kEmZfBf7U/MDt0gJdriiIyRBZ51V3J/u2QRfekI=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=n46JAHCFAF33CnSdqXUC2HLJs395QS/c2kpzZWvGEbzTr+BHI+0YGt4RRCyzoNzQ8mBdWPZQWs1m3m50aqPQEph161Q1SXyO/+bQhVjp0XqOR8ngF++3HTEM5azSGsjqtzgyXVqlGZFrlwd8suJ2qJEwKtcBSaRI6kZz43NQtOc= 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.162.254]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4TGMdQ2DZ5zGpnJ; Fri, 19 Jan 2024 09:35:54 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id DDBDD18005B; Fri, 19 Jan 2024 09:36: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; Fri, 19 Jan 2024 09:36:14 +0800 From: Ye Bin <yebin10@huawei.com> To: <rostedt@goodmis.org>, <mhiramat@kernel.org>, <mathieu.desnoyers@efficios.com>, <linux-trace-kernel@vger.kernel.org> CC: <linux-kernel@vger.kernel.org>, <yebin10@huawei.com> Subject: [PATCH 0/3] support '%pd' and '%pD' for print file name Date: Fri, 19 Jan 2024 09:38:45 +0800 Message-ID: <20240119013848.3111364-1-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500010.china.huawei.com (7.192.105.118) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788480826501543177 X-GMAIL-MSGID: 1788480826501543177 |
Series |
support '%pd' and '%pD' for print file name
|
|
Message
Ye Bin
Jan. 19, 2024, 1:38 a.m. UTC
During fault locating, the file name needs to be printed based on the dentry/file address. The offset needs to be calculated each time, which is troublesome. Similar to printk, kprobe supports printing file names for dentry/file addresses. Ye Bin (3): tracing/probes: support '%pd' type for print struct dentry's name tracing/probes: support '%pD' type for print struct file's name Documentation: tracing: add new type 'pd' and 'pD' for kprobe Documentation/trace/kprobetrace.rst | 3 +- kernel/trace/trace_probe.c | 50 +++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-)
Comments
On Fri, 19 Jan 2024 09:38:45 +0800 Ye Bin <yebin10@huawei.com> wrote: > During fault locating, the file name needs to be printed based on the > dentry/file address. The offset needs to be calculated each time, which > is troublesome. Similar to printk, kprobe supports printing file names > for dentry/file addresses. Hi Ye, Thanks for your proposal! Generically, I think this type of hack is not good for the tracing because there are already some ways to do that. e.g. - Use perf probe to specify dentry->name:string or file->name:string - Use BTF to specify in the same way (but only for function entry) And those are more obvious what it does. However, if this is implemented in more generic syntax, it will be acceptable. For example, type specifying with "arg1:printfmt(%pD)" will be more generic because it is apparently one of the printfmt and output string. Or, maybe we can just allow to use ":%pD" as a fetch type (start with '%' means the printfmt) Also, could you update readme_msg[] in kernel/trace/trace.c if you add a type, and add a testcase of selftests/ftrace, for this feature? Documentation should also be updated with more syntax information. Thank you, > > Ye Bin (3): > tracing/probes: support '%pd' type for print struct dentry's name > tracing/probes: support '%pD' type for print struct file's name > Documentation: tracing: add new type 'pd' and 'pD' for kprobe > > Documentation/trace/kprobetrace.rst | 3 +- > kernel/trace/trace_probe.c | 50 +++++++++++++++++++++++++++++ > 2 files changed, 52 insertions(+), 1 deletion(-) > > -- > 2.31.1 >
On Fri, 19 Jan 2024 23:43:56 +0900 Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote: > Thanks for your proposal! > > Generically, I think this type of hack is not good for the tracing > because there are already some ways to do that. e.g. > - Use perf probe to specify dentry->name:string or file->name:string > - Use BTF to specify in the same way (but only for function entry) > And those are more obvious what it does. > > However, if this is implemented in more generic syntax, it will be > acceptable. > For example, type specifying with "arg1:printfmt(%pD)" will be > more generic because it is apparently one of the printfmt and output > string. Or, maybe we can just allow to use ":%pD" as a fetch type > (start with '%' means the printfmt) Yes, I like this idea a lot. Please add the '%' keyword/token to change how to display this in the print format. We may need to add more than one token though. Is that supported? $arg1:u32:%08x or that could also be: $arg1:%08x:u32 That is, the order should not be important. Thoughts? -- Steve > > Also, could you update readme_msg[] in kernel/trace/trace.c if > you add a type, and add a testcase of selftests/ftrace, for this > feature? Documentation should also be updated with more syntax > information.
On 2024/1/19 22:43, Masami Hiramatsu (Google) wrote: > On Fri, 19 Jan 2024 09:38:45 +0800 > Ye Bin <yebin10@huawei.com> wrote: > >> During fault locating, the file name needs to be printed based on the >> dentry/file address. The offset needs to be calculated each time, which >> is troublesome. Similar to printk, kprobe supports printing file names >> for dentry/file addresses. > Hi Ye, > > Thanks for your proposal! > > Generically, I think this type of hack is not good for the tracing > because there are already some ways to do that. e.g. > - Use perf probe to specify dentry->name:string or file->name:string > - Use BTF to specify in the same way (but only for function entry) > And those are more obvious what it does. > > However, if this is implemented in more generic syntax, it will be > acceptable. > For example, type specifying with "arg1:printfmt(%pD)" will be > more generic because it is apparently one of the printfmt and output > string. Or, maybe we can just allow to use ":%pD" as a fetch type > (start with '%' means the printfmt) > > Also, could you update readme_msg[] in kernel/trace/trace.c if > you add a type, and add a testcase of selftests/ftrace, for this > feature? Documentation should also be updated with more syntax > information. > > Thank you, Thank you very much for your suggestion. I will re-implement this function according to your suggestion. >> Ye Bin (3): >> tracing/probes: support '%pd' type for print struct dentry's name >> tracing/probes: support '%pD' type for print struct file's name >> Documentation: tracing: add new type 'pd' and 'pD' for kprobe >> >> Documentation/trace/kprobetrace.rst | 3 +- >> kernel/trace/trace_probe.c | 50 +++++++++++++++++++++++++++++ >> 2 files changed, 52 insertions(+), 1 deletion(-) >> >> -- >> 2.31.1 >> >
On Fri, 19 Jan 2024 10:52:43 -0500 Steven Rostedt <rostedt@goodmis.org> wrote: > On Fri, 19 Jan 2024 23:43:56 +0900 > Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote: > > > Thanks for your proposal! > > > > Generically, I think this type of hack is not good for the tracing > > because there are already some ways to do that. e.g. > > - Use perf probe to specify dentry->name:string or file->name:string > > - Use BTF to specify in the same way (but only for function entry) > > And those are more obvious what it does. > > > > However, if this is implemented in more generic syntax, it will be > > acceptable. > > For example, type specifying with "arg1:printfmt(%pD)" will be > > more generic because it is apparently one of the printfmt and output > > string. Or, maybe we can just allow to use ":%pD" as a fetch type > > (start with '%' means the printfmt) > > Yes, I like this idea a lot. Please add the '%' keyword/token to change how > to display this in the print format. > > We may need to add more than one token though. Is that supported? > > $arg1:u32:%08x > > or that could also be: > > $arg1:%08x:u32 No, not yet. But I rather like comma separated. $arg1:u32,%08x Hm, this needs more changes, like a new type parser. And it will be a option of the default type. Thank you, > > That is, the order should not be important. > > Thoughts? > > -- Steve > > > > > > Also, could you update readme_msg[] in kernel/trace/trace.c if > > you add a type, and add a testcase of selftests/ftrace, for this > > feature? Documentation should also be updated with more syntax > > information. >