All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: Clark Williams <williams@redhat.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 03/24] perf session: Get rid of file_size variable
Date: Mon, 21 Jan 2019 20:56:45 -0300	[thread overview]
Message-ID: <20190121235706.20005-4-acme@kernel.org> (raw)
In-Reply-To: <20190121235706.20005-1-acme@kernel.org>

From: Jiri Olsa <jolsa@kernel.org>

It's not needed and removing it makes the code a little simpler for the
upcoming changes.

It's safe to replace file_size with data_size, because the
perf_data__size() value is never smaller than data_offset + data_size.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20190110101301.6196-3-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/session.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index ad14192db811..c8c2069fb01e 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1825,7 +1825,6 @@ static int __perf_session__process_events(struct perf_session *session)
 	struct ordered_events *oe = &session->ordered_events;
 	struct perf_tool *tool = session->tool;
 	int fd = perf_data__fd(session->data);
-	u64 file_size = perf_data__size(session->data);
 	u64 data_offset = session->header.data_offset;
 	u64 data_size = session->header.data_size;
 	u64 head, page_offset, file_offset, file_pos, size;
@@ -1845,14 +1844,13 @@ static int __perf_session__process_events(struct perf_session *session)
 	if (data_size == 0)
 		goto out;
 
-	if (data_offset + data_size < file_size)
-		file_size = data_offset + data_size;
+	ui_progress__init_size(&prog, data_size, "Processing events...");
 
-	ui_progress__init_size(&prog, file_size, "Processing events...");
+	data_size += data_offset;
 
 	mmap_size = MMAP_SIZE;
-	if (mmap_size > file_size) {
-		mmap_size = file_size;
+	if (mmap_size > data_size) {
+		mmap_size = data_size;
 		session->one_mmap = true;
 	}
 
@@ -1917,7 +1915,7 @@ static int __perf_session__process_events(struct perf_session *session)
 	if (session_done())
 		goto out;
 
-	if (file_pos < file_size)
+	if (file_pos < data_size)
 		goto more;
 
 out:
-- 
2.20.1


  parent reply	other threads:[~2019-01-21 23:57 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-21 23:56 [GIT PULL 00/24] perf/core improvements and fixes Arnaldo Carvalho de Melo
2019-01-21 23:56 ` [PATCH 01/24] perf tools: Replace automatic const char[] variables by statics Arnaldo Carvalho de Melo
2019-01-21 23:56 ` [PATCH 02/24] perf session: Rearrange perf_session__process_events function Arnaldo Carvalho de Melo
2019-01-21 23:56 ` Arnaldo Carvalho de Melo [this message]
2019-01-21 23:56 ` [PATCH 04/24] perf session: Add reader object Arnaldo Carvalho de Melo
2019-01-21 23:56 ` [PATCH 05/24] perf session: Add 'data_size' member to " Arnaldo Carvalho de Melo
2019-01-21 23:56 ` [PATCH 06/24] perf session: Add 'data_offset' " Arnaldo Carvalho de Melo
2019-01-21 23:56 ` [PATCH 07/24] perf session: Add reader__process_events function Arnaldo Carvalho de Melo
2019-01-21 23:56 ` [PATCH 08/24] perf: Remove duplicated workqueue.h include from perf_event.h Arnaldo Carvalho de Melo
2019-01-21 23:56 ` [PATCH 09/24] perf tools: Remove duplicate headers Arnaldo Carvalho de Melo
2019-01-21 23:56 ` [PATCH 10/24] perf report: Display arch specific diagnostic counter sets, starting with s390 Arnaldo Carvalho de Melo
2019-01-21 23:56 ` [PATCH 11/24] perf report: Display names in s390 diagnostic counter sets Arnaldo Carvalho de Melo
2019-01-21 23:56 ` [PATCH 12/24] perf report: Dump s390 counter set data to file Arnaldo Carvalho de Melo
2019-01-21 23:56 ` [PATCH 13/24] perf: Make perf_event_output() propagate the output() return Arnaldo Carvalho de Melo
2019-01-21 23:56 ` [PATCH 14/24] perf, bpf: Introduce PERF_RECORD_KSYMBOL Arnaldo Carvalho de Melo
2019-01-21 23:56 ` [PATCH 15/24] tools headers uapi: Sync tools/include/uapi/linux/perf_event.h Arnaldo Carvalho de Melo
2019-01-21 23:56 ` [PATCH 16/24] perf, bpf: Introduce PERF_RECORD_BPF_EVENT Arnaldo Carvalho de Melo
2019-01-21 23:56 ` [PATCH 17/24] tools headers uapi: Sync tools/include/uapi/linux/perf_event.h Arnaldo Carvalho de Melo
2019-01-21 23:57 ` [PATCH 18/24] perf tools: Handle PERF_RECORD_KSYMBOL Arnaldo Carvalho de Melo
2019-01-21 23:57 ` [PATCH 19/24] perf tools: Handle PERF_RECORD_BPF_EVENT Arnaldo Carvalho de Melo
2019-01-21 23:57 ` [PATCH 20/24] perf tools: Synthesize PERF_RECORD_* for loaded BPF programs Arnaldo Carvalho de Melo
2019-01-21 23:57 ` [PATCH 21/24] perf top: Synthesize BPF events for pre-existing " Arnaldo Carvalho de Melo
2019-01-21 23:57 ` [PATCH 22/24] bpf: Add module name [bpf] to ksymbols for bpf programs Arnaldo Carvalho de Melo
2019-01-21 23:57 ` [PATCH 23/24] perf python: Remove -fstack-clash-protection when building with some clang versions Arnaldo Carvalho de Melo
2019-01-21 23:57 ` [PATCH 24/24] perf utils: Move perf_config using routines from color.c to separate object Arnaldo Carvalho de Melo
2019-01-22 10:07 ` [GIT PULL 00/24] perf/core improvements and fixes Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190121235706.20005-4-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.