Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1506310pxv; Fri, 2 Jul 2021 05:36:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyazfPIHp6XAuUyy8NAIpulw71uENeQg12yPkV7DhayfL6qoAde+DMcrVrq0MMicZUmrB/L X-Received: by 2002:a05:6402:849:: with SMTP id b9mr6513204edz.270.1625229367192; Fri, 02 Jul 2021 05:36:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625229367; cv=none; d=google.com; s=arc-20160816; b=CWZ2tuG4H3NzE3FtUnEFi5naASNUBY3pz4eHB8IM9fwtBSopyw6yCMF3mns08gLW1x osw2qet5y6z9K2VVvq8A9nK7d2LJQawu86woXTDql/robmyP9+CpycCGdL1T6lx/73Fr jP4/4tNOsMfC+ulmX5mkBcVR2Nf9m8ozheuc7gsqUkL1fdHaQj5Hu5KZptUcycFoBcKL 0C4rOZ8KsOgU9Pmzmh5qUGdxLJKTqN57ts9uqdo+2ZJ6ypoau0VrnRy0C/nZmYIeoUia NWfF+PelJvPprT6Cuz8AbMWQMFjnkaEIZZXKzv6VfgoFOtUUBOphdutxGR8U5IEbo3Py e8PQ== 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=RAV9nLDEVFjw3Bv9zKFH7spjN3aZAO4PvK+SDBWd55w=; b=QYjnGAnsGannIYdWUyikErksAY3/jXCXsb6OFuagiR3KiQ7k1NzP0VopLcorrPYoHW 2v0mlhyUAWe3pSr4R/CLGfjZSIqgI/R91Ho5xR7ZA3IXOXwNqrmfjm/eJLQ5e7Q58Q94 qkpG2aV/ouX2l45UIZjl9qMlsSaFUdjXQXiPRc7ZHbe6aCpRREf7+FLvkGghUSK1d1oT 8+CqnELxv/69Pf9gmYz0wg/zmWEORwreTFQva1AzjASBP2821mh/IkBs1MHKKsVK/h0u DwBkg5/6V1UZ8C+ouIuLU9633kAnK+cq8m1PyyOLRe87W+gWXtE2eqCxZnYu9GfnPeyK 1zXw== 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 z5si2658831edd.58.2021.07.02.05.35.44; Fri, 02 Jul 2021 05:36:07 -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 S232502AbhGBMgQ (ORCPT + 99 others); Fri, 2 Jul 2021 08:36:16 -0400 Received: from mga17.intel.com ([192.55.52.151]:32637 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232512AbhGBMgN (ORCPT ); Fri, 2 Jul 2021 08:36:13 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10032"; a="189107345" X-IronPort-AV: E=Sophos;i="5.83,317,1616482800"; d="scan'208";a="189107345" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2021 05:33:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,317,1616482800"; d="scan'208";a="642660346" Received: from nntpat99-84.inn.intel.com ([10.125.99.84]) by fmsmga006.fm.intel.com with ESMTP; 02 Jul 2021 05:33:38 -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 v9 21/24] perf session: Move init into reader__init function Date: Fri, 2 Jul 2021 15:32:29 +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 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 2a0d3b3fd979..f25f5f33bec1 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -2214,28 +2214,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)); @@ -2243,6 +2240,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; @@ -2358,6 +2369,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