From patchwork Sun Feb 19 09:28:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13145845 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C1BF4C6379F for ; Sun, 19 Feb 2023 09:45:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=swjUaFAdL+ZX9ZV1meiXb77PteqQJqInzt30zxFeiYo=; b=zTF7oF/wndjTWg8l9Nb5wTlfA9 BrZvSmBueJIOFDU3dUrrIM/AVK/NaHVR32Sit3mKBrzF8j/9TRiv62ahf+iwp18sdnffbyDcm3hFQ TU+xlL09VR9v4e5leMc6jgWtunxwXom+9Sjb9cHFUa8lDv1Te9wK+G6uPIVu0W6PeZUXEx/o64WRP lIhXhcy5MZZOFlhM6uw4zQfzLFoKG6x1NbiV+jRs7KtiHiL6TEskXsp8HC6ryu3z5t7YdcW/rg50q 22NL9ecMoHAULcrfoyd51I15gJlnp9i4lCviZNKtHbRwbRUaU8UxmFfnCg+Pp96KV3tmDskD/h+n4 Xuh+3eIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pTgFD-0019lL-Ps; Sun, 19 Feb 2023 09:44:32 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pTg65-00160q-Lo for linux-arm-kernel@lists.infradead.org; Sun, 19 Feb 2023 09:35:07 +0000 Received: by mail-yb1-xb49.google.com with SMTP id e194-20020a2537cb000000b0095d2ada3d26so1955042yba.5 for ; Sun, 19 Feb 2023 01:35:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=83ufvBpHVtY5n0dRrsyH94JHmCN6bDj+Te8NRRpOnv0=; b=lxWRJOz1YmAnLVIpr+fpP4VDEQycUyWETLBz0W+CvZOIA6Kr/CoxJ2NsHEn41bEINl xdOo4dSeb6JldrmmHx8t98bCU9i7l7fSaOmRZyGpziCtv6bpIJCU9iN0JcYU+NjDa2O+ 9XTFi0YHaXrGx64qq4FOlIRjg9uoMS8Ya2jorXHuAwkk2xbnSK++ZlozuUPqdODuJFKs 6tKq8t5/yfeYhmVTyuQilkmzIWpSy5DP2e7xVmQeMyMJXwX8z5cUkxyl2CUbyclghtcG xaFP4bc1MAn1II2okkTepHrecIc0FvHgfZ29b/HmYpMob81nIptOTI3KNc6OhwmW2xc0 LwxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=83ufvBpHVtY5n0dRrsyH94JHmCN6bDj+Te8NRRpOnv0=; b=s8QoGTejvuv08v4hDtIPSzNtzR+WKjUGz6BNsUvO/1TDIO+QQUkRcxBt/04Iy4rSH4 fNzhFzWDTxnu5nGoYgdBJYDEgk2AiZ/QvJmOXgpmnv5oxvIA6FUJEO2SZNz/9mpS3nho oEQCiwLGxz0Qsf9qzQVlvBTPybwKUN7OvAhKKv8VHNnMAvRDKA+Zijcjd0kq4VZVjgQN ULxUrxnRR5N0lImANMcTDg0l8a1MRlHBiHve/sdHsvgvaodCJuYUGunqanDIT+PHFvWi pRgdcCbkpViCjPHigiUb06Jnk6hkSROG/PF3foLO6D0B9Q9ZsjIAXtNl25DbhWYArSlb wZgw== X-Gm-Message-State: AO0yUKWq+B0RdgkRqHSUN0Z9QOTdzedZ+UybofwPgZVJ2AiaF5+j9pBK BjgUX6F3+RJ59/m/+fJ1DapsDlXf6z+g X-Google-Smtp-Source: AK7set8t3rcgc5hL8cNAhis/P84/LQFLK5QsqBjIvZYGgI+BUkbIeJCgbTvi2p9zIdmfba0Vf3xefkV5CXYn X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:cde9:3fbc:e1f1:6e3b]) (user=irogers job=sendgmr) by 2002:a05:6902:10c6:b0:855:fdcb:4467 with SMTP id w6-20020a05690210c600b00855fdcb4467mr151684ybu.0.1676799302521; Sun, 19 Feb 2023 01:35:02 -0800 (PST) Date: Sun, 19 Feb 2023 01:28:40 -0800 In-Reply-To: <20230219092848.639226-1-irogers@google.com> Message-Id: <20230219092848.639226-44-irogers@google.com> Mime-Version: 1.0 References: <20230219092848.639226-1-irogers@google.com> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Subject: [PATCH v1 43/51] perf stat: Remove hard coded transaction events From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Maxime Coquelin , Alexandre Torgue , Zhengjun Xing , Sandipan Das , James Clark , Kajol Jain , John Garry , Kan Liang , Adrian Hunter , Andrii Nakryiko , Eduard Zingerman , Suzuki Poulouse , Leo Yan , Florian Fischer , Ravi Bangoria , Jing Zhang , Sean Christopherson , Athira Rajeev , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Perry Taylor , Caleb Biggers Cc: Stephane Eranian , Ian Rogers X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230219_013505_894588_399C504F X-CRM114-Status: GOOD ( 18.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The metric group "transaction" is now present for Intel architectures so the legacy hard coded approach won't be used. Remove the associated logic. Signed-off-by: Ian Rogers --- tools/perf/builtin-stat.c | 59 ++++++----------------------------- tools/perf/util/stat-shadow.c | 48 +--------------------------- tools/perf/util/stat.c | 4 --- tools/perf/util/stat.h | 7 ----- 4 files changed, 11 insertions(+), 107 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index bdb1ef4fc6ad..e6b60b058257 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -100,30 +100,6 @@ static void print_counters(struct timespec *ts, int argc, const char **argv); -/* Default events used for perf stat -T */ -static const char *transaction_attrs = { - "task-clock," - "{" - "instructions," - "cycles," - "cpu/cycles-t/," - "cpu/tx-start/," - "cpu/el-start/," - "cpu/cycles-ct/" - "}" -}; - -/* More limited version when the CPU does not have all events. */ -static const char * transaction_limited_attrs = { - "task-clock," - "{" - "instructions," - "cycles," - "cpu/cycles-t/," - "cpu/tx-start/" - "}" -}; - static const char *smi_cost_attrs = { "{" "msr/aperf/," @@ -1811,37 +1787,22 @@ static int add_default_attributes(void) return 0; if (transaction_run) { - struct parse_events_error errinfo; /* Handle -T as -M transaction. Once platform specific metrics * support has been added to the json files, all architectures * will use this approach. To determine transaction support * on an architecture test for such a metric name. */ - if (metricgroup__has_metric("transaction")) { - return metricgroup__parse_groups(evsel_list, "transaction", - stat_config.metric_no_group, - stat_config.metric_no_merge, - stat_config.metric_no_threshold, - stat_config.user_requested_cpu_list, - stat_config.system_wide, - &stat_config.metric_events); - } - - parse_events_error__init(&errinfo); - if (pmu_have_event("cpu", "cycles-ct") && - pmu_have_event("cpu", "el-start")) - err = parse_events(evsel_list, transaction_attrs, - &errinfo); - else - err = parse_events(evsel_list, - transaction_limited_attrs, - &errinfo); - if (err) { - fprintf(stderr, "Cannot set up transaction events\n"); - parse_events_error__print(&errinfo, transaction_attrs); + if (!metricgroup__has_metric("transaction")) { + pr_err("Missing transaction metrics"); + return -1; } - parse_events_error__exit(&errinfo); - return err ? -1 : 0; + return metricgroup__parse_groups(evsel_list, "transaction", + stat_config.metric_no_group, + stat_config.metric_no_merge, + stat_config.metric_no_threshold, + stat_config.user_requested_cpu_list, + stat_config.system_wide, + &stat_config.metric_events); } if (smi_cost) { diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index 5189756bf16d..3cfe4b4eb3de 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -235,12 +235,6 @@ void perf_stat__update_shadow_stats(struct evsel *counter, u64 count, update_runtime_stat(st, STAT_NSECS, map_idx, count_ns, &rsd); else if (evsel__match(counter, HARDWARE, HW_CPU_CYCLES)) update_runtime_stat(st, STAT_CYCLES, map_idx, count, &rsd); - else if (perf_stat_evsel__is(counter, CYCLES_IN_TX)) - update_runtime_stat(st, STAT_CYCLES_IN_TX, map_idx, count, &rsd); - else if (perf_stat_evsel__is(counter, TRANSACTION_START)) - update_runtime_stat(st, STAT_TRANSACTION, map_idx, count, &rsd); - else if (perf_stat_evsel__is(counter, ELISION_START)) - update_runtime_stat(st, STAT_ELISION, map_idx, count, &rsd); else if (evsel__match(counter, HARDWARE, HW_STALLED_CYCLES_FRONTEND)) update_runtime_stat(st, STAT_STALLED_CYCLES_FRONT, map_idx, count, &rsd); @@ -695,7 +689,7 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, { void *ctxp = out->ctx; print_metric_t print_metric = out->print_metric; - double total, ratio = 0.0, total2; + double total, ratio = 0.0; struct runtime_stat_data rsd = { .ctx = evsel_context(evsel), .cgrp = evsel->cgrp, @@ -808,46 +802,6 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, } else { print_metric(config, ctxp, NULL, NULL, "Ghz", 0); } - } else if (perf_stat_evsel__is(evsel, CYCLES_IN_TX)) { - total = runtime_stat_avg(st, STAT_CYCLES, map_idx, &rsd); - - if (total) - print_metric(config, ctxp, NULL, - "%7.2f%%", "transactional cycles", - 100.0 * (avg / total)); - else - print_metric(config, ctxp, NULL, NULL, "transactional cycles", - 0); - } else if (perf_stat_evsel__is(evsel, CYCLES_IN_TX_CP)) { - total = runtime_stat_avg(st, STAT_CYCLES, map_idx, &rsd); - total2 = runtime_stat_avg(st, STAT_CYCLES_IN_TX, map_idx, &rsd); - - if (total2 < avg) - total2 = avg; - if (total) - print_metric(config, ctxp, NULL, "%7.2f%%", "aborted cycles", - 100.0 * ((total2-avg) / total)); - else - print_metric(config, ctxp, NULL, NULL, "aborted cycles", 0); - } else if (perf_stat_evsel__is(evsel, TRANSACTION_START)) { - total = runtime_stat_avg(st, STAT_CYCLES_IN_TX, map_idx, &rsd); - - if (avg) - ratio = total / avg; - - if (runtime_stat_n(st, STAT_CYCLES_IN_TX, map_idx, &rsd) != 0) - print_metric(config, ctxp, NULL, "%8.0f", - "cycles / transaction", ratio); - else - print_metric(config, ctxp, NULL, NULL, "cycles / transaction", - 0); - } else if (perf_stat_evsel__is(evsel, ELISION_START)) { - total = runtime_stat_avg(st, STAT_CYCLES_IN_TX, map_idx, &rsd); - - if (avg) - ratio = total / avg; - - print_metric(config, ctxp, NULL, "%8.0f", "cycles / elision", ratio); } else if (evsel__is_clock(evsel)) { if ((ratio = avg_stats(&walltime_nsecs_stats)) != 0) print_metric(config, ctxp, NULL, "%8.3f", "CPUs utilized", diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 0b8c91ca13cd..b5b18d457254 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c @@ -87,10 +87,6 @@ bool __perf_stat_evsel__is(struct evsel *evsel, enum perf_stat_evsel_id id) #define ID(id, name) [PERF_STAT_EVSEL_ID__##id] = #name static const char *id_str[PERF_STAT_EVSEL_ID__MAX] = { ID(NONE, x), - ID(CYCLES_IN_TX, cpu/cycles-t/), - ID(TRANSACTION_START, cpu/tx-start/), - ID(ELISION_START, cpu/el-start/), - ID(CYCLES_IN_TX_CP, cpu/cycles-ct/), ID(SMI_NUM, msr/smi/), ID(APERF, msr/aperf/), }; diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index 42af350a96d9..c5fe847dd344 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -21,10 +21,6 @@ struct stats { enum perf_stat_evsel_id { PERF_STAT_EVSEL_ID__NONE = 0, - PERF_STAT_EVSEL_ID__CYCLES_IN_TX, - PERF_STAT_EVSEL_ID__TRANSACTION_START, - PERF_STAT_EVSEL_ID__ELISION_START, - PERF_STAT_EVSEL_ID__CYCLES_IN_TX_CP, PERF_STAT_EVSEL_ID__SMI_NUM, PERF_STAT_EVSEL_ID__APERF, PERF_STAT_EVSEL_ID__MAX, @@ -92,9 +88,6 @@ enum stat_type { STAT_LL_CACHE, STAT_ITLB_CACHE, STAT_DTLB_CACHE, - STAT_CYCLES_IN_TX, - STAT_TRANSACTION, - STAT_ELISION, STAT_SMI_NUM, STAT_APERF, STAT_MAX