Received: by 2002:a19:771d:0:0:0:0:0 with SMTP id s29csp1258804lfc; Wed, 1 Jun 2022 13:20:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9HIw6syPO8sjOn+1y1xB8lvcRNI1vaLDtHZqP1VEi7+MIiUwvmve2Sgy7JKvz/qi4Z5ac X-Received: by 2002:a63:e4a:0:b0:3fc:a85f:8c08 with SMTP id 10-20020a630e4a000000b003fca85f8c08mr970139pgo.450.1654114829820; Wed, 01 Jun 2022 13:20:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654114829; cv=none; d=google.com; s=arc-20160816; b=FmiVejoNp1gViqXKaYUcgKAXBtgiXbm7p/RoGhG5Rt29UcuZQtjzvktv7z//QJ4uWZ mbsSjWuFy3CoMb4WUHaaywVCVKxiDF4tHrF1Og+RVtTePtTGnAQFaDJ1TIjdOi9j1VqL F1BRquXhT6yq8ItFSkRF4RN8xs6IMiC/yemBSQnZPNmkk1xxmOhQ3MAaf0kwd3TH1d+b 6WevhJArMsUlEk9d0ck77sqUhWaDLLCCfZxMDdq2Cn9PzDGD05HB7EHxCAECXH+4yfC/ HgGLMc/CuMPxlaTSxqhhxZdyA2Sa1UBEtyVS7XAMiAQ+ifDTHFG4G6+p+BvAad5oj1+3 1jtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=NiRkn+A1iBTo5YsOaMxuHLBWyT1tMe8QmsR4pNlDf2Q=; b=fwYYLe0m2WdnbxyD/a0KItac/1hw4sOb6rNe6JopMm18fEIWz29Q7oDQNIHRxbb/qW +nSGbGaIQhp4cQR97l8HQR7PFHFWsi9cJ88p8bzmNlWafGvaNKvgxFKIUsqi7lrJx9uG cfmKF5Za+n1svf7m4qEgDHSvN6ugd4II8aJJ6Zirs23gjPqFi2gdvu3L2Op/a6nVrtEe 3eHi0Gek5WIsGIW/iXYzE6HJjL2YtyVC6HkuZagxs2mpCSIN4k1oUyWSPoWW2lE0VcsR ++JHWr576J1+NSL4sNR+LrA+UW7YfBjTF+L866B3gWsty17P28ZSUr1eX17kt/hqGtX4 3x1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FXPtJGDX; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id w11-20020aa7858b000000b0050bb3e9c4f7si3023993pfn.134.2022.06.01.13.20.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 13:20:29 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FXPtJGDX; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E60F3190D16; Wed, 1 Jun 2022 12:32:28 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354764AbiFAPNm (ORCPT + 99 others); Wed, 1 Jun 2022 11:13:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348999AbiFAPNj (ORCPT ); Wed, 1 Jun 2022 11:13:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2685D6FD09 for ; Wed, 1 Jun 2022 08:13:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CC7CBB81BA4 for ; Wed, 1 Jun 2022 15:13:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 049D1C385B8; Wed, 1 Jun 2022 15:13:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654096415; bh=AKied9qL7mPMb5TN8YdwIpBfNWBe+n2m6OCjzvUfk5Y=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=FXPtJGDXdKYrZnL/FdYQtJlCyPdwKfdevDysVc8GecPOOM0z79+HAqHKkE9Fn4fv6 Kuu8Luzckze5LPiZrCfpx503KV63d4cPd8Kkb0qwndrbut94UzcBdw7od7EH0yDubN QeGjKM6mxRmQqa+THEqRox8TEyqAFCxyacqI10s2Pzy9OQThSCadGqm/kRvkR9IZjR 1MtnqgSvDHA+2A3cAUBewOgIosvgb1CoXbXEbHJJNjkD5uQo6sYMMLTzgAJqRrC9ug TLbUUtd2fv/+mS4e1AfERgJN4Wl8AIDa2pJtIPB7f5fdNzqeINQCQqjfzSKV2eGsnD 5Zid04fiNyXnA== Date: Thu, 2 Jun 2022 00:13:31 +0900 From: Masami Hiramatsu (Google) To: Jeff Xie Cc: Steven Rostedt , mingo@redhat.com, Tom Zanussi , linux-kernel@vger.kernel.org Subject: Re: [PATCH v10 2/4] trace/objtrace: Get the value of the object Message-Id: <20220602001331.fab92b2dcd2c9aaad800ddae@kernel.org> In-Reply-To: References: <20220512170008.1301613-1-xiehuan09@gmail.com> <20220512170008.1301613-3-xiehuan09@gmail.com> <20220522232216.bb1451fb6efc18c2bccc8d09@kernel.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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. 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.) > > 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)