Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4511733pxj; Tue, 22 Jun 2021 01:47:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3TQ4DtvU/2ff2HPCYaxdYlTAWziTR2IeNTZpx1ANnx0vfHLaND9gan5vGOVchkwlCaeRR X-Received: by 2002:a17:907:6f6:: with SMTP id yh22mr2750586ejb.257.1624351674944; Tue, 22 Jun 2021 01:47:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624351674; cv=none; d=google.com; s=arc-20160816; b=el6IipWNtIU+5hMAFRR3V6NYEnTA7RrEJOA8GAIVZ2UneU+Ur2HwtuTW1BNqwQGyrH FuwmSJ3mpyIZ7Xs9/pMsxbWwKfR0SlyaYfwLjuyrffkzkUTiefZSO1fVINtaigaNHKvi M1LeHpN+fwlFTAH2rzNv3/8rdc7dJWx7fnw+iXzlCwFkChWnnlXyN3bdnci5P1/8lukz FTxOQEuLquO5QwImqGzKoz9icD5i187ZRPVfTn/NoWk36NKs0fGrQHFANW2B6t2/Zs48 D1TShydVyUfsYsJ5zs3VLxy4o16qbXDv02+BC1PDJ759HeJwsodZSQGhrFV/nVxKrE1s +N6g== 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 :ironport-sdr:ironport-sdr; bh=rvp0sRkP8T8ymCF95mPM17nRhYd7KYA/fBbYdEPuixs=; b=Se5rcPqHB4IdHEb1dDA03oMbS9n5leRt8ly42AlV/0i1wpPkUlawBi5IOSCj8fq2+P SooCKgU1K9Ky1bP24eBw40o3PXDytA7fTPxaG7RTqE37A5i45bmY55ty1SPwYLFZMLX1 t5HeO/3pRZnz70FWUUP8qBilwlZE83vEA+0SVRA1wh2ntJDYjKjGMiJX1dLHEMPMaJsL eK3tB1ygstFAX+ehGW+8F71Nk3IHNhHS07bY3UGvQpzEwAYPc6B91J8mWxonsl9DhXui yJ3olKadCz9VER3t1KCAOou5mZogHlMZZ/WBrhRXiericx86dhnUSH9VZ2mqpm1Kz7SL +4Ng== 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 g13si2021679edb.248.2021.06.22.01.47.32; Tue, 22 Jun 2021 01:47:54 -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 S231350AbhFVIqG (ORCPT + 99 others); Tue, 22 Jun 2021 04:46:06 -0400 Received: from mga05.intel.com ([192.55.52.43]:57647 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229853AbhFVIpw (ORCPT ); Tue, 22 Jun 2021 04:45:52 -0400 IronPort-SDR: El9mRvyGe8mldJpr8zK+cvIveLEg55EkvLzW+QAvrCRj9ygmbK0uvXup9OAVV+wWhyxjxzi9UJ 31nUQqJBBS3w== X-IronPort-AV: E=McAfee;i="6200,9189,10022"; a="292641658" X-IronPort-AV: E=Sophos;i="5.83,291,1616482800"; d="scan'208";a="292641658" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2021 01:43:30 -0700 IronPort-SDR: dDbzeFcx/VJx5+6vC3IKZCvbIktcK1EJOevDyhpq9Z2CWEFOdUOxlEk+InA06mGmbS9iRVy52v cfhUkVw9XUZg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,291,1616482800"; d="scan'208";a="417332720" Received: from nntpat99-84.inn.intel.com ([10.125.99.84]) by fmsmga007.fm.intel.com with ESMTP; 22 Jun 2021 01:43:26 -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 v7 17/20] perf session: Move init into reader__init function Date: Tue, 22 Jun 2021 11:42:26 +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 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 3c89fed4f93c..2b3548525229 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -2211,28 +2211,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)); @@ -2240,6 +2237,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; @@ -2355,6 +2366,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