Linux Perf Users
 help / color / mirror / Atom feed
From: Leo Yan <leo.yan@arm.com>
To: Amir Ayupov <aaupov@fb.com>
Cc: James Clark <james.clark@linaro.org>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Mike Leach <mike.leach@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jonathan Corbet <corbet@lwn.net>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Daniel Pereira <danielmaraboo@gmail.com>,
	coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
	linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 3/4] coresight: perf: Filter sources lacking the selected configuration
Date: Mon, 30 Nov 2026 17:47:28 +0000	[thread overview]
Message-ID: <20261130174728.GN861809@e132581.arm.com> (raw)
In-Reply-To: <7ba910406fc81e09d31e9c6f3909012b9b85bf22.1795196854.git.aaupov@fb.com>

On Fri, Nov 20, 2026 at 10:54:33AM -0800, Amir Ayupov wrote:

[...]

> diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
> index 09b21a711a8764..2d64c3314c0bad 100644
> --- a/drivers/hwtracing/coresight/coresight-etm-perf.c
> +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
> @@ -350,6 +350,7 @@ etm_event_build_path(struct perf_event *event, int cpu,
>  {
>  	struct coresight_path *path = NULL;
>  	struct coresight_device *source, *sink;
> +	u32 cfg_hash = ATTR_CFG_GET_FLD(&event->attr, configid);
>  	int ret;
>  
>  	source = coresight_get_percpu_source_ref(cpu);
> @@ -361,6 +362,9 @@ etm_event_build_path(struct perf_event *event, int cpu,
>  	if (!source)
>  		return NULL;
>  
> +	if (cfg_hash && !cscfg_csdev_can_activate_config(source, cfg_hash))
> +		goto out;

Can we reuse cscfg_csdev_enable_active_config() for the check?

@@ -535,7 +533,7 @@ static void cscfg_set_configs_available(struct cscfg_config_desc **config_descs)
 
        if (config_descs) {
                for (i = 0; config_descs[i]; i++)
-                       config_descs[i]->available = true;
+                       smp_store_release(&config_descs[i]->available, true);
        }
 }
 
@@ -1119,8 +1117,16 @@ int cscfg_csdev_enable_active_config(struct coresight_device *csdev,
        raw_spin_lock_irqsave(&csdev->cscfg_csdev_lock, flags);
        list_for_each_entry(config_csdev_item, &csdev->config_csdev_list, node) {
                config_desc = config_csdev_item->config_desc;
-               if (((unsigned long)config_desc->event_ea->var == cfg_hash) &&
-                               cscfg_config_desc_get(config_desc)) {
+               if ((unsigned long)config_desc->event_ea->var != cfg_hash)
+                       continue;
+
+               /* Pairs with cscfg_set_configs_available() after loading */
+               if (!smp_load_acquire(&config_desc->available)) {
+                       err = -EBUSY;
+                       break;
+               }
+
+               if (cscfg_config_desc_get(config_desc)) {
                        config_csdev_active = config_csdev_item;
                        csdev->active_cscfg_ctxt = (void *)config_csdev_active;
                        break;

Please see whole change suggest by AI: https://termbin.com/fjkw3 (it
also tries to fix a race condition).

@Mike, does this seem feasible to you? I'd prefer not to introduce new
interfaces here.

  parent reply	other threads:[~2026-11-30 17:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 18:54 [PATCH v6 0/4] coresight: Pulse an ETM external output for a PMU event Amir Ayupov
2026-11-20 18:54 ` [PATCH v6 1/4] coresight: etm4x: Fix event count decoding Amir Ayupov
2026-11-20 19:03   ` sashiko-bot
2026-11-20 18:54 ` [PATCH v6 2/4] coresight: etm4x: Skip features requiring unavailable events Amir Ayupov
2026-11-20 19:16   ` sashiko-bot
2026-11-30 15:51   ` Leo Yan
2026-11-20 18:54 ` [PATCH v6 3/4] coresight: perf: Filter sources lacking the selected configuration Amir Ayupov
2026-11-20 19:05   ` sashiko-bot
2026-11-30 17:47   ` Leo Yan [this message]
2026-11-20 18:54 ` [PATCH v6 4/4] coresight: Add pmu_pulse/extout_pulse Amir Ayupov
2026-11-20 19:02   ` sashiko-bot
2026-11-30 17:55   ` Leo Yan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130174728.GN861809@e132581.arm.com \
    --to=leo.yan@arm.com \
    --cc=aaupov@fb.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=corbet@lwn.net \
    --cc=coresight@lists.linaro.org \
    --cc=danielmaraboo@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=james.clark@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.poirier@linaro.org \
    --cc=mike.leach@arm.com \
    --cc=rdunlap@infradead.org \
    --cc=skhan@linuxfoundation.org \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox