From patchwork Mon Jan 22 07:40:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 189935 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2416611dyb; Sun, 21 Jan 2024 23:38:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1JoEuzvZ4O2aIWLpijb4p1UcRDTA8JgGhLitELC8Bu9Pr4D0x4EZlwqlWFKdO+ERIM71E X-Received: by 2002:a05:6402:28f:b0:559:9da5:19f6 with SMTP id l15-20020a056402028f00b005599da519f6mr1847249edv.19.1705909092574; Sun, 21 Jan 2024 23:38:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705909092; cv=pass; d=google.com; s=arc-20160816; b=lROdEzhkEO7rif1Ip7fAsJr/Lh8iASHM+zslS00rUi3vzqEjkD4RoZHjvv4gLXLlaJ faBWlLgj9fvCOh+St4ssOL7EK/lq+VyW+UtH2p9V+jGCkPTVlbz8rv+FiLcgy4zSKUEw VM6TOeDo3/++y7Q10Gk00/qVhe9CWLlCrv9hDqIxH0W2rDKUY5kggFv0AHPQaoggTMJt yzgggVyVoAH3bf86ipFnQjpSeBrlzx7PmM8aT/zy76bLpuGVqlLy/FDT3Nn+HQRKNLgw t39n2O9meAHpdJFYVGFW8BgmF6xbtCigrY8DmpFV/mlSnoECbqFd4hyaekW3gmYo3fRu wFMQ== 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=xOlOUqAMj8ivc8bsmDQh2fWmsKd9HFqcyqEb2t7uYL8=; fh=Us/DORbzHj5XmgnBeJW+VlCBdo2pSXKHAejHonylCvY=; b=O2AhKA0b6mf89az28WjB4PWTn62LK7NA4q86W4MNfFYvwandipaEJQlZSXDc0wQYrG c8RwVB34KKYwnj4Uema+c8If9pUv4Csidg6qdowcBOfL5Bh5fxXSzJQadJ3IoEXXD6Ac 1zUNV4J5fTaImcIzhTPpPqK+4U6/AiI6VabbEeEeQx/3JEm0Ep4OInOD2rpAoyEXX6ZW dwY7L54Zu1+m0X8ymtywC/IskmZNTs0EKZjK2zLYfoZQwqWaS9cKAWnK+CCv2o+QJavV tNCTiZFDYe9ti1/X/qUA+8ibKhgrFgkARs2wfp7xETq3rAnmg94rFbdfqt/yB8JIhdHz vCdQ== 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-32434-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32434-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q35-20020a05640224a300b0055400f1f188si11187003eda.41.2024.01.21.23.38.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 23:38:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32434-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-32434-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32434-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 331571F228AE for ; Mon, 22 Jan 2024 07:38:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C2DC8179BA; Mon, 22 Jan 2024 07:37:53 +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 2319D16416; Mon, 22 Jan 2024 07:37:49 +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=1705909072; cv=none; b=tCJpB3ZWssMxwMwmSiSpq/4HokrxhUzH4LgVxw6N2X8Fqutv/2JY5GIb4wMrU7b8HlGHBi3u2BwjTgUFFMQEqqJHolhp/QA/eOEH6gUWiSo9TkP/GgjkPHchobEiBKZjZgcQAfytMnblyLOEOOJXOwwsg4QPgxWQG6mA4yJTevo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705909072; c=relaxed/simple; bh=sBwc0e0LX68ujIGPPtdpEdCtFeOhchnf4ztfTmcCrW4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PqdnJLFmR2y4yr6IFpsaa/yKHdTSXPzt3OZqQYX9CUSh8sw5QdTNl2T7fct/lxsUj66XLtH47+7utJiXYORZNx5BSTyOXtgMNRSOsgD1/hmDTl5dJpU+sn70ozaFgIDgu9NG9Z1uqGmlHcxpiZgS1pnXZ3tTfsim5bhHxPrf+jk= 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.163.174]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4TJMVC181kzVjFn; Mon, 22 Jan 2024 15:36:35 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 49E9D1400E4; Mon, 22 Jan 2024 15:37: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; Mon, 22 Jan 2024 15:37:39 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v2 1/7] string.h: add str_has_suffix() helper for test string ends with specify string Date: Mon, 22 Jan 2024 15:40:09 +0800 Message-ID: <20240122074015.4042575-2-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240122074015.4042575-1-yebin10@huawei.com> References: <20240122074015.4042575-1-yebin10@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500010.china.huawei.com (7.192.105.118) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788775332512687409 X-GMAIL-MSGID: 1788775332512687409 str_has_suffix() is test string if ends with specify string. Signed-off-by: Ye Bin --- include/linux/string.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/string.h b/include/linux/string.h index 433c207a01da..e47e9597af27 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -405,4 +405,24 @@ static __always_inline size_t str_has_prefix(const char *str, const char *prefix return strncmp(str, prefix, len) == 0 ? len : 0; } +/** + * 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 + * + * 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 len = strlen(suffix); + size_t str_len = strlen(str); + + if (len > str_len) + return 0; + + return strncmp(str + str_len - len, suffix, len) == 0 ? len : 0; +} + #endif /* _LINUX_STRING_H_ */ From patchwork Mon Jan 22 07:40:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 189936 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2416818dyb; Sun, 21 Jan 2024 23:38:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IET8QxbHXYuK3JiLlPBxtY9OerhQMIvzbO9amZUO8wbiCcnNeMEVqYYtEdKZEmz0xd/ixjv X-Received: by 2002:a05:6808:ec4:b0:3bd:6b73:58d9 with SMTP id q4-20020a0568080ec400b003bd6b7358d9mr5524767oiv.21.1705909136011; Sun, 21 Jan 2024 23:38:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705909135; cv=pass; d=google.com; s=arc-20160816; b=UDr3msov4xKdEz7fWUpqpJyqzBlRbpY4qk+10mQNmXZQMDL1UbQBe2NJ9eKl+BAttw G2rGCvFWsh7pOQfrcMS0aWxg2uV2FUpxPnrOqGE9qBLmJXN37OOFZWkevnlgDqji3vZy E7A7OExb6oa8vMYDZSVPDPstujwWduvrbqpM2KBIL4sb78veN212AA8fyNY7nZNd6Glu xI9CDBFT3f5KDpyifEajzQJ8cQbA0qH5nMt9q64jtXh9w9110KLRiQeMEjkK+9Ml1mS2 E0Nigg4oh7ZNdJw+qNO7J0UtA1UiKz1hKzQ2aFGwWoCubBTsXKcmImQSsne4hGeQevsI 2F5Q== 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=2dnJ+YRF+VhtsUOpiEMSpM2yJJYMTvJHPO69bl2ifRk=; fh=Us/DORbzHj5XmgnBeJW+VlCBdo2pSXKHAejHonylCvY=; b=L6/p+eMrubR08Leq5/km3IxZgi0QO44LlMZJRhaqUXTR0lDEMyzjfLL+/mATEADs4P mVfbvHxOy7vJnmQtvPPCvpz29syRh1x8TH6BBlGSt8Gn9DAYW0R/sEb3BSApXr3V2Q+O 1uWh7b0slGw8/U2eLC+EmgnJ57NyHuhiTJfN/5ww1txooBDW7caSOov+fDuPtOLRVQ2a WrIxcJsjJ/3uSrFpk3T/vdtOGI5aaJjR6rrOq9Lw322eUSnOz7GGe1gVxUTHxp4eeHAr zzOL8ZbBlx7UV0m37GiR8Umfd4Fnpchdwgu2cFSECMD+CjCM+TxwJuWeGPzvbmfFvBVz ozbw== 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-32437-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32437-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c14-20020a63724e000000b005b86142ee56si7620400pgn.277.2024.01.21.23.38.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 23:38:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32437-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; 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-32437-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32437-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 BB5A2281531 for ; Mon, 22 Jan 2024 07:38:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA8AB17729; Mon, 22 Jan 2024 07:38:13 +0000 (UTC) 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 BBC6320DEB; Mon, 22 Jan 2024 07:38:09 +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=1705909092; cv=none; b=QGCbOWPwmdFdcta/nVwjTdDYTlf2hLCKYITdeuKLIyKDuSgQMPS+0FXnayJqAyDp0X4eGuwLZLYdww1+gE5lLhyhCtGK8GfoPlm+9dC2FPPxAIr+eOQIwoGocboMGPdtjfB5TklS2CmfL889Px+L9JV//iWo2DPzda9c70jcOdM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705909092; c=relaxed/simple; bh=uRi7b/OnTFYE7tce+ThtNtXL9uYhQDA1900RsEUwyxY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kYJn2o4tGNAsHEab20yi+4Bj2khaofXAdKFOWQEtDlrNXJ3oozQm+P7gtwR3dulFs5+OxX3J0Jk4TcsQv6FptQ5V74Ko67YH5aQKBd/oxIWIpeAVRobippb5Z0o/BHDlNwzrB5ZjjbRASMgT1jN/MHpMVCDJ0rkt0YRD4+1zhjI= 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.88.214]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4TJMV02SKYz1S5NB; Mon, 22 Jan 2024 15:36:24 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 1DE4C1A0179; Mon, 22 Jan 2024 15:37:52 +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; Mon, 22 Jan 2024 15:37:39 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v2 2/7] tracing/probes: add traceprobe_expand_dentry_args() helper Date: Mon, 22 Jan 2024 15:40:10 +0800 Message-ID: <20240122074015.4042575-3-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240122074015.4042575-1-yebin10@huawei.com> References: <20240122074015.4042575-1-yebin10@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500010.china.huawei.com (7.192.105.118) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788775378089300277 X-GMAIL-MSGID: 1788775378089300277 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 | 34 ++++++++++++++++++++++++++++++++++ kernel/trace/trace_probe.h | 2 ++ 2 files changed, 36 insertions(+) diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index 4dc74d73fc1d..1599c0c3e6b7 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -1565,6 +1565,40 @@ const char **traceprobe_expand_meta_args(int argc, const char *argv[], return ERR_PTR(ret); } +int traceprobe_expand_dentry_args(int argc, const char *argv[], char *buf, + int bufsize) +{ + int i, used, ret; + + used = 0; + for (i = 0; i < argc; i++) { + if (str_has_suffix(argv[i], ":%pd")) { + char *tmp = kstrdup(argv[i], GFP_KERNEL); + char *equal; + + if (!tmp) + return -ENOMEM; + + equal = strchr(tmp, '='); + if (equal) + *equal = '\0'; + tmp[strlen(argv[i]) - 4] = '\0'; + ret = snprintf(buf + used, bufsize - used, + "%s%s+0x0(+0x%zx(%s)):string", + equal ? tmp : "", equal ? "=" : "", + offsetof(struct dentry, d_name.name), + equal ? equal + 1 : tmp); + kfree(tmp); + if (ret >= bufsize - used) + return -ENOMEM; + argv[i] = buf + used; + used += 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_probe *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[], char *buf, + int bufsize); extern int traceprobe_update_arg(struct probe_arg *arg); extern void traceprobe_free_probe_arg(struct probe_arg *arg); From patchwork Mon Jan 22 07:40:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 189937 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2417031dyb; Sun, 21 Jan 2024 23:39:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IGfuZ8bGF7IGql6YYrrxGOtRHjFLWnkwjtjpDGUrwoRtQn956cvXGxJtSArNvVpHIsNmmxo X-Received: by 2002:a05:6358:9386:b0:173:203:c5c1 with SMTP id h6-20020a056358938600b001730203c5c1mr1457329rwb.62.1705909178633; Sun, 21 Jan 2024 23:39:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705909178; cv=pass; d=google.com; s=arc-20160816; b=VGlyaNmFxaG2T2RORMz0sXJltXxqfCX2un+qRJ1Z6RXcMGUu/L5QFd1xE4wj7DQc3E nqbypajupw14+QB7H0jCpxUpSvoZ/aAsVyXTUmsq+12045XuNN9i7SEhkk1Gvm8iS5Ue gr0M2TMHsAGGYChulnqVHM4nJHpJle9eWHUQ7R7rpflY0UHcTNViLtgFYtqnE9wnnEXq TwGoSvBXstoWYgrGybYZj4rmcTcjVcXhGUJuSNnrAQRhrEx7WEUip0KfYy7Wwp+jV9mo bkExXJ4ebvLHCz+lopjeBYfjt4XRf6mImpOD/bmqNz8XEPYGsZfnntZOdomBsqh42gTM dAHQ== 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=m8LjomVwrXT4T62mIm13eH431OWptUKNTv39dGu0u2Y=; fh=Us/DORbzHj5XmgnBeJW+VlCBdo2pSXKHAejHonylCvY=; b=c1oJcYZBeZ/YGTvjHnBjRY6j2+GkeDyvM0OKA01BsekkwewDVQTHaBw1BHCMVKGZlP kUOZM1h88Z2GlHUCJuO12JtBtfkNPnHqBNryh0OVJGDA15GK28gJfKvK5Fx2/5S8rHhh ukuj8M6e6T9hGhYIB7Bql9erq70c75bp5Uo5j6Ukpp4haJWBM/6P2Jj/skbxYIYZxuCP hR674KTK+J+zp95+J20+c10/T/V/LowPIn2CSxT4ybwAU/TBbnZl6uWfaW/jAukxqN4b f92Cd0XknmSFQ7chdmVgPgL+CmGSNZ4UoUbHrllFN35V8vWVxO05oszGid8gdXAgJLm+ Jp+g== 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-32438-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32438-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id fb18-20020a056a002d9200b006dbce4a61e0si3925363pfb.387.2024.01.21.23.39.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 23:39:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32438-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-32438-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32438-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 46ED6B233AF for ; Mon, 22 Jan 2024 07:39:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E8A818AF1; Mon, 22 Jan 2024 07:38:43 +0000 (UTC) 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 9BBDE17BD1; Mon, 22 Jan 2024 07:38:39 +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=1705909121; cv=none; b=mrnDj/orcNUxuyXyEcY1m91zBs2Q93Z0nHXeQqo+J4FsGUTfTe8YgJLhMwynnrT5Uyx/C+JhOiRpOv7Q7ge1Yrc4/ZbLhSYAdt8qfdWy1m3Bp9Z5n+MfggCBKxLzxk5Gd2apwqCOBJ200WCUzSIM4nruFdr8byQCwVHtawfXZng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705909121; c=relaxed/simple; bh=R+0EqFIiGaBBpGCVcH0I4eW51HMRsop2Clw0T8UHkPY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=G0dyfKuvKCnr8dr6e/eaJFAbxPO9sNiFgwdSLykWVsbBalLpbtJ/WYDr92oIGk50VfdKqHnDQSWlULQUkYlXi2pLb06Px1mYmLUItYwXUbIhmriVG4omiu4wPHi4/tdULIbhCaPRwVoLGRkevluTieVXqhvELKaEqnNloVCcgSA= 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 4TJMRY6CBkz1FJcT; Mon, 22 Jan 2024 15:34:17 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 24FAD1A0173; Mon, 22 Jan 2024 15:38:22 +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; Mon, 22 Jan 2024 15:37:39 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v2 3/7] tracing/probes: support '%pd' type for print struct dentry's name Date: Mon, 22 Jan 2024 15:40:11 +0800 Message-ID: <20240122074015.4042575-4-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240122074015.4042575-1-yebin10@huawei.com> References: <20240122074015.4042575-1-yebin10@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500010.china.huawei.com (7.192.105.118) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788775422772254861 X-GMAIL-MSGID: 1788775422772254861 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 = { .flags = TPARG_FL_KERNEL }; switch (argv[0][0]) { @@ -930,6 +931,11 @@ static int __trace_kprobe_create(int argc, const char *argv[]) argv = new_argv; } + ret = traceprobe_expand_dentry_args(argc, argv, dbuf, + MAX_DENTRY_ARGS_LEN); + if (ret) + goto out; + /* setup a probe */ tk = 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) From patchwork Mon Jan 22 07:40:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 189939 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2417307dyb; Sun, 21 Jan 2024 23:40:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IE5rjO/+6QPMN8YGtmNSz0qSpvqtTiwMjIs6Mr+3E5cKUi0cd3FEplG6s6Uqn0MwRh19WZh X-Received: by 2002:a05:6402:c0a:b0:55a:8431:ba7c with SMTP id co10-20020a0564020c0a00b0055a8431ba7cmr3102378edb.37.1705909230696; Sun, 21 Jan 2024 23:40:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705909230; cv=pass; d=google.com; s=arc-20160816; b=gJkaN3Nf4iZPw/oY8b5+EafJZNTwHSaTSMq6XWJwbc6HHk6besmpbEneVkIVUDL5Ao XdhKLuFb2Evb3d1MqbrAhTpT4aO7EuuQxiXdcprQBvvHNa0nkJ82Id985dSN9l3ZrKvY 3l86c/L678gJrZqWXPjdCyrekxuJ6G/XMB5Evl2ITgiRkeRvPcwObLx1T01JEBnheIme RfFzrvUDFNurNl1qn66sXhmKijQovHhoItoLGUhpotrhPhE/y4iiBIb9rhCtwi5c8/HD rYiM3Nmd9VRsrEJUI/EDpuzCaD6Az03Mk1PdN7ZlqSqyeGYseyy+T78NWa+Xv55itjVo vNUQ== 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=WhJPbl4e63vSoFGFLv1u4x+ecdfCxI5h9kbIs8VTKwY=; fh=Us/DORbzHj5XmgnBeJW+VlCBdo2pSXKHAejHonylCvY=; b=Uca82SC3GIFeZpSM/nX66IQtr8sDwb7HzzcRLkLsND1Vl9vsH9t7lsF+xAPRwEOQG6 /+kMYsSsfU1NGLfCgVi6yaIUhTIFtQcINdhcyBVaVyyAaS4T89YQZI8bLRdg8Z9jNjla r5YMWc1Pf3T5YaWXNkmbNg69T06KvWYAA6QZ1EGTyOYOw9qp5xOqQ0H5TnP0Nwh4EEHI d7u5oYdIicsqUDpCcxmzQOocc+FL8s8Dttr8K2gHvX5DU0POtyvrh1FkOzLNxNRBh1XR G61hWK+ChPOA1VEo4pluX8xcV3oPbzNFTuctgR+stS0BWHHZebK+VAduPJTw9nHPORq3 MJ+Q== 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-32443-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32443-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m6-20020a056402510600b0055a55a806f8si3696494edd.478.2024.01.21.23.40.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 23:40:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32443-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-32443-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32443-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 525381F2326B for ; Mon, 22 Jan 2024 07:40:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 81DF433CF8; Mon, 22 Jan 2024 07:39:12 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EFDA2FE15; Mon, 22 Jan 2024 07:39:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705909151; cv=none; b=qq6Zdd0tKJuY7hM/e+6XpN57ayVYLvelhbk05Pqa4Jt1x2xtKqDtT7THOhK+C0M73jYPQjdcRlPpLJQ4SdaSbKGhqiYWCrIrIWXZS2+uE5wDsft1fyP1WkzX1TCWgQ6Te4L196kGXCNdINGEg00N6vkY8GaTLstNz9ES+nrQfsA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705909151; c=relaxed/simple; bh=ASkvNL+WBKTxbaQNMIjBmg1cXddIy1p77kjdfuRrvQo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rB43jXMgFN4Z2jGxKjBENo4UCtqsPHP1o7Sm6WVfGdXBXNjh9Mz/D/QqRwnCn6+jea36AWlX5KenmDd30+2W/G5IUURfhJoYJRYDC6VamjOXTixc9g/p84kxCthcdk9ff1ptXbBu/50Abahz0s8tvx1yrYDDpEoYZWOYyv5ab7c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TJMX905Vqz1xmYs; Mon, 22 Jan 2024 15:38:17 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 2D2B41A016B; Mon, 22 Jan 2024 15:38:52 +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; Mon, 22 Jan 2024 15:37:40 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v2 5/7] tracing: add new type "%pd/%pD" in readme_msg[] Date: Mon, 22 Jan 2024 15:40:13 +0800 Message-ID: <20240122074015.4042575-6-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240122074015.4042575-1-yebin10@huawei.com> References: <20240122074015.4042575-1-yebin10@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500010.china.huawei.com (7.192.105.118) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788775477827430625 X-GMAIL-MSGID: 1788775477827430625 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[] = "\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" From patchwork Mon Jan 22 07:40:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 189938 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2417214dyb; Sun, 21 Jan 2024 23:40:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IFfcSINZz8wfdQfUVx6ntqQs9VCwu3u1lkYBSE6XiNAUzG1k8vtvIoWagv+QPd0rF2k/g0f X-Received: by 2002:a05:6a21:a589:b0:19a:7dd4:502 with SMTP id gd9-20020a056a21a58900b0019a7dd40502mr1607880pzc.14.1705909213001; Sun, 21 Jan 2024 23:40:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705909212; cv=pass; d=google.com; s=arc-20160816; b=UEPcuGNOrXokCvygYp4n6APs5EjWnY6zozX4bs2TXxWbVYhhMH2o4drucfrnWmAzST cOI3y9PVx+vuw3Nt2D85s5dNvAoSYbcNigdRyZxCcqSFz9UhmcFXNi1jiVrA7QqYfatf e1MM+M8xWZ+C+w2x1PZNQh1WZADPWQWNI5Tx0rU/yycBCycXQb9GsuPvW0+1prKMqLLc FwF5JVQOq9olQhfBhLU4dSbWYRy67+/baZdJITrbKU0lnTTYXUSu1RudCp9Oysg+H8Yp vPf/fGmgCXIqoBc+ZE0muLWZi4dKOWeQqoq71xzzRoP7B4NAvM2H60RiHly4HjptFBFN B2yw== 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=6/XQvalnxwBoE0JeQUz1ckWQn9Ogdxk175QFj+rhRDU=; fh=Us/DORbzHj5XmgnBeJW+VlCBdo2pSXKHAejHonylCvY=; b=PoM4rESrYALd869x4nF9ryVCeCw9fatkgetGTOkT6nnSCTLjKIuEcrCAg0EXA9yuAR LYuALg81xld0Bj1paz0m4fm1CW9FWyMfz0+ZW0nQGSat+5DWvv8rgwX6WaJRT+3+ZpAs 2vEdgO95WiUpquf4G3r+s0Gq7TQ8DJsYUrbJLWwzvikgn2VB9Mvqe0m5hk/ZAUAj5F9H 05IsNxvY5dE87kHmV/RbC8JT3VTv6tumXUcbs1MhhAPnShM8FGuE5gkHUnRdy7Vwloyc /Bf1NIvzrSkoFyW1Is5ba1CGuS2832OM0TPJvmT4EmsWU6w2xuyYHAQaNaQl1tMeVJlV jLfg== 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-32442-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32442-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c11-20020a170902d48b00b001d704e2da3dsi7562056plg.407.2024.01.21.23.40.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 23:40:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32442-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; 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-32442-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32442-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 B96DD2817A9 for ; Mon, 22 Jan 2024 07:40:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6106B2136B; Mon, 22 Jan 2024 07:39:04 +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 505B120DD2; Mon, 22 Jan 2024 07:39:01 +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=1705909142; cv=none; b=Hspp8Q5IAi2WudvIkeq269z6y26HRRu95pIGGDjVUyHhHC9zrqp46/BagGJqrFQx2aoFMO7mIFENTuofCVDWwXECgcqln9QZyQrceISGy1xCerkcN0Y1qzJtx+nxp+IWTB++s1ka4EZa8ZghaeYzzER6FCwAvUtfIvne3g8GKko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705909142; c=relaxed/simple; bh=wqD3BcIyhEmryJcEFaCD5uVA14nzmG5cK5v0iik8hsM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=R6Hs6jZDOlUuv9DNioAM5VfLJ5ZJ/Q0qB+BOdQ7erHeFQHdg2KOQrwOHZzVuAx1RZz5D5K4osUQRvV0pHw1e7mC1qZtHmFZghKCxBlSDHeosOmNKlZYT8IEjq3bcVeBWyBC2fostEGemuGJEyRWGVTVcMPUx/kPJDBxbCGf7Pws= 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.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4TJMWd6s7LzVhkZ; Mon, 22 Jan 2024 15:37:49 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 0E1201850CA; Mon, 22 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; Mon, 22 Jan 2024 15:37:41 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH v2 7/7] selftests/ftrace: add test cases for VFS type "%pd" and "%pD" Date: Mon, 22 Jan 2024 15:40:15 +0800 Message-ID: <20240122074015.4042575-8-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240122074015.4042575-1-yebin10@huawei.com> References: <20240122074015.4042575-1-yebin10@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500010.china.huawei.com (7.192.105.118) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788775458772379229 X-GMAIL-MSGID: 1788775458772379229 This patch adds test cases for new print format type "%pd/%pD".The test cases 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_args_vfs.tc diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_vfs.tc 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=%di +;; +i[3456]86) + ARG1=%ax +;; +aarch64) + ARG1=%x0 +;; +arm*) + ARG1=%r0 +;; +ppc64*) + ARG1=%r3 +;; +ppc*) + ARG1=%r3 +;; +s390*) + ARG1=%r2 +;; +mips*) + ARG1=%r4 +;; +loongarch*) + ARG1=%r4 +;; +riscv*) + ARG1=%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=${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=${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