public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Leo Yan <leo.yan@linaro.org>
To: Daniel Kiss <daniel.kiss@arm.com>
Cc: mathieu.poirier@linaro.org, suzuki.poulose@arm.com,
	mike.leach@linaro.org, coresight@lists.linaro.org,
	linux-arm-kernel@lists.infradead.org, denik@google.com,
	Branislav Rankov <Branislav.Rankov@arm.com>
Subject: Re: [PATCH 2/4] coresight: tmc-etr: Track perf handler.
Date: Mon, 26 Apr 2021 08:25:51 +0800	[thread overview]
Message-ID: <20210426002551.GA176271@leoy-ThinkPad-X240s> (raw)
In-Reply-To: <20210423092038.GB377091@leoy-ThinkPad-X240s>

On Fri, Apr 23, 2021 at 05:20:38PM +0800, Leo Yan wrote:
> Hi Daniel,
> 
> On Wed, Apr 21, 2021 at 02:04:11PM +0200, Daniel Kiss wrote:
> 
> [...]
> 
> > diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c
> > index dd19d1d1c3b38..bf9f6311d8663 100644
> > --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c
> > +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c
> > @@ -1511,6 +1511,12 @@ tmc_update_etr_buffer(struct coresight_device *csdev,
> >  		goto out;
> >  	}
> >  
> > +	/* Serve only the tracer with the right handler */
> > +	if (drvdata->perf_handle != handle) {
> > +		spin_unlock_irqrestore(&drvdata->spinlock, flags);
> > +		goto out;
> > +	}
> > +
> 
> I have concern for this change, Let's use the system-wide tracing as
> an example.
> 
> If a system have 4 CPUs, for the perf with system wide tracing, the
> tool maps the AUX ring buffers for four times, but the CoreSight
> driver only allocates pages once and maps these physical pages for
> four times to user space.  Therefore, the perf tool in the userspace
> manages 4 AUX ring buffers, every AUX ring buffer is served for one
> CPU.
> 
> The confusion between the CoreSight driver (in the kernel) and the
> perf tool (in the userspace) is: there actually has only one ring
> buffer for the enabled sink (let's say ETR), but there have four ring
> buffer control structures, the control structure is
> 'perf_event_mmap_page' which is resident in the first page for perf's
> general ring buffer (please note, this ring buffer is different from
> AUX ring buffer).
> 
> IIUC, this patch only allows the first CPU which enables coresight path
> to update the AUX ring buffer.  This can break the case:
> 
>   - Step 1: perf tool opens ETM event; we can use the command:
> 
>     # perf record -o ${perfdata} -e cs_etm/@tmc_etr0/ -a
>            -- dd if=/dev/zero of=/dev/null
> 
>   - Step 2: the profiled program "dd" is firstly schedued in CPU0, so
>     its "perf_handle" will be assigned to "drvdata->perf_handle";
> 
>   - Step 3: if the program "dd" is migrated to CPU1 and it never runs
>     on CPU0 afterwards, then this patch will prevent to update the AUX
>     ring buffer, due to the "drvdata->perf_handle" cannot match with
>     CPU1's handler.

Want to clarify, this case only happens with "snapshot" mode; With
Mathieu's reminding, "snapshot" mode is quite special: it creates AUX
ring buffer per CPU, but when enable the tracing, if without
specifying the option "-a" for system wide tracing, it only enables
ETM tracer for a CPU when the profiled program is scheduled on that CPU.

To avoid over complexsity, let's give this low priority and firstly
focus on the system-wide tracing case.

Thanks,
Leo

> On the other hand, I think we should change to always stick to the
> same "perf_output_handle" for all CPUs, thus it can allow all CPUs
> to use the same structure 'perf_event_mmap_page' for AUX ring buffer
> management.

> 
> [...]
> 
> Thanks,
> Leo

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-04-26  0:28 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-21 12:04 [PATCH 0/4] coresight: Add ETR-PERF polling Daniel Kiss
2021-04-21 12:04 ` [PATCH 1/4] coresight: tmc-etr: Advance buffer pointer in sync buffer Daniel Kiss
2021-04-23  8:23   ` Leo Yan
2021-04-26 10:40   ` Suzuki K Poulose
2021-04-27  3:45     ` Leo Yan
2021-04-27 10:00       ` Suzuki K Poulose
2021-04-28  2:34         ` Leo Yan
2021-04-21 12:04 ` [PATCH 2/4] coresight: tmc-etr: Track perf handler Daniel Kiss
2021-04-23  9:20   ` Leo Yan
2021-04-26  0:25     ` Leo Yan [this message]
2021-04-21 12:04 ` [PATCH 3/4] coresight: etm-perf: Export etm_event_cpu_path Daniel Kiss
2021-04-21 12:04 ` [PATCH 4/4] coresight: Add ETR-PERF polling Daniel Kiss
2021-04-26  1:18   ` Leo Yan
2021-05-05  7:21   ` Denis Nikitin
2021-04-26 17:54 ` [PATCH 0/4] " Mathieu Poirier
2021-04-27 10:43   ` Al Grant
2021-04-27 14:41     ` Mike Leach
2021-04-27 15:47       ` Mathieu Poirier
2021-04-27 16:04         ` Leo Yan
2021-05-05  6:46           ` Denis Nikitin
2021-05-05 15:29             ` Mathieu Poirier
2021-05-14  9:02               ` Denis Nikitin
2021-05-14 16:16                 ` Mike Leach
2021-05-18 14:00                 ` Leo Yan
2021-05-18 14:14                   ` Leo Yan
2021-05-18 15:41                   ` Mathieu Poirier
2021-05-26  6:47                   ` Denis Nikitin
2021-05-23  8:45                 ` Leo Yan
2021-05-27  7:50                   ` Denis Nikitin
2021-05-27 15:07                     ` Leo Yan
2021-05-27 16:22                       ` Denis Nikitin
2021-05-28 16:37                         ` Leo Yan
2021-04-27 16:24 ` James Clark
2021-04-28 11:30   ` James Clark
2021-04-28 11:52   ` Daniel Kiss

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=20210426002551.GA176271@leoy-ThinkPad-X240s \
    --to=leo.yan@linaro.org \
    --cc=Branislav.Rankov@arm.com \
    --cc=coresight@lists.linaro.org \
    --cc=daniel.kiss@arm.com \
    --cc=denik@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=mike.leach@linaro.org \
    --cc=suzuki.poulose@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