Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp2888416ima; Sun, 3 Feb 2019 08:48:47 -0800 (PST) X-Google-Smtp-Source: ALg8bN6mqmIkZ9w6ysetyItEhBO/8qYll6XRn7Y/n9secZVvyPm522wmCSHPMRVG6mvuFUjEf/J3 X-Received: by 2002:a17:902:9691:: with SMTP id n17mr49561006plp.9.1549212527303; Sun, 03 Feb 2019 08:48:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549212527; cv=none; d=google.com; s=arc-20160816; b=raLjJbnZOT/IUfoE+JezPSXrC4LCiH66mDFOYw3JB9iIUj6kQshGcYIb5sZNgNlyKp 39EgmEidNyUc+qQtqik4K5EBq++1xkddLZmyIfp7qS9aAPRApqUf/VH/8URLaSGinoWl w2lgIEeSK1k+mtykKWCJa7BpD3yjAkyTUne+KLJMeot7t63SIYtXqEFJ5Lq8em2fsYx8 mZRMYulLnx4QslsRNo3VwSeUaPXNTqbRZKS0tlrrXz8yS93Rc/P0mmKKVnqmL5W92lNk pLDPRNEbWY5PoZkytfkR+BS4jbE+k6ieaZv+EFKCbr6UNPoOPjNufIhBphq5r66rKDMD g2Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=MzcqfCTqqS1JPB4F7qU8BdMNkoa6jkZRReq6lyT1mko=; b=ZN4WuJJqYPgfiChKLSV8daUzmw+iQjsteTYPp6UoZusGb27BXFvgZNtKJN0mNAJuGo 2ZK7/NPmHzqAuZ6vFfUI+/oTpVqF7quFCEW/yJlnFyCOrVUaZ587Yvfn2wdI5T4pJt8J YkHzZM7uG9ADbd8J5/TlKHU4zMjHK1afbndWgtWZxIvMob6CmNtys83dcYdputpf1mPf 8l7ioV4S77bOU29gTKvuJGoRX2xubzMNO1wT/Tm30iN0PXaQdyjx0yJmV552bNlCGbNU s0nYI7Hwrh99TiuIyY+VURU6vrSw2apM2eCdf7J1aVWDJt/tvBQSGtThBnbOueDOR/00 fw/A== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5si1774639pgu.52.2019.02.03.08.48.31; Sun, 03 Feb 2019 08:48:47 -0800 (PST) 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728732AbfBCPbO (ORCPT + 99 others); Sun, 3 Feb 2019 10:31:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54466 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728575AbfBCPa6 (ORCPT ); Sun, 3 Feb 2019 10:30:58 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3731D8666C; Sun, 3 Feb 2019 15:30:58 +0000 (UTC) Received: from krava.redhat.com (ovpn-204-46.brq.redhat.com [10.40.204.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id C83E45C238; Sun, 3 Feb 2019 15:30:55 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Adrian Hunter , Andi Kleen , Stephane Eranian , Alexey Budankov Subject: [PATCH 12/14] perf session: Add __perf_session__process_dir_events function Date: Sun, 3 Feb 2019 16:30:16 +0100 Message-Id: <20190203153018.9650-13-jolsa@kernel.org> In-Reply-To: <20190203153018.9650-1-jolsa@kernel.org> References: <20190203153018.9650-1-jolsa@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sun, 03 Feb 2019 15:30:58 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding __perf_session__process_dir_events function to process events over the directory data. All directory events are pushed into sessions ordered data and flushed for processing. Link: http://lkml.kernel.org/n/tip-n3zl0wo3z18tatv5x7epmjrh@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/util/session.c | 86 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index b81182b7602a..38d2854cebc1 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1864,8 +1864,6 @@ reader__process_events(struct reader *rd, struct perf_session *session, file_offset = page_offset; head = rd->data_offset - page_offset; - ui_progress__init_size(prog, data_size, "Processing events..."); - data_size += rd->data_offset; mmap_size = MMAP_SIZE; @@ -1994,6 +1992,87 @@ static int __perf_session__process_events(struct perf_session *session) return err; } +static s64 process_index(struct perf_session *session, + union perf_event *event, + u64 file_offset) +{ + struct perf_evlist *evlist = session->evlist; + u64 timestamp; + s64 ret; + + if (session->header.needs_swap) + event_swap(event, perf_evlist__sample_id_all(evlist)); + + if (event->header.type >= PERF_RECORD_HEADER_MAX) + return -EINVAL; + + events_stats__inc(&evlist->stats, event->header.type); + + if (event->header.type >= PERF_RECORD_USER_TYPE_START) + return perf_session__process_user_event(session, event, file_offset); + + ret = perf_evlist__parse_sample_timestamp(evlist, event, ×tamp); + if (ret) + return ret; + + return ordered_events__queue(&session->ordered_events, event, + timestamp, file_offset); +} + +static int __perf_session__process_dir_events(struct perf_session *session) +{ + struct perf_data *data = session->data; + struct perf_tool *tool = session->tool; + struct reader rd = { + .fd = perf_data__fd(session->data), + .data_size = session->header.data_size, + .data_offset = session->header.data_offset, + .process = process_simple, + }; + int i, ret = 0; + struct ui_progress prog; + u64 total_size = perf_data__size(session->data); + + perf_tool__fill_defaults(tool); + + ui_progress__init_size(&prog, total_size, "Processing events..."); + + ret = reader__process_events(&rd, session, &prog); + if (ret) + goto out_err; + + for (i = 0; i < data->dir.nr ; i++) { + struct perf_data_file *file = &data->dir.files[i]; + + if (file->size == 0) + continue; + + rd = (struct reader) { + .fd = file->fd, + .data_size = file->size, + .data_offset = 0, + .process = process_index, + }; + + ret = reader__process_events(&rd, session, &prog); + if (ret) + goto out_err; + } + + ret = ordered_events__flush(&session->ordered_events, OE_FLUSH__FINAL); + +out_err: + if (!tool->no_warn) + perf_session__warn_about_errors(session); + + /* + * We may switching perf.data output, make ordered_events + * reusable. + */ + ordered_events__reinit(&session->ordered_events); + return ret; +} + int perf_session__process_events(struct perf_session *session) { if (perf_session__register_idle_thread(session) < 0) @@ -2002,6 +2081,9 @@ int perf_session__process_events(struct perf_session *session) if (perf_data__is_pipe(session->data)) return __perf_session__process_pipe_events(session); + if (perf_data__is_dir(session->data)) + return __perf_session__process_dir_events(session); + return __perf_session__process_events(session); } -- 2.17.2