Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp882237ybg; Fri, 18 Oct 2019 08:44:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwuFLHR4btak574pwTQ6p7052pwny8WMvikz+cPXPKU5xMSKq+qQdBvvWn9h98S0+XWbZWg X-Received: by 2002:aa7:dd0a:: with SMTP id i10mr10204081edv.189.1571413490269; Fri, 18 Oct 2019 08:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571413490; cv=none; d=google.com; s=arc-20160816; b=bJgAzu3vctIn4tuZEAgndkcnKnuMWhzOp+2EbpplRac6RPzVW/FQD+ORMPwS7Kq3Ca qChEqon2O2t7IuPkRZBNWgnErBa0+AWprQX5QqSokd8SslU01A8OfaxHKFVAlilhhhd2 mj6Zh7GxlKji2C6LzF4/6np68MlPEShBhYCk2qfvBrDCYxBf0+vc+WSF26kV7XOtpF6G URYu1K5DDD6HAvyQiPAUMAw/6ZyQzJ3ATt8WZWYIR9GPANtBx6oe//qwWFmlr8kOgq87 EMzp2ZK0halcOEZsH4p5bNEXh2vLyE3A62M5odvM2/S1sbw3K95W4PfmzuKh7FcJtsBr TpuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :reply-to:message-id:subject:cc:to:from:date; bh=TcbzyfbZF7yasXE0Yjod7tlf+W4Ne5JYVMFsOQztDvU=; b=DHTIJtBHNsMd80jJMof5fu0+DxvZNjNfRYk9GthDAK2c6urMsljWP22DcSwN9BpooI III/S+rra8B13FeE9bz1bpl6OFjY4bWyHQw8eLTQg5G/jjrQauQpX/j8HH50lQMTJVrT GnwSwwbl10rs0LtFEMNIX7j+C0YLfMXR4QtytRVhy7hiJI8IA2KS86mWXpFP5tlYj8QY bYOdt2F6t2rwPG/iDCtpkO/QsWJVfB9GCG2DxQYFeYy8kF24aMT81k6+WtoojGtY4Fef HCKHxsxXiQNxWwTnftGEjjfL6PkhJ1k8iZJaLkmw9rCVG9GKsvLK2orxkXVYw5NrzIhc yBFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fj16si3886934ejb.385.2019.10.18.08.44.27; Fri, 18 Oct 2019 08:44:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2409334AbfJQLyP (ORCPT + 99 others); Thu, 17 Oct 2019 07:54:15 -0400 Received: from mx2.suse.de ([195.135.220.15]:42224 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2405897AbfJQLyP (ORCPT ); Thu, 17 Oct 2019 07:54:15 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C3A38AEF6; Thu, 17 Oct 2019 11:54:12 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id F3F9BDA808; Thu, 17 Oct 2019 13:54:23 +0200 (CEST) Date: Thu, 17 Oct 2019 13:54:23 +0200 From: David Sterba To: David Sterba Cc: Qu Wenruo , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-devel@vger.kernel.org Subject: Re: [PATCH v2] tools/lib/traceevent, perf tools: Handle %pU format correctly Message-ID: <20191017115423.GH2751@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Qu Wenruo , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-devel@vger.kernel.org References: <20191017022800.31866-1-wqu@suse.com> <20191017115209.GG2751@twin.jikos.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191017115209.GG2751@twin.jikos.cz> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 17, 2019 at 01:52:09PM +0200, David Sterba wrote: > On Thu, Oct 17, 2019 at 10:28:00AM +0800, Qu Wenruo wrote: > > [BUG] > > For btrfs related events, there is a field for fsid, but perf never > > parse it correctly. > > > > # perf trace -e btrfs:qgroup_meta_convert xfs_io -f -c "pwrite 0 4k" \ > > /mnt/btrfs/file1 > > 0.000 xfs_io/77915 btrfs:qgroup_meta_reserve:(nil)U: refroot=5(FS_TREE) type=0x0 diff=2 > > ^^^^^^ Not a correct UUID > > ... > > > > [CAUSE] > > The pretty_print() function doesn't handle the %pU format correctly. > > In fact it doesn't handle %pU as uuid at all. > > > > [FIX] > > Add a new function, print_uuid_arg(), to handle %pU correctly. > > > > Now perf trace can at least print fsid correctly: > > 0.000 xfs_io/79619 btrfs:qgroup_meta_reserve:23ad1511-dd83-47d4-a79c-e96625a15a6e refroot=5(FS_TREE) type=0x0 diff=2 > > > > Signed-off-by: Qu Wenruo > > --- > > Changelog: > > v2: > > - Use more comment explaining the finetunings we skipped for %pU* > > - Use more elegant way to output uuid string > > --- > > tools/lib/traceevent/event-parse.c | 56 ++++++++++++++++++++++++++++++ > > 1 file changed, 56 insertions(+) > > > > diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c > > index d948475585ce..3c9473f46efe 100644 > > --- a/tools/lib/traceevent/event-parse.c > > +++ b/tools/lib/traceevent/event-parse.c > > @@ -18,6 +18,7 @@ > > #include > > #include > > #include > > +#include > > #include > > > > #include > > @@ -4508,6 +4509,45 @@ get_bprint_format(void *data, int size __maybe_unused, > > return format; > > } > > > > +static void print_uuid_arg(struct trace_seq *s, void *data, int size, > > + struct tep_event *event, struct tep_print_arg *arg) > > +{ > > + unsigned char *buf; > > + int i; > > + > > + if (arg->type != TEP_PRINT_FIELD) { > > + trace_seq_printf(s, "ARG TYPE NOT FIELID but %d", arg->type); > > + return; > > + } > > + > > + if (!arg->field.field) { > > + arg->field.field = tep_find_any_field(event, arg->field.name); > > + if (!arg->field.field) { > > + do_warning("%s: field %s not found", > > + __func__, arg->field.name); > > + return; > > + } > > + } > > + if (arg->field.field->size < 16) { > > + trace_seq_printf(s, "INVALID UUID: size have %u expect 16", > > + arg->field.field->size); > > + return; > > + } > > So if there's an interest for very compact printing loop, something like > this produces the same output: > > for (i = 0; i < 8; i++) { > printf("%02X", buf[i]); > printf("%02X", buf[i]); Ok, test-before-post failure, this should be printf("%02X", buf[2 * i]); printf("%02X", buf[2 * i + 1]); > if (1 <= i && i <= 4) > putchar('-'); > }