Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp440086pxv; Wed, 30 Jun 2021 09:01:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxetLIaYJS/h8/x0aHz0OzTgQ+cRbxausDYO78u82IEzafGBkZtXENtAx0wKVC3NDddI78s X-Received: by 2002:a50:d64a:: with SMTP id c10mr49105326edj.199.1625068911353; Wed, 30 Jun 2021 09:01:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625068911; cv=none; d=google.com; s=arc-20160816; b=Dt3iawYDWUq8MQKyZ31+w3kwkbNdbMbe2bDasA107yK7VcmAEF+9C6z/BQ9/mcMTug oNHqBzVpsGUD/klyMuc2nqHVhqcv1Ch30JhG0TrpG5LxDhQHw39VEES+LvrmjgK//vnr vBsqHtH2mkiqzQfirQgC/IyzNY6RQDxsBI59p3gtndvhMincBF9/jPDGom/gYXMP3+1/ ZVdLtloXUXs/7DPzoRwljgOADLv5hXNSpH+Yy4ExAX75anp+hOEaiEf8Iufj6h+G5aoJ 9q6FgGWSqIqVB+1aHLb/wIR/Udg/Cz7+d/bkppQ8QvvhkVJU/4MniTc4UDkTlgoctQ5H RBEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=m0h4/QHuRTUHbKC0TqBpyp0rQhhlWiS8f1sHohmILIU=; b=RIJeXM98lwdbRPCgzyid31xXp9XNNr8f1+ccW9XWQ14Jswo36S76OgQ3yA8C/llVma TKfbumMVt0bBUY2unqPXzG4k2M0xMG8WZ8lZHJcBUTmE/hpOouNlcS15WLswELwv1y2Z c5EShwqTA4a4JtfTFFli80fhtjs+XEjW1eiFkRuWW46A1/K28i6no8LJeZIaUNcMjhP+ TLFYjiMN+qxTFQq4TZpSq/b2Q3E9rA8YgeH3OdIMR/dUUU0Ya08MQ8kRV9AqQEgnuu/J XMfkmN2KDXx86W99ksMzpRn1MwaZnOBmqucrBd12TAbLoYG8Sep28WICT4XFa/XJfZmf 8ZPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nd1si3289992ejc.483.2021.06.30.09.01.26; Wed, 30 Jun 2021 09:01:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236206AbhF3QBw (ORCPT + 99 others); Wed, 30 Jun 2021 12:01:52 -0400 Received: from mga01.intel.com ([192.55.52.88]:4069 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235933AbhF3QAn (ORCPT ); Wed, 30 Jun 2021 12:00:43 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10031"; a="230016025" X-IronPort-AV: E=Sophos;i="5.83,312,1616482800"; d="scan'208";a="230016025" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2021 08:56:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,312,1616482800"; d="scan'208";a="559099829" Received: from nntpat99-84.inn.intel.com ([10.125.99.84]) by fmsmga001.fm.intel.com with ESMTP; 30 Jun 2021 08:55:58 -0700 From: Alexey Bayduraev To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , linux-kernel , Andi Kleen , Adrian Hunter , Alexander Antonov , Alexei Budankov , Riccardo Mancini Subject: [PATCH v8 17/22] perf session: Move init into reader__init function Date: Wed, 30 Jun 2021 18:54:56 +0300 Message-Id: <43edda148c2e91fad81353cf6c34ee8725f8090b.1625065643.git.alexey.v.bayduraev@linux.intel.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Separating initialization code into reader__init function. Design and implementation are based on the prototype [1], [2]. [1] git clone https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git -b perf/record_threads [2] https://lore.kernel.org/lkml/20180913125450.21342-1-jolsa@kernel.org/ Suggested-by: Jiri Olsa Acked-by: Namhyung Kim Signed-off-by: Alexey Bayduraev --- tools/perf/util/session.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index ab243010148e..578ff304fdb4 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -2212,28 +2212,25 @@ static int __perf_session__process_decomp_events(struct perf_session *session) } static int -reader__process_events(struct reader *rd, struct perf_session *session, - struct ui_progress *prog) +reader__init(struct reader *rd, bool *one_mmap) { struct reader_state *st = &rd->state; - u64 page_offset, size; - int err = 0, mmap_prot, mmap_flags; - char *buf, **mmaps = st->mmaps; - union perf_event *event; - s64 skip; + u64 page_offset; + char **mmaps = st->mmaps; + + pr_debug("reader processing %s\n", rd->path); page_offset = page_size * (rd->data_offset / page_size); st->file_offset = page_offset; st->head = rd->data_offset - page_offset; - ui_progress__init_size(prog, rd->data_size, "Processing events..."); - st->data_size = rd->data_size + rd->data_offset; st->mmap_size = MMAP_SIZE; if (st->mmap_size > st->data_size) { st->mmap_size = st->data_size; - session->one_mmap = true; + if (one_mmap) + *one_mmap = true; } memset(mmaps, 0, sizeof(st->mmaps)); @@ -2241,6 +2238,20 @@ reader__process_events(struct reader *rd, struct perf_session *session, if (zstd_init(&rd->zstd_data, 0)) return -1; + return 0; +} + +static int +reader__process_events(struct reader *rd, struct perf_session *session, + struct ui_progress *prog) +{ + struct reader_state *st = &rd->state; + u64 page_offset, size; + int err = 0, mmap_prot, mmap_flags; + char *buf, **mmaps = st->mmaps; + union perf_event *event; + s64 skip; + mmap_prot = PROT_READ; mmap_flags = MAP_SHARED; @@ -2356,6 +2367,9 @@ static int __perf_session__process_events(struct perf_session *session) ui_progress__init_size(&prog, rd->data_size, "Processing events..."); + err = reader__init(rd, &session->one_mmap); + if (err) + goto out_err; err = reader__process_events(rd, session, &prog); if (err) goto out_err; -- 2.19.0