Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp868451rdb; Tue, 23 Jan 2024 19:02:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHhgQ0gfIUKtK9bcUzz7hj9aM0AJYO/5DfPO0L5uK1mgUZlzL9SBSoN2EmBEXE5jzYlCCuE X-Received: by 2002:a05:6808:aa5:b0:3bd:62ac:cd3d with SMTP id r5-20020a0568080aa500b003bd62accd3dmr754732oij.47.1706065362880; Tue, 23 Jan 2024 19:02:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706065362; cv=pass; d=google.com; s=arc-20160816; b=rqTOsYXCmk1NBZw+QH3WxrXbm7vJVw/inhyUVivvXimLElBcsLGENCyLn81i0ZyrgH e4aq8ZiFTapP6of6C0HUCJYg04EBX8/C3ukQvjbMKbl7UiUmFlerj+uTcyWz+CKz/elB p9C0BkcnZc+tJ3cflt+UbYym749QNt4skK25cfPyThPyxrclDfwpDH327xmQh9jM2D59 utQUIVT/JttwNpJVs+k2rkHy5oB7ba0u1JGfQpsIPx+KtLwWjjEzHpSwGDcsOINnjy0G S3KhFubGCCrt+H++/xwpSyDRb3+cijdPv9Cb5+83oKUoDvUnzTS9JrNr5M8Z1fgClGfG honA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:date:message-id:from :cc:references:to:subject; bh=RMa4p5hh6p2v8bSh5VH8X5hvYkpEkMrT12uo8MIyyKc=; fh=U7+Kl4iOc6GRDohPpdpak/XYrqxg+RT6K7OQcA7TI3I=; b=B7RhsoCpPSegu8deP8HNJ/0QUjrdNc9UbmDghHrXllTIXxu7TmMs3bayPpbWls+Wqs 9/6mX14w6UoxU5X1Opgf9AYGzmlaVInsTwS+5BqxVuBtrWr091sUvY9xL8bdW3A7nLIC cJRID66vRrIRL+1b/aCCEGhQE6mEe3soQb1p4kuJe1GxPqHyVj48DIBCf0DEykorVL0T VPyoaePr4JPHYdsUTSmMmtAaTObcdcZ8kk0rIOY3QivneHF46LAtelLyLLztv52RzJ5o NtJEEGmDtBHBEn8D7PXPHFLobU9ZieaH5mP5ni2QLmVrvzzXb46yQvhCOB6GSAy1NMHy kjNw== 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-36353-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36353-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id k18-20020a63f012000000b005ce3c33c303si10895718pgh.301.2024.01.23.19.02.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 19:02:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-36353-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::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-36353-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36353-linux.lists.archive=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 80718B287BC for ; Wed, 24 Jan 2024 02:53:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D5C31566E; Wed, 24 Jan 2024 02:46:38 +0000 (UTC) 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 978495225; Wed, 24 Jan 2024 02:46:35 +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=1706064398; cv=none; b=MYtb+E+zxIbHI03Lrir1TSUHYYDM7KhqvdPz7P79zZpXhPja2SAGbfvZiPZ24xxldsIRkAeW0b7AkzYeHa9OvlsnU0iUgopab/oQBxos8cJMgycF3aVKP9DfcPWmh+iHFL+ydjRziEo+9Zf0qPBB69EFEA78qlxXiBl3JhGxpw0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706064398; c=relaxed/simple; bh=kIfCbyqTIfHCDLX59SJ1DP0+CgVWCIkjSYqLb5Zq1x4=; h=Subject:To:References:CC:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=pYkQwb39xtlpJpacsB16+B6GPH7JsN3pc3ubjYKKkXWRL2JceK/Q65c7a/ZGZMHNeW8fCROpOIfCPxVT7DamULCNBinpzb6ldw3Zmuz7JRYQBYXwKdXCDI4XgYDl+k+CXQyq8HhSKk8ekE7vLqVxXBd+Bv/RBqhCF7V3MBrAMaI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4TKSyB4VnJz1vsYX; Wed, 24 Jan 2024 10:46:10 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 8ED3E1A0172; Wed, 24 Jan 2024 10:46:17 +0800 (CST) Received: from [10.174.178.185] (10.174.178.185) 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; Wed, 24 Jan 2024 10:46:10 +0800 Subject: Re: [PATCH v4 3/7] tracing/probes: support '%pd' type for print struct dentry's name To: "Masami Hiramatsu (Google)" References: <20240123092139.3698375-1-yebin10@huawei.com> <20240123092139.3698375-4-yebin10@huawei.com> <20240123234013.52b1834908da7be0272e7a73@kernel.org> CC: , , , From: "yebin (H)" Message-ID: <65B079F2.4000802@huawei.com> Date: Wed, 24 Jan 2024 10:46:10 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20240123234013.52b1834908da7be0272e7a73@kernel.org> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500010.china.huawei.com (7.192.105.118) On 2024/1/23 22:40, Masami Hiramatsu (Google) wrote: > On Tue, 23 Jan 2024 17:21:35 +0800 > Ye Bin wrote: > >> 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]; > Hmm, no, I don't like to expand stack anymore. Please allocate it > from heap. Do I need to change the other buffers on the stacks to allocate memory from heap? >> 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; > And calling this here will not cover the trace_fprobe. > > Could you call this from traceprobe_expand_meta_args() instead of > calling it directly from trace_kprobe? Then it can be used from > fprobe_event too. > > Thank you, At first I wanted to implement the extension logic in traceprobe_expand_meta_args(), but I found that the code was difficult to understand when I started writing. If fprobe_event wants to support this function, is traceprobe_expand_dentry_args() also called? Or re-encapsulate an interface to include the logic of different extensions. In this way, the same buffer is used for the entire extension process, and the extension function needs to return the information about the length of the buffer. >> + >> /* 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 > Why do you think I determined this value according to the extreme case that a parameter is expanded to occupy 64 bytes, and a maximum of four such large parameters are supported. >> #define MAX_STRING_SIZE PATH_MAX >> #define MAX_ARG_BUF_LEN (MAX_TRACE_ARGS * MAX_ARG_NAME_LEN) >> >> -- >> 2.31.1 >> >> >