From mboxrd@z Thu Jan 1 00:00:00 1970 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 9F2FCC433EF for ; Thu, 23 Dec 2021 07:54:11 +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=xDOItIwO9Kl0TJYcS/lO66WtGczG30pEXZVTdUjK5OA=; b=U/uiNWuFO85EFBs9QsQU1IvkGm FE78gR6/HdDnDPHVwAAiNkhcxWySrfo4bI0kLv+XJ7hc8PyYuYRXLSSIrQtbHEiFO7gU7TPwEVYQ0 toAHhyaMU0R2o8sakanuqGZmSB9zTnRWIjd0Oiqnaqvt5teqUyf4GfmExDnql9ipz1EJLIjLhETIm fHOsSSand15MN3/Ym5IrvLdnV2/wtHzBPnpYynFlPHTvAMXWdNv/gEiu+Xd3LIgzhHRbyGpQI4QaE vG4wYeroVQQW6UU26Nb1hgumwFiVjHMRDyXvqzoKVswgW5KFuV8wlxKQhnD2/T/Dq6Cqg9fLDQ9s3 t9FsB6Gw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n0Iu2-00C2BI-0O; Thu, 23 Dec 2021 07:52:42 +0000 Received: from mail-pf1-x44a.google.com ([2607:f8b0:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n0IoD-00BzaK-LV for linux-arm-kernel@lists.infradead.org; Thu, 23 Dec 2021 07:46:43 +0000 Received: by mail-pf1-x44a.google.com with SMTP id h5-20020a62de05000000b004ba9b333a4dso2940014pfg.18 for ; Wed, 22 Dec 2021 23:46:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=5u9uOvrM0MZW4hQbQrlJVSUOMIL0GMHYnyDBSXZC4ik=; b=qIVAAtr6ofyUe6ovBipZf/c3cfC9KP2iym9VMkWZ4IVlc+tsXbWVqXAa1VrJxlRlNG cGUqPpCr0XoycqNLxyVHg9yY6QxvehmlfyYLGTNPVAzLWmWtPlP3zZci+2xKNxyJdMlh UgZHnrsETcaQz1wXVRdwJPnfA8yH9siGL2PQq44JxrjhrSkhXqdCdyfvHZhMqzqdhBDA qp4Csm/vekB5JSLS3+zLgvea0ib92e9kNtnrPkN5507gWo3oAbjbvgAYuZ0oQPehKGy/ kMIiRpvJJpgJ9EkHWxHzyJ+//Nf93g2E5qVTUnoYY6rZAkXwgti4aeCHEdH4et9cTmJo xw0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=5u9uOvrM0MZW4hQbQrlJVSUOMIL0GMHYnyDBSXZC4ik=; b=E7c/KW+bZ3SXTFPdO7i8xS0w84ilz/G9wOiV+uWTsaqb3w0L9dWRWthWQY8J2LOZBb frLPZX3WZrY3rGgo08LOSb5BYfDE2EAu7nYiThj0AcrqqvngrnfvV0wyKJh3OO/avl29 /wZUibPIjQ/8Ff2FtjWMQ1poxSVOxoyzUdqkG3RMp+zhX7+LPfML4KVoROVLeA4bBXy/ t1sULoTZW8uuc0TlUvcbJ+EwcduSWtansEgLB5GGhhYTp5fMjUm5HV7lB1g0FQjrPUY7 WGw4+2p28wE6CLZPzN2d/Z9Gj8+VyQWxooIigxyhS3fzbPlEyqrgCivVA88IRow9dsY1 1W6Q== X-Gm-Message-State: AOAM5336XGlEGUhlfK7S+mS4rm7ydy8BRBvfWFa3py3siWWWtHbGtxAf kh7m8JlIINKafG2n/Ia/e8N6im6MHWOt X-Google-Smtp-Source: ABdhPJwlhHfxKAtk99Bk5IZEENVaNeKaQwYA2sTDg9XONvjMttn4NmO8MtIsYPprP67p/o9LkTxB5nLnKDmB X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:4fef:90ff:589d:24ca]) (user=irogers job=sendgmr) by 2002:a62:8cca:0:b0:4ba:d6d4:7bac with SMTP id m193-20020a628cca000000b004bad6d47bacmr1310531pfd.43.1640245600048; Wed, 22 Dec 2021 23:46:40 -0800 (PST) Date: Wed, 22 Dec 2021 23:45:06 -0800 In-Reply-To: <20211223074541.3318938-1-irogers@google.com> Message-Id: <20211223074541.3318938-14-irogers@google.com> Mime-Version: 1.0 References: <20211223074541.3318938-1-irogers@google.com> X-Mailer: git-send-email 2.34.1.307.g9b7440fafd-goog Subject: [PATCH v2 13/48] perf cpumap: Simplify equal function name. From: Ian Rogers To: Andi Kleen , Jiri Olsa , Namhyung Kim , John Garry , Kajol Jain , "Paul A . Clarke" , Arnaldo Carvalho de Melo , Riccardo Mancini , Kan Liang , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Vineet Singh , James Clark , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Cc: eranian@google.com, Ian Rogers X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211222_234641_733953_611E6D13 X-CRM114-Status: GOOD ( 15.54 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Rename cpu_map__compare_aggr_cpu_id to aggr_cpu_id__equal, the cpu_map part of the name is misleading. Equal better describes the function than compare. Switch to const pointer rather than value as struct given the number of variables in aggr_cpu_id. Reviewed-by: James Clark Signed-off-by: Ian Rogers --- tools/perf/util/cpumap.c | 14 +++++++------- tools/perf/util/cpumap.h | 2 +- tools/perf/util/stat-display.c | 18 ++++++++++-------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index f67b2e7aac13..8fa00a6221c8 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c @@ -171,7 +171,7 @@ int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res, for (cpu = 0; cpu < nr; cpu++) { s1 = f(cpu, data); for (s2 = 0; s2 < c->nr; s2++) { - if (cpu_map__compare_aggr_cpu_id(s1, c->map[s2])) + if (aggr_cpu_id__equal(&s1, &c->map[s2])) break; } if (s2 == c->nr) { @@ -593,13 +593,13 @@ const struct perf_cpu_map *cpu_map__online(void) /* thread unsafe */ return online; } -bool cpu_map__compare_aggr_cpu_id(struct aggr_cpu_id a, struct aggr_cpu_id b) +bool aggr_cpu_id__equal(const struct aggr_cpu_id *a, const struct aggr_cpu_id *b) { - return a.thread == b.thread && - a.node == b.node && - a.socket == b.socket && - a.die == b.die && - a.core == b.core; + return a->thread == b->thread && + a->node == b->node && + a->socket == b->socket && + a->die == b->die && + a->core == b->core; } bool cpu_map__aggr_cpu_id_is_empty(struct aggr_cpu_id a) diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h index 22e53fd54657..652b76c69376 100644 --- a/tools/perf/util/cpumap.h +++ b/tools/perf/util/cpumap.h @@ -67,7 +67,7 @@ int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res, int cpu_map__cpu(struct perf_cpu_map *cpus, int idx); bool cpu_map__has(struct perf_cpu_map *cpus, int cpu); -bool cpu_map__compare_aggr_cpu_id(struct aggr_cpu_id a, struct aggr_cpu_id b); +bool aggr_cpu_id__equal(const struct aggr_cpu_id *a, const struct aggr_cpu_id *b); bool cpu_map__aggr_cpu_id_is_empty(struct aggr_cpu_id a); struct aggr_cpu_id cpu_map__empty_aggr_cpu_id(void); diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 6c40b91d5e32..0241436bb1fb 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -328,20 +328,22 @@ static void print_metric_header(struct perf_stat_config *config, } static int first_shadow_cpu(struct perf_stat_config *config, - struct evsel *evsel, struct aggr_cpu_id id) + struct evsel *evsel, const struct aggr_cpu_id *id) { struct perf_cpu_map *cpus; int cpu, idx; if (config->aggr_mode == AGGR_NONE) - return id.core; + return id->core; if (!config->aggr_get_id) return 0; cpus = evsel__cpus(evsel); perf_cpu_map__for_each_cpu(cpu, idx, cpus) { - if (cpu_map__compare_aggr_cpu_id(config->aggr_get_id(config, cpu), id)) + struct aggr_cpu_id cpu_id = config->aggr_get_id(config, cpu); + + if (aggr_cpu_id__equal(&cpu_id, id)) return cpu; } return 0; @@ -501,7 +503,7 @@ static void printout(struct perf_stat_config *config, struct aggr_cpu_id id, int } perf_stat__print_shadow_stats(config, counter, uval, - first_shadow_cpu(config, counter, id), + first_shadow_cpu(config, counter, &id), &out, &config->metric_events, st); if (!config->csv_output && !config->metric_only) { print_noise(config, counter, noise); @@ -525,12 +527,12 @@ static void aggr_update_shadow(struct perf_stat_config *config, val = 0; perf_cpu_map__for_each_cpu(cpu, idx, cpus) { s2 = config->aggr_get_id(config, cpu); - if (!cpu_map__compare_aggr_cpu_id(s2, id)) + if (!aggr_cpu_id__equal(&s2, &id)) continue; val += perf_counts(counter->counts, idx, 0)->val; } perf_stat__update_shadow_stats(counter, val, - first_shadow_cpu(config, counter, id), + first_shadow_cpu(config, counter, &id), &rt_stat); } } @@ -641,7 +643,7 @@ static void aggr_cb(struct perf_stat_config *config, struct perf_counts_values *counts; s2 = config->aggr_get_id(config, cpu); - if (!cpu_map__compare_aggr_cpu_id(s2, ad->id)) + if (!aggr_cpu_id__equal(&s2, &ad->id)) continue; if (first) ad->nr++; @@ -1217,7 +1219,7 @@ static void print_percore_thread(struct perf_stat_config *config, s2 = config->aggr_get_id(config, cpu); for (s = 0; s < config->aggr_map->nr; s++) { id = config->aggr_map->map[s]; - if (cpu_map__compare_aggr_cpu_id(s2, id)) + if (aggr_cpu_id__equal(&s2, &id)) break; } -- 2.34.1.307.g9b7440fafd-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel