All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Gutson <daniel.gutson@tallertechnologies.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: Leonardo Boquillon <leonardo.boquillon@tallertechnologies.com>,
	linux-perf-users@vger.kernel.org
Subject: Re: Ability for classifying of measurements\
Date: Wed, 4 May 2016 14:20:37 -0300	[thread overview]
Message-ID: <CAF5HaEXP1vvDod5eRnY2DYvTzeZDC_w15SbNpPEdosbv52qbAQ@mail.gmail.com> (raw)
In-Reply-To: <20160420174724.GP9407@two.firstfloor.org>

On Wed, Apr 20, 2016 at 2:47 PM, Andi Kleen <andi@firstfloor.org> wrote:
>>  Agree, this was the first step. What we would like to see implemented from
>>  this feature is, 1) some dwarf-aided ability to specify watched variables in
>>  the perf record command (e.g. perf record --groupby="::var1,
>> class1::staticvar2" ),
>> and 2) provide an API to the applications so they can
>>  communicate with perf_events telling what's going on, such as the example we
>>  are showing here (which is *just* an example to fuel this discussion). This
>>  API would lead to intrusively mess the code of the app but not more than
>>  people already do with debugging printfs; this would be very important for
>>  performance-centric applications.
>
> perf probe has an ability to reference variables relative
> to a register or in a register, and parse dwarf for it.
>
> I'm not sure it's a good idea to have a lot of arbitrary memory
> accesses in the PMI handler (although there is already some for stack
> walking)
>
> One problem with global variables is that they can move
> around with ASLR, so it can be difficult to find them.
>
> If the variable is in a register you can already get it from the PEBS
> record on Intel CPUs.  There is no good tooling for it currently,
> but the information is in perf script output, and can be enabled
> for perf record.
>
> An easy way to implement it would be to use a
> global register variable (register asm("...") ...).
> However you would need to rebuild all your libraries to preserve
> the global register.
>
> Best would be to use an unused register. One that comes to
> mind on x86-64bit Linux is GS, which is normally only used by the kernel.

I kept thinking about all this, and I changed my mind towards a
simpler (a first step) yet useful approach.
In the same way people spread some printfs for old school debugging, I
keep the idea of some perf API made available
for the application (which calls depend on some flag, say -DNPERF
similar to -DNDEBUG, so if the macro is
not defined, calls have no effects).
The first relatively easy (again, but yet useful) feature that comes
to my mind, is the ability (from the app) to
label phases of the perf recording, including enabling, disabling, and
labelling.
For example, let's suppose that an application has an initialization
phase, then a communication with a server,
then data gathering, then processing, then storing the processed
results. Currently, all the recording and reporting would mix all that
measured information, whereas we could be interested in some phases
only (or disabling the rest).

Thus, the API could have:

perf_enable();
perf_disable();
perf_label(const char* label);

So, the application would appropriately call those functions; at
reporting, both a summary and a breakdown of analysis would be
performed.
A quick hack that comes to my mind is that perf_label just changes the
destination file of perf record, closing the previous file and opening
(potentially appending)
the specified in the argument. This way I think perf report could be
left unmodified, so the user would just do perf report
[labelled_file].

The communication from the application to perf_events (when enabled
with e.g. compiled wih NPERF) could be through some /proc/perf or any
other mechanism.

>
> With this pending patchkit[1] the application can write to it
> using WRGSBASE, previously it needed a syscall.

-ENOLINK

>
> Currently perf cannot log GS I believe, but that would be fairly
> easy to add. Would also need some tooling to make the value
> an extra sort key in perf report.
>
> -Andi
>

Thanks Andi.

   Daniel.


-- 

Daniel F. Gutson
Engineering Manager

San Lorenzo 47, 3rd Floor, Office 5
Córdoba, Argentina

Phone:   +54 351 4217888 / +54 351 4218211
Skype:    dgutson
LinkedIn: http://ar.linkedin.com/in/danielgutson

  reply	other threads:[~2016-05-04 17:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-19 20:51 Ability for classifying of measurements Leonardo Boquillon
2016-04-20 13:08 ` Andi Kleen
     [not found]   ` <CAF5HaEXOwn0_b=an2RR2FT++ktRXLpAP2WHPE7O=kdVKVRYKVQ@mail.gmail.com>
2016-04-20 16:08     ` Daniel Gutson
2016-04-20 17:47       ` Ability for classifying of measurements\ Andi Kleen
2016-05-04 17:20         ` Daniel Gutson [this message]
2016-05-04 17:26           ` Daniel Gutson
2016-05-04 21:41           ` Andi Kleen
2016-05-04 21:56             ` Daniel Gutson
2016-05-04 23:19               ` Vince Weaver
2016-05-04 23:50               ` Andi Kleen

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=CAF5HaEXP1vvDod5eRnY2DYvTzeZDC_w15SbNpPEdosbv52qbAQ@mail.gmail.com \
    --to=daniel.gutson@tallertechnologies.com \
    --cc=andi@firstfloor.org \
    --cc=leonardo.boquillon@tallertechnologies.com \
    --cc=linux-perf-users@vger.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 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.