Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp317959lqh; Mon, 6 May 2024 23:00:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXfIKzt0a73DrgfbNuvbWiflaZosJda9XZGLiTXJMKuso87DxJltGMYuOa/yVZmu8sVchmJJVgv6OdX+cSbqVIa7VKHkKLat5o6B7ftuQ== X-Google-Smtp-Source: AGHT+IGRqBlHtPy7oMiPT37s/vEfKJ7WJaEwBRAtdbjaeZQcKvBEn9srQ/aGOcZ+0RNmLUbIpvqm X-Received: by 2002:a05:620a:1aa2:b0:78f:a08:64fc with SMTP id bl34-20020a05620a1aa200b0078f0a0864fcmr13983511qkb.30.1715061625397; Mon, 06 May 2024 23:00:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715061625; cv=pass; d=google.com; s=arc-20160816; b=zxmB0YLcqjV//A1UQPpiJ/lF1oD4OBCLFeFX+sXIIAGjqhvvxWBi7dqFOcIgINFaBx lJgKW2gUiki2LEE/9djsABjW364jS7MEt1mZ88s/JomeTtGqPl48q7Zdujih9DS10Q9x CUrARmAyxJJn71/hB2umwp/7tRc44obIZUaGqDxlKbyc2DnD8Jl4FjH0bwnpROjDeFhY XyqH8UFHWKFrkWS5IH2k46yo/3UNk9KbwpUJ+DOtlLtBxj0afSnZT4fbKkeNmh+n/O/j IA/lU9cl9C9Ck6bowo7SW4fjSPf29dOsctg8wYcoqwdw3pOEeL4V/4WNh7QcFmFGBzJL BlVA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=R7aX3OeYdl+RuCcSi20lqTo5NILFLtIFu9FCLUsrrXc=; fh=VZwZbsQXtmVFpxvC7gcuhPF/zVY5sB/CE4c7obzPUYw=; b=qC4WEpiRU2llv1x9vQ5fZSEUnV6VU6xQwrjD2JPVeX7m8j8eKus8/YW852SLE1DHM6 VfhqjHQUKAa7xHlf65FZkW4LvMJXILZx9dEC6cRioQlGdi9EktBfI1xqYiTPdG2vgT0p ZIkaodhk8+jnXusP3CqBi9VRadQjSJdSgpnOcPsLDVNM03xVsGufhoXc6nSs7BSVScxN Z1o093DgD48jI8APRQMe9p4IgW546HY2pwRyxFWX0oQNUl0tXO0PR6dWVA+K4mONjSll bCduGl5nUqqOEMtDxELu4C17H66UdWysas4cbHAzo+9yoRKCJHsu8d7SCAsY4la3bTHv i+qQ==; 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-170717-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170717-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v19-20020a05620a0a9300b0079292cca481si4899770qkg.88.2024.05.06.23.00.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 23:00:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170717-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-170717-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170717-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 079A01C21292 for ; Tue, 7 May 2024 06:00:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 149116E613; Tue, 7 May 2024 06:00:19 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8EBB96E602; Tue, 7 May 2024 06:00:15 +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=1715061618; cv=none; b=EMZyk8NuksMG7LO30xEzT7NlxNAf1uKvXrMs86e0rdD8IDAi/6S9/rKLhufeTyCby72ik/RPsaejEYQHoXGc7nfhuIw1Mc805UAwLJjcFw9hL0eraJEwJN2kHwEDCz8hhj6SEp8EVUhr/XX4aJDiYscT1KedqGoQ/i2+gWght9c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715061618; c=relaxed/simple; bh=NoTu1cDaz5Vv906K626wxEwxNJv9Jn5/aGcFrxBl8Pg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=K4VIg3oZ5jsPsGSXlCLMi+LubN7fGQvdnv7sj1gHG4y0dG5xRdxSxGbuqXFLAox3izPy7E/ZEvkL4huxLP5DtLg8qJVPSXxmxyvvTqQ9vaQJrVOr4OW17TcDuk9ewndLZ+Ymq0n9xpYAEVGZ3Z1rkSJBfZh4AAQLAQQ43BSzDNI= 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 DE3661042; Mon, 6 May 2024 23:00:40 -0700 (PDT) Received: from [10.163.37.41] (unknown [10.163.37.41]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 860323F587; Mon, 6 May 2024 23:00:06 -0700 (PDT) Message-ID: <0875aac2-61cb-484a-bd7e-043c208f53c1@arm.com> Date: Tue, 7 May 2024 11:30:07 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 11/17] coresight: Expose map argument in trace ID API Content-Language: en-US To: James Clark , 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: 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 References: <20240429152207.479221-1-james.clark@arm.com> <20240429152207.479221-12-james.clark@arm.com> From: Anshuman Khandual In-Reply-To: <20240429152207.479221-12-james.clark@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 4/29/24 20:51, James Clark wrote: > The trace ID API is currently hard coded to always use the global map. > The functions that take the map as an argument aren't currently public. > Make them public so that Perf mode can pass in its own maps. At the > moment all usages are still hard coded to use the global map, but now > on the caller side. > > System ID functions are unchanged because they will always use the > default map. > > Signed-off-by: James Clark Reviewed-by: Anshuman Khandual > --- > .../hwtracing/coresight/coresight-etm-perf.c | 5 +++-- > .../coresight/coresight-etm3x-core.c | 5 +++-- > .../coresight/coresight-etm4x-core.c | 5 +++-- > .../hwtracing/coresight/coresight-trace-id.c | 22 +++++++------------ > .../hwtracing/coresight/coresight-trace-id.h | 9 +++++--- > 5 files changed, 23 insertions(+), 23 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c > index c0c60e6a1703..4afb9d29f355 100644 > --- a/drivers/hwtracing/coresight/coresight-etm-perf.c > +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c > @@ -232,7 +232,7 @@ 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); > + coresight_trace_id_put_cpu_id(cpu, coresight_trace_id_map_default()); > } > > /* mark perf event as done for trace id allocator */ > @@ -401,7 +401,8 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, > } > > /* ensure we can allocate a trace ID for this CPU */ > - trace_id = coresight_trace_id_get_cpu_id(cpu); > + trace_id = coresight_trace_id_get_cpu_id(cpu, > + coresight_trace_id_map_default()); > if (!IS_VALID_CS_TRACE_ID(trace_id)) { > cpumask_clear_cpu(cpu, mask); > coresight_release_path(path); > diff --git a/drivers/hwtracing/coresight/coresight-etm3x-core.c b/drivers/hwtracing/coresight/coresight-etm3x-core.c > index 9d5c1391ffb1..4149e7675ceb 100644 > --- a/drivers/hwtracing/coresight/coresight-etm3x-core.c > +++ b/drivers/hwtracing/coresight/coresight-etm3x-core.c > @@ -465,7 +465,8 @@ int etm_read_alloc_trace_id(struct etm_drvdata *drvdata) > * > * trace id function has its own lock > */ > - trace_id = coresight_trace_id_get_cpu_id(drvdata->cpu); > + trace_id = coresight_trace_id_get_cpu_id(drvdata->cpu, > + coresight_trace_id_map_default()); > if (IS_VALID_CS_TRACE_ID(trace_id)) > drvdata->traceid = (u8)trace_id; > else > @@ -477,7 +478,7 @@ int etm_read_alloc_trace_id(struct etm_drvdata *drvdata) > > void etm_release_trace_id(struct etm_drvdata *drvdata) > { > - coresight_trace_id_put_cpu_id(drvdata->cpu); > + coresight_trace_id_put_cpu_id(drvdata->cpu, coresight_trace_id_map_default()); > } > > static int etm_enable_perf(struct coresight_device *csdev, > diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c > index a0bdfabddbc6..f32c8cd7742d 100644 > --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c > +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c > @@ -241,7 +241,8 @@ int etm4_read_alloc_trace_id(struct etmv4_drvdata *drvdata) > * or return the one currently allocated. > * The trace id function has its own lock > */ > - trace_id = coresight_trace_id_get_cpu_id(drvdata->cpu); > + trace_id = coresight_trace_id_get_cpu_id(drvdata->cpu, > + coresight_trace_id_map_default()); > if (IS_VALID_CS_TRACE_ID(trace_id)) > drvdata->trcid = (u8)trace_id; > else > @@ -253,7 +254,7 @@ int etm4_read_alloc_trace_id(struct etmv4_drvdata *drvdata) > > void etm4_release_trace_id(struct etmv4_drvdata *drvdata) > { > - coresight_trace_id_put_cpu_id(drvdata->cpu); > + coresight_trace_id_put_cpu_id(drvdata->cpu, coresight_trace_id_map_default()); > } > > struct etm4_enable_arg { > diff --git a/drivers/hwtracing/coresight/coresight-trace-id.c b/drivers/hwtracing/coresight/coresight-trace-id.c > index 19005b5b4dc4..45ddd50d09a6 100644 > --- a/drivers/hwtracing/coresight/coresight-trace-id.c > +++ b/drivers/hwtracing/coresight/coresight-trace-id.c > @@ -12,7 +12,7 @@ > > #include "coresight-trace-id.h" > > -/* Default trace ID map. Used on systems that don't require per sink mappings */ > +/* Default trace ID map. Used in sysfs mode and for system sources */ > static struct coresight_trace_id_map id_map_default; > > /* maintain a record of the mapping of IDs and pending releases per cpu */ > @@ -152,7 +152,7 @@ static void coresight_trace_id_release_all_pending(void) > DUMP_ID_MAP(id_map); > } > > -static int coresight_trace_id_map_get_cpu_id(int cpu, struct coresight_trace_id_map *id_map) > +int coresight_trace_id_get_cpu_id(int cpu, struct coresight_trace_id_map *id_map) > { > unsigned long flags; > int id; > @@ -195,8 +195,9 @@ static int coresight_trace_id_map_get_cpu_id(int cpu, struct coresight_trace_id_ > DUMP_ID_MAP(id_map); > return id; > } > +EXPORT_SYMBOL_GPL(coresight_trace_id_get_cpu_id); > > -static void coresight_trace_id_map_put_cpu_id(int cpu, struct coresight_trace_id_map *id_map) > +void coresight_trace_id_put_cpu_id(int cpu, struct coresight_trace_id_map *id_map) > { > unsigned long flags; > int id; > @@ -222,6 +223,7 @@ static void coresight_trace_id_map_put_cpu_id(int cpu, struct coresight_trace_id > DUMP_ID_CPU(cpu, id); > DUMP_ID_MAP(id_map); > } > +EXPORT_SYMBOL_GPL(coresight_trace_id_put_cpu_id); > > static int coresight_trace_id_map_get_system_id(struct coresight_trace_id_map *id_map) > { > @@ -250,19 +252,11 @@ static void coresight_trace_id_map_put_system_id(struct coresight_trace_id_map * > DUMP_ID_MAP(id_map); > } > > -/* API functions */ > - > -int coresight_trace_id_get_cpu_id(int cpu) > -{ > - return coresight_trace_id_map_get_cpu_id(cpu, &id_map_default); > -} > -EXPORT_SYMBOL_GPL(coresight_trace_id_get_cpu_id); > - > -void coresight_trace_id_put_cpu_id(int cpu) > +struct coresight_trace_id_map *coresight_trace_id_map_default(void) > { > - coresight_trace_id_map_put_cpu_id(cpu, &id_map_default); > + return &id_map_default; > } > -EXPORT_SYMBOL_GPL(coresight_trace_id_put_cpu_id); > +EXPORT_SYMBOL_GPL(coresight_trace_id_map_default); > > int coresight_trace_id_read_cpu_id(int cpu) > { > diff --git a/drivers/hwtracing/coresight/coresight-trace-id.h b/drivers/hwtracing/coresight/coresight-trace-id.h > index 49438a96fcc6..54b9d8ed903b 100644 > --- a/drivers/hwtracing/coresight/coresight-trace-id.h > +++ b/drivers/hwtracing/coresight/coresight-trace-id.h > @@ -42,7 +42,10 @@ > #define IS_VALID_CS_TRACE_ID(id) \ > ((id > CORESIGHT_TRACE_ID_RES_0) && (id < CORESIGHT_TRACE_ID_RES_TOP)) > > -/* Allocate and release IDs for a single default trace ID map */ > +/** > + * Get the global map that's used by sysfs > + */ > +struct coresight_trace_id_map *coresight_trace_id_map_default(void); > > /** > * Read and optionally allocate a CoreSight trace ID and associate with a CPU. > @@ -57,7 +60,7 @@ > * > * return: CoreSight trace ID or -EINVAL if allocation impossible. > */ > -int coresight_trace_id_get_cpu_id(int cpu); > +int coresight_trace_id_get_cpu_id(int cpu, struct coresight_trace_id_map *id_map); > > /** > * Release an allocated trace ID associated with the CPU. > @@ -70,7 +73,7 @@ int coresight_trace_id_get_cpu_id(int cpu); > * > * @cpu: The CPU index to release the associated trace ID. > */ > -void coresight_trace_id_put_cpu_id(int cpu); > +void coresight_trace_id_put_cpu_id(int cpu, struct coresight_trace_id_map *id_map); > > /** > * Read the current allocated CoreSight Trace ID value for the CPU.