Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp6922949ioo; Thu, 2 Jun 2022 17:13:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwT2mwlg7q5P0u+kefLkLg8KTrqkqEUh/xMJGmrGllGSh+IXYf/sfpt/Z8EvvDh4oZS94lh X-Received: by 2002:a17:906:4fd5:b0:6ff:2b0d:6031 with SMTP id i21-20020a1709064fd500b006ff2b0d6031mr6321546ejw.607.1654215180368; Thu, 02 Jun 2022 17:13:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654215180; cv=none; d=google.com; s=arc-20160816; b=JmI8EvbRZyBb4Eteqz9pNbJ24iMTqdIMRLZXxpJyIses5+HQ9+D8gMTExwG1cl+L7a oobYFR4axvdG/Wm9mnck1O4AwU5an5nJyYO50bzW7pn2iUC5K4ICeD5dNg83lh4ylulK z0Z8+WS26TSYjG4wHdNtULi6bde3y+p58wFd3WEF8E0nq7z+CGToqfDUT1yQW48kij1C OxWix9ZZCuaZ9p0IwbgITinNdPeKR4+qzLMtv0x+PZVoN0/itqpGNeks0biobUD7OXhG mJCx/BCK+p6tfnai31/Nt7S7uhdsLFoStpINpKXXDiV60R/RqapJTl4xwQ0P+GHjo4pe Lqxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=1eSiFQMELLSa5Z07ibxKS6Uu+L0qY0UU5WkKVpdJwBc=; b=GSk4W0wLIHEt/YbdUAP5lgVOp/7ZbYdui78IpokdFzZpGP6/7kxpmjgUVcC96rc8wq 2FfEwGPyqccI42lCkw/ujpCD7Sg8rfeoIveO8Z6D1BT4bYZK68fI0gQ1iflunelOxxN2 CNxHZnxNipU/VO6wLfgr+qLes/SwGIXsrkQcA0CGs0lXH7ZApxGYKTdLIiZ1gLzznI28 oe9/3if+PdiBy8QRs1iUMC0AQo1xip8zPfgao5uaJLe3WrZb1lmoNsf5jlI1wSCIAEb2 M7lg6Qps1CR4akbFQY263TD9RhNnxShnd+YgEQbBSpkzHMMkp21P8vkux+hAET365/oZ oapw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=axZZklCF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg26-20020a170907971a00b0070b43a2659asi2914782ejc.716.2022.06.02.17.12.35; Thu, 02 Jun 2022 17:13:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=axZZklCF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236948AbiFBQXa (ORCPT + 99 others); Thu, 2 Jun 2022 12:23:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236847AbiFBQX3 (ORCPT ); Thu, 2 Jun 2022 12:23:29 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 473EF186E9 for ; Thu, 2 Jun 2022 09:23:28 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id e29so1359068wra.11 for ; Thu, 02 Jun 2022 09:23:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1eSiFQMELLSa5Z07ibxKS6Uu+L0qY0UU5WkKVpdJwBc=; b=axZZklCFshHH21Hz7kBAhD3S7f3uQKv52XBA5zgPzeffQgMZes9XwMCn+rvTnKTXho 9/cQqhX9B0gDwKk9mC/Mz02eiYxe0UW5zP2L71zSGX7wTu2iEM1n2mNH/2HfuRDrAWIA A2xjkSNHDeLtb0uUrBO5uxFTP7SdbS7sIQAfkGVj+92rNXgw1UCkKynadXFVvtcuRVRn V5uvNV/u+Xi/JWFG81DewXO2pFCNeAbRf18DY3A530j8rTKhhKwpWomUwR/4vzILyU7R R9mGAKFMo2WA5ZKXLXCDhDwJLth00JhPI4k/lyxLITQfe6hAR+OUHdxwjECnRKDVVenE v3sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1eSiFQMELLSa5Z07ibxKS6Uu+L0qY0UU5WkKVpdJwBc=; b=EJZ43E4CLGy9gboqWGR77FldoyAWB/1n2yn3dzff22UNJdjFbILunk+NCjr06xFog5 Qp3sNq2V7EqMVOun2p0cQubfz8c938RS7ZX5PyUVkg98PfQxF6eQUoriOQuYwXEUSlqx 1XDuBo4WTtNUxpcZLemqoVQBAz5vT9/IxUkdyI6U4CBbQz+B33MCLF5qK6Ezcj3WdPl4 mew5oQz+Dx7vPHh2VQtcr2ITL5MRuCxMaSs70r3I0yt1G0BCZyhuYn97IkJFeYTB9FG8 JnAR+PXEJbpi5RyjWF+igiX9CGMC90XqLflRiB8ZGoxaZ3QYKN/7i8zWPSvyGZaevDcV 6HOA== X-Gm-Message-State: AOAM5310y8QweKUnu9Lwg9BqfRJ926Wp0JKHdFJbF47iFw6kUnsRWvoH I5a9CyWqn7E21ezz2erfa6TT9TEFbg+ZlNgcL1WAW4KnKjWzwQ== X-Received: by 2002:a5d:5343:0:b0:210:2f76:649f with SMTP id t3-20020a5d5343000000b002102f76649fmr4361260wrv.554.1654187006673; Thu, 02 Jun 2022 09:23:26 -0700 (PDT) MIME-Version: 1.0 References: <20220512170008.1301613-1-xiehuan09@gmail.com> <20220512170008.1301613-3-xiehuan09@gmail.com> <20220522232216.bb1451fb6efc18c2bccc8d09@kernel.org> <20220602001331.fab92b2dcd2c9aaad800ddae@kernel.org> In-Reply-To: <20220602001331.fab92b2dcd2c9aaad800ddae@kernel.org> From: Jeff Xie Date: Fri, 3 Jun 2022 00:23:14 +0800 Message-ID: Subject: Re: [PATCH v10 2/4] trace/objtrace: Get the value of the object To: Masami Hiramatsu Cc: Steven Rostedt , mingo@redhat.com, Tom Zanussi , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Masami, On Wed, Jun 1, 2022 at 11:13 PM Masami Hiramatsu wrote: > > On Tue, 31 May 2022 15:13:24 +0800 > Jeff Xie wrote: > > > Hi Masami and steve, > > > > On Sun, May 22, 2022 at 10:22 PM Masami Hiramatsu wrote: > > > > > > Hi Jeff, > > > > > > On Fri, 13 May 2022 01:00:06 +0800 > > > Jeff Xie wrote: > > > > > > [...] > > > > @@ -175,9 +271,27 @@ trace_object_trigger(struct event_trigger_data *data, > > > > > > > > field = obj_data->field; > > > > memcpy(&obj, rec + field->offset, sizeof(obj)); > > > > - set_trace_object(obj, tr); > > > > + /* set the offset from the special object and the type size of the value*/ > > > > + set_trace_object(obj, obj_data->obj_offset, > > > > + obj_data->obj_value_type_size, tr); > > > > } > > > > > > > > +static const struct objtrace_fetch_type objtrace_fetch_types[] = { > > > > + {"u8", 1}, > > > > + {"s8", 1}, > > > > + {"x8", 1}, > > > > + {"u16", 2}, > > > > + {"s16", 2}, > > > > + {"x16", 2}, > > > > + {"u32", 4}, > > > > + {"s32", 4}, > > > > + {"x32", 4}, > > > > + {"u64", 8}, > > > > + {"s64", 8}, > > > > + {"x64", 8}, > > > > > > Hmm, as far as I can see, you don't distinguish the prefix 'u','s','x'. > > > If so, please support only 'x' at this moment. kprobe events supports > > > those types, and it distinguishes the types when printing the logged > > > data. E.g. 's16' shows '-1' for 0xffff, but 'x16' shows '0xffff'. > > > You can add another patch to support such different types afterwards. > > > > I feel to let the objtrace trigger to distinguish the prefix 'u', 's', > > 'x', It seems a very challenging work ;-) > > I spent a lot of time thinking, I would like to add a callback > > function(print function) in the struct trace_object_entry for each > > data type. > > Not sure if this is possible or allowed, as I haven't seen any example > > like this to add function in the struct *_entry ;-) > > Hmm, I don't recommend this, becuase this event record can be exposed > to user space as binary data. So please do not put such a function > pointer which will be used in the ftrace directly. > Instead, add a new event type of the object-trace for each type-prefix, > since each of them has different print-fmt. This place is still a difficult point for me ;-) > Anyway I would like to ask you is to share the next version of the > series without that improvement. You can improve it after merging the > basic feature. No need to stop the series until all possible feature > set are implemented (unless it will change the user-exposed interface > much.) Thanks for your suggestion, I will submit the next version. > > > > > The following is part of the code I have prepared. I don't know if you > > can give any suggestions or wait until I submit the next version to > > discuss. > > But thanks for sharing the code. This helps me to understand what you > are trying :) > > Thank you, > > > > > > > > > diff --git a/kernel/trace/trace_entries.h b/kernel/trace/trace_entries.h > > index 2407c45a568c..5f8289e26f91 100644 > > --- a/kernel/trace/trace_entries.h > > +++ b/kernel/trace/trace_entries.h > > @@ -414,6 +414,7 @@ FTRACE_ENTRY(object, trace_object_entry, > > __field( unsigned long, parent_ip ) > > __field( unsigned long, object ) > > __field( unsigned long, value ) > > + __field( unsigned long, print ) > > ), > > > > +/* get the type size for the special object */ > > +struct objtrace_fetch_type { > > + char *name; > > + int type_size; > > + int is_signed; > > + print_type_func_t print; > > +}; > > + > > > > static const struct objtrace_fetch_type objtrace_fetch_types[] = { > > - {"x8", 1}, > > - {"x16", 2}, > > - {"x32", 4}, > > - {"x64", 8}, > > - {NULL, 0} > > + {"u8", 1, 0, PRINT_TYPE_FUNC_NAME(u8)}, > > + {"s8", 1, 1, PRINT_TYPE_FUNC_NAME(s8)}, > > + {"x8", 1, 0, PRINT_TYPE_FUNC_NAME(x8)}, > > + {"u16", 2, 0, PRINT_TYPE_FUNC_NAME(u16)}, > > + {"s16", 2, 1, PRINT_TYPE_FUNC_NAME(s16)}, > > + {"x16", 2, 0, PRINT_TYPE_FUNC_NAME(x16)}, > > + {"u32", 4, 0, PRINT_TYPE_FUNC_NAME(u32)}, > > + {"s32", 4, 1, PRINT_TYPE_FUNC_NAME(s32)}, > > + {"x32", 4, 0, PRINT_TYPE_FUNC_NAME(x32)}, > > + {"u64", 8, 0, PRINT_TYPE_FUNC_NAME(u64)}, > > + {"s64", 8, 1, PRINT_TYPE_FUNC_NAME(s64)}, > > + {"x64", 8, 1, PRINT_TYPE_FUNC_NAME(x64)}, > > + {NULL, 0, 0, NULL} > > }; > > > > > > > > + {} > > > > > > If this array is null terminated, please explictly do that, like > > > > > > {NULL, 0}, > > > > > > for readability. > > > > > > Thank you, > > > > > > -- > > > Masami Hiramatsu (Google) > > > > Thanks, > > JeffXie > > > -- > Masami Hiramatsu (Google) Thanks, JeffXie