Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2371738ybl; Mon, 20 Jan 2020 01:31:04 -0800 (PST) X-Google-Smtp-Source: APXvYqyUMqMc2tlxMhwaH+TfrNyPHANFFNYtoVKXaQN8aj0eXWbK+07GxAP9QTsv0b04By39IPUW X-Received: by 2002:a9d:7851:: with SMTP id c17mr15770532otm.58.1579512663766; Mon, 20 Jan 2020 01:31:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579512663; cv=none; d=google.com; s=arc-20160816; b=qxY9cGZoTqa3h4Mb2uoSDCtZ5HG7vxiE+f0KTzc6cBhTi6UzPvdvMxJ89Kryta6Yq/ zYsKdnQD7wiOzMCZmocLphjNsxvQma+9MJ37liCzGSL3OIWx/CzezrOMQ+0yQT1KExct c1e3F2MNvPggSFBroBICYCoz552yLyvbq8I9ig6idnwvgbU9UBVK0lg0DAleNl/TrZRM LVyoslvXLe+IG3QTlx91NIFs7HYoPrZYDfwiQM9Z9MTG6qvfirfPtr2Hnhz/CMgn3+8V j7xqlyOUETJh2r3ejrCe9DYd3DWQ3Gu4jeduAzEFs6jaQs/UPiqsojMYENA+6vGE29Jh 2AGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=y2AyZJjezQPayOoYoOZDjEemml5k2ADZSs5c/XlCC8U=; b=sMwfYurKhzRvtYVvqji7W9mkskB0HgMWpg3A2+6GERTfQkv77qfv+UPiFbE2+ZH4kT 6Eo95sWtQUZSOJ5/Noh6WAbErUK9mAUiqTV20PUaLOw4XL5MSTuqUMOmRZlHuvFQEBFD jnl23722lxxonMtt0O0bCIYRiR/1jpEbvPxsEaZtY3cYq2Yf1Ty4fHuKfJiU0Kr4/dLp C+dyZR0Ve6IPmCeNYJwCB9NvTC8l3nRqyErqIJuyvfMTYsA7t7GLU+2ezsWOrrWuFINu mvzk8adqkUCVELf96BLcc8BvzsL8+W/xTXSeB+UCmwysup48m8/YWHkkOKOGY8fjF6U9 CJKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Tmx/4xWo"; 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=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 h8si17287629oib.104.2020.01.20.01.30.51; Mon, 20 Jan 2020 01:31:03 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b="Tmx/4xWo"; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726942AbgATJ3m (ORCPT + 99 others); Mon, 20 Jan 2020 04:29:42 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:41629 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726451AbgATJ3l (ORCPT ); Mon, 20 Jan 2020 04:29:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579512579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=y2AyZJjezQPayOoYoOZDjEemml5k2ADZSs5c/XlCC8U=; b=Tmx/4xWozigOVvRqXg4lM299C/5sP+UIbw9T2vnDnGPcZfgAro0JDyRBrlx9IdcpotS5ur s/cgukkB9mKMvGAnxKyY4MIDVVvAp73sIrsvY2WiKStVoFRueYcy2tqHaz+URL74LEIQGR 5zeuvdFgMtGC14wqfhODsGPRefC6eu8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-30-sFTa31syPk-YGwtq8dhJxQ-1; Mon, 20 Jan 2020 04:29:35 -0500 X-MC-Unique: sFTa31syPk-YGwtq8dhJxQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A83A0DB21; Mon, 20 Jan 2020 09:29:33 +0000 (UTC) Received: from krava (unknown [10.43.17.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B25A360C05; Mon, 20 Jan 2020 09:29:30 +0000 (UTC) Date: Mon, 20 Jan 2020 10:29:28 +0100 From: Jiri Olsa To: Kim Phillips Cc: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Cong Wang , Andi Kleen , Jin Yao , Kan Liang , Song Liu , Davidlohr Bueso , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] perf stat: don't report a null stalled cycles per insn metric Message-ID: <20200120092928.GD608405@krava> References: <20200115222949.7247-1-kim.phillips@amd.com> <20200115222949.7247-2-kim.phillips@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200115222949.7247-2-kim.phillips@amd.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 15, 2020 at 04:29:49PM -0600, Kim Phillips wrote: > For data collected on machines with front end stalled cycles supported, > such as found on modern AMD CPU families, commit 146540fb545b ("perf > stat: Always separate stalled cycles per insn") introduces a new line > in CSV output with a leading comma that upsets some automated scripts. > Scripts have to use "-e ex_ret_instr" to work around this issue, after > upgrading to a version of perf with that commit. > > We could add "if (have_frontend_stalled && !config->csv_sep)" > to the not (total && avg) else clause, to emphasize that CSV users > are usually scripts, and are written to do only what is needed, i.e., > they wouldn't typically invoke "perf stat" without specifying an > explicit event list. > > But - let alone CSV output - why should users now tolerate a constant > 0-reporting extra line in regular terminal output?: > > BEFORE: > > $ sudo perf stat --all-cpus -einstructions,cycles -- sleep 1 > > Performance counter stats for 'system wide': > > 181,110,981 instructions # 0.58 insn per cycle > # 0.00 stalled cycles per insn > 309,876,469 cycles > > 1.002202582 seconds time elapsed > > The user would not like to see the now permanent > "0.00 stalled cycles per insn" line fixture, as it gives > no useful information. > > So this patch removes the printing of the zeroed stalled cycles > line altogether, almost reverting the very original commit fb4605ba47e7 > ("perf stat: Check for frontend stalled for metrics"), which seems > like it was written to normalize --metric-only column output > of common Intel machines at the time: modern Intel machines > have ceased to support the genericised frontend stalled metrics AFAICT. > > AFTER: > > $ sudo perf stat --all-cpus -einstructions,cycles -- sleep 1 > > Performance counter stats for 'system wide': > > 244,071,432 instructions # 0.69 insn per cycle > 355,353,490 cycles > > 1.001862516 seconds time elapsed > > Output behaviour when stalled cycles is indeed measured is not affected > (BEFORE == AFTER): > > $ sudo perf stat --all-cpus -einstructions,cycles,stalled-cycles-frontend -- sleep 1 > > Performance counter stats for 'system wide': > > 247,227,799 instructions # 0.63 insn per cycle > # 0.26 stalled cycles per insn > 394,745,636 cycles > 63,194,485 stalled-cycles-frontend # 16.01% frontend cycles idle > > 1.002079770 seconds time elapsed looks reasonable to me, Andi, are you ok with this? Acked-by: Jiri Olsa > Cc: Peter Zijlstra > Cc: Ingo Molnar > Cc: Arnaldo Carvalho de Melo > Cc: Mark Rutland > Cc: Alexander Shishkin > Cc: Jiri Olsa > Cc: Namhyung Kim > Cc: Cong Wang > Cc: Andi Kleen > Cc: Jin Yao > Cc: Kan Liang > Cc: Kim Phillips > Cc: Song Liu > Cc: Davidlohr Bueso > Cc: linux-perf-users@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Fixes: 146540fb545b ("perf stat: Always separate stalled cycles per insn") > Signed-off-by: Kim Phillips > --- > tools/perf/util/stat-shadow.c | 6 ------ > 1 file changed, 6 deletions(-) > > diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c > index 2c41d47f6f83..90d23cc3c8d4 100644 > --- a/tools/perf/util/stat-shadow.c > +++ b/tools/perf/util/stat-shadow.c > @@ -18,7 +18,6 @@ > * AGGR_NONE: Use matching CPU > * AGGR_THREAD: Not supported? > */ > -static bool have_frontend_stalled; > > struct runtime_stat rt_stat; > struct stats walltime_nsecs_stats; > @@ -144,7 +143,6 @@ void runtime_stat__exit(struct runtime_stat *st) > > void perf_stat__init_shadow_stats(void) > { > - have_frontend_stalled = pmu_have_event("cpu", "stalled-cycles-frontend"); > runtime_stat__init(&rt_stat); > } > > @@ -853,10 +851,6 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, > print_metric(config, ctxp, NULL, "%7.2f ", > "stalled cycles per insn", > ratio); > - } else if (have_frontend_stalled) { > - out->new_line(config, ctxp); > - print_metric(config, ctxp, NULL, "%7.2f ", > - "stalled cycles per insn", 0); > } > } else if (perf_evsel__match(evsel, HARDWARE, HW_BRANCH_MISSES)) { > if (runtime_stat_n(st, STAT_BRANCHES, ctx, cpu) != 0) > -- > 2.24.1 >