Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3253298pxb; Wed, 13 Oct 2021 02:09:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2s1jynVIaEhr4Qzmp2R4ySN7gO7ZGfGGqKM2sSAHCDQMWMWOMCmMxRf8RiAFEmlGHLYng X-Received: by 2002:a17:906:26c4:: with SMTP id u4mr37764364ejc.511.1634116175648; Wed, 13 Oct 2021 02:09:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634116175; cv=none; d=google.com; s=arc-20160816; b=aq00siBrqEQMY+Uty1uT0oK7ZervnBL23+3GMvamr3YxeDaSqLU34LwfqK8lR+1DuT QvPhiGiej4/TRZfIMW5ONpbGuzloc9Y6qcTOUZ768oDKHwhk8Y9FJOwVYVy9j5lPukHD BaOEUdOvHYvc4QdDLq7KMvQvzMKFGcL4dhZGQK37VnfvGMK+LYbveGBLKoI1TDXLyy1N JGYkSub3Gpt97Eup4xEsoQXVFeahdLl0auWaG6YOeJ+moStZLYg7f9ki4wq1rSuBbaRl PuuxFlUsrTH3aYnjhOe/tcYuaGdUrBeK2zUei+GpfxHCZdt4woKRq4dGdT4fFnEb/Gnp Jd9Q== 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=96Plr+KAvlpIhSfQ2xJovGrctGhFq45o8cod+P2Nsyw=; b=U8CNjsLfowiI3I5BVXXNzo0GX5k2b31YeyyogA9MqL4bkZR5McH/HKEvBTNVpYvnkQ YMQ99gqiwrMlGRr8fsfoc8/uh8qEtn9GQcomGM8kstCEl2AjufUNhznaY1Gue7hrsz77 EbeLu1jHpHXSxmyjH/OCtBlS3e35OQVZPRpCn86ULlwnLT096a2SpAMlWAqeRvpfar8n 2UL3x+gNJkUkx9QDLyQbRbIF/ysZ8zVrXx/OTnPuM+VrfqTAVpe5iIQQti3TMsNmc4/8 /aMZT17mCneRAQNOt2rP3RrgHPZMfqoGR3zpvZ34AuNMXrM80eqyESXrCzdsWVrD84Dt sD2A== 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 d13si21142335edo.317.2021.10.13.02.09.12; Wed, 13 Oct 2021 02:09:35 -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 S239017AbhJMJJ0 (ORCPT + 99 others); Wed, 13 Oct 2021 05:09:26 -0400 Received: from mga07.intel.com ([134.134.136.100]:48244 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235203AbhJMJJZ (ORCPT ); Wed, 13 Oct 2021 05:09:25 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10135"; a="290877020" X-IronPort-AV: E=Sophos;i="5.85,370,1624345200"; d="scan'208";a="290877020" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2021 02:07:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,370,1624345200"; d="scan'208";a="460706000" Received: from nntpat99-84.inn.intel.com ([10.125.99.84]) by orsmga002.jf.intel.com with ESMTP; 13 Oct 2021 02:07:03 -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 v4 4/8] perf session: Move map code to separate function Date: Wed, 13 Oct 2021 12:06:38 +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 Moving mapping code into separate reader__mmap function. Suggested-by: Jiri Olsa Acked-by: Namhyung Kim Reviewed-by: Riccardo Mancini Tested-by: Riccardo Mancini Signed-off-by: Alexey Bayduraev --- tools/perf/util/session.c | 43 +++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 396f8279757e..50258319bb26 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -2220,20 +2220,10 @@ reader__release_decomp(struct reader *rd) } static int -reader__process_events(struct reader *rd, struct perf_session *session, - struct ui_progress *prog) +reader__mmap(struct reader *rd, struct perf_session *session) { - u64 page_offset, size; - int err = 0, mmap_prot, mmap_flags; + int mmap_prot, mmap_flags; char *buf, **mmaps = rd->mmaps; - union perf_event *event; - s64 skip; - - err = reader__init(rd, &session->one_mmap); - if (err) - goto out; - - session->active_decomp = &rd->decomp_data; mmap_prot = PROT_READ; mmap_flags = MAP_SHARED; @@ -2244,13 +2234,12 @@ reader__process_events(struct reader *rd, struct perf_session *session, mmap_prot |= PROT_WRITE; mmap_flags = MAP_PRIVATE; } -remap: + buf = mmap(NULL, rd->mmap_size, mmap_prot, mmap_flags, rd->fd, rd->file_offset); if (buf == MAP_FAILED) { pr_err("failed to mmap file\n"); - err = -errno; - goto out; + return -errno; } mmaps[rd->mmap_idx] = rd->mmap_cur = buf; rd->mmap_idx = (rd->mmap_idx + 1) & (ARRAY_SIZE(rd->mmaps) - 1); @@ -2260,6 +2249,30 @@ reader__process_events(struct reader *rd, struct perf_session *session, session->one_mmap_offset = rd->file_offset; } + return 0; +} + +static int +reader__process_events(struct reader *rd, struct perf_session *session, + struct ui_progress *prog) +{ + u64 page_offset, size; + int err = 0; + char **mmaps = rd->mmaps; + union perf_event *event; + s64 skip; + + err = reader__init(rd, &session->one_mmap); + if (err) + goto out; + + session->active_decomp = &rd->decomp_data; + +remap: + err = reader__mmap(rd, session); + if (err) + goto out; + more: event = fetch_mmaped_event(rd->head, rd->mmap_size, rd->mmap_cur, session->header.needs_swap); -- 2.19.0