Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp148873lqb; Tue, 4 Jun 2024 07:36:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU+Ayp29GPeTaMdp18js79ZKuxbfjdCJeipjkxQ9LRilEdAHMFN0dB5Muimy4qr57Sb7yGj8vwH9uXujav64kzxBHyAKNZB0Kd2pzRjbg== X-Google-Smtp-Source: AGHT+IG6KnbRbzuz03QNGF1R8fsHbtPWiNVdP/1Q9hLK4eLxaacf6TE8dDc6jqAkvBCDxpiu1aJx X-Received: by 2002:a05:6358:4320:b0:19c:50d0:b909 with SMTP id e5c5f4694b2df-19c50d0c18emr132291055d.8.1717511760431; Tue, 04 Jun 2024 07:36:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717511760; cv=pass; d=google.com; s=arc-20160816; b=lrzbmO5aHvrD/dVxZA+oJdcLWjWf9++GBkh0H5wfiKkNohL5GR2QBce5OU5n7sDFaY nw+uafI43PJJI+z7fWhX56p4uMqxfHUikKorJHYKavFp7KMFUlCXmUlDybtc+J5AD4bp mVikKop9yXgPihk+yA9iii4lI0yn+oRbLffiz4PJnzP4lDNbU5Jg7pKC9M2ABPf+TNby BJIG3AksbsMzKivHoYHN1Kzm0/qOvlX8GylSOPmWGUL5eVYhIz1s8eOyLWRWH+tzP72p H0DeoagsHeHd/YXpyj3hTQVFaUkUtqN0X1auUP4/1DSqZgHLdoZ6OVr6SjQZCV4Csqki bU+w== 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=eQRUGQEXgPAyNQxJCgnhX7u3U7u5yt4Zz12ZFBhMAw8=; fh=PS2xZ37x6i1et2MxEVJy4TSpqrJZGNwd6DyYCR5/2fw=; b=0bMKUtUrrMkk//6x7Q4lg4Ea/kLuRY5E8kCQfZxlxGzJLPaZxcGaqTRZp0IMyVLfck EX+P36xJtX3jWPXHcEE4pSHvztbNZ0Pqu3SN4CEBbP7DdfJtQaZd1y4RLdqypCbf9xgS MDjuRUdPcsy5yuEuaRXFt+cSWDyHliUXEKEbG0eE4JCz0Yj35Mergf4K/9ks4VfEeB08 JBgkVduv95fOQ0sUmVfXfjW9+MStOk48D423NxV90uRQByddRKPi9oKjj3ty8G6f7idR Uu1fbU2RgTO5jQOyjjrXo1dfcqBLcWDIkKSlIEoHQeaHiRfZYmDfGE1CD/1PRp9Ok28q 2KhQ==; 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-200834-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200834-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c35b40bd99si8344760a12.511.2024.06.04.07.36.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 07:36:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200834-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-200834-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200834-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 67DE32862AB for ; Tue, 4 Jun 2024 14:35:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B29E01448CD; Tue, 4 Jun 2024 14:32:55 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D22FF144306; Tue, 4 Jun 2024 14:32:53 +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=1717511575; cv=none; b=R6+PbbtGvrT4iQRTGHK0cVj3TSvcxb31xtf8K5AFI8skMoL0wkEbBZuSDesc0S09lyRTLY3jMHAwEuRU1mvnczB8vNjLqGlgdCZkhnDRx85nOSSz0I1DxWqg+hkxzb5CI/YsTyLByspnM/5iNmPdfyxmDAKST2KjebyaMiRtmHk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717511575; c=relaxed/simple; bh=h3XxyN6IXydL8e0zIIIS9V4ZStSl00kff0Mk919Sp94=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GzvjMCi6sKCgIMKGAVITlsZO1541MtiefCT2pSr8oQUn8x69Va5t6F1HQnXkv6f0GrcBDnvdRfqfqSO0N7FBWk3zi0+TpniFmjTvEwtwvHpNhsRLo36weHjbP/bsGhtpDOgpllo3I6gRGuf/YEUFNi+0xgTXOv28xw5xe2XQxUk= 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 BCD511042; Tue, 4 Jun 2024 07:33:17 -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 525523F64C; Tue, 4 Jun 2024 07:32:50 -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 12/16] coresight: Make CPU id map a property of a trace ID map Date: Tue, 4 Jun 2024 15:30:21 +0100 Message-Id: <20240604143030.519906-13-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 The global CPU ID mappings won't work for per-sink ID maps so move it to the ID map struct. coresight_trace_id_release_all_pending() is hard coded to operate on the default map, but once Perf sessions use their own maps the pending release mechanism will be deleted. So it doesn't need to be extended to accept a trace ID map argument at this point. Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-trace-id.c | 16 +++++++++------- include/linux/coresight.h | 1 + 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-trace-id.c b/drivers/hwtracing/coresight/coresight-trace-id.c index 5561989a03fa..8a777c0af6ea 100644 --- a/drivers/hwtracing/coresight/coresight-trace-id.c +++ b/drivers/hwtracing/coresight/coresight-trace-id.c @@ -13,10 +13,12 @@ #include "coresight-trace-id.h" /* Default trace ID map. Used in sysfs mode and for system sources */ -static struct coresight_trace_id_map id_map_default; +static DEFINE_PER_CPU(atomic_t, id_map_default_cpu_ids) = ATOMIC_INIT(0); +static struct coresight_trace_id_map id_map_default = { + .cpu_map = &id_map_default_cpu_ids +}; -/* maintain a record of the mapping of IDs and pending releases per cpu */ -static DEFINE_PER_CPU(atomic_t, cpu_id) = ATOMIC_INIT(0); +/* maintain a record of the pending releases per cpu */ static cpumask_t cpu_id_release_pending; /* perf session active counter */ @@ -49,7 +51,7 @@ static void coresight_trace_id_dump_table(struct coresight_trace_id_map *id_map, /* unlocked read of current trace ID value for given CPU */ static int _coresight_trace_id_read_cpu_id(int cpu, struct coresight_trace_id_map *id_map) { - return atomic_read(&per_cpu(cpu_id, cpu)); + return atomic_read(per_cpu_ptr(id_map->cpu_map, cpu)); } /* look for next available odd ID, return 0 if none found */ @@ -145,7 +147,7 @@ static void coresight_trace_id_release_all_pending(void) clear_bit(bit, id_map->pend_rel_ids); } for_each_cpu(cpu, &cpu_id_release_pending) { - atomic_set(&per_cpu(cpu_id, cpu), 0); + atomic_set(per_cpu_ptr(id_map_default.cpu_map, cpu), 0); cpumask_clear_cpu(cpu, &cpu_id_release_pending); } spin_unlock_irqrestore(&id_map_lock, flags); @@ -181,7 +183,7 @@ static int _coresight_trace_id_get_cpu_id(int cpu, struct coresight_trace_id_map goto get_cpu_id_out_unlock; /* allocate the new id to the cpu */ - atomic_set(&per_cpu(cpu_id, cpu), id); + atomic_set(per_cpu_ptr(id_map->cpu_map, cpu), id); get_cpu_id_clr_pend: /* we are (re)using this ID - so ensure it is not marked for release */ @@ -215,7 +217,7 @@ static void _coresight_trace_id_put_cpu_id(int cpu, struct coresight_trace_id_ma } else { /* otherwise clear id */ coresight_trace_id_free(id, id_map); - atomic_set(&per_cpu(cpu_id, cpu), 0); + atomic_set(per_cpu_ptr(id_map->cpu_map, cpu), 0); } spin_unlock_irqrestore(&id_map_lock, flags); diff --git a/include/linux/coresight.h b/include/linux/coresight.h index c16c61a8411d..7d62b88bfb5c 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -234,6 +234,7 @@ struct coresight_sysfs_link { struct coresight_trace_id_map { DECLARE_BITMAP(used_ids, CORESIGHT_TRACE_IDS_MAX); DECLARE_BITMAP(pend_rel_ids, CORESIGHT_TRACE_IDS_MAX); + atomic_t __percpu *cpu_map; }; /** -- 2.34.1