From patchwork Tue Oct 18 02:02:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 3891 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1736418wrs; Mon, 17 Oct 2022 19:10:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6qcCsYZzLQeIYxmX+mSf1TuPKzpP7womKZ9zfHOL+Ab7ewngJUgFLDz3BDH0mtO2xsojzv X-Received: by 2002:a17:907:25c5:b0:782:978d:c3da with SMTP id ae5-20020a17090725c500b00782978dc3damr479410ejc.623.1666059028324; Mon, 17 Oct 2022 19:10:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666059028; cv=none; d=google.com; s=arc-20160816; b=cx+BQ+uNNwiPKP78A8Cw0NRzrwM0p806iCe8isPJpJ6p68HXyuoeRfkU5cp8yNDyUj S44hoXHQA0B6GF9zmdLWut0qayGm3qqlmyQcmlf2PPIhvWIntO+pzKiaOFiiBpaQCdIt idGw7qLhTHBfsfVBcFRfj03vdshiXGNZBAbwW3FTL/AQcZwI5Sgg2/ABHU8tw9Oay5uL aID+FbgTt2RXAY0hPwn+0HNlvb9l3SNpvk2Hzaug/V3aBR+wfZbUG5ETkI9u0+JMdEGI yGDuPLyb9KU0S2vzwxFfp1CBuvnnUcm9kPsdf5BYjW2pLlY1ePF+LtVvhi4AGnIxH3Ui mZgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=Eqf99fYG2bxqOCUE0EsbHGsdrtUHS7k4C0PA8A7LPhA=; b=A6nnEunQUnm7X2l3W+hBHvHvHG9B4KuIGIJxxcx6VLAwnaZS+a6wqdf4V3lJqZVENy MtTCe7dSiwoBoxoXLSErCenq3hjisLxRWQMpcTJbpj/c8zrSO/moqpNXzQoJ3W4ZYbaC GTuybP/uqj1iY2BVImxYyhdoEJ3zclCwxxWldc6LTHPXhOuVXtFHuF+b3evDF+Sbsc2X BxYD3ftoQGDJy/9pRvX6OXATenriymUcyHgECSmaG72Dgiy7O0Fpn+ZXxCbM2//bjL+B uX99p2qpsJ//JxORdmmoDcBCXDoKf8t0afmoC8ucym3XOpoRlGLxE2N9k43h0XQXmeHy 1apQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=krDtDn29; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f7-20020a056402354700b0043d00293d23si11281074edd.391.2022.10.17.19.10.03; Mon, 17 Oct 2022 19:10:28 -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=@gmail.com header.s=20210112 header.b=krDtDn29; 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 S231222AbiJRCE6 (ORCPT + 99 others); Mon, 17 Oct 2022 22:04:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231237AbiJRCD4 (ORCPT ); Mon, 17 Oct 2022 22:03:56 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 879298E455; Mon, 17 Oct 2022 19:03:02 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id d7-20020a17090a2a4700b0020d268b1f02so15973717pjg.1; Mon, 17 Oct 2022 19:03:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Eqf99fYG2bxqOCUE0EsbHGsdrtUHS7k4C0PA8A7LPhA=; b=krDtDn294PHFNxNUjn3QOGC128mXt4iEr8yQacbsB4ANbJQfKuosMJ8HzlOc/7jy8X PhnLHfdIdKFOArFh2qxy5Fvc2SQ+pjC3adAqBXGnF2rTFHbTUaGrnsP4QuIf7V7rvoZZ Gl3pSs99C49Rv45o0RpLZaYg2zD3Kn/1qBb87iYoIfT2wojwfF9kXpjEgYNCCjsQUN7k J0m9LFocsfjSXxSgR8NaFr96yNv2XTCGMgcQ9fNA3IOTULcEJCBfbSphBNYnTejfnn6g PqfJ0ZI7Erq2CqCMRMGzGuLgl/hjxZCmdBrS9uAcyn7W4nPWr3VGxap3iZ1mX7j6bEtO A3yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Eqf99fYG2bxqOCUE0EsbHGsdrtUHS7k4C0PA8A7LPhA=; b=V9/2zdQSMvnQ6lDMHtMDY+mk2vBlR+0FaAJh0hpNrqsCg+N8ksKzT/308nB6akCPzf eTOnylJ8+56r2oklt7fXm0uQHGUpgqVZFtnFbYN8+RcBs0VyiwJ/AXUrpLD4O+fui8nP EoW2mKhqV+DUW5OEJcHKqZogJfNUjL6s6M5KPLE8UR7WAKBtPqSqRNebf8pX2+1PsA5S TlxFUlH5KI0dvOKLWSCRXHh2sPdiWxenAyPycrtxZB+K13489V+utpMk21N82Hi9TCoQ hDbksmf6Tj2F1yT2CqLkuHO/CEJ88enCSFvOq0Db2ZkxbPOdGoo1li4fHzf926ciyOic v+Dw== X-Gm-Message-State: ACrzQf33Mk6Yz6D9f9ls+1Xcve7FzAHLQgta6WwB5rBO2xBVCthDewrs J5wQUZXGso/rwepY6JiqK9s= X-Received: by 2002:a17:90b:1b4d:b0:20d:7bbf:46f0 with SMTP id nv13-20020a17090b1b4d00b0020d7bbf46f0mr844247pjb.77.1666058581153; Mon, 17 Oct 2022 19:03:01 -0700 (PDT) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:1f90:85c4:58f0:7a81:6bb5]) by smtp.gmail.com with ESMTPSA id t4-20020a655544000000b00464858cf6b0sm6851564pgr.54.2022.10.17.19.02.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 19:03:00 -0700 (PDT) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: 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 , Michael Petlan Subject: [PATCH 17/20] perf stat: Add perf_stat_process_shadow_stats() Date: Mon, 17 Oct 2022 19:02:24 -0700 Message-Id: <20221018020227.85905-18-namhyung@kernel.org> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221018020227.85905-1-namhyung@kernel.org> References: <20221018020227.85905-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746989511468317096?= X-GMAIL-MSGID: =?utf-8?q?1746989511468317096?= This function updates the shadow stats using the aggregated counts uniformly since it uses the aggr_counts for the every aggr mode. It'd have duplicate shadow stats for each items for now since the display routines will update them once again. But that'd be fine as it shows the average values and it'd be gone eventually. Acked-by: Ian Rogers Signed-off-by: Namhyung Kim --- tools/perf/builtin-stat.c | 1 + tools/perf/util/stat.c | 50 ++++++++++++++++++++------------------- tools/perf/util/stat.h | 1 + 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index d6a006e41da0..d7c52cef70a3 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -489,6 +489,7 @@ static void process_counters(void) perf_stat_merge_counters(&stat_config, evsel_list); perf_stat_process_percore(&stat_config, evsel_list); + perf_stat_process_shadow_stats(&stat_config, evsel_list); } static void process_interval(void) diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 26c48ef7ca92..c0955a0427ab 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c @@ -474,7 +474,7 @@ process_counter_values(struct perf_stat_config *config, struct evsel *evsel, aggr_counts->val += count->val; aggr_counts->ena += count->ena; aggr_counts->run += count->run; - goto update; + return 0; } if (ps->aggr) { @@ -511,32 +511,10 @@ process_counter_values(struct perf_stat_config *config, struct evsel *evsel, } } -update: - switch (config->aggr_mode) { - case AGGR_THREAD: - case AGGR_CORE: - case AGGR_DIE: - case AGGR_SOCKET: - case AGGR_NODE: - case AGGR_NONE: - if ((config->aggr_mode == AGGR_NONE) && (!evsel->percore)) { - perf_stat__update_shadow_stats(evsel, count->val, - cpu_map_idx, &rt_stat); - } - - if (config->aggr_mode == AGGR_THREAD) { - perf_stat__update_shadow_stats(evsel, count->val, - thread, &rt_stat); - } - break; - case AGGR_GLOBAL: + if (config->aggr_mode == AGGR_GLOBAL) { aggr->val += count->val; aggr->ena += count->ena; aggr->run += count->run; - case AGGR_UNSET: - case AGGR_MAX: - default: - break; } return 0; @@ -762,6 +740,30 @@ void perf_stat_process_percore(struct perf_stat_config *config, struct evlist *e evsel__process_percore(evsel); } +static void evsel__update_shadow_stats(struct evsel *evsel) +{ + struct perf_stat_evsel *ps = evsel->stats; + int i; + + if (ps->aggr == NULL) + return; + + for (i = 0; i < ps->nr_aggr; i++) { + struct perf_counts_values *aggr_counts = &ps->aggr[i].counts; + + perf_stat__update_shadow_stats(evsel, aggr_counts->val, i, &rt_stat); + } +} + +void perf_stat_process_shadow_stats(struct perf_stat_config *config __maybe_unused, + struct evlist *evlist) +{ + struct evsel *evsel; + + evlist__for_each_entry(evlist, evsel) + evsel__update_shadow_stats(evsel); +} + int perf_event__process_stat_event(struct perf_session *session, union perf_event *event) { diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index d23f8743e442..3d413ba8c68a 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -284,6 +284,7 @@ int perf_stat_process_counter(struct perf_stat_config *config, struct evsel *counter); void perf_stat_merge_counters(struct perf_stat_config *config, struct evlist *evlist); void perf_stat_process_percore(struct perf_stat_config *config, struct evlist *evlist); +void perf_stat_process_shadow_stats(struct perf_stat_config *config, struct evlist *evlist); struct perf_tool; union perf_event;