All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leo Yan <leo.yan@arm.com>
To: Yeoreum Yun <yeoreum.yun@arm.com>
Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, suzuki.poulose@arm.com,
	mike.leach@arm.com, james.clark@linaro.org,
	alexander.shishkin@linux.intel.com, jie.gan@oss.qualcomm.com
Subject: Re: [PATCH v5 07/12] coresight: etm4x: fix inconsistencies with sysfs configuration
Date: Tue, 21 Apr 2026 14:28:42 +0100	[thread overview]
Message-ID: <20260421132842.GC929984@e132581.arm.com> (raw)
In-Reply-To: <aedcDEpBAnAieSRX@e129823.arm.com>

On Tue, Apr 21, 2026 at 12:14:20PM +0100, Yeoreum Yun wrote:

[...]

> > >   - There is a risk of corrupting drvdata->config if a perf session enables
> > >     tracing while cscfg_csdev_disable_active_config() is being handled in
> > >     etm4_disable_sysfs().
> >
> > Similiar to above, cscfg_csdev_disable_active_config() is not
> > protected in etm4_disable_sysfs().
> 
> This is not true.
> at the time of etm4_disable_sysfs() "mode" is already taken
> (whether sysfs or perf). In this situation, it's enough to
> call cscfg_csdev_disable_active_config() before chaning
> mode to DISABLED.

To be clear, I am trying to understand issue _before_ your patch.
Without this patch, cscfg_csdev_disable_active_config() is not
protected by the mode.

> > >  struct etm4_enable_arg {
> > >  	struct etmv4_drvdata *drvdata;
> > > +	struct etmv4_config config;
> >
> > We don't need this. We can defer to get drvdata->config in SMP call.
> 
> This is not true ane make a situation more complex.
> If we get config in SMP call, that would be a problem when some user is
> trying to modify config.
> 
> IOW, while user modifying config via sysfs, and SMP call happens,
> it makes a dead lock. so for this if we try to grab the lock in SMP call,
> we should change every sysfs raw_spin_lock() into raw_spin_lock_irqsave().
> 
> Instead of this it would be much clear and simpler to get config in here
> rather than to add some latencies via sysfs.

Thanks for info. If so, it is fine for me to add "config".

> > > @@ -1386,6 +1401,7 @@ static void etm4_init_arch_data(void *info)
> > >  	drvdata = dev_get_drvdata(init_arg->dev);
> > >  	caps = &drvdata->caps;
> > >  	csa = init_arg->csa;
> > > +	config = &drvdata->active_config;
> >
> > Should we init drvdata->config instead so make it has sane values ?
> >
> > In other words, drvdata->active_config are always set at the runtime,
> > so don't need to init it at all, right?
> 
> No. at least when the initialise, I think we should fill the its
> contesnt with the "etm4_set_default()".
> 
> That's why the consequence call etm4_set_default() called with
> active_config and config is coped with the default configutation.

I'm concerned that some config fields may be reused across sessions.
For example, a sysfs session copies drvdata->config into
drvdata->active_config, and later a perf session may reuse stale
values. The same issue can happen in the reverse direction.

A clean approach would be to treat drvdata->active_config as
per-session state:

  1) clear drvdata->active_config at session start
  2) apply the session-specific config
     2.1) sysfs: use drvdata->config
     2.2) perf: use event config
  3) then apply configfs configuration

So we should clear drvdata->active_config at the start of each session
and rebuild it with the correct configuration.

Thanks,
Leo


  reply	other threads:[~2026-04-21 13:28 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-15 16:55 [PATCH v5 00/12] fix several inconsistencies with sysfs configuration in etmX Yeoreum Yun
2026-04-15 16:55 ` [PATCH v5 01/12] coresight: etm4x: fix wrong check of etm4x_sspcicrn_present() Yeoreum Yun
2026-04-16 15:02   ` Leo Yan
2026-04-21  8:47   ` Suzuki K Poulose
2026-04-21  9:48     ` Yeoreum Yun
2026-04-15 16:55 ` [PATCH v5 02/12] coresight: etm4x: fix underflow for nrseqstate Yeoreum Yun
2026-04-16 15:11   ` Leo Yan
2026-04-16 17:07     ` Yeoreum Yun
2026-04-21  8:50     ` Suzuki K Poulose
2026-04-21  8:50       ` Suzuki K Poulose
2026-04-21  9:56         ` Yeoreum Yun
2026-04-21  9:37       ` Yeoreum Yun
2026-04-15 16:55 ` [PATCH v5 03/12] coresight: etm4x: introduce struct etm4_caps Yeoreum Yun
2026-04-15 16:55 ` [PATCH v5 04/12] coresight: etm4x: exclude ss_status from drvdata->config Yeoreum Yun
2026-04-16  5:42   ` Jie Gan
2026-04-16  6:54     ` Yeoreum Yun
2026-04-16  7:20       ` Jie Gan
2026-04-16 15:51   ` Leo Yan
2026-04-21  8:57     ` Suzuki K Poulose
2026-04-21  9:06       ` Yeoreum Yun
2026-04-21  9:58       ` Mike Leach
2026-04-21 10:03         ` Yeoreum Yun
2026-04-21 10:30           ` Yeoreum Yun
2026-04-21 14:16             ` Mike Leach
2026-04-21 14:23               ` Yeoreum Yun
2026-04-15 16:55 ` [PATCH v5 05/12] coresight: etm4x: remove redundant fields in etmv4_save_state Yeoreum Yun
2026-04-21  6:41   ` Leo Yan
2026-04-15 16:55 ` [PATCH v5 06/12] coresight: etm4x: fix leaked trace id Yeoreum Yun
2026-04-16 16:55   ` Leo Yan
2026-04-16 17:06     ` Yeoreum Yun
2026-04-17  7:52       ` Leo Yan
2026-04-17  1:01     ` Jie Gan
2026-04-17  8:41       ` Leo Yan
2026-04-17  8:51         ` Jie Gan
2026-04-17  8:58           ` Jie Gan
2026-04-15 16:55 ` [PATCH v5 07/12] coresight: etm4x: fix inconsistencies with sysfs configuration Yeoreum Yun
2026-04-16  4:35   ` Jie Gan
2026-04-16  6:49     ` Yeoreum Yun
2026-04-21 10:46   ` Leo Yan
2026-04-21 11:14     ` Yeoreum Yun
2026-04-21 13:28       ` Leo Yan [this message]
2026-04-21 14:02         ` Yeoreum Yun
2026-04-15 16:55 ` [PATCH v5 08/12] coresight: etm4x: remove redundant call etm4_enable_hw() with hotplug Yeoreum Yun
2026-04-15 16:55 ` [PATCH v5 09/12] coresight: etm3x: change drvdata->spinlock type to raw_spin_lock_t Yeoreum Yun
2026-04-15 16:55 ` [PATCH v5 10/12] coresight: etm3x: introduce struct etm_caps Yeoreum Yun
2026-04-15 16:55 ` [PATCH v5 11/12] coresight: etm3x: fix inconsistencies with sysfs configuration Yeoreum Yun
2026-04-15 16:55 ` [PATCH v5 12/12] coresight: etm3x: remove redundant call etm_enable_hw() with hotplug 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=20260421132842.GC929984@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=jie.gan@oss.qualcomm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mike.leach@arm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.