Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2831215pxv; Mon, 12 Jul 2021 03:02:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnqr6wLNs+audIIJzD/mnqHgUhJ/fGEINuPJjY6/FXL1T6IJSHMleEeOf3B+aS3XiQpVbg X-Received: by 2002:a05:6402:1615:: with SMTP id f21mr10581820edv.35.1626084131921; Mon, 12 Jul 2021 03:02:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626084131; cv=none; d=google.com; s=arc-20160816; b=HkQoosAZ+0MQMYnxCyMWb5h7XfeuerWulmGdtlWfcpKu9pSAt4zgrSg9nccan8un2w X/xv+SUgmPSDxRImOGLNcO+yZjo5qmMjd+YVGgK6XBfrQX4yqkH8+XOBGjDj5ULOSq4m V7s28q7qfjFAHDcx5ul2Q+M8L+16urX5Zjd/MkwtDNKw0nDQ/PhzX49BJ8PqEo9w0J73 aNwiZIBkDG7zKAZZpTwoq49xahJUOh79SB6IFfeaYWxjCWld/iNicEeiE8VYT7Uh90cd uL6EahQBL9tvVvFnkKAUDQB804XYPzDru1xtsL8/gpcQAV1hL2TpN4jvPi7g7FUnTmkf d4OQ== 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=EeBEMRED7oARTvUxzS1gPpS3Z5CiE8KWLBWQtHX+RdZuLogEe/Hcp9oS+pI/geNmLf C6yYBtqYX53HxOpUBwietySC5hwdne4nv0/4F59l6+DSf2p1ZkGWdQLw7apkglamv3TJ nwzjffzdZ09Rm2r2oQymvqGj+D0NNkdJkqYav8KI3KsDna96PhkiTfZ3ZjW7uoifQdZM 9aU/p6HLdEwrNYn/u66/difLoJmm/54z+zHt2p1i5bwiZIIeyv8T0KlX6mHIAV6QAUbM IBWf4v7os4PXt/xWHi4vpYs+Pm0R8gDxPNcATiwWrE7EVIec0REqZuGQzlSs3lfXoQ8p Nk8g== 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 k14si6447770ejx.722.2021.07.12.03.01.33; Mon, 12 Jul 2021 03:02:11 -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 S243068AbhGLHPH (ORCPT + 99 others); Mon, 12 Jul 2021 03:15:07 -0400 Received: from mga03.intel.com ([134.134.136.65]:25899 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240108AbhGLGuq (ORCPT ); Mon, 12 Jul 2021 02:50:46 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10042"; a="209973432" X-IronPort-AV: E=Sophos;i="5.84,232,1620716400"; d="scan'208";a="209973432" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2021 23:47:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,232,1620716400"; d="scan'208";a="491916390" Received: from nntpat99-84.inn.intel.com ([10.125.99.84]) by FMSMGA003.fm.intel.com with ESMTP; 11 Jul 2021 23:47:41 -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 v10 21/24] perf session: Move init into reader__init function Date: Mon, 12 Jul 2021 09:46:21 +0300 Message-Id: <68c2f137a3e5ba6c8e4cca8248911a5bbfc513d4.1626072009.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 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