Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp535031ybe; Mon, 2 Sep 2019 05:38:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzy9TyVw6VaSlEJPn6G00IQIbC7FulUvHNCMIMI31epWU6cIKGqBQu50kVcZOMbhPZUdEI7 X-Received: by 2002:a17:90a:648:: with SMTP id q8mr10737855pje.80.1567427928896; Mon, 02 Sep 2019 05:38:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567427928; cv=none; d=google.com; s=arc-20160816; b=EOFHOBkSK1VW5PoAuIPNgxQ8552k5/kA/MNxYXs9DMtlTdYvgvvfQsA1AlBNOyty3S 8EZnmX+qq6zEuc7EAYQEtoPMmoUtiNkRK1+1N7f9pXRtmgiLroTSSxWoGLb5rhqKZD+Z D/yLlojGPOo4YPIe7Z+Dxn6fFJkulPKfbGv1haBGKbO8/5N9jubfgLrAOHI6XxEToDgf weRTRNEoaRs75WdMfpByLUGJ2epA3lIuB55M5W8kse6cwNpjhe1jb9qsc9KZgJTlUc1U NF3FtThq4GtE6rcHHzDLPK++cwo8YJRwyexzES7OE20+TH0Rq5aWO0aoXIRkRl2r94OB Aufg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/eCQq9zi+8hvxspMuYZ3xvqf1m79W4u3RCisJjMFvGc=; b=aTBxyF0zbxAnOtd/a29TG+vEPbZ8Iif6JxZBaaTsb7QUi9HWlPHW8/D+c3NV9otPlb VoJpYusHxG6BYwNVyfxvrXht2pBBkGHzI/OvGkxQmvY3QU2pc6xdTcL72dxMp5LQbMaf HNaU6CYHMkjIQ22cVwt7Zi5BB+X5Cb8Z5qbl2+LagcH5RW1GqftJZ8jQwNfhExeKdCgU 5bUtTxYqoyCuM2qnAnncmQKMATwcEyaWXUVPErQK2Z2f0q6VIyQghVFGvSoGHYNpsmlY 6N3ZoYIp6ngZHaPg9jOj+/yjlflG0yLYNkdlNHts+gFl1OZSf8C0U4DxvnjHwBubMJ0W cCfw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1si10965027plt.277.2019.09.02.05.38.33; Mon, 02 Sep 2019 05:38:48 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731420AbfIBMNG (ORCPT + 99 others); Mon, 2 Sep 2019 08:13:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60852 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729658AbfIBMNG (ORCPT ); Mon, 2 Sep 2019 08:13:06 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 3CBD7307D90D; Mon, 2 Sep 2019 12:13:05 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.103]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BB9060C05; Mon, 2 Sep 2019 12:12:58 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Joe Mario , Kan Liang , Andi Kleen Subject: [PATCH 1/3] libperf: Add perf_cpu_map__max function Date: Mon, 2 Sep 2019 14:12:53 +0200 Message-Id: <20190902121255.536-2-jolsa@kernel.org> In-Reply-To: <20190902121255.536-1-jolsa@kernel.org> References: <20190902121255.536-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 02 Sep 2019 12:13:05 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org So it can be used from multiple places. Link: http://lkml.kernel.org/n/tip-yp3h5rl9e8piybufq41zqnla@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/builtin-stat.c | 14 +------------- tools/perf/lib/cpumap.c | 12 ++++++++++++ tools/perf/lib/include/perf/cpumap.h | 1 + tools/perf/lib/libperf.map | 1 + 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 7e17bf9f700a..5bc0c570b7b6 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -822,18 +822,6 @@ static int perf_stat__get_core(struct perf_stat_config *config __maybe_unused, return cpu_map__get_core(map, cpu, NULL); } -static int cpu_map__get_max(struct perf_cpu_map *map) -{ - int i, max = -1; - - for (i = 0; i < map->nr; i++) { - if (map->map[i] > max) - max = map->map[i]; - } - - return max; -} - static int perf_stat__get_aggr(struct perf_stat_config *config, aggr_get_id_t get_id, struct perf_cpu_map *map, int idx) { @@ -928,7 +916,7 @@ static int perf_stat_init_aggr_mode(void) * taking the highest cpu number to be the size of * the aggregation translate cpumap. */ - nr = cpu_map__get_max(evsel_list->core.cpus); + nr = perf_cpu_map__max(evsel_list->core.cpus); stat_config.cpus_aggr_map = perf_cpu_map__empty_new(nr + 1); return stat_config.cpus_aggr_map ? 0 : -ENOMEM; } diff --git a/tools/perf/lib/cpumap.c b/tools/perf/lib/cpumap.c index 1f0e6f334237..2ca1fafa620d 100644 --- a/tools/perf/lib/cpumap.c +++ b/tools/perf/lib/cpumap.c @@ -260,3 +260,15 @@ int perf_cpu_map__idx(struct perf_cpu_map *cpus, int cpu) return -1; } + +int perf_cpu_map__max(struct perf_cpu_map *map) +{ + int i, max = -1; + + for (i = 0; i < map->nr; i++) { + if (map->map[i] > max) + max = map->map[i]; + } + + return max; +} diff --git a/tools/perf/lib/include/perf/cpumap.h b/tools/perf/lib/include/perf/cpumap.h index 8aa995c59498..ac9aa497f84a 100644 --- a/tools/perf/lib/include/perf/cpumap.h +++ b/tools/perf/lib/include/perf/cpumap.h @@ -16,6 +16,7 @@ LIBPERF_API void perf_cpu_map__put(struct perf_cpu_map *map); LIBPERF_API int perf_cpu_map__cpu(const struct perf_cpu_map *cpus, int idx); LIBPERF_API int perf_cpu_map__nr(const struct perf_cpu_map *cpus); LIBPERF_API bool perf_cpu_map__empty(const struct perf_cpu_map *map); +LIBPERF_API int perf_cpu_map__max(struct perf_cpu_map *map); #define perf_cpu_map__for_each_cpu(cpu, idx, cpus) \ for ((idx) = 0, (cpu) = perf_cpu_map__cpu(cpus, idx); \ diff --git a/tools/perf/lib/libperf.map b/tools/perf/lib/libperf.map index dc4d66363bc4..cd0d17b996c8 100644 --- a/tools/perf/lib/libperf.map +++ b/tools/perf/lib/libperf.map @@ -9,6 +9,7 @@ LIBPERF_0.0.1 { perf_cpu_map__nr; perf_cpu_map__cpu; perf_cpu_map__empty; + perf_cpu_map__max; perf_thread_map__new_dummy; perf_thread_map__set_pid; perf_thread_map__comm; -- 2.21.0