lkml.org 
[lkml]   [2015]   [May]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 5/5] perf tools: Fix data_read_offset() file opening
On 19/05/2015 5:48 p.m., Namhyung Kim wrote:
> Hi Adrian,
>
> On Tue, May 19, 2015 at 04:05:46PM +0300, Adrian Hunter wrote:
>> Patch "perf tools: Protect dso cache fd with a mutex"
>> changed data_file_size() to open the data file if it
>> was not open.
>>
>> data_read_offset() was calling data_file_size() to read
>> the data file size, but data_file_size() can fail to
>> open the file because the binary_type has not been set up.
>>
>> The correct function to call is dso__data_size() which
>> uses dso__data_fd() to open the file correctly.
>
> Right, but I worried about the locking overhead. By using
> dso__data_size() it'll call dso__data_fd() everytime which grabs the
> dso__data_open_lock that is a global mutex. It can be a performance
> bottleneck on multi-thread report IMHO.
>
> I assumed that correct code should check the data fd or size before
> calling read function as I read the comment in dso.h file.
>
> What about adding the missing check in a proper place instead?

It looks to me like you need to change data_file_size() and
dso_cache__read() so that they open the fd properly i.e. call
dso__data_fd() instead of open_dso().

dso__data_fd() should not be taking a lock because the lock must
be held while the fd in being used.

Perhaps there should be dso__get_fd() and dso__put_fd() that lock/open
and the unlock.

But I will have to leave this to you because I am snowed with
my own problems.

>
> Thanks,
> Namhyung
>
>
>>
>> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
>> ---
>> tools/perf/util/dso.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
>> index 1b96c8d..e248f56 100644
>> --- a/tools/perf/util/dso.c
>> +++ b/tools/perf/util/dso.c
>> @@ -756,7 +756,7 @@ off_t dso__data_size(struct dso *dso, struct machine *machine)
>> static ssize_t data_read_offset(struct dso *dso, struct machine *machine,
>> u64 offset, u8 *data, ssize_t size)
>> {
>> - if (data_file_size(dso, machine))
>> + if (dso__data_size(dso, machine) < 0)
>> return -1;
>>
>> /* Check the offset sanity. */
>> --
>> 1.9.1
>>


\
 
 \ /
  Last update: 2015-05-19 22:21    [W:0.080 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site