Re: [PATCH] perf tools: fix endian conversion reading event attrfrom header

From: David Ahern
Date: Fri Jul 15 2011 - 12:02:51 EST


On 07/15/2011 09:47 AM, Frederic Weisbecker wrote:
>> - if (perf_header__getbuffer64(header, fd, &f_attr, sizeof(f_attr)))
>> + if (readn(fd, &f_attr, sizeof(f_attr)) <= 0)
>> goto out_errno;
>>
>> + if (header->needs_swap) {
>> + f_attr.attr.type = bswap_32(f_attr.attr.type);
>> + f_attr.attr.size = bswap_32(f_attr.attr.size);
>> + mem_bswap_64(&f_attr.attr.config,
>> + sizeof(struct perf_event_attr) - 8);
>> + }
>> +
>
> Good catch!

A long, painful discovery

> But would be nice to also handle the wakeup_events and bp_type fields.
>

I did not think those values were used in userspace, so did not touch
them. But then your inquiry pushed me into cscope and I found the
perf_event__attr_swap() function. I'll redo the patch leveraging the
swapping done there.

David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/