Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3196211rwb; Mon, 16 Jan 2023 05:08:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXvWzZNND9JwVWAp/s4moime1oK3X1L0skKLpP1V3xfb1qbdxd5qKraBZJGDHsQ+5guFRV/7 X-Received: by 2002:a05:6402:c0b:b0:49c:fde2:a6f4 with SMTP id co11-20020a0564020c0b00b0049cfde2a6f4mr11670167edb.15.1673874496365; Mon, 16 Jan 2023 05:08:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673874496; cv=none; d=google.com; s=arc-20160816; b=1LHL3am1/UM0cBguNRswnqMVqzurIyM5RXVOpM6dTR0ekq+Yf4uUPxH6+EbhguMuwC 1f+aOCjAibmyNmEITvxwcbhNMz1YZmAijt9y3oDdsYp1AHVMfkthryiDBfUVnv3gVX3y QPUhfUYpSCq3q3QG3oYFXKb3NFtqoBlrO0416tUed6dx4sDOJTIdbsueJSZXTTHv0TtB iYsp3Zfww0iJj3T/4e4f2XuqdZtITYlHvyNW6Xze5YdqaUyMtlXVazBbvA6I19gwFXYE HqIcybnSQ9BtXqGO5eq/LaI370uZBdaQRsPAomY7pADfEIVyHOz2s8RbwIHLYkfM+cP9 Do/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=q+K11GrFOPMrxvDYNvmhX0YpDA/5RBsqSxpF+D0Uhgs=; b=dPCEAVxQRPvYU5aCsi0cQtbu5KidbbkPm2g419TyJu1gQsixX8zK4SXmcIKFSPpLcY R/nWZs5/x7z2uP+oPbuFs+7WKEkzTyJtX+3yHTT2ZaGUXYU0krFsFjUedzNQORdICs6t uxpwb7aC52vZEGqyVmD0kHE8jF+6RnLk9w/koBj+imQoaAZuaDkLbBWnPBGYvvXk+PGv DFpacTh9gogWCZjRjfgxYhBIg8ZQyhL7raCeds6RushDPrhogqSU5rOQgSYbHNXYaTtT 6ENDxzqq2Fvs+qZGRjCSIzpPnL390Hy0so1ick4gIgTR11QvrJK9VQwLgtZob/6TX+ht BJdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nF4xSw3r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y26-20020aa7ccda000000b0049b935e07e4si12111479edt.207.2023.01.16.05.08.03; Mon, 16 Jan 2023 05:08:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nF4xSw3r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230514AbjAPMuB (ORCPT + 51 others); Mon, 16 Jan 2023 07:50:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230443AbjAPMto (ORCPT ); Mon, 16 Jan 2023 07:49:44 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CF4B1E5EC for ; Mon, 16 Jan 2023 04:49:38 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id bg13-20020a05600c3c8d00b003d9712b29d2so23542990wmb.2 for ; Mon, 16 Jan 2023 04:49:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=q+K11GrFOPMrxvDYNvmhX0YpDA/5RBsqSxpF+D0Uhgs=; b=nF4xSw3rSARS2cIPc+a5XikugDM3czBaJC3hWw6A6F2JalQw5NqCuq3y8E9aui1E5U vxvz7VVZ4iBx9qfrJDGc6rv+Vg1HAFnww9Ysx40j84Mz1ounkdy6P/yWTQJs4kr29vVg 2GrVvNbOVeS+Z+89cY52B1FU+bsJcWaF5j8jPIJmHsXf9pY3t+KEP/xmRU138PtpvXZn M6PhyIPfdTcd8lvs1W2Esv4KHic/PxxUKcRH5w323wLwg7TkKo1ymZ6E27ZBPBV1VzVN 72Ev6GMLI18NmgpibFCi9MpBykskMYDV08C3RdkbnlFGRpEhHUeS7sMyOpEsK6khrjYz vPDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=q+K11GrFOPMrxvDYNvmhX0YpDA/5RBsqSxpF+D0Uhgs=; b=leTgAKJfX6UFHqM0/JJPjKhYZDHCrkkzXVUvfZ4Q+m4hk+dxRgUFEtdfcWx8k5XwTq 3b1CbyxNotSNP8NLFRuCB9tWf/pcw1ieBtaLoKPEQsl0WSuliLiBt7K5oIhCQ2NlSgEi RWi0AUVcwO9BtJ5riuWvnXaqF0q6zQkRbArW5EbXXQaXYYrohV5GyvKql1GE1N2KFPX2 EQ5GMeWrLa7AYpa6RNH78HWKic0bhheVBeq4Eqvs7B4pEGB5KrcyuF8koGsrX0kZWMxg l9ri7+O8m+crxDYvahe/kjPWGxualKpxkzjh7UNkrcafl4uifxGhG4JWPwMUz0qrMdJ5 VzwQ== X-Gm-Message-State: AFqh2kqI0e8XAZJoiZQZajref+RLyWjf+yoK56ydRosU82raniz8n9R2 pWWAs0NhDeILfGWcnPU1APqvaQ== X-Received: by 2002:a05:600c:1c21:b0:3cf:9844:7b11 with SMTP id j33-20020a05600c1c2100b003cf98447b11mr78716386wms.23.1673873377614; Mon, 16 Jan 2023 04:49:37 -0800 (PST) Received: from linaro.org ([2a00:23c5:6809:2201:6c91:710d:9433:e868]) by smtp.gmail.com with ESMTPSA id fl12-20020a05600c0b8c00b003dab40f9eafsm6896832wmb.35.2023.01.16.04.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Jan 2023 04:49:37 -0800 (PST) From: Mike Leach To: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: mathieu.poirier@linaro.org, suzuki.poulose@arm.com, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, linux-perf-users@vger.kernel.org, leo.yan@linaro.org, quic_jinlmao@quicinc.com, Mike Leach Subject: [PATCH v7 03/15] coresight: perf: traceid: Add perf ID allocation and notifiers Date: Mon, 16 Jan 2023 12:49:16 +0000 Message-Id: <20230116124928.5440-4-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230116124928.5440-1-mike.leach@linaro.org> References: <20230116124928.5440-1-mike.leach@linaro.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adds in calls to allocate and release Trace ID for the CPUs in use by the perf session. Adds in notifier calls to the trace ID allocator that perf events are starting and stopping. This ensures that Trace IDs associated with CPUs remain the same throughout the perf session, and are only released when all perf sessions are complete. Signed-off-by: Mike Leach Reviewed-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-etm-perf.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index 43bbd5dc3d3b..bdb9ab86173a 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -22,6 +22,7 @@ #include "coresight-etm-perf.h" #include "coresight-priv.h" #include "coresight-syscfg.h" +#include "coresight-trace-id.h" static struct pmu etm_pmu; static bool etm_perf_up; @@ -228,8 +229,12 @@ static void free_event_data(struct work_struct *work) if (!(IS_ERR_OR_NULL(*ppath))) coresight_release_path(*ppath); *ppath = NULL; + coresight_trace_id_put_cpu_id(cpu); } + /* mark perf event as done for trace id allocator */ + coresight_trace_id_perf_stop(); + free_percpu(event_data->path); kfree(event_data); } @@ -300,6 +305,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, { u32 id, cfg_hash; int cpu = event->cpu; + int trace_id; cpumask_t *mask; struct coresight_device *sink = NULL; struct coresight_device *user_sink = NULL, *last_sink = NULL; @@ -316,6 +322,9 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, sink = user_sink = coresight_get_sink_by_id(id); } + /* tell the trace ID allocator that a perf event is starting up */ + coresight_trace_id_perf_start(); + /* check if user wants a coresight configuration selected */ cfg_hash = (u32)((event->attr.config2 & GENMASK_ULL(63, 32)) >> 32); if (cfg_hash) { @@ -388,6 +397,13 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, continue; } + /* ensure we can allocate a trace ID for this CPU */ + trace_id = coresight_trace_id_get_cpu_id(cpu); + if (!IS_VALID_CS_TRACE_ID(trace_id)) { + cpumask_clear_cpu(cpu, mask); + continue; + } + *etm_event_cpu_path_ptr(event_data, cpu) = path; } -- 2.17.1