Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp410480lqp; Tue, 11 Jun 2024 08:02:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW12H0DXlhv9UuLlFBbE46CmPWYUYza2aUkLgzJESjB2RWv9WN3OQDc28J+gnAdhvvRcQrf9sNjApS/HM7qT/0MRm/jz/4geUtThpA/Gw== X-Google-Smtp-Source: AGHT+IHzo+4RXpT3KH7tVIMnSX1VYMxNj2ncADk2H3I1uOQepQWBIE8ATejLK7THjWQd2nb50jB6 X-Received: by 2002:a50:ab58:0:b0:57c:61a3:546 with SMTP id 4fb4d7f45d1cf-57c61a3066cmr7035021a12.21.1718118170874; Tue, 11 Jun 2024 08:02:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718118170; cv=pass; d=google.com; s=arc-20160816; b=eqKHNcz1rVMcfRjGA9I294EPEc3PhjQOiUZMqVvZ+MqOcedo0AbAAosenDntfIchpM xzW/lo8j/Xl4tRxv29DGqFYV/bIAv8drfvfm2135CoAlRfP/4OzUxthNLEHlMGJGIQV7 5ud0Nm/HJ+kY8w3r19UP1ODFd+CgPC8ORhV6SVsGICM0IGk+vsWYQTRtMbecYnrYjZC8 4Qx28NCcrdawOw6gM02M/B89yI9Y6VH+D0HP2EhqQ6N9MVhAevB0oXoWq9tawVIGNxKw n/bV90C+c6hLLMF2AyaWSURDRm7//iWYeIlR0p3RHHdaoYMdSX1CDOZ1h+pYXSSPKnQg mjiQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=i/Ds9aieW2TuZSX67Rq2lfDZ6iuN9n/HDqtTTKrqWOM=; fh=2s+eIsKHHam+jMV7/s2ffLwy54AhQ8M2v8jHKEN3Fe4=; b=Yb+DKxavdjyd5UjTLDUqV+Rg5sYJs1Hqa7M7usrINGha4olAcE4vS1XOu+Nx2DS61i jXymmUvCe2rvxgj/IiGFsu+ntjcPj9slcqh65q/w8d1yBYgo+pvfBRCn0ygJ6hXebDUp zzoNxFuEx/Fb5DUdldG5aa0bGNr2W0Z+560vaUPuqbmpNj2sUYs//bV/ssS1YfRlsVNo kQWVK3lsiHwEh70wl6HCmCnILT6/R0iQd3DDJjH0o6B2E2PvAWs5f8diaAOZVuXk3lw/ WJl6dQiP8qRJqb19znRkU4SIq8WyTksoXvd6fbEqRXEnCeqM9+CcYN+z1hsUvIw+crU6 DocA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-210110-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210110-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57c6f505846si3549610a12.623.2024.06.11.08.02.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 08:02:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-210110-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-210110-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210110-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 83DC81F24A2E for ; Tue, 11 Jun 2024 15:02:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C59FB1BDD0; Tue, 11 Jun 2024 15:02:43 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE8FE171C2; Tue, 11 Jun 2024 15:02:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718118163; cv=none; b=TFEFeTw2dPvLDWjbcj0Fr7rCZM/D4u32dswcEs0fEO6i6znN6E7FcR2p0lyVhG54YzK27he7FXA+N77KRBlSDZ0md0UBMCrYX55BhAZ2YqriZgGwBgyVGyfCFC7tynHnQfQ+mzvo77jsZdcVHBAPTelN6M6D80bldTs+eqQaNd4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718118163; c=relaxed/simple; bh=QZ5m5EWS90C6rr5lOM4FnFkkxG81uFVCs0gFsgp2b/Q=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=IWh/ntwrMWSJxiwd+SAkjSjl/sTTgya7X27KOWHiMPUwBjyef2rwOmbtk37i/kddtUjdt8r1WLlPr9fd9JnjBtmgSw/nr82bE+wYC8a9sjfRQaboNAc4uu/AK0jgaUlNgEq0GRm+a1nqVqfcIGKIqI63yQ7CSNyNhXrF0UKfycE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 591DC152B; Tue, 11 Jun 2024 08:03:04 -0700 (PDT) Received: from e127643.arm.com (unknown [10.57.41.181]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D48103F64C; Tue, 11 Jun 2024 08:02:35 -0700 (PDT) From: James Clark To: coresight@lists.linaro.org, suzuki.poulose@arm.com, gankulkarni@os.amperecomputing.com, mike.leach@linaro.org, leo.yan@linux.dev, anshuman.khandual@arm.com Cc: James Clark , Alexander Shishkin , Maxime Coquelin , Alexandre Torgue , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , John Garry , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-perf-users@vger.kernel.org Subject: [PATCH v3 00/14] coresight: Use per-sink trace ID maps for Perf sessions Date: Tue, 11 Jun 2024 16:02:11 +0100 Message-Id: <20240611150228.1802828-1-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This will allow sessions with more than CORESIGHT_TRACE_IDS_MAX ETMs as long as there are fewer than that many ETMs connected to each sink. Each sink owns its own trace ID map, and any Perf session connecting to that sink will allocate from it, even if the sink is currently in use by other users. This is similar to the existing behavior where the dynamic trace IDs are constant as long as there is any concurrent Perf session active. It's not completely optimal because slightly more IDs will be used than necessary, but the optimal solution involves tracking the PIDs of each session and allocating ID maps based on the session owner. This is difficult to do with the combination of per-thread and per-cpu modes and some scheduling issues. The complexity of this isn't likely to worth it because even with multiple users they'd just see a difference in the ordering of ID allocations rather than hitting any limits (unless the hardware does have too many ETMs connected to one sink). Per-thread mode works but only until there are any overlapping IDs, at which point Perf will error out. Both per-thread mode and sysfs mode are left to future changes, but both can be added on top of this initial implementation and only sysfs mode requires further driver changes. The HW_ID version field hasn't been bumped in order to not break Perf which already has an error condition for other values of that field. Instead a new minor version has been added which signifies that there are new fields but the old fields are backwards compatible. Changes since v2: * Rebase on coresight-next 6.10-rc2 (b9b25c8496). * Fix double free of csdev if device registration fails. * Fix leak of coresight_trace_id_perf_start() if trace ID allocation fails. * Don't resend HW_ID for sink changes in per-thread mode. The existing CPU field on AUX records can be used to track this instead. * Tidy function doc for coresight_trace_id_release_all() * Drop first two commits now that they are in coresight-next * Add a commit to make the trace ID spinlock local to the map Changes since V1: * Rename coresight_device.perf_id_map to perf_sink_id_map. * Instead of outputting a HW_ID for each reachable ETM, output the sink ID and continue to output only the HW_ID once for each mapping. * Keep the first two Perf patches so that it applies cleanly on coresight-next, although they have been applied on perf-tools-next * Add new *_map() functions to the trace ID public API instead of modifying existing ones. * Collapse "coresight: Pass trace ID map into source enable" into "coresight: Use per-sink trace ID maps for Perf sessions" because the first commit relied on the default map being accessible which is no longer necessary due to the previous bullet point. James Clark (14): perf: cs-etm: Create decoders after both AUX and HW_ID search passes perf: cs-etm: Allocate queues for all CPUs perf: cs-etm: Move traceid_list to each queue perf: cs-etm: Create decoders based on the trace ID mappings perf: cs-etm: Support version 0.1 of HW_ID packets coresight: Remove unused ETM Perf stubs coresight: Clarify comments around the PID of the sink owner coresight: Move struct coresight_trace_id_map to common header coresight: Expose map arguments in trace ID API coresight: Make CPU id map a property of a trace ID map coresight: Use per-sink trace ID maps for Perf sessions coresight: Remove pending trace ID release mechanism coresight: Emit sink ID in the HW_ID packets coresight: Make trace ID map spinlock local to the map drivers/hwtracing/coresight/coresight-core.c | 37 +- drivers/hwtracing/coresight/coresight-dummy.c | 3 +- .../hwtracing/coresight/coresight-etm-perf.c | 36 +- .../hwtracing/coresight/coresight-etm-perf.h | 18 - .../coresight/coresight-etm3x-core.c | 9 +- .../coresight/coresight-etm4x-core.c | 9 +- drivers/hwtracing/coresight/coresight-priv.h | 1 + drivers/hwtracing/coresight/coresight-stm.c | 3 +- drivers/hwtracing/coresight/coresight-sysfs.c | 3 +- .../hwtracing/coresight/coresight-tmc-etr.c | 5 +- drivers/hwtracing/coresight/coresight-tmc.h | 5 +- drivers/hwtracing/coresight/coresight-tpdm.c | 3 +- .../hwtracing/coresight/coresight-trace-id.c | 133 ++-- .../hwtracing/coresight/coresight-trace-id.h | 70 +- include/linux/coresight-pmu.h | 17 +- include/linux/coresight.h | 21 +- tools/include/linux/coresight-pmu.h | 17 +- .../perf/util/cs-etm-decoder/cs-etm-decoder.c | 28 +- tools/perf/util/cs-etm.c | 600 +++++++++++------- tools/perf/util/cs-etm.h | 2 +- 20 files changed, 614 insertions(+), 406 deletions(-) -- 2.34.1