From: "stephane eranian" <eranian@googlemail.com>
To: "Markus Metzger" <markus.t.metzger@googlemail.com>
Cc: "Metzger, Markus T" <markus.t.metzger@intel.com>,
"Ingo Molnar" <mingo@elte.hu>, "Andi Kleen" <andi@firstfloor.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org
Subject: Re: debugctl msr
Date: Wed, 12 Nov 2008 11:10:22 +0100 [thread overview]
Message-ID: <7c86c4470811120210j2ea5ccdcv59a654aadc32ebd2@mail.gmail.com> (raw)
In-Reply-To: <491A812D.9010208@gmail.com>
Markus,
On Wed, Nov 12, 2008 at 8:09 AM, Markus Metzger
<markus.t.metzger@googlemail.com> wrote:
> stephane eranian wrote:
>
>> For perfmon, PEBS can be used for both per-thread and per-cpu. With
>> perfmon, the allocation/initialization of the buffer is separated from its
>> activation. In other words, allocation/initialization may be done before
>> you
>> actually have to write the DS_AREA MSR. Allocation/initialization may not
>> necessary be done on the cpu you want to measure in per-cpu mode. The
>> logic of DS is different, ds_request_pebs() allocates and immediately
>> writes
>> DS_AREA. I cannot use that.
>
> DS_AREA contains a pointer to the actual configuration struct.
> The idea is that once I allocated the configuration struct, I can write
> the pointer to it into DS_AREA. It won't be used unless I turn on a feature
> that uses DS.
> So, the flow is:
> 1. allocate configuration struct
> 2. write DS_AREA
What if you are allocating the buffer for another task. For instance,
a tool is attaching
to a running process and wants to use PEBS. The tool allocates and
initializes the
PEBS buffer and then attaches it to the task to monitor (which is
stopped). When the
task is scheduled again, it picks up the PEBS buffer, and DS_AREA is written to.
> 3. configure BTS/PEBS
> 4. enable BTS/PEBS
enable PEBS consists in writing a PMU MSR. Perfmon takes care of that.
>
>
>> Concerning memory allocation of the buffer, the current kernel module
>> exporting PEBS lumps together the memory for the DS_AREA + PEBS
>> buffer. The entire region is then remapped to user space via mmap().
>> That implies that the memory region needs to be page-aligned and multiple
>> of page size. If I wanted to keep this, it is not clear to me how I could
>> use
>> your API to simply pass the addresses.
>
> Higher layers are not meant to know about DS configuration details. I admit
> that
> the interface is still very near to the actual h/w and that the developers
> of
> higher layers do of course know DS details. But they should not care, for
> example, that DS configuration requires memory allocation.
>
> The DS configuration is shared between PEBS and BTS users.
> Assuming there is already a BTS user for that thread or cpu. What should
> ds.c
> do with the memory you allocated for the DS configuration? It must have
> already
> allocated one to satisfy the BTS user.
>
> Besides, I would not expose this configuration to user-space. If the user
> were
> to modify the configuration, he could bring down the system. The PEBS/BTS
> buffers should be save, since they are write-only from h/w perspective.
>
The PEBS buffer (and thus DS_AREA) are remapped read-only.
There is another reason why the DS_AREA is exposed. This is the only way for
tools to see the current position in the PEBS buffer. They may want to poll on
that position index. The PEBS buffer is not necessarily full. What if
the session
terminates with a partial buffer. There must be a way for the tool to figure out
where the last sample is. By exposing DS read-only the index is always available
and always guaranteed current. Without this, the kernel would have to
extract the
index (pebs_get_index) and store it somewhere so the user can see it. This copy
could be tirggered by a PEBS buffer overflow or a stop of monitoring. Sampling
buffers formats currently do not have a stop callback but this can be
added easily.
next parent reply other threads:[~2008-11-12 10:10 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <7c86c4470810300753v7d377092qbcd266178d8e7338@mail.gmail.com>
[not found] ` <029E5BE7F699594398CA44E3DDF5544402AB2C50@swsmsx413.ger.corp.intel.com>
[not found] ` <7c86c4470811040822i6745bee6mbe451284d76549be@mail.gmail.com>
[not found] ` <7c86c4470811050505j678c6929if00cceda2af8cb17@mail.gmail.com>
[not found] ` <7c86c4470811050711w3753232fk1030fb00259a7b8@mail.gmail.com>
[not found] ` <029E5BE7F699594398CA44E3DDF5544402AB350E@swsmsx413.ger.corp.intel.com>
[not found] ` <7c86c4470811060249g62666885nbaa559c1777217a0@mail.gmail.com>
[not found] ` <1226236327.6104.4.camel@raistlin>
[not found] ` <7c86c4470811111411k754887a8ic9b63163928157a6@mail.gmail.com>
[not found] ` <491A812D.9010208@gmail.com>
2008-11-12 10:10 ` stephane eranian [this message]
2008-11-12 10:59 ` Metzger, Markus T
2008-11-13 14:50 ` stephane eranian
2008-11-14 14:41 ` Metzger, Markus T
2008-11-14 21:10 ` stephane eranian
2008-11-15 10:01 ` Markus Metzger
2008-11-18 22:00 ` stephane eranian
2008-11-19 12:14 ` Metzger, Markus T
2008-11-19 12:59 ` stephane eranian
2008-11-19 15:47 ` Metzger, Markus T
2008-11-19 17:13 ` stephane eranian
2008-11-19 18:27 ` Markus Metzger
2008-11-19 19:20 ` stephane eranian
2008-11-19 20:53 ` stephane eranian
2008-11-19 22:26 ` Markus Metzger
2008-11-20 21:19 ` stephane eranian
2008-11-21 8:22 ` Metzger, Markus T
2008-11-21 8:47 ` stephane eranian
2008-11-21 8:58 ` Metzger, Markus T
2008-11-21 13:38 ` stephane eranian
2008-11-21 15:27 ` stephane eranian
2008-11-21 16:10 ` Metzger, Markus T
2008-11-21 16:33 ` stephane eranian
2008-11-21 22:47 ` stephane eranian
2008-11-22 9:51 ` Markus Metzger
2008-11-23 22:31 ` stephane eranian
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=7c86c4470811120210j2ea5ccdcv59a654aadc32ebd2@mail.gmail.com \
--to=eranian@googlemail.com \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=eranian@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markus.t.metzger@googlemail.com \
--cc=markus.t.metzger@intel.com \
--cc=mingo@elte.hu \
/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
Powered by JetHome