linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	mingo@elte.hu, peterz@infradead.org, fweisbec@gmail.com,
	paulus@samba.org, tglx@linutronix.de, anton@samba.org
Subject: Re: [PATCH] perf tool: fix endianness handling of u32 data in samples
Date: Fri, 02 Sep 2011 14:06:08 -0600	[thread overview]
Message-ID: <4E613730.4080508@gmail.com> (raw)
In-Reply-To: <20110902200255.GG17970@ghostprotocols.net>



On 09/02/2011 02:02 PM, Arnaldo Carvalho de Melo wrote:
> Em Fri, Sep 02, 2011 at 01:41:51PM -0600, David Ahern escreveu:
>> @@ -423,18 +449,25 @@ int perf_event__parse_sample(const union perf_event *event, u64 type,
>>  	}
>>  
>>  	if (type & PERF_SAMPLE_RAW) {
>> -		u32 *p = (u32 *)array;
>> +		u.val64 = *array;
>> +		if (swapped) {
>> +			/* undo swap of u64, then swap on individual u32s */
>> +			u.val64 = bswap_64(u.val64);
>> +			u.val32[0] = bswap_32(u.val32[0]);
>> +			u.val32[1] = bswap_32(u.val32[1]);
>> +
>> +			WARN_ONCE(swapped, "Endianness of raw data not corrected!\n");
>> +		}
> 
> That works too, but then we'll be always testing swapped two times :-)
> 
> - Arnaldo


I did not see a WARN_ONCE with no 'condition' variable, so I went with
the redundant test. I guess swapped really could be changed to '1' --
like an example I saw in the acpi code.

David

  reply	other threads:[~2011-09-02 20:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-02 19:41 [PATCH] perf tool: fix endianness handling of u32 data in samples David Ahern
2011-09-02 20:02 ` Arnaldo Carvalho de Melo
2011-09-02 20:06   ` David Ahern [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-08-29 21:55 David Ahern
2011-09-01 16:19 ` Arnaldo Carvalho de Melo
2011-09-01 16:41   ` David Ahern
2011-09-01 16:54     ` David Ahern

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=4E613730.4080508@gmail.com \
    --to=dsahern@gmail.com \
    --cc=acme@ghostprotocols.net \
    --cc=anton@samba.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).