Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5560604yba; Mon, 13 May 2019 13:02:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwD9e3weqpCX0WXP1nmCTU425HWovaH1avhQaGnsgFczcqaKP+FW+zuxCGDjrhK2DE1iDQK X-Received: by 2002:a63:c601:: with SMTP id w1mr34119624pgg.190.1557777755714; Mon, 13 May 2019 13:02:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557777755; cv=none; d=google.com; s=arc-20160816; b=OFXWaIDaRQqxbQJKEjlxF60PWjOgUNiIBBg74ToyYmiTkvDGVik21Wvc7VJDESFS58 BkFUASyM/ufISVs0/vyL8kC8DhvCS9szPUOr5lKBPvf+QU39X8UJqYlGV8oTUzJQM3VZ 2CKHrrnlC5oRsEFvviD900J1fPR7UJkq6lT0hXeLdlWHrGUHUGAj2yX82Rab9ll6RrOr C0X2fO2pNzaX9hl2mUB1XE3D8nHsjQ7nEk7FEYVylMuJuyFVgK++2uYIMVEUSTw9kCNR bDrqcCRlluD+fhYG08WLPR0r6+H0nuaOKSi7CYauOtTDs/q62kfxWEga5cefUEOlSVJD BJOQ== 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=CpL0GLaWkv0nQE6N6/OK/5GRgfE3e8w1QA29uD/xCrA=; b=ApP5QPPbV7Kst8mIDJW/2xoP52ejw7pbAi8Vku0JqmExNZQcdgcixdzAFBgtxmWFVt SVhmqADAJC9JN6n3MZsRQA72F6EfGOEwFpkUW2IRwOhCnQuX4+WylJ3fG1xy5WREOKlM RZ4q9IoQO9Iqb8dDZ3Mn9qOIYI0hcYdLwrwLoJh64bvPztuxPq4uUVtTScW6DUCgoTaZ M7LwCnXpn7T5/FUXeVwCcOWguZ0T13tzvxteyhaGZEzSc4io2d268DPEQE39z6JMrROW OtwAwV18CNiQoJJKOkuKuhsyCjIEL+rupQ59aB5HoaTzjBjYAm9/b+yHP51q6KHzDy4F uHpg== 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 cm8si19945649plb.159.2019.05.13.13.02.19; Mon, 13 May 2019 13:02:35 -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 S1726200AbfEMUAT (ORCPT + 99 others); Mon, 13 May 2019 16:00:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37404 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725928AbfEMUAT (ORCPT ); Mon, 13 May 2019 16:00:19 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DF3F359440; Mon, 13 May 2019 20:00:18 +0000 (UTC) Received: from krava (ovpn-204-124.brq.redhat.com [10.40.204.124]) by smtp.corp.redhat.com (Postfix) with SMTP id 6702B413F; Mon, 13 May 2019 20:00:16 +0000 (UTC) Date: Mon, 13 May 2019 22:00:15 +0200 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , lkml , Ingo Molnar , Namhyung Kim , 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: <20190513200015.GA2064@krava> References: <20190508132010.14512-1-jolsa@kernel.org> <20190508132010.14512-2-jolsa@kernel.org> <20190513194754.GB3198@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190513194754.GB3198@kernel.org> User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 13 May 2019 20:00:19 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 jirka