All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Andrew Vagin <avagin@openvz.org>,
	linux-kernel@vger.kernel.org, a.p.zijlstra@chello.nl,
	paulus@samba.org, mingo@elte.hu, asharma@fb.com,
	devel@openvz.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 3/7] perf: add ability to change event according to sample (v2)
Date: Tue, 06 Dec 2011 07:57:38 -0700	[thread overview]
Message-ID: <4EDE2D62.9050802@gmail.com> (raw)
In-Reply-To: <20111206141942.GE10709@infradead.org>



On 12/06/2011 07:19 AM, Arnaldo Carvalho de Melo wrote:
> Em Mon, Nov 28, 2011 at 12:03:31PM +0300, Andrew Vagin escreveu:
>> It's opposition of perf_session__parse_sample.
>>
>> v2: fixed mistakes which David Arhen found
> 
> Ok, I'm taking this one, David, can I added an 'Acked-by: you"? Or even
> "reviewed-by:" ?
> 
> I'm just changing 'data' to 'sample', data is way to vague, I kept it
> for a while in the past just to reduce patch size, but this is something
> completely new, so better use 'sample'.
> 
> - Arnaldo
>  
>> Signed-off-by: Andrew Vagin <avagin@openvz.org>
>> ---
>>  tools/perf/util/event.h   |    2 +
>>  tools/perf/util/evsel.c   |   74 +++++++++++++++++++++++++++++++++++++++++++++
>>  tools/perf/util/session.h |    9 +++++
>>  3 files changed, 85 insertions(+), 0 deletions(-)
>>
>> diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
>> index 357a85b..0493101 100644
>> --- a/tools/perf/util/event.h
>> +++ b/tools/perf/util/event.h
>> @@ -187,5 +187,7 @@ const char *perf_event__name(unsigned int id);
>>  int perf_event__parse_sample(const union perf_event *event, u64 type,
>>  			     int sample_size, bool sample_id_all,
>>  			     struct perf_sample *sample, bool swapped);
>> +int perf_event__change_sample(union perf_event *event, u64 type,
>> +			     const struct perf_sample *data, bool swapped);
>>  
>>  #endif /* __PERF_RECORD_H */
>> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
>> index e426264..d697568 100644
>> --- a/tools/perf/util/evsel.c
>> +++ b/tools/perf/util/evsel.c
>> @@ -494,3 +494,77 @@ int perf_event__parse_sample(const union perf_event *event, u64 type,
>>  
>>  	return 0;
>>  }
>> +
>> +int perf_event__change_sample(union perf_event *event, u64 type,
>> +			     const struct perf_sample *data, bool swapped)
>> +{
>> +	u64 *array;
>> +
>> +	/*
>> +	 * used for cross-endian analysis. See git commit 65014ab3
>> +	 * for why this goofiness is needed.
>> +	 */
>> +	union {
>> +		u64 val64;
>> +		u32 val32[2];
>> +	} u;
>> +
>> +	array = event->sample.array;
>> +
>> +	if (type & PERF_SAMPLE_IP) {
>> +		event->ip.ip = data->ip;
>> +		array++;
>> +	}
>> +
>> +	if (type & PERF_SAMPLE_TID) {
>> +		u.val32[0] = data->pid;
>> +		u.val32[1] = data->tid;
>> +		if (swapped) {
>> +			/* undo swap of u64, then swap on individual u32s */

Comment is from the parse sample code; this is the inverse of that code
so the comment needs to be updated here.

>> +			u.val32[0] = bswap_32(u.val32[0]);
>> +			u.val32[1] = bswap_32(u.val32[1]);
>> +			u.val64 = bswap_64(u.val64);
>> +		}
>> +
>> +		*array = u.val64;
>> +		array++;
>> +	}
>> +
>> +	if (type & PERF_SAMPLE_TIME) {
>> +		*array = data->time;
>> +		array++;
>> +	}
>> +
>> +	if (type & PERF_SAMPLE_ADDR) {
>> +		*array = data->addr;
>> +		array++;
>> +	}
>> +
>> +	if (type & PERF_SAMPLE_ID) {
>> +		*array = data->id;
>> +		array++;
>> +	}
>> +
>> +	if (type & PERF_SAMPLE_STREAM_ID) {
>> +		*array = data->stream_id;
>> +		array++;
>> +	}
>> +
>> +	if (type & PERF_SAMPLE_CPU) {
>> +		u.val32[0] = data->cpu;
>> +		if (swapped) {
>> +			/* undo swap of u64, then swap on individual u32s */

Ditto on that comment.

I did not test it, but the logic is in the inverse of parse_sample so it
should be correct.

Arnaldo: you could use remove the 2 comment lines on the commit since
there are no logic impacts.

Reviewed-by: David Ahern <dsahern@gmail.com>

David

  parent reply	other threads:[~2011-12-06 14:57 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-28  9:03 [PATCH 0/7] Profiling sleep times (v3) Andrew Vagin
2011-11-28  9:03 ` [PATCH 1/7] perf: use event_name() to get an event name Andrew Vagin
2011-12-06 14:02   ` Arnaldo Carvalho de Melo
2011-12-08  4:34   ` [tip:perf/urgent] perf header: Use " tip-bot for Andrew Vagin
2011-11-28  9:03 ` [PATCH 2/7] perf: add ability to record event period Andrew Vagin
2011-12-06 14:02   ` Arnaldo Carvalho de Melo
2011-11-28  9:03 ` [PATCH 3/7] perf: add ability to change event according to sample (v2) Andrew Vagin
2011-12-06 14:19   ` Arnaldo Carvalho de Melo
2011-12-06 14:24     ` Arnaldo Carvalho de Melo
2011-12-06 14:57     ` David Ahern [this message]
2011-12-06 15:06       ` Arnaldo Carvalho de Melo
2011-11-28  9:03 ` [PATCH 4/7] perf: teach "perf inject" to work with files Andrew Vagin
2011-11-28  9:03 ` [PATCH 5/7] perf: teach perf inject to merge sched_stat_* and sched_switch events Andrew Vagin
2011-11-28  9:03 ` [PATCH 6/7] perf: add scripts for profiling sleep times (v2) Andrew Vagin
2011-11-28  9:03 ` [PATCH 7/7] event: add tracepoint for accounting block time Andrew Vagin
2011-11-28 11:42   ` Peter Zijlstra
2011-11-28 14:02     ` Arjan van de Ven
2011-11-28 14:31       ` Arnaldo Carvalho de Melo
2011-11-28 14:43         ` Arjan van de Ven
2011-11-28 14:59           ` Arnaldo Carvalho de Melo
2011-12-06  9:48   ` [tip:sched/core] events, sched: Add tracepoint for accounting blocked time tip-bot for Andrew Vagin
2011-12-06  7:15 ` [Devel] [PATCH 0/7] Profiling sleep times (v3) Andrey Vagin
2011-12-06  8:30   ` Ingo Molnar
2011-12-06 13:45   ` Arnaldo Carvalho de Melo
2011-12-07 20:33   ` Arun Sharma
2011-12-07 20:33     ` Arun Sharma

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=4EDE2D62.9050802@gmail.com \
    --to=dsahern@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=asharma@fb.com \
    --cc=avagin@openvz.org \
    --cc=devel@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.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.