Re: [PATCH] perf: make perf.data more self-descriptive (v8)

From: Stephane Eranian
Date: Tue Nov 29 2011 - 13:35:25 EST


Robert,

On Tue, Nov 29, 2011 at 10:22 AM, Robert Richter <robert.richter@xxxxxxx> wrote:
> On 30.09.11 09:40:40, Stephane Eranian wrote:
>> @@ -385,36 +1433,69 @@ static int perf_header__adds_write(struct perf_header *header,
>> Â Â Â Â sec_start = header->data_offset + header->data_size;
>> Â Â Â Â lseek(fd, sec_start + sec_size, SEEK_SET);
>>
>> - Â Â Â if (perf_header__has_feat(header, HEADER_TRACE_INFO)) {
>> - Â Â Â Â Â Â Â struct perf_file_section *trace_sec;
>> -
>> - Â Â Â Â Â Â Â trace_sec = &feat_sec[idx++];
>> + Â Â Â err = do_write_feat(fd, header, HEADER_TRACE_INFO, &p, evlist);
>> + Â Â Â if (err)
>> + Â Â Â Â Â Â Â goto out_free;
>>
>> - Â Â Â Â Â Â Â /* Write trace info */
>> - Â Â Â Â Â Â Â trace_sec->offset = lseek(fd, 0, SEEK_CUR);
>> - Â Â Â Â Â Â Â read_tracing_data(fd, &evlist->entries);
>> - Â Â Â Â Â Â Â trace_sec->size = lseek(fd, 0, SEEK_CUR) - trace_sec->offset;
>> + Â Â Â err = do_write_feat(fd, header, HEADER_BUILD_ID, &p, evlist);
>> + Â Â Â if (err) {
>> + Â Â Â Â Â Â Â perf_header__clear_feat(header, HEADER_BUILD_ID);
>> + Â Â Â Â Â Â Â goto out_free;
>> Â Â Â Â }
>
> Stephane,
>
> I am just looking at the code and got a question:
>
> Is there a reason for the different error handling for
> HEADER_TRACE_INFO and HEADER_BUILD_ID? All other types simply disable
> the feature and go on without returning an error (goto out_free).
>
You're looking at an old version of that code. I fixed that later on.
If you look in tip
you'll see that TRACE_INFO follows the same logic.

sec_start = header->data_offset + header->data_size;
lseek(fd, sec_start + sec_size, SEEK_SET);

err = do_write_feat(fd, header, HEADER_TRACE_INFO, &p, evlist);
if (err)
goto out_free;

err = do_write_feat(fd, header, HEADER_BUILD_ID, &p, evlist);
if (err) {
perf_header__clear_feat(header, HEADER_BUILD_ID);
goto out_free;
}

The 'clear_feat' is missing for TRACE_INFO, that's all. The question is:
is case do_write_feat(trace_info) fails, is there still a way to parse the file
correctly? If not, then perf should bail out, if yes, then we need to add the
clear_feat(TRACE_INFO) in case of error.
--
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/