From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnaldo Carvalho de Melo Subject: [PATCH 22/41] perf dso: Separate generic code in dso__data_file_size() Date: Wed, 29 May 2019 10:35:46 -0300 Message-ID: <20190529133605.21118-23-acme@kernel.org> References: <20190529133605.21118-1-acme@kernel.org> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <20190529133605.21118-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org To: Ingo Molnar , Thomas Gleixner Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Song Liu , Adrian Hunter , Alexander Shishkin , Andi Kleen , Peter Zijlstra , Stanislav Fomichev , Arnaldo Carvalho de Melo List-Id: linux-perf-users.vger.kernel.org From: Jiri Olsa Moving file specific code in dso__data_file_size function into separate file_size function. I'll add bpf specific code in following patches. Signed-off-by: Jiri Olsa Acked-by: Song Liu Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stanislav Fomichev Link: http://lkml.kernel.org/r/20190508132010.14512-2-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- 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); +} + /** * dso__data_size - Return dso data size * @dso: dso object -- 2.20.1