From: Leo Yan <leo.yan@arm.com>
To: Yeoreum Yun <yeoreum.yun@arm.com>
Cc: suzuki.poulose@arm.com, mike.leach@linaro.org,
james.clark@linaro.org, alexander.shishkin@linux.intel.com,
coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 2/3] coresight: holding cscfg_csdev_lock while removing cscfg from csdev
Date: Wed, 14 May 2025 10:15:09 +0100 [thread overview]
Message-ID: <20250514091509.GD26114@e132581.arm.com> (raw)
In-Reply-To: <20250513170622.3071637-3-yeoreum.yun@arm.com>
On Tue, May 13, 2025 at 06:06:21PM +0100, Yeoreum Yun wrote:
> There'll be possible race scenario for coresight config:
>
> CPU0 CPU1
> (perf enable) load module
> cscfg_load_config_sets()
> activate config. // sysfs
> (sys_active_cnt == 1)
> ...
> cscfg_csdev_enable_active_config()
> lock(csdev->cscfg_csdev_lock)
> deactivate config // sysfs
> (sys_activec_cnt == 0)
> cscfg_unload_config_sets()
> <iterating config_csdev_list> cscfg_remove_owned_csdev_configs()
> // here load config activate by CPU1
> unlock(csdev->cscfg_csdev_lock)
>
> iterating config_csdev_list could be raced with config_csdev_list's
> entry delete.
>
> To resolve this race , hold csdev->cscfg_csdev_lock() while
> cscfg_remove_owned_csdev_configs()
>
> Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
> Fixes: 02bd588e12df ("coresight: configuration: Update API to permit dynamic load/unload")
> ---
> drivers/hwtracing/coresight/coresight-syscfg.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/hwtracing/coresight/coresight-syscfg.c b/drivers/hwtracing/coresight/coresight-syscfg.c
> index a70c1454b410..5d194b9269f5 100644
> --- a/drivers/hwtracing/coresight/coresight-syscfg.c
> +++ b/drivers/hwtracing/coresight/coresight-syscfg.c
> @@ -391,14 +391,17 @@ static void cscfg_owner_put(struct cscfg_load_owner_info *owner_info)
> static void cscfg_remove_owned_csdev_configs(struct coresight_device *csdev, void *load_owner)
> {
> struct cscfg_config_csdev *config_csdev, *tmp;
> + unsigned long flags;
>
> if (list_empty(&csdev->config_csdev_list))
> return;
>
> + raw_spin_lock_irqsave(&csdev->cscfg_csdev_lock, flags);
Could we use the format:
guard(raw_spinlock_irqsave)(&csdev->cscfg_csdev_lock);
Sorry I did not mention this in the earlier review. Otherwise:
Reviewed-by: Leo Yan <leo.yan@arm.com>
> list_for_each_entry_safe(config_csdev, tmp, &csdev->config_csdev_list, node) {
> if (config_csdev->config_desc->load_owner == load_owner)
> list_del(&config_csdev->node);
> }
> + raw_spin_unlock_irqrestore(&csdev->cscfg_csdev_lock, flags);
> }
>
> static void cscfg_remove_owned_csdev_features(struct coresight_device *csdev, void *load_owner)
> --
> LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}
>
next prev parent reply other threads:[~2025-05-14 9:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-13 17:06 [PATCH v5] coresight: prevent deactivate active config while enabling the config Yeoreum Yun
2025-05-13 17:06 ` [PATCH v5 1/3] coresight/etm4: fix missing disable active config Yeoreum Yun
2025-05-13 17:06 ` [PATCH v5 2/3] coresight: holding cscfg_csdev_lock while removing cscfg from csdev Yeoreum Yun
2025-05-13 17:06 ` [PATCH v5 3/3] coresight: prevent deactivate active config while enabling the config Yeoreum Yun
2025-05-14 9:30 ` Leo Yan
2025-05-14 9:39 ` Leo Yan
2025-05-14 11:14 ` Yeoreum Yun
2025-05-14 11:04 ` Yeoreum Yun
2025-05-14 12:47 ` Leo Yan
2025-05-14 9:15 ` Leo Yan [this message]
2025-05-14 11:13 ` [PATCH v5 2/3] coresight: holding cscfg_csdev_lock while removing cscfg from csdev Yeoreum Yun
2025-05-14 9:05 ` [PATCH v5 1/3] coresight/etm4: fix missing disable active config Leo Yan
2025-05-14 11:16 ` Yeoreum Yun
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=20250514091509.GD26114@e132581.arm.com \
--to=leo.yan@arm.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=coresight@lists.linaro.org \
--cc=james.clark@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.leach@linaro.org \
--cc=suzuki.poulose@arm.com \
--cc=yeoreum.yun@arm.com \
/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