Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4596071ybp; Mon, 14 Oct 2019 07:10:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzq2w8wtdjKAiuMkkaXC5BqvJKbsu3xpguUmoJTnS6zG83AqpUiqGAKwkyJvhF4b9V5teCr X-Received: by 2002:a50:d70c:: with SMTP id t12mr28522916edi.252.1571062234870; Mon, 14 Oct 2019 07:10:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571062234; cv=none; d=google.com; s=arc-20160816; b=XAVWtJ/+jmo+VaEzT6ULynZe9dbl067buZn+DXdqpXwfVYJZtPRgIUY03OAd/ObLQi SGkbPZcjdxMvSqu77iVza2onVO1ZKW6eeJUWh0jPwd1fR2jiGZ7AKc0N56sXtcaAEvLg RudBdsdWuBJAGbsLU7Ljok0x1kWBEIrNAEeOONGp1yzb0lLYRACcfjU+g7ZvVX3/hhIT ByFGpJijSIYPaULGdZPbEPHBhI3kq+ZycbF8sPB/pBzHwTPVceuGO6kyDywf0R0wJYj5 yBRZOiSxCefBhsnBLm6iARi2zbhfBf+vViTq45gFaHGWQsDj+s4EHkmKzw/lBQqAZ9D0 0L9g== 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:message-id:subject:cc :to:date:from:dkim-signature; bh=CZh/4+0Z8RBRsTGb7kMQmVAyPDPVIRlZbYr5vCA4tD4=; b=MvcTgMRID4g8OqlI3vXYy/qY/UNoW+Xn2oj8UNIZ2q2uUY1Bu2Ou2OlrXeROeIS5js 34+BpB+DBYE1FpPBotpehT7Ux73Y8NB4WRShe/PHAykC9E58AalM0PJBASCDZC+++A3R Fq0XgRn+I/qumf5dtzOjp7+NgHEWaqlcCPZPZDfwgaiq24MPIvZ6jRWD3PJEakY+9grk TsJdzVO8G7Xfw1HV/5TkpJ0rOq1ywfRj1AwgLeRSI3oy2UAEzoRiJhTWuOvb68kRHv51 VUkzjKmEtrEbO9dlBL5UNEsRz2BhcAJx9GcC3UO6faeTGo2/wojndwYEtYGG2xi2SFhO FBcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rLKwzAAj; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j51si12565752ede.301.2019.10.14.07.10.09; Mon, 14 Oct 2019 07:10:34 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rLKwzAAj; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732448AbfJNOHN (ORCPT + 99 others); Mon, 14 Oct 2019 10:07:13 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:36337 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732337AbfJNOHN (ORCPT ); Mon, 14 Oct 2019 10:07:13 -0400 Received: by mail-qt1-f196.google.com with SMTP id o12so25615922qtf.3 for ; Mon, 14 Oct 2019 07:07:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=CZh/4+0Z8RBRsTGb7kMQmVAyPDPVIRlZbYr5vCA4tD4=; b=rLKwzAAjQHr/4u7K4ivWpY5wVS9RWG4cki1/3zbfWZKdYSFzFAstHlkISKGrJQE5uN s3rQxRCQEIXR2CZZjTcRDzfetRTtAwadYijfKIgtXOBGOc1YilnL7dQUKomDfOLtX0Td 0M5+jcMVHgGVX+4LII33kh/nmrFpNh3lmUXPgnOcBpjipUFSDfpmlla64rjbG7s0v1of pOw5R7W8ysWOpDPzRG2BYBD7QduJR5ip9AXv4pt+hV68NnjI5oD5VOaieo+R575UD/EM X3wFdeXwtFfbC76IOKyql4tbOdeJrFHdSGpj5OyP48n5N3cLP6VHxYQ0GW8iaVrAk74X EZKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=CZh/4+0Z8RBRsTGb7kMQmVAyPDPVIRlZbYr5vCA4tD4=; b=YmK7vLBQQR1BgEjKhPGfw8zDwKzmPrkk3u2TZfAftS/gSBNHZHGZm1rfWEIgCvpsXA QoWrtOAhepqF7PKm6IkKzpssZ4V+jrsKke7RMC1andjJfvSz5LkG4D7XSyDEzXOOEUX1 WGJc3rFAdtRwNSE480IRnrC2gVIkgNMA7RsYnOt5o5TIPr66+G/uq3eGouSJE5t1UtGY r+GqKA/uQxlEVvTV4jiWdNH1WuzrAAkBqQRqJLtKHX+62W6hNlreiDifHUwPKQ8SuBSy X0+StBiKsHyIgAeJm8+jqEEdDhNYgxhjj5iXemsK+ZDjr/t+tHLp1WyiyqJDw7v7xNP3 WYnw== X-Gm-Message-State: APjAAAUdgY2qzXZfOmRHE2+C57jz5P1l19IERJvTkBvDkVqAxdIOgpKl xw2uK9qhmnSAxu45BrQs9ynzGH1K X-Received: by 2002:ac8:6686:: with SMTP id d6mr31073251qtp.332.1571062031536; Mon, 14 Oct 2019 07:07:11 -0700 (PDT) Received: from quaco.ghostprotocols.net ([179.97.35.50]) by smtp.gmail.com with ESMTPSA id 62sm8758567qki.130.2019.10.14.07.07.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 07:07:10 -0700 (PDT) From: Arnaldo Carvalho de Melo X-Google-Original-From: Arnaldo Carvalho de Melo Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 010674DD66; Mon, 14 Oct 2019 11:07:07 -0300 (-03) Date: Mon, 14 Oct 2019 11:07:07 -0300 To: Andi Kleen Cc: jolsa@kernel.org, linux-kernel@vger.kernel.org, Andi Kleen Subject: Re: [PATCH 1/2] perf script: Fix --reltime with --time Message-ID: <20191014140707.GB19627@kernel.org> References: <20191011182140.8353-1-andi@firstfloor.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191011182140.8353-1-andi@firstfloor.org> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Fri, Oct 11, 2019 at 11:21:39AM -0700, Andi Kleen escreveu: > From: Andi Kleen > > My earlier patch to just enable --reltime with --time was a little too optimistic. > The --time parsing would accept absolute time, which is very confusing to the user. > > Support relative time in --time parsing too. This only works with recent perf > record that records the first sample time. Otherwise we error out. Thanks, applied both patches. - Arnaldo > Fixes: 3714437d3fcc ("perf script: Allow --time with --reltime") > Signed-off-by: Andi Kleen > --- > tools/perf/builtin-script.c | 5 +++-- > tools/perf/util/time-utils.c | 27 ++++++++++++++++++++++++--- > tools/perf/util/time-utils.h | 5 +++++ > 3 files changed, 32 insertions(+), 5 deletions(-) > > diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c > index 1c797a948ada..f86c5cce5b2c 100644 > --- a/tools/perf/builtin-script.c > +++ b/tools/perf/builtin-script.c > @@ -3864,10 +3864,11 @@ int cmd_script(int argc, const char **argv) > goto out_delete; > > if (script.time_str) { > - err = perf_time__parse_for_ranges(script.time_str, session, > + err = perf_time__parse_for_ranges_reltime(script.time_str, session, > &script.ptime_range, > &script.range_size, > - &script.range_num); > + &script.range_num, > + reltime); > if (err < 0) > goto out_delete; > > diff --git a/tools/perf/util/time-utils.c b/tools/perf/util/time-utils.c > index 9796a2e43f67..302443921681 100644 > --- a/tools/perf/util/time-utils.c > +++ b/tools/perf/util/time-utils.c > @@ -458,10 +458,11 @@ bool perf_time__ranges_skip_sample(struct perf_time_interval *ptime_buf, > return true; > } > > -int perf_time__parse_for_ranges(const char *time_str, > +int perf_time__parse_for_ranges_reltime(const char *time_str, > struct perf_session *session, > struct perf_time_interval **ranges, > - int *range_size, int *range_num) > + int *range_size, int *range_num, > + bool reltime) > { > bool has_percent = strchr(time_str, '%'); > struct perf_time_interval *ptime_range; > @@ -471,7 +472,7 @@ int perf_time__parse_for_ranges(const char *time_str, > if (!ptime_range) > return -ENOMEM; > > - if (has_percent) { > + if (has_percent || reltime) { > if (session->evlist->first_sample_time == 0 && > session->evlist->last_sample_time == 0) { > pr_err("HINT: no first/last sample time found in perf data.\n" > @@ -479,7 +480,9 @@ int perf_time__parse_for_ranges(const char *time_str, > "(if '--buildid-all' is enabled, please set '--timestamp-boundary').\n"); > goto error; > } > + } > > + if (has_percent) { > num = perf_time__percent_parse_str( > ptime_range, size, > time_str, > @@ -492,6 +495,15 @@ int perf_time__parse_for_ranges(const char *time_str, > if (num < 0) > goto error_invalid; > > + if (reltime) { > + int i; > + > + for (i = 0; i < num; i++) { > + ptime_range[i].start += session->evlist->first_sample_time; > + ptime_range[i].end += session->evlist->first_sample_time; > + } > + } > + > *range_size = size; > *range_num = num; > *ranges = ptime_range; > @@ -504,6 +516,15 @@ int perf_time__parse_for_ranges(const char *time_str, > return ret; > } > > +int perf_time__parse_for_ranges(const char *time_str, > + struct perf_session *session, > + struct perf_time_interval **ranges, > + int *range_size, int *range_num) > +{ > + return perf_time__parse_for_ranges_reltime(time_str, session, ranges, > + range_size, range_num, false); > +} > + > int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz) > { > u64 sec = timestamp / NSEC_PER_SEC; > diff --git a/tools/perf/util/time-utils.h b/tools/perf/util/time-utils.h > index 4f42988eb2f7..1142b0bddd5e 100644 > --- a/tools/perf/util/time-utils.h > +++ b/tools/perf/util/time-utils.h > @@ -26,6 +26,11 @@ bool perf_time__ranges_skip_sample(struct perf_time_interval *ptime_buf, > > struct perf_session; > > +int perf_time__parse_for_ranges_reltime(const char *str, struct perf_session *session, > + struct perf_time_interval **ranges, > + int *range_size, int *range_num, > + bool reltime); > + > int perf_time__parse_for_ranges(const char *str, struct perf_session *session, > struct perf_time_interval **ranges, > int *range_size, int *range_num); > -- > 2.21.0 -- - Arnaldo