From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752201AbbETAyF (ORCPT ); Tue, 19 May 2015 20:54:05 -0400 Received: from lgeamrelo02.lge.com ([156.147.1.126]:58438 "EHLO lgeamrelo02.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750901AbbETAyC (ORCPT ); Tue, 19 May 2015 20:54:02 -0400 X-Original-SENDERIP: 10.177.220.203 X-Original-MAILFROM: namhyung@kernel.org Date: Wed, 20 May 2015 09:44:37 +0900 From: Namhyung Kim To: Adrian Hunter Cc: Arnaldo Carvalho de Melo , linux-kernel@vger.kernel.org, Jiri Olsa Subject: Re: [PATCH 5/5] perf tools: Fix data_read_offset() file opening Message-ID: <20150520004437.GF22713@sejong> References: <1432040746-1755-1-git-send-email-adrian.hunter@intel.com> <1432040746-1755-6-git-send-email-adrian.hunter@intel.com> <20150519144818.GA29162@danjae.kornet> <555B95F3.9080003@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <555B95F3.9080003@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 19, 2015 at 10:58:43PM +0300, Adrian Hunter wrote: > 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(). OK, I'll change it to have a proper binary type before calling open_dso() like dso__data_fd() does. But I still think it's good to open data fd explicitly before reading from dso cache. > > 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. That is already a part of my patchset but not merged yet. > > But I will have to leave this to you because I am snowed with > my own problems. No problem. I can see you're doing hardwork ;-) Thanks, Namhyung