Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1460026lqa; Mon, 29 Apr 2024 09:03:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX+/Y7Unm3GxhXasoR1Fms3jH4pdVMQzfvzYvLSKWXuyVPEC66VhHawaROMfEAjhlyqoaD5Te3UsOoJqRi/XF33JqJTx9lUDkfWPtYzyA== X-Google-Smtp-Source: AGHT+IF/YwYKp2tg/mGiW5jqRMoZzzkG6Ime2lh4ToSDyA92sRNFNoVyDVsElrlzS8DHeg4Ppj4b X-Received: by 2002:a17:902:e98a:b0:1e2:3e1e:3d9 with SMTP id f10-20020a170902e98a00b001e23e1e03d9mr38033plb.63.1714406587396; Mon, 29 Apr 2024 09:03:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714406587; cv=pass; d=google.com; s=arc-20160816; b=0kmTn9JJtfRrWiCfH9l0udYwnEjAaknuVTicpZOo+HjrB6fHPTdNrTXLNb6hlcAzJa yjBGUTGYKS+SlOulCaf5SYLKRxQpipQKtmM1dNd3+wBGFrJFcQ+3SxkHS7Kho4sdhmfV 0EWFmaXmTGFI77UesFnHTQXX3vq3nDMs4e7Ms/GtDDzLTl4qZ4iNFdGFFnvXXzwA3Tnp qnUUZJzibI0NahwrbtGyel7l+boFLUkyK55sZ+b1JVVUUgm0mnq6En6J18xFdbCVR7pY f+eERx7waoyVGTkwQWhkxHnl8fvDoAhRskZWOAgt8NM1PSjExoB678v1DihXQhA1e3TJ kaFg== 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=dTyN2Zcbhu5leBKDKX9L4Mfxdgp15trnQfrlFgVVMFQ=; fh=eTkjUs/l3a9lPpUjmicKO4brnHa0D6Qg87n5LIjfzgo=; b=UDySx1n5sgXNAt51Nsbg+NSlRKjMHEEGZ7+4QvWEV57vv4Rd7IwCic3L2Ep2uiv/BQ Tm5bFx77LMI1bN5Fc3i/xFnmQ6NOKMMQSm0gdrjI1/T5np2xU4uaqhLpfRTZpvJSafqw UZibKT6Q6VlMZWRdngwl2mCqOk4TGmcJSeG7DdwuqheJIm0IUxdgFcETQmG9TfncK7A0 4bApX9YyvOEt3gaszgl2cPpD9MEsEUsQfD2UC7X4tJz2lkV9u51I27FjbWmlMHk0vMGP ncZf+r9KFsiu4JYa2KX1DxnxRJ/6L35vujLOZkcqWw1W3Y0nie/ta09zkeFJB+jH3VGo Bahw==; 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-162585-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162585-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id j16-20020a170903029000b001e4154e8a81si20011757plr.526.2024.04.29.09.03.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 09:03:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162585-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; 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-162585-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162585-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A0D8FB2092F for ; Mon, 29 Apr 2024 15:29:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 661D3128376; Mon, 29 Apr 2024 15:25:54 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7BF9082883; Mon, 29 Apr 2024 15:25:52 +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=1714404353; cv=none; b=db171k1UweKr/NaAmDc75foirjG7JaU4Pdvmbf1fyDa/wdQ+7P0BUI2691hAQisPwmPBUyvJFbgHruUuZ9u3ya6oqaccbWW3Qox1VtGCqSzcni2EsUMLqPbuoOxnv0ReDJ9F1NRFJLfzUiL0Xph4BG4O8QEwtOLXXZXZNo6KLno= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714404353; c=relaxed/simple; bh=sUWl+2SuNWPIAipog5j74l/S4ZA72wYtPl7HrncvgoQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uioIkEizJnyxhyQIVkkPfrU+6S2In8ZbROtEgCBiYkq3WeUto8UuNn0tluP6K9P1T5jj2Psw9JWf3bnHqbdXaBzbu9yT1vCuVZI3ueH/zmba6BULxhjMyqBByXjCbQ+b/WdEIiGtDxi4DwYjzfRYGpkj9YHURvHBVlOBvJ+5IWM= 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 7F2E22F4; Mon, 29 Apr 2024 08:26:18 -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 B42FB3F793; Mon, 29 Apr 2024 08:25:48 -0700 (PDT) From: James Clark To: linux-perf-users@vger.kernel.org, gankulkarni@os.amperecomputing.com, scclevenger@os.amperecomputing.com, coresight@lists.linaro.org, suzuki.poulose@arm.com, mike.leach@linaro.org 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 , Leo Yan , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH 16/17] coresight: Re-emit trace IDs when the sink changes in per-thread mode Date: Mon, 29 Apr 2024 16:22:02 +0100 Message-Id: <20240429152207.479221-18-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240429152207.479221-1-james.clark@arm.com> References: <20240429152207.479221-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 f07173aa4d66..08f3958f9367 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_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