Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1444736ybm; Thu, 23 May 2019 00:50:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDof1V4p8D9QmIrRCU/5mGPj2tkX5Bq4RdM7BSocPtDA1XTaPZjM4mhgcVGbcJ2QzL8zTy X-Received: by 2002:a62:e117:: with SMTP id q23mr101890498pfh.60.1558597852386; Thu, 23 May 2019 00:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558597852; cv=none; d=google.com; s=arc-20160816; b=mKdO9ci3cV0h2CuomTXvJ4Pj2QscusSFqG18Bo1qPeusy3R0OolLetFEp0J7mmboXa NMQjbTFhOid/cw3rl4UeA8VtoGTZ2iFkHKR1u73K9N2VzcV4OMSouz8bqdmtCVA5x7cg 6z/xSiMij8hgi2PX4A83AQBFte65WsLjh4LVMUr3f0tcNNjt9Gx3vtu9H65BGyJmxY8I LtgG6PoT70A5K9Np/QCWXe9+4/0NaMG5tCX3kETrTf03jgy9PYDsSFyFCL7r+/aI8N+8 FISxBERAIg1zOsL8cbUCuQErUHWKHVvdDgubrPfqElQchhoS2QdfbH6d/qaGNkNQ6/QL xruA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=TdhTtM1GVqZTM6vag/U529MKo7qsAFXRUCrTwMKNQJs=; b=rDu9SSdp6sJH1xTEYbuR2Ep6Shfh5ZCflhGpum2yXo11WJCWzkO+Nz3bThDMDsysXT Wv7ePlvP1QXgDmwkDp6P/AdAYdj7WKiSbjJm/LFb+S6tK22uTUwqa+wzSfS91Olt9TdG 4zJw394MFGPVeICcQsGwlWAyWYsKfN02zikuNphG0HrJkrAN0ATJIBnd0cqWmlID4Loz dgsCSQOPpRZBcUhaGI+jtm0Pr6XIi0OYPAxLtBvdQKqHF4zrOcT3kzomMJT3pidnHCme sOvsWW9zP0gP4r+/b8TdYusnh2xVxuvtwiAQzrGICjNlQzAExG+lVmnlLfJv1p4Fit4C dPVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t136si31490178pfc.144.2019.05.23.00.50.37; Thu, 23 May 2019 00:50:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729064AbfEWHtN (ORCPT + 99 others); Thu, 23 May 2019 03:49:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32798 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725814AbfEWHtN (ORCPT ); Thu, 23 May 2019 03:49:13 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 373FF13A82; Thu, 23 May 2019 07:49:12 +0000 (UTC) Received: from krava (unknown [10.40.205.45]) by smtp.corp.redhat.com (Postfix) with SMTP id CB37210021B1; Thu, 23 May 2019 07:49:09 +0000 (UTC) Date: Thu, 23 May 2019 09:49:09 +0200 From: Jiri Olsa To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Jiri Olsa , lkml , Ingo Molnar , Alexander Shishkin , Peter Zijlstra , Stanislav Fomichev , Song Liu , Adrian Hunter , Andi Kleen Subject: Re: [PATCH 01/12] perf tools: Separate generic code in dso__data_file_size Message-ID: <20190523074909.GA27913@krava> References: <20190508132010.14512-1-jolsa@kernel.org> <20190508132010.14512-2-jolsa@kernel.org> <20190513194754.GB3198@kernel.org> <20190513200015.GA2064@krava> <20190523031001.GD196218@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190523031001.GD196218@google.com> User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 23 May 2019 07:49:12 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 23, 2019 at 12:10:02PM +0900, Namhyung Kim wrote: > Hi Jirka, > > On Mon, May 13, 2019 at 10:00:15PM +0200, Jiri Olsa wrote: > > On Mon, May 13, 2019 at 04:47:54PM -0300, Arnaldo Carvalho de Melo wrote: > > > Em Wed, May 08, 2019 at 03:19:59PM +0200, Jiri Olsa escreveu: > > > > Moving file specific code in dso__data_file_size function > > > > into separate file_size function. I'll add bpf specific > > > > code in following patches. > > > > > > I'm applying this patch, as it just moves things around, no logic > > > change, but can you please clarify a question I have after looking at > > > this patch? > > > > > > > Link: http://lkml.kernel.org/n/tip-rkcsft4a0f8sw33p67llxf0d@git.kernel.org > > > > Signed-off-by: Jiri Olsa > > > > --- > > > > tools/perf/util/dso.c | 19 ++++++++++++------- > > > > 1 file changed, 12 insertions(+), 7 deletions(-) > > > > > > > > diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c > > > > index e059976d9d93..cb6199c1390a 100644 > > > > --- a/tools/perf/util/dso.c > > > > +++ b/tools/perf/util/dso.c > > > > @@ -898,18 +898,12 @@ static ssize_t cached_read(struct dso *dso, struct machine *machine, > > > > return r; > > > > } > > > > > > > > -int dso__data_file_size(struct dso *dso, struct machine *machine) > > > > +static int file_size(struct dso *dso, struct machine *machine) > > > > { > > > > int ret = 0; > > > > struct stat st; > > > > char sbuf[STRERR_BUFSIZE]; > > > > > > > > - if (dso->data.file_size) > > > > - return 0; > > > > - > > > > - if (dso->data.status == DSO_DATA_STATUS_ERROR) > > > > - return -1; > > > > - > > > > pthread_mutex_lock(&dso__data_open_lock); > > > > > > > > /* > > > > @@ -938,6 +932,17 @@ int dso__data_file_size(struct dso *dso, struct machine *machine) > > > > return ret; > > > > } > > > > > > > > +int dso__data_file_size(struct dso *dso, struct machine *machine) > > > > +{ > > > > + if (dso->data.file_size) > > > > + return 0; > > > > + > > > > + if (dso->data.status == DSO_DATA_STATUS_ERROR) > > > > + return -1; > > > > + > > > > + return file_size(dso, machine); > > > > +} > > > > > > > > > So the name of the function suggests we want to know the > > > "data_file_size" of a dso, then the logic in it returns _zero_ if a > > > member named "dso->data.file_size" is _not_ zero, can you please > > > clarify? > > > > > > I was expecting something like: > > > > > > if (dso->data.file_size) > > > return dso->data.file_size; > > > > > > I.e. if we had already read it, return the cached value, otherwise go > > > and call some other function to get that info somehow. > > > > we keep the data size in dso->data.file_size, > > the function just updates it > > > > the return code is the error code.. not sure, > > why its like that, but it is ;-) > > > > maybe we wanted separate size and error code, > > because the size needs to be u64 and we use > > int everywhere.. less casting > > Maybe we can rename it to dso__update_file_size(). sounds good, I'll queue it thanks, jirka