Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1221375pxb; Thu, 7 Oct 2021 03:28:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYvAr3B1cX32sLQjRt/4ncOZDrBeKvR2Eb2JUQa9Y4LdcX7i3RBoBrVwPf46JAliJi4y3U X-Received: by 2002:a17:906:1299:: with SMTP id k25mr4656228ejb.139.1633602492436; Thu, 07 Oct 2021 03:28:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633602492; cv=none; d=google.com; s=arc-20160816; b=mTNR0yZfJ2Zt7TM6cEOtn61duwwezYy+EB8LH8g0pjYLHEqg++zMDcBb6aPo2jQ/c/ xOjwqEeboF2q4ZGGQeAmz9eBDqNNNfY47d8ZUIMyo1BuSYazitMDvVDY79OcdYEI4/aD Zudg9Ex3D7rdcJOOwfwHhE61yqTREBsjXt1YHuEdl2rzi2YrHgwar3pO1FoIQ6BfBHnU KUascVkiiqfVuJDQx2mvt+w2ppLVbw46dnAEnNCzgVX3t1BzBIe4J0rHXDcrHlR576+w YPUV7IvMqvJBNSQkw0erdZ26Hn/0t0o4F9GCnmRDF+Z38uAJS0+VbeGbM+F6MoVj8cuH OUnw== 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=A33fLrMYCk5filIzkKlRb8wv+POhhhfK3Q2IfRQgFqQ=; b=OwOUezcLNnBNGGUCnLicMt49dzSf+HOj3pYTikpxyERCVOxQBfxiwFgREyInS+74CV JqdRb6Zqd4riG67xxZIKAIZOxgx0B68TuoL8R5WirPxaT6kLT5ElxhTrkGIJuBqjV00w XE2VdPylbEMZ4EJXz8BeerKTyEC80/vNDctDhXRZBdVY+bF/Q9URhiuGFSUI51H3/C0g h/RZD3VjpLDp/Hk7m8nA6mxgOQ3+UfvNnzItM7cZ7EedcnRZ7WPAa8m4ucVhMIVkfeMJ Mo7Rxs9qHrUgMmYbxuUVfaLyOYzpL3+7rgHzMxlBs13SYIzLlET31ghxIKOiG26/hIbh GjGg== 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 k8si1413751ejz.181.2021.10.07.03.27.47; Thu, 07 Oct 2021 03:28:12 -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 S240910AbhJGK2C (ORCPT + 99 others); Thu, 7 Oct 2021 06:28:02 -0400 Received: from mga01.intel.com ([192.55.52.88]:3735 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240894AbhJGK2A (ORCPT ); Thu, 7 Oct 2021 06:28:00 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10129"; a="249532664" X-IronPort-AV: E=Sophos;i="5.85,354,1624345200"; d="scan'208";a="249532664" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2021 03:26:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,354,1624345200"; d="scan'208";a="657335479" Received: from nntpat99-84.inn.intel.com ([10.125.99.84]) by orsmga005.jf.intel.com with ESMTP; 07 Oct 2021 03:25:57 -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 v3 4/8] perf session: Move map code to separate function Date: Thu, 7 Oct 2021 13:25:39 +0300 Message-Id: <7e4309ecdbb54fad42b75ae68e474b17a1f40b07.1633596227.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 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 | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 00417b0d29ec..36faa2d598b2 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -2220,18 +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; mmap_prot = PROT_READ; mmap_flags = MAP_SHARED; @@ -2242,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); @@ -2258,6 +2249,28 @@ 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; + +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