From patchwork Wed Nov 23 19:49:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 13054307 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BBEA4C43219 for ; Wed, 23 Nov 2022 21:02:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oFxH81Jehs/FUeLU+SOqq8C0BgHD6Aj6iq6PNGL59Mo=; b=L3cYsgHhmIQ+uf j9THn9EuZ6cr6bNYcZ7iG1J/+E8lKBcd14S8uTq2fy8UAMp1+nXuFurKI26mRefiHd23sQD1K0eZC RjowMZklyS22Bok20nbQi/YZ5JRvGCQ2vY/2hjc7AoVMr5s0Qc5s6WRLBhjO8V9g7fYlcQC0K73SO I6upyBEq6haTlf6pP1j1mQHCKC3vyJHvllbYnEW31sC78sZhy5fR/FisRH7eIByMsO7rMIkXXrNI4 tLvTfuCi8fB51v06Th55CoEuy9tkmXk1WK4OQhT6AO7btK7E7mZ+EggaJQG7qoJw2+ZqN2p57Hif5 cB7l1EgE/CfsnILLbihQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxwsF-002Q3N-Fc; Wed, 23 Nov 2022 21:01:39 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxvlN-0023jG-1H for linux-arm-kernel@lists.infradead.org; Wed, 23 Nov 2022 19:50:30 +0000 Received: by mail-wr1-x42b.google.com with SMTP id n3so14458070wrp.5 for ; Wed, 23 Nov 2022 11:50:25 -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=SixwwV3AAy5lbGBsGKJ9ikQymchwRHfI5t4Re1DfkBoRpdTlEzLgRbaCYmlHWN0aS+ b9k+Y3rXgw4fYKod3k1c5dGndJ4VpIi4LL45s0QKEiVsGRBcjrHOUcwTxD5HGD2mw+rl Rzj8wZoZOedq1+djO3f3iSsAGCa7PoTWQDm5RMcP3K9j7qqxcCYypOkHAFBgWr/54hOU Rr0CajOMcxEaciN51PYCjt4+9dJ+SmNmFhxnJsIyjl0QR6cP7DAHtKvMFTJxw9ZxBYIe qV+JO7MUGsWOE9MbQjU87Zp+Yu7alzy2Lf8OPo8TAqn7kwzrRrZ4bY97NbfdMtMvyywr cOUQ== 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=P4Po4N2KenDm9f/VN4WgbYIMn2AY1fen082ef8EuEHkQPSXHbJ+laQxL+pkN5ZcIV5 +xJP4NzWgy0+xxpfXxmbh8fHIdSwYMAwg/c2ii+cNSH7qw3sEFbcyNkGsIhir8F7bsTB VZmjRDJdszP/InGKS2w/GpjLivIXoLYZ4GSwik+K7CsQrdB1nrLScQHUBWJUxlftduNF W8lz1oOjkD1EQVoj4BG/ntX8opGdc2HJ2K0WY4kNoAsoqxrqvFl8zCzXBLJR7yUP5NS9 a1Wi9zt77Rz36uDTN4ti4go8/1D7HZUNGbHMHv9GC8qxfg2Uta6aIrRIHow8T8Bg0/g4 Zx/Q== X-Gm-Message-State: ANoB5pnReZcGrCUA/ItVEDSltSV2ecAlJmQqJqBqRk7Sm1iYhuex65SZ bABTyRwrqpdSeZ+RknTX+tT74A== X-Google-Smtp-Source: AA0mqf7ZbrFI/I145ojO0uyWGnlzcDBou29muNZCalcuOvcFuQaS4NMOOkfnimSafXEy/4QTi1EBmg== X-Received: by 2002:adf:f544:0:b0:241:f85e:75c8 with SMTP id j4-20020adff544000000b00241f85e75c8mr1296002wrp.337.1669233023921; Wed, 23 Nov 2022 11:50:23 -0800 (PST) Received: from linaro.org ([2a00:23c5:6809:2201:fcbc:7b5d:8d6c:43a4]) by smtp.gmail.com with ESMTPSA id w5-20020a5d6805000000b002364c77bcacsm7267414wru.38.2022.11.23.11.50.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 11:50:23 -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 v6 03/14] coresight: perf: traceid: Add perf ID allocation and notifiers Date: Wed, 23 Nov 2022 19:49:59 +0000 Message-Id: <20221123195010.6859-4-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221123195010.6859-1-mike.leach@linaro.org> References: <20221123195010.6859-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221123_115029_128472_71206F3F X-CRM114-Status: GOOD ( 15.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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; }