From patchwork Fri Dec 15 18:09:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 122146 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp806281qgn; Fri, 15 Dec 2017 10:11:26 -0800 (PST) X-Google-Smtp-Source: ACJfBosFF7NEfcs5ZU1V5W/KV+2uLw+RJyWkcaVRYwBQuG+UGp5kfB12lidYXNf26Ly/d3HkqWxb X-Received: by 10.101.91.5 with SMTP id y5mr12873767pgq.445.1513361486569; Fri, 15 Dec 2017 10:11:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513361486; cv=none; d=google.com; s=arc-20160816; b=k6raLnoXtFb4d+bOJycJxVEKd5BfyOglDTdFD7OFH0ClqrEwQYBRzKrbTuZ+04811B iqacrhu1cbhGqckn+Tp2+opMWnsYn3aWlZHP6qCJx56W/7L+p1McQoS1uteMrIdyGnD1 sXUZlOt4eRmdIVvHa06tdEh1hf/Nyo9ubl+5frlwJ4oWarGJfszpHs/gwdMavR3DdXlN d490jRjuC1yQf9A5uizOz97mfHWaEdLG8MZLZ7NasZfWQtkpfqkhKjYssMlmvgFaYgPL /8yvgLJ6gGK1f9qG5AV52rJtl/4weNM1+grt8RwC6r9J6okPLetSKRpNFd2d+mAGKkbO 3fYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=hkTEQ6OQ3/45psgevD9mnBfcN3KRTBJCK38uRCZAkdc=; b=ouvdbi3hgaLY5StdS0njB6Ikc6dWj2+gEeuODb+YoCu02orIVDRZbLDX1yuMg5HoQM t+3ejmFhHl+YKyWt+Ih01akv+LvYeT6kY913GWnlytlQYHHhWUnODNwIqoOhunhOHGzP GXweGbFGnAfUohcJofCNZ7RFpBiW/OTe9xXKQgdfQ+keDKZL28jSBexxBU8gGraLluJr DTFKnMhKSlbVa3H9UNJbRMR05Ykd0S7AXoKMW8lWj44E98yJ91NOij0gNxDZAvR1odFB YB+c7b4yXbDz6rnX2tktEuvOAYH3Ubm+9Jl1vC2dza9J6lTpKWDK4ygxu67gjYSlyWgP F0kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fnzw0M3p; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h125si4912601pgc.54.2017.12.15.10.11.26; Fri, 15 Dec 2017 10:11:26 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=Fnzw0M3p; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756516AbdLOSLY (ORCPT + 24 others); Fri, 15 Dec 2017 13:11:24 -0500 Received: from mail-it0-f68.google.com ([209.85.214.68]:46997 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755824AbdLOSJT (ORCPT ); Fri, 15 Dec 2017 13:09:19 -0500 Received: by mail-it0-f68.google.com with SMTP id t1so21422305ite.5 for ; Fri, 15 Dec 2017 10:09:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=hkTEQ6OQ3/45psgevD9mnBfcN3KRTBJCK38uRCZAkdc=; b=Fnzw0M3piFHvAWxzZKfaPmKTQ7S/P+38YHW6normEM93PpAI4TLUNHWVoYB6p6YPGu xNP2Pujx0/RCS0mbDqxvic5Ph0OWTVfmUixucCCUh+YsnCNSoAGMdgUZENcxXwAS7woD Hwyk9VA/jTIdIbm2TPWPgDUJ9tc27K7X0EkGI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=hkTEQ6OQ3/45psgevD9mnBfcN3KRTBJCK38uRCZAkdc=; b=TSjXNUsGXuNqU+bcSH1Kv/aFZzZM/Sk698VZO6YFxhSKrxHqe95Vq2dj6fIwz/ZwFh /0B317fF4q7k9lE3vg3iK2HS9JI4u8v2mncCCXIm9pd1zvHrIhF2ZbPIoHF7tJ3pj1DY gl400EsUGk5vsrb+Y3T8njnJq18G19VKC+BeUsedG0HhTnw3TnTOxYGuVpU2SC4VYNjw urCj9Di5fOK/KibpN8zD5V6xrt+/EdkYuIf25coKcmNWPx/2+7NeQoKtZqUGK+leVj/+ erTo3a5l+5s5In7cQmvi1aFruLKesAZHMKFTULQUejsFm10tI4gj7MyRNr5OPHZVF8Qh FyuQ== X-Gm-Message-State: AKGB3mJzwby4+QZHhlKxDEFJys4FFq3zYnF+c4ivygL6MEhUup1GF1Xi t4lEHi40i2/22SN/z5NfOPuK1w== X-Received: by 10.36.33.87 with SMTP id e84mr9121330ita.79.1513361359101; Fri, 15 Dec 2017 10:09:19 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id f13sm3587542ioh.70.2017.12.15.10.09.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Dec 2017 10:09:17 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org Cc: peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] perf tools: cs-etm: Properly deal with cpu maps Date: Fri, 15 Dec 2017 11:09:15 -0700 Message-Id: <1513361355-29107-1-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch allows the CoreSight header file to fit topologies where only a subset of all available CPUs are present, avoiding at the same time accessing the ETM configuration areas of CPUs that have been offlined. Signed-off-by: Mathieu Poirier --- tools/perf/arch/arm/util/cs-etm.c | 51 +++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 15 deletions(-) -- 2.7.4 diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index fbfc055d3f4d..5c655ad4621e 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -298,12 +298,17 @@ cs_etm_info_priv_size(struct auxtrace_record *itr __maybe_unused, { int i; int etmv3 = 0, etmv4 = 0; - const struct cpu_map *cpus = evlist->cpus; + struct cpu_map *event_cpus = evlist->cpus; + struct cpu_map *online_cpus = cpu_map__new(NULL); /* cpu map is not empty, we have specific CPUs to work with */ - if (!cpu_map__empty(cpus)) { - for (i = 0; i < cpu_map__nr(cpus); i++) { - if (cs_etm_is_etmv4(itr, cpus->map[i])) + if (!cpu_map__empty(event_cpus)) { + for (i = 0; i < cpu__max_cpu(); i++) { + if (!cpu_map__has(event_cpus, i) || + !cpu_map__has(online_cpus, i)) + continue; + + if (cs_etm_is_etmv4(itr, i)) etmv4++; else etmv3++; @@ -311,6 +316,9 @@ cs_etm_info_priv_size(struct auxtrace_record *itr __maybe_unused, } else { /* get configuration for all CPUs in the system */ for (i = 0; i < cpu__max_cpu(); i++) { + if (!cpu_map__has(online_cpus, i)) + continue; + if (cs_etm_is_etmv4(itr, i)) etmv4++; else @@ -318,6 +326,8 @@ cs_etm_info_priv_size(struct auxtrace_record *itr __maybe_unused, } } + cpu_map__put(online_cpus); + return (CS_ETM_HEADER_SIZE + (etmv4 * CS_ETMV4_PRIV_SIZE) + (etmv3 * CS_ETMV3_PRIV_SIZE)); @@ -447,7 +457,9 @@ static int cs_etm_info_fill(struct auxtrace_record *itr, int i; u32 offset; u64 nr_cpu, type; - const struct cpu_map *cpus = session->evlist->cpus; + struct cpu_map *cpu_map; + struct cpu_map *event_cpus = session->evlist->cpus; + struct cpu_map *online_cpus = cpu_map__new(NULL); struct cs_etm_recording *ptr = container_of(itr, struct cs_etm_recording, itr); struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu; @@ -458,8 +470,21 @@ static int cs_etm_info_fill(struct auxtrace_record *itr, if (!session->evlist->nr_mmaps) return -EINVAL; - /* If the cpu_map is empty all CPUs are involved */ - nr_cpu = cpu_map__empty(cpus) ? cpu__max_cpu() : cpu_map__nr(cpus); + /* If the cpu_map is empty all online CPUs are involved */ + if (cpu_map__empty(event_cpus)) { + cpu_map = online_cpus; + } else { + /* Make sure all specified CPUs are online */ + for (i = 0; i < cpu_map__nr(event_cpus); i++) { + if (cpu_map__has(event_cpus, i) && + !cpu_map__has(online_cpus, i)) + return -EINVAL; + } + + cpu_map = event_cpus; + } + + nr_cpu = cpu_map__nr(cpu_map); /* Get PMU type as dynamically assigned by the core */ type = cs_etm_pmu->type; @@ -472,15 +497,11 @@ static int cs_etm_info_fill(struct auxtrace_record *itr, offset = CS_ETM_SNAPSHOT + 1; - /* cpu map is not empty, we have specific CPUs to work with */ - if (!cpu_map__empty(cpus)) { - for (i = 0; i < cpu_map__nr(cpus) && offset < priv_size; i++) - cs_etm_get_metadata(cpus->map[i], &offset, itr, info); - } else { - /* get configuration for all CPUs in the system */ - for (i = 0; i < cpu__max_cpu(); i++) + for (i = 0; i < cpu__max_cpu() && offset < priv_size; i++) + if (cpu_map__has(cpu_map, i)) cs_etm_get_metadata(i, &offset, itr, info); - } + + cpu_map__put(online_cpus); return 0; }