Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1143304rwi; Fri, 14 Oct 2022 13:37:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6MM6toO4bqa8InWNfwTWytQFdor1klSpb/46FAVxxq/8BTb8pglhO7B69l8SLSnOIbzauK X-Received: by 2002:a05:6a00:1412:b0:557:d887:2025 with SMTP id l18-20020a056a00141200b00557d8872025mr6919450pfu.39.1665779870008; Fri, 14 Oct 2022 13:37:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665779870; cv=none; d=google.com; s=arc-20160816; b=fUqVeiKFDPflU7EzcIfuWVZzankH0w6NJ8EujRKNRYbi1BIqgp7xRVTt7Jz4G9+CIx 4CXY6JeymbLhXYaX93n26/dxaCOn1QU0akxy7WAUOb5hQin7wFtI5W+hv9EgICFVNYOL L7DS23XMpP4JPxwst6lZ07nYMsSEDZeukpVTt+oCBeLjSTIztzDz2XxIl9MaeZaaWQI/ LEx61pKAWeUf1XClSoH6Cyjy0yAKixnRLr54NFz0gguvuhPeOwpJKC/+jJZHfADNfQ+c 5ByQTivonOt+4GtlsZPaAGglDZlsl1srghZorZPHlcEga0P86liexZZ+/3mYX25N5x74 cD5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=t8btuJNcbARCvOKrU+IN2m00AmKpvvaQaodzK97cY24=; b=pgVr45r8dYmU5yb5x69nf3bbaO6YSA3ihCF71D7cCh5lonTDVjYcZoXeb8Hm1+Sn2p DC0YDZJmrvQ8w2I9D3T4aOKWo/BFyDdWJ9GmodCiqFnvU3Mm4JdDdtTH4R3xROC87sLm TAy17kGj4iEG6mAobO5VSekrR1AsqgfcLAKR9QcxKsjqtPLy3jZzHtzZ9O5vA5N20pA+ bIvKI75WQp3jjvDs9/WWRS3JtUUYDIfuh/tsE9TpAj9zs45iUiH7LLX74kV1DtS8LCsj mmpK7df5syUAMYNVLOpRux/qRC6VBa3Xw6Fm7CmEGGZ4yCquM5sbgCeWsKdivKUHAnQi oAGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lfzljnxZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l3-20020a655603000000b00434dd5dc135si3812702pgs.855.2022.10.14.13.37.38; Fri, 14 Oct 2022 13:37:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lfzljnxZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230160AbiJNUEy (ORCPT + 99 others); Fri, 14 Oct 2022 16:04:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229997AbiJNUEq (ORCPT ); Fri, 14 Oct 2022 16:04:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6759810BF; Fri, 14 Oct 2022 13:04:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C22AFB8234D; Fri, 14 Oct 2022 20:04:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 499A1C433C1; Fri, 14 Oct 2022 20:04:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665777881; bh=WgK8GBODPu1il2l6bsz7fk4bsQA1FopzCrhUOulcM70=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lfzljnxZzAC2jO/hx2kly2jM4aiqMiyneVW6H27F17PXKtYJh0BYrHkzWP11NIqEZ y+fq6qBvKdrp0f3eIZIZ6idKv5U7D2plbHmI5ONgld1G2EAJ1WMfoxIYyQBDcOGqte fHK6U58HSZW2DZsUEhroVUciKzqFj5ooKy+54tURxNGHmGIiRlBgaN3lVimzKhYZt2 qSHdC09YLieWGSermrs+fDekE3LZVyjRo1LaDn3N1nzFdytYk9Fx5DsIXd2vx6ARqJ 0SA9YOF+JqhevnXRhxXmAmUAtZexC6umSMDhnh+39SGXB6Lq1OsRSU0wiRPIGiCFg0 bqqFmaFsKpwCg== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 9A31A4062C; Fri, 14 Oct 2022 17:04:38 -0300 (-03) Date: Fri, 14 Oct 2022 17:04:38 -0300 From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Jiri Olsa , Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Kan Liang , Leo Yan , Andi Kleen , Athira Rajeev , James Clark , Xing Zhengjun Subject: Re: [PATCH 20/19] perf stat: Factor out evsel__count_has_error() Message-ID: References: <20221014181655.771612-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221014181655.771612-1-namhyung@kernel.org> X-Url: http://acmel.wordpress.com X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Fri, Oct 14, 2022 at 11:16:55AM -0700, Namhyung Kim escreveu: > It's possible to have 0 enabled/running time for some per-task or per-cgroup > events since it's not scheduled on any CPU. Treating the whole event as > failed would not work in this case. Thinking again, the code only existed > when any CPU-level aggregation is enabled (like per-socket, per-core, ...). > > To make it clearer, factor out the condition check into the new > evsel__count_has_error() function and add some comments. So I should just add this one to the 19-long patchkit I already applied locally, ok. - Arnaldo > Signed-off-by: Namhyung Kim > --- > tools/perf/util/stat.c | 25 +++++++++++++++++++++---- > 1 file changed, 21 insertions(+), 4 deletions(-) > > diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c > index 6ab9c58beca7..9dfa8cac6bc4 100644 > --- a/tools/perf/util/stat.c > +++ b/tools/perf/util/stat.c > @@ -396,6 +396,25 @@ static int check_per_pkg(struct evsel *counter, struct perf_counts_values *vals, > return ret; > } > > +static bool evsel__count_has_error(struct evsel *evsel, > + struct perf_counts_values *count, > + struct perf_stat_config *config) > +{ > + /* the evsel was failed already */ > + if (evsel->err || evsel->counts->scaled == -1) > + return true; > + > + /* this is meaningful for CPU aggregation modes only */ > + if (config->aggr_mode == AGGR_GLOBAL) > + return false; > + > + /* it's considered ok when it actually ran */ > + if (count->ena != 0 && count->run != 0) > + return false; > + > + return true; > +} > + > static int > process_counter_values(struct perf_stat_config *config, struct evsel *evsel, > int cpu_map_idx, int thread, > @@ -450,11 +469,9 @@ process_counter_values(struct perf_stat_config *config, struct evsel *evsel, > > /* > * When any result is bad, make them all to give consistent output > - * in interval mode. But per-task counters can have 0 enabled time > - * when some tasks are idle. > + * in interval mode. > */ > - if (((count->ena == 0 || count->run == 0) && cpu.cpu != -1) || > - evsel->counts->scaled == -1) { > + if (evsel__count_has_error(evsel, count, config) && !ps_aggr->failed) { > ps_aggr->counts.val = 0; > ps_aggr->counts.ena = 0; > ps_aggr->counts.run = 0; > -- > 2.38.0.413.g74048e4d9e-goog -- - Arnaldo