Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5099475img; Wed, 27 Mar 2019 01:59:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqx5ZRP1Y6WqTWoEnuNG/yZfoQMHkv1V7adohXCDYB+JRxjVQxo24uS1iZn68/zV1z9ROk78 X-Received: by 2002:a17:902:8a8a:: with SMTP id p10mr35616502plo.92.1553677158795; Wed, 27 Mar 2019 01:59:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553677158; cv=none; d=google.com; s=arc-20160816; b=fwvw1F5BlBqwa3xSWSt7lViuMQeF0mJCV0Y2kzTfqnAK8nabsCfPfZS2iarlstm0Fw fHMYZED2IGlJlrYjgzwpj10rMApe3AnOVhhUmOPdtra0HLGChiQuSiz03KX/3gQBG/nG huTn3AL1shbGJiAJwewebZKph1YJo94jlBy9naas/xLPt01qb3TZCrrgxh57xqgGyZGC cK818+Cc8LyWqMAjeah0LGT+vSqUXNHRqCdiNO6aO/5toWxFZv6TUGr2FNyXndFs/bcK 91ZVMNl2VXyFw/ERbyP+TGt6pvLhxT7tjRE2iWYGK1UjeIWUS9wAn0IDJRIwBG0qyl+u O61g== 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:from:date; bh=EPEqn15l5VlXcHRLQJCVu4ibDvLRO6qeMpTdoaH6YOo=; b=WmKz5F/5X66y56fud07Ki9gettT3NAofk7hYXEGQq5rn0+aTpBlQ6dkuXx1Qo8JVcR ST+cCAKwnOdTMsahSmF/lWmI207tGQuUdQHU2JQuMIH4rCykod6h1ty6D39n9DYSPVZQ FKYFQbuRtsZq5go38WFV+D3iV6y02HVxduRWgFk48PnAC8MtH8RDTpFBMeizMASn1DFm CCndNbtWoPaOtozZMUSuI73T001LQ+1rYtVvYYaG/2gP6jOY7c/Se7ZuSG5M/N+aRfJH X9ed2LpFaLcpJVRzVktBsVNdX1FxxhIs8dwjVdjAVNlcVJXOCe5VatC6eWw0u83AGsLu DJRw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t19si17387018pgu.272.2019.03.27.01.59.03; Wed, 27 Mar 2019 01:59:18 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732452AbfC0I6Q (ORCPT + 99 others); Wed, 27 Mar 2019 04:58:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42490 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726344AbfC0I6P (ORCPT ); Wed, 27 Mar 2019 04:58:15 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AAA58C06783F; Wed, 27 Mar 2019 08:58:15 +0000 (UTC) Received: from krava (unknown [10.43.17.124]) by smtp.corp.redhat.com (Postfix) with SMTP id 4BD862B8D9; Wed, 27 Mar 2019 08:58:14 +0000 (UTC) Date: Wed, 27 Mar 2019 09:58:13 +0100 From: Jiri Olsa To: Andi Kleen Cc: acme@kernel.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Andi Kleen Subject: Re: [PATCH 2/4] perf, tools: Implement duration_time as a proper event Message-ID: <20190327085813.GB24156@krava> References: <20190326221823.11518-1-andi@firstfloor.org> <20190326221823.11518-3-andi@firstfloor.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190326221823.11518-3-andi@firstfloor.org> User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 27 Mar 2019 08:58:15 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 26, 2019 at 03:18:21PM -0700, Andi Kleen wrote: > From: Andi Kleen > > The perf metric expression use duration_time internally to normalize > events. Normal perf stat without -x also prints the duration time. > But when using -x, the interval is not output anywhere, which > is inconvenient for any post processing which often wants to > normalize values to time. > > So implement duration_time as a proper perf event that > can be specified explicitely with -e. > > The previous implementation of duration_time only worked > for metric processing. This adds the concept of a tool > event that is handled by the tool. On the kernel level > it is still mapped to the dummy software event, but the > values are not read anymore, but instead computed by the tool. > > Add proper plumbing to handle this in the event parser, > and display it in perf stat. We don't want duration_time to be added up, > so it's only printed for the first CPU. > > % perf stat -e duration_time,cycles true > > Performance counter stats for 'true': > > 555,476 ns duration_time > 771,958 cycles > > 0.000555476 seconds time elapsed > > 0.000644000 seconds user > 0.000000000 seconds sys > > Signed-off-by: Andi Kleen > --- > tools/perf/builtin-stat.c | 28 ++++++++++++++++++------- > tools/perf/util/evsel.h | 6 ++++++ > tools/perf/util/parse-events.c | 38 +++++++++++++++++++++++++++++----- > tools/perf/util/parse-events.h | 4 ++++ > tools/perf/util/parse-events.l | 11 +++++++++- > tools/perf/util/parse-events.y | 12 +++++++++++ > 6 files changed, 86 insertions(+), 13 deletions(-) > > diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c > index 49ee3c2033ec..7f9c4b7f5d69 100644 > --- a/tools/perf/builtin-stat.c > +++ b/tools/perf/builtin-stat.c > @@ -244,11 +244,25 @@ perf_evsel__write_stat_event(struct perf_evsel *counter, u32 cpu, u32 thread, > process_synthesized_event, NULL); > } > > +static int read_single_counter(struct perf_evsel *counter, int cpu, > + int thread, struct timespec *rs) > +{ > + if (counter->tool_event == PERF_TOOL_DURATION_TIME) { > + u64 val = rs->tv_nsec + rs->tv_sec*1000000000ULL; > + struct perf_counts_values *count = > + perf_counts(counter->counts, cpu, thread); > + count->ena = count->run = val; > + count->val = val; > + return 0; > + } > + return perf_evsel__read_counter(counter, cpu, thread); > +} so now that we have time in a separate event, we could get rid of the isolated update_stats(&walltime_nsecs_stats) calls and move them to perf_stat__update_shadow_stats? jirka