From patchwork Mon Feb 12 23:38:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 128175 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3690548ljc; Mon, 12 Feb 2018 15:39:14 -0800 (PST) X-Google-Smtp-Source: AH8x227fjkQB97Mh26J36Q4KR3W1Jtrd56KBE5K6JSCHCfzeitQan8vwCfYJqfFgYCdepjETA9qc X-Received: by 2002:a17:902:22e:: with SMTP id 43-v6mr1123695plc.384.1518478754774; Mon, 12 Feb 2018 15:39:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518478754; cv=none; d=google.com; s=arc-20160816; b=bW4Fl/xd5KpwByhmpl4Dvn3pPl1tU7dM51l+BfwYQWWPYga7mcmksIOw7ATmou26xN tz+hLUotSDdPYs/gnKLlLf2AuWRZHjd7UKEBlxlY9+6n9jVNePjg7eOn6dN+vmUlFjrM uc1g+XX61DXDqEiWqFVsvpV0PDsUjgFBYLssAADhZk3bBWyeirFdoUiRent5J1B9uzF4 jsjP/dh1gqND1k7qJ7tLAzcyehXueupAXwB1IYSRlNNDy+0pgU7HCgp4i8VZShgJMp1F vRD9oEua3PKiIE52AIf6fihWKBskpGF5EaBfSh4rGnQ4dS3/PHronaews5GeI6YRh0fd c7VA== 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=7hdMPZXO/En4TXsM9C0cBhJnf3eMdp3dZeUCImJO+ng=; b=wMKFSlQoBLSGPRL3FADa8uqxiwv0Alcj8bbSLOygt1C1AfvZLE2donxBkYMVxAzAKk ynC/PtbVQBKpVt/JsNda7X9kD2f4lRr/ITGiaOIs67DmsR1GkHPKEe2XGsK+b2dtZyES vxTlE1NzJLbw9JfzfgDVfRa1Jo4CLdDmz5VMLGZjX5qpzB1h6qMB4e50tf6llLDVaB2k NF/vNxwlYqHhMPO8FLApAoRR19tCdfZnGvqeFCbcskYYdKtVejQ8SYRrDNC4k4tqLpP0 FsGNATfTDY79C9L+A+3anK9o7XfvK33iKunntAN1SQnGhWwE8X2k8UqEbsLZ98Aj5a9L fD3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fp1p4J0X; 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 y17si4066538pgv.311.2018.02.12.15.39.14; Mon, 12 Feb 2018 15:39:14 -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=Fp1p4J0X; 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 S932637AbeBLXjB (ORCPT + 27 others); Mon, 12 Feb 2018 18:39:01 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:44722 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932378AbeBLXjA (ORCPT ); Mon, 12 Feb 2018 18:39:00 -0500 Received: by mail-pl0-f65.google.com with SMTP id f8so5735381plk.11 for ; Mon, 12 Feb 2018 15:39:00 -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=7hdMPZXO/En4TXsM9C0cBhJnf3eMdp3dZeUCImJO+ng=; b=Fp1p4J0XI69xSb1pwMDWRQSN+JTg94Z+Iw1EbJfFws04Nb/M3v+FnnRMB+DYr6trkI n9/sl+JY4qotIhxWSUL+9dwUuK+KHhpWvN8iiu58KhftXn8IST1dZ4hXR0QCA66DaavF JYJgmYx0MLLeO9q8HUl+VYxGVNxDE2H3TYX4s= 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=7hdMPZXO/En4TXsM9C0cBhJnf3eMdp3dZeUCImJO+ng=; b=W4xNzGbYISkMDYm9orhf56si8CVMsGzw4QH6qWAJyFL6KgXeVczcUnbyva3mfUchQw lVOi/NSpcNZaYl6y38ujxmyNsY5PhRTHXlX9W0LU1wDWJ+mVKJHEPIC8y/kQ6KwFg7GM 0b5uSoDuqYOIaQ9XOJ06pwOJmC66ZNprQbm/zCtc0oeGQmqGTchHsBFSVDOf1AOqlqvx exsHOFf5ENljcNqwbix/z4hY/seSVWTho0LZ0ewRhF4gGf4/evrsGLYh41F8i16tPTVQ 4gNttfpuB6NtLuwG56R6LEkFr81y9I6vYlo5qo8W9CykKI/eew1Z6335haMgaRz8py8Z HrZA== X-Gm-Message-State: APf1xPAAaTSGObDNMkM5S2B75gBnpPm6sncZxyBCWaIv3UOVGp5Vtn7s Yy0jPvSl5+FxYypuHJxqNfhpmw== X-Received: by 2002:a17:902:8498:: with SMTP id c24-v6mr12068996plo.450.1518478740012; Mon, 12 Feb 2018 15:39:00 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id r26sm29392530pfi.72.2018.02.12.15.38.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Feb 2018 15:38:59 -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: Mon, 12 Feb 2018 16:38:57 -0700 Message-Id: <1518478737-24649-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 AUX info section 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; }