Re: [PATCH] [RFC] perf: robustify proc and debugfs file recording

From: Sonny Rao
Date: Tue Jul 12 2011 - 19:01:42 EST


On Tue, Jul 12, 2011 at 3:56 PM, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
> On Tue, 2011-07-12 at 14:15 -0700, Sonny Rao wrote:
>> While attempting to create a timechart of boot up I found
>> perf didn't tolerate modules being loaded/unloaded.  This patch
>> fixes this by reading the file once and then writing the size
>> read at the correct point in the file.  It also simplifies the
>> code somewhat.
>>
>> Signed-off-by: Sonny Rao <sonnyrao@xxxxxxxxxxxx>
>
>>  static bool name_in_tp_list(char *sys, struct tracepoint_path *tps)
>> @@ -338,14 +292,8 @@ static void copy_event_system(const char *sys, struct tracepoint_path *tps)
>>               sprintf(format, "%s/%s/format", sys, dent->d_name);
>>               ret = stat(format, &st);
>>
>> -             if (ret >= 0) {
>> -                     /* unfortunately, you can not stat debugfs files for size */
>> -                     size = get_size(format);
>> -                     write_or_die(&size, 8);
>> -                     check_size = copy_file(format);
>> -                     if (size != check_size)
>> -                             die("error in size of file '%s'", format);
>
> You mean to tell me that you are hitting a race between the get_size()
> and check_size()?  This is a very quick action, and this only happens at
> start up. Are you starting up perf and loading modules at the same time?

I sure am... the thing we're trying to do here is analyze our boot time
and udev is asynchronously loading modules in the background while
perf is starting up.

We've put in stupid hacks like sleep for a while, but they've proven to be
unreliable so I figured I'd take a stab at fixing the issue. I also think this
change will make the overhead a bit lower since we only read these files
once.

Sonny
--
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/