Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3375501pxy; Tue, 4 May 2021 00:08:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJfbH6qozlD055jcYTCgD6a0NUhERrmhbejq0+6HYfN2CrdGE2hY6KEbz8uDXfARxbtcT/ X-Received: by 2002:a17:902:da88:b029:ee:cd32:808e with SMTP id j8-20020a170902da88b02900eecd32808emr12094457plx.15.1620112108353; Tue, 04 May 2021 00:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620112108; cv=none; d=google.com; s=arc-20160816; b=07H7z0gMQgb1On+oOHkv4HiJaFWM5q9r9zak7AOjs1Xb8AsS7pHf5dPYYBrYpkIRA5 +SwFtmGCl+l3ztBhHyeF0D/5YfDcllo3/PBpAbZmq2d7so/BxOF9I4Ha4BaLhY6tR2jI VTttkW0n+deOe/zjqqOifB+5BgqirGOvyz+8YFQsjKdcensr1nT7ryVrbV2oKjWWBuuC FnYpjWf3++LuZ3+D9sXCct3kYqiqqQI//wj4qWqFl4oi0ZrS6tTpimmZiPe/769KYmQ2 UVSH4LBoMpk9OJJbV7tnlFrjfHJ6lslAjRGifwloCUdhEZYvpCskwNJvG6e1IlJGu0su daUA== 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=kzyMitkXD78s4JMAnCqKYaVDQsy4PAZG2HGeeaemRmo=; b=rH1i7BpAdbSJ1U1BBogmD7TUzekKN5aN+tuOX3P8Bee7vLOcVSU/a1T2buG0o40v/k 6yF97j7TY5m9iv00RslgZ6kwEOppF++Lfh5jrmwW95lKUK3VG7Mb493S67NUvLi6uz0E sjZQiK6Jl611eiFI3W1Ik6+8xHz8cnLem7cz6BewrxOs6WEXZbyK8O6BETexyNzo3CuN rwqN7e+POzahyyi6erhse+HibOt5oe3pgqWkDGYDHVsiQLU5JZgHUdD4ddFKMw0cDg3o BA4w3Z2hWiA1Y9vWNToupzACuhAZ3gftiBRsnim82mjgrri0+UwckMcx2pZEG8xWTGEo eArw== 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 gj1si2372352pjb.64.2021.05.04.00.08.15; Tue, 04 May 2021 00:08:28 -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 S230145AbhEDHHo (ORCPT + 99 others); Tue, 4 May 2021 03:07:44 -0400 Received: from mga03.intel.com ([134.134.136.65]:37661 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230015AbhEDHHY (ORCPT ); Tue, 4 May 2021 03:07:24 -0400 IronPort-SDR: mhal7IoFPOBhJCwl1i92sgBBXLbbl+D/+IaHHKSKOfoz74kNImI7OF21qKxytCrbttJ+UHd5qd pAi6g8aMolSA== X-IronPort-AV: E=McAfee;i="6200,9189,9973"; a="197971035" X-IronPort-AV: E=Sophos;i="5.82,271,1613462400"; d="scan'208";a="197971035" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 May 2021 00:06:18 -0700 IronPort-SDR: 1J5YtLS4f0oS4pvKBX248SnNH+3Wba/83+6pdPLJJuS4FRij8LCxUa39SCwQt4CLxH4YHZVtWu 7LWKL+i4nPOg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,271,1613462400"; d="scan'208";a="450895737" Received: from nntpat99-84.inn.intel.com ([10.125.99.84]) by fmsmga004.fm.intel.com with ESMTP; 04 May 2021 00:06:11 -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 Subject: [PATCH v5 17/20] perf session: move init into reader__init function Date: Tue, 4 May 2021 10:04:52 +0300 Message-Id: <753d1244e8d3151075adbea5f7d0d9c4000b34cc.1619781188.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 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 81214052b2e3..08447376fa92 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -2207,28 +2207,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)); @@ -2236,6 +2233,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; @@ -2348,6 +2359,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