Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp149264lqb; Tue, 4 Jun 2024 07:36:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXxnqqj2Rcu7UP6gzBuXcaHN/bE3wXDSSLAajIBfAac+QMZNwL3I8sOzRgbYkyfoOY9Hcn7itTHWS8dH0XcBRff8e2OgZfNza2IPvlcig== X-Google-Smtp-Source: AGHT+IHzLXOUnBaKZmMnkX/gVDUf3e+h8kwDtA5twmd5ixrN8yBPT2RyhTqNBGToQwsfNtj46LNP X-Received: by 2002:a17:906:a293:b0:a68:e58b:2c35 with SMTP id a640c23a62f3a-a68e58b2c64mr495992966b.31.1717511803415; Tue, 04 Jun 2024 07:36:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717511803; cv=pass; d=google.com; s=arc-20160816; b=yJBHpCqDWytocyW1ko3/VWx8Q0OuSuuB+tySX7to0SjEKSFXM5vDr0bt45dfzzfp4E zEkYE0y6+0j+HNru0r682rEEM5z+Tctdi+TnH+hPzWZzJC2bFYMziCbA/Y2TW3+6cT4y ZML/GRgjxhZPu1tE2DRbikH9FA6NMt8xiMA7g8VUWgmhoVk1yxMPTz8X+zEZPg7nLsvI B1FcTY+p27tmPJd9iv2fjcGF0AsFkJxoOvj8yYeZk3FqgDnN1ef2wNqQvwvPl+eRX80f S3LOibwWtugqbvzf4I7FJB4UQ3JfX/plYyXb2xYpn4tP6YABeBKdNGy876RfN3kRdaDw 1F7A== 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=qOWCwJMtF0gCd2OTXzrhLmwQqRstOBda+g7z+qS7fho=; fh=PS2xZ37x6i1et2MxEVJy4TSpqrJZGNwd6DyYCR5/2fw=; b=Y8mdOlBkUf6vQq8ddJ1ex2ag9iAroMXxMmDflePcqt7XnivPe2SojqgF+YMZ1KyrjU Uy5h/S+YrzvQOCdqaTT6bYHsZvz50UbP5Ge2wD86Q0G5uKoXxDfuYAmZJr/mrMqF8Nqi r/3vdFKOx38hcJNQoawOCWiTVXjTiBHQg99rdgSI3XIhGS9KS9e7nOsLFK9PqvAO2vHP iIpg68CXkKwi6GXlhmVO4iQfDqq8XxQoB9aNZy0EqwqrfnxioyZ4TFqZW5v4DyfcgF/s MPzPT6TYgG8oh0HLNr9XeWSlmCz0frReHnIBjEO7nPqsvHXuQamtmdSYUUOH228e8u6C bHvw==; 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-200839-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200839-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6921f878eesi153450766b.322.2024.06.04.07.36.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 07:36:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200839-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-200839-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200839-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 295571F21DB4 for ; Tue, 4 Jun 2024 14:36:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F632149DFB; Tue, 4 Jun 2024 14:33:19 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 76B3F1465BB; Tue, 4 Jun 2024 14:33:17 +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=1717511598; cv=none; b=jsgveJXw2jemEjHX1CD4bOv4bNS4e79fFIdFN90ju+tOxtJVGvfIkG3LysayuVZvQeoLCL3uVXd0f6HR5I19eKQofREetT5tc4tEft+O02rPUzPEQ4y037EGquE7Kj/KEH+bB7kI8QPfxXNwm4tYcYzvrhgO30C7NBawbUrxZz4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717511598; c=relaxed/simple; bh=y7xNLn9XuqoEgeGbYseeZwudJQLOaoFCJmiHnIB8mBk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UTlVjO1P1/CkXAMwvar94BNx8wU7q/4qL7BeBKlxqkprud8VKxefLdAJzb51S1DRy/a2ZdhlbsGgQKLWs41BXpNrqjqehZJD9H6SSi+kK56wvbYyrqidRlrQ5MIE2H+fYEIuRDZn3MzLa535OrMOHh+4wbZhdR0nw8NvWK5v1r8= 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 2786E1474; Tue, 4 Jun 2024 07:33:41 -0700 (PDT) Received: from e127643.broadband (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C4CD43F64C; Tue, 4 Jun 2024 07:33:13 -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 , 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 v2 15/16] coresight: Re-emit trace IDs when the sink changes in per-thread mode Date: Tue, 4 Jun 2024 15:30:24 +0100 Message-Id: <20240604143030.519906-16-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604143030.519906-1-james.clark@arm.com> References: <20240604143030.519906-1-james.clark@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In per-cpu mode there are multiple aux buffers and each one has a fixed sink, so the hw ID mappings which only need to be emitted once for each buffer, even with the new per-sink trace ID pools. But in per-thread mode there is only a single buffer which can be written to from any sink with now potentially overlapping trace IDs, so hw ID mappings need to be re-emitted every time the sink changes. This will require a change in Perf to track this so it knows which decode tree to use for each segment of the buffer. In theory it's also possible to look at the CPU ID on the AUX records, but this is more consistent with the existing system, and allows for correct decode using either mechanism. Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm-perf.c | 14 ++++++++++++++ drivers/hwtracing/coresight/coresight-etm-perf.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index 17cafa1a7f18..b6f505b50e67 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -499,6 +499,20 @@ static void etm_event_start(struct perf_event *event, int flags) &sink->perf_sink_id_map)) goto fail_disable_path; + /* + * In per-cpu mode there are multiple aux buffers and each one has a + * fixed sink, so the hw ID mappings which only need to be emitted once + * for each buffer. + * + * But in per-thread mode there is only a single buffer which can be + * written to from any sink with potentially overlapping trace IDs, so + * hw ID mappings need to be re-emitted every time the sink changes. + */ + if (event->cpu == -1 && event_data->last_sink_hwid != sink) { + cpumask_clear(&event_data->aux_hwid_done); + event_data->last_sink_hwid = sink; + } + /* * output cpu / trace ID in perf record, once for the lifetime * of the event. diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.h b/drivers/hwtracing/coresight/coresight-etm-perf.h index 744531158d6b..bd4553b2a1ec 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.h +++ b/drivers/hwtracing/coresight/coresight-etm-perf.h @@ -52,6 +52,7 @@ struct etm_filters { * @snk_config: The sink configuration. * @cfg_hash: The hash id of any coresight config selected. * @path: An array of path, each slot for one CPU. + * @last_sink_hwid: Last sink that a hwid was emitted for. */ struct etm_event_data { struct work_struct work; @@ -60,6 +61,7 @@ struct etm_event_data { void *snk_config; u32 cfg_hash; struct list_head * __percpu *path; + struct coresight_device *last_sink_hwid; }; int etm_perf_symlink(struct coresight_device *csdev, bool link); -- 2.34.1