Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp881664ybg; Fri, 18 Oct 2019 08:44:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxEz9HJgPQBCnzxsEcML09wx+87rAc+76Aeeby8o5mikuIeT4DUXlY/2qIi9vTMU7TCzwOi X-Received: by 2002:a17:906:250d:: with SMTP id i13mr9491062ejb.275.1571413461538; Fri, 18 Oct 2019 08:44:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571413461; cv=none; d=google.com; s=arc-20160816; b=Oe5ojDNBZeSWfXL3nsfmwiZ4llGbuSx6UzOJU3TCxXBXwBWk2kteW2/pFEXkdagJOh iu4263gfXeSvJuvSYcF5SuA1RKeXSCLxu1bXJUdtiPdEV2M2bW0vvE9KXsrUKaGk20JT GIE78heqYTG7gSQBGKR6+nnr8F0EfufMbHDL7J7rv8WorwfvqWQNfSkkFLioPcHzpkLT GNi+DqIoQ0yIKK+bxDTMRVo4wcSRaVs5M9lEZR+30jX5TFnzwy2zEqSH4KugTnjiqjg8 qbalAPQXcLvxu3MPYalVozguolMog65D1FN3mINk+MH6aLXm9wuZarC+/ETU/jDASIlf Gd7A== 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=Hl/QmcNrsqzPBAFjazIyUk8PKT+Wth3GMa1rxBpD+6o=; b=WtQbI4T3HyGh2FFPVXcv0oeixi63vkiXQBemla4jpBD10zkX180egshTF4nYrU7uCf J6hoewABPnGUXibQDROEoczT/BTIiRJOyKwOwNDkWHHMaomhKlyfarQTDEe6r29BI3t2 MSfI4RFewZVFfqdmN+5b9DAnbuud6iLsUJyvWuN0LHN5SnJp/Tl3naFQLPsAIqtP6Q62 u9IrQ+1Au4uCPBKx0Ii3avbMbaXClUzr6KgrUK/yNGT9McYrTGOwQxV3I90LXop2W2cf e0Yy4yFHi/qRs8Y0cxfQ5LfcSAbodiyii1tlsTNWuGXdJDeK2r4nMIRpi5ZKVZvkmzlX 7eAA== 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 ci22si3789167ejb.162.2019.10.18.08.43.57; Fri, 18 Oct 2019 08:44:21 -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 S2502184AbfJQLwA (ORCPT + 99 others); Thu, 17 Oct 2019 07:52:00 -0400 Received: from mx2.suse.de ([195.135.220.15]:41070 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2502168AbfJQLwA (ORCPT ); Thu, 17 Oct 2019 07:52:00 -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 73E88B03A; Thu, 17 Oct 2019 11:51:58 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 9C1DEDA808; Thu, 17 Oct 2019 13:52:09 +0200 (CEST) Date: Thu, 17 Oct 2019 13:52:09 +0200 From: David Sterba To: Qu Wenruo Cc: 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: <20191017115209.GG2751@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191017022800.31866-1-wqu@suse.com> 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 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]); if (1 <= i && i <= 4) putchar('-'); } "23ad 1511 - dd83 - 47d4 - a79c - e966 25a1 5a6e" 0 1 2 3 4 5 6 7 IOW, split into pairs and print dash after a few of them.