Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1014826pxb; Tue, 17 Aug 2021 01:29:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzN9S9qCR41PW/yG/JKMu2xd06/Mcbs/R1zuaL1byqmekGqs4bTeniVahnitvIlrhVQNOi4 X-Received: by 2002:a05:6402:1c03:: with SMTP id ck3mr2894800edb.312.1629188989683; Tue, 17 Aug 2021 01:29:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629188989; cv=none; d=google.com; s=arc-20160816; b=fkI2+xHZwySk1bZ8A0fHDpMjsPfpbu1Kk1aFTuouYUlq3jlB7wdqOWLjIreEqeKejx EDrPg72FcJYChKII0yo18+4CnQO0HcZDyeVaef/9Y0AVBqq5R/VnPI87VbLv9rJnmvOG ZrXFqsAI0MOLTie5SrHpigfHni+q3earO9WEZpk68BrRDI2ZOsdLHh2FIaJx9xlRbC41 czZOEAIKzif6DYsbu29oSbdgR79e2L9JBeQ/oUJ9AyDGkZDgkIuPBko4IygLnJ31Qu8S /rtTKCQj+RiE8e3hhoMwCYShS8UPvzZryt7f7/dExz5uCi60FDfFw3R95Bw7/xb3EW8B angg== 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=dnTLHLoWdX35bMV5BaFFoqoPeUT93O5YAdiUykZmUU0=; b=YPPRWIeflpfp7pL6sTPl6d4aL8hhOn0jZnP75dx4hHuR5Ellkaay4to53oOakVgBF8 YPS/xNsWKbmTw/dbYWxEgzhGQMV5Vkh4l54n+jxpvCYzzrirA1j3w1MTAdaiQ5fif8Ap Ubu1FTuqFKgDGp7bT0h2Su1Q4YHDQTtrnyXxNO/o+6sJXtktO49YxkhH6OVqupQaRjdS GfzFm+1fdLiTPgesSRrsmXgXTkH5581JGdUhxM6tAvT9JKrHqZeKNkNRH8CqleVlUy18 xqLg5BWvihh3foU4dACnd6gDx7MGZSEw9aNNxbhBQ//NwUwjzMeHebPfs39opuOvyzsq P7ng== 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 nd38si1578217ejc.558.2021.08.17.01.29.27; Tue, 17 Aug 2021 01:29:49 -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 S239694AbhHQIZn (ORCPT + 99 others); Tue, 17 Aug 2021 04:25:43 -0400 Received: from mga04.intel.com ([192.55.52.120]:18151 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239381AbhHQIZL (ORCPT ); Tue, 17 Aug 2021 04:25:11 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10078"; a="214171969" X-IronPort-AV: E=Sophos;i="5.84,328,1620716400"; d="scan'208";a="214171969" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2021 01:24:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,328,1620716400"; d="scan'208";a="471080433" Received: from nntpat99-84.inn.intel.com ([10.125.99.84]) by orsmga008.jf.intel.com with ESMTP; 17 Aug 2021 01:24:35 -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 v11 21/24] perf session: Move init into reader__init function Date: Tue, 17 Aug 2021 11:23:24 +0300 Message-Id: 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 Reviewed-by: Riccardo Mancini Tested-by: Riccardo Mancini 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 ed41bccb15ff..3cb1691483f3 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -2216,28 +2216,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)); @@ -2245,6 +2242,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; @@ -2360,6 +2371,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