From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6C72C433DF for ; Mon, 12 Oct 2020 15:37:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 709772087E for ; Mon, 12 Oct 2020 15:37:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602517043; bh=UDFXDkJshI9WAzh09i45Ygqd33LHOwbKvPeaq9Kg3zc=; h=Subject:From:To:Cc:Date:In-Reply-To:References:List-ID:From; b=KnzdExU79oNKF+tNZzILSmqddg+qW3nMWdbmUsSygYzA8+jy1FmSJKBnjFb1VX1zd AQDipPri9kK8nwwL1CXNyLaYlwPncmhs3dzxwTVUtyrcT96cVSytBBlTxEB3gtsLqZ 3dqujGnBQRhuKwCZaaErtL3xeg8R/DEmgUgBvHu4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390037AbgJLPhW (ORCPT ); Mon, 12 Oct 2020 11:37:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:42460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389121AbgJLPhW (ORCPT ); Mon, 12 Oct 2020 11:37:22 -0400 Received: from tzanussi-mobl (c-73-209-127-30.hsd1.il.comcast.net [73.209.127.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1AD6420575; Mon, 12 Oct 2020 15:37:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602517041; bh=UDFXDkJshI9WAzh09i45Ygqd33LHOwbKvPeaq9Kg3zc=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=iZIzFOBIQ2g6VoIejkNSZN7V2YtZ+gspaiPktmn6VwijFUupqzHIJp+Wp4EstDCrs GEjUgcnwfAPX9GWZA+WlD2aZ3LWzYSqd2W4yKBhZxYgDNeXN06ePgT21h0/Hc8gwg7 6pkzNpixu5G9PyhiQqr/WvvyTI6Vgo9+fxdc++6g= Message-ID: <1a3863252345703b469821f128ecbac6bc55e1c0.camel@kernel.org> Subject: Re: [PATCH 1/5] tracing: Don't show dynamic string internals in synthetic event description From: Tom Zanussi To: Masami Hiramatsu Cc: rostedt@goodmis.org, axelrasmussen@google.com, linux-kernel@vger.kernel.org Date: Mon, 12 Oct 2020 10:37:19 -0500 In-Reply-To: <20201011000344.4056fd1b0e8a7e48f2677ac0@kernel.org> References: <20201011000344.4056fd1b0e8a7e48f2677ac0@kernel.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Masami, On Sun, 2020-10-11 at 00:03 +0900, Masami Hiramatsu wrote: > Hi Tom, > > On Fri, 9 Oct 2020 10:17:07 -0500 > Tom Zanussi wrote: > > > For synthetic event dynamic fields, the type contains "__data_loc", > > which is basically an internal part of the type which is only meant > > to > > be displayed in the format, not in the event description itself, > > which > > is confusing to users since they can't use __data_loc on the > > command-line to define an event field, which printing it would lead > > them to believe. > > > > So filter it out from the description, while leaving it in the > > type. > > > > OK, I confirmed this removes __data_loc from synth_events interface. > However, I also found another issue. > > /sys/kernel/debug/tracing # echo "myevent char str[]; int v" >> > synthetic_events > /sys/kernel/debug/tracing # cat synthetic_events > myevent char[]; str; int v > > It seems that the type "char[]" includes ";" as a type, this results > Yeah, this isn't a result of this patchset - it's a different bug which I'll submit a new fix for. Basically in the array case it doesn't effectively strip off trailing characters when creating the array type. Thanks, Tom > > /sys/kernel/debug/tracing # cat events/synthetic/myevent/format > name: myevent > ID: 1220 > format: > field:unsigned short common_type; offset:0; size:2; signe > d:0; > field:unsigned char common_flags; offset:2; size:1; signe > d:0; > field:unsigned char common_preempt_count; offset:3; size: > 1; signed:0; > field:int common_pid; offset:4; size:4; signed:1; > > field:__data_loc char[]; str; offset:8; size:8; signe > d:1; > field:int v; offset:16; size:4; signed:1; > > print fmt: "str=%.*s, v=%d", __get_str(str), REC->v > > > As you can see, the field type has ";" in format file too. This will > prevent > parsing event information correctly. > I also try to remove ";" as below, it seems to work correctly. > > /sys/kernel/debug/tracing # echo "myevent char[] str; int v" >> > synthetic_events > /sys/kernel/debug/tracing # cat events/synthetic/myevent/format > name: myevent > ID: 1221 > format: > field:unsigned short common_type; offset:0; size:2; signe > d:0; > field:unsigned char common_flags; offset:2; size:1; signe > d:0; > field:unsigned char common_preempt_count; offset:3; size: > 1; signed:0; > field:int common_pid; offset:4; size:4; signed:1; > > field:__data_loc char[] str; offset:8; size:8; signe > d:1; > field:int v; offset:16; size:4; signed:1; > > print fmt: "str=%.*s, v=%d", __get_str(str), REC->v > > > Thank you, > > > Reported-by: Masami Hiramatsu > > Signed-off-by: Tom Zanussi > > --- > > kernel/trace/trace_events_synth.c | 10 +++++++++- > > 1 file changed, 9 insertions(+), 1 deletion(-) > > > > diff --git a/kernel/trace/trace_events_synth.c > > b/kernel/trace/trace_events_synth.c > > index 3b2dcc42b8ee..b19e2f4159ab 100644 > > --- a/kernel/trace/trace_events_synth.c > > +++ b/kernel/trace/trace_events_synth.c > > @@ -1867,14 +1867,22 @@ static int __synth_event_show(struct > > seq_file *m, struct synth_event *event) > > { > > struct synth_field *field; > > unsigned int i; > > + char *type, *t; > > > > seq_printf(m, "%s\t", event->name); > > > > for (i = 0; i < event->n_fields; i++) { > > field = event->fields[i]; > > > > + type = field->type; > > + t = strstr(type, "__data_loc"); > > + if (t) { /* __data_loc belongs in format but not event > > desc */ > > + t += sizeof("__data_loc"); > > + type = t; > > + } > > + > > /* parameter values */ > > - seq_printf(m, "%s %s%s", field->type, field->name, > > + seq_printf(m, "%s %s%s", type, field->name, > > i == event->n_fields - 1 ? "" : "; "); > > } > > > > -- > > 2.17.1 > > > >