Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5140922pxj; Wed, 26 May 2021 03:57:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyP51Bdgv/gVQ4SzPksS2de6Sc1UIV9nPrGXTZwvI4q/E+7jv0jjkyHZmBp2hV63gEI5hbt X-Received: by 2002:a17:906:b1cc:: with SMTP id bv12mr32578636ejb.407.1622026638620; Wed, 26 May 2021 03:57:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622026638; cv=none; d=google.com; s=arc-20160816; b=Z9fG86wS8RFEHtj8MXS5ruiGewe3T4HdZ4yZy3EQHBpsoIaUCohEXSq1w5TPOgKqCi WsGWk8i/yzk7CqHwGLKMlBTNq+o45PzPD2D0bjwDfyB96aneBmR2UWbYUfJkaGsBmfdg M/O8JApJEbgCsLDv6w9QAchn2AYPDmYFbj0shEmq0EzHY5cE5GKF2ZNaL9kQ+XqiDYfo B48f3GdcRm5l281/AlYbdFsatrxCeUS1HoiaEa1rQNMT/lUDInpF/NQ4mU1NDvxKant2 +aWp60GwgiUQXYvkdSlrhnXiEfyNpj/us4SmM/0wZXVhA8JGBPJHdLQlbO2sLW8woejw 7EsQ== 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=sJdXSk6GBnbfclVywklOi1VEIrKl7C2tpJhJKvgPMw8=; b=ZQ/+Joc0FcXy28irqdMO0ONpuhxdqWri9UY6MsbIIEQD8teepTdiEG0PWm/BOAvBoo CtC3OK/NciUgQwZXKoEsbgRSMxZ/k6tymfv1AtNrN/HIgL+hpTDf6c8KJxyYZg1ZBV8/ dOw0d0yEB+GLkyg2ALDlr7Ht6uXdpiB6ZAkDAmzsTseKtEj16oTRz6IWcYDVRqitZzxJ 1rx8m1nrBWi2XX7/gx7r86v1ZO9ptqcrhnZoEgGP7Gvck+kyarIWzWc8ahCkdgOMslmN n/Y9/hLPEKyksv5P/xV64I8+ZRm4HYr/nphtGob6dNeDPijJ+6CniHIFBXLOLuJ5nk6L Ddng== 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 q26si18354401edr.164.2021.05.26.03.56.56; Wed, 26 May 2021 03:57:18 -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 S234385AbhEZK4y (ORCPT + 99 others); Wed, 26 May 2021 06:56:54 -0400 Received: from mga02.intel.com ([134.134.136.20]:1593 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234378AbhEZK4b (ORCPT ); Wed, 26 May 2021 06:56:31 -0400 IronPort-SDR: ECGA6QE7WLAefZVa99Ja6p6HOlDEYVqJHiR34Vosrfo+nZCynqrVSPCxdk5SE5JoXmC9WDUBLY +2sDcl4KeKWA== X-IronPort-AV: E=McAfee;i="6200,9189,9995"; a="189556525" X-IronPort-AV: E=Sophos;i="5.82,331,1613462400"; d="scan'208";a="189556525" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2021 03:54:10 -0700 IronPort-SDR: lH2Z29gOAbOgysE8EWb0B8EweaRPUyoO4KDZEE9HwOxgDFKhAJUfiDjU6+sKqM6HIYjbgw1nJz c3XkdmkBp9FQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,331,1613462400"; d="scan'208";a="436079419" Received: from nntpat99-84.inn.intel.com ([10.125.99.84]) by orsmga007.jf.intel.com with ESMTP; 26 May 2021 03:54:07 -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 v6 17/20] perf session: Move init into reader__init function Date: Wed, 26 May 2021 13:53:10 +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 6c9a682eb291..b63d28554ad2 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -2208,28 +2208,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)); @@ -2237,6 +2234,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; @@ -2352,6 +2363,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