Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1221142pxb; Thu, 7 Oct 2021 03:27:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUR3qx8QcZ2O2bkWnOyDDry6NonJsvMkgU0m09IDWxIiJc+bs6OV8FfGiuCyapRDyn4vGN X-Received: by 2002:a17:90b:3901:: with SMTP id ob1mr4573501pjb.12.1633602470252; Thu, 07 Oct 2021 03:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633602470; cv=none; d=google.com; s=arc-20160816; b=ln3blu4U61QeM1AVS5fycv9rrx1z32aCMxf2eLfM+njFt40F823CB/1YYYqz+rMW/3 6FkM2/rUqrYPRcsTiPNTzureQ4hXMv9EQkD4oWBoXpe3sdxxvZ2RtwF4rv901q/T3tlc SyH3iSPGc1x36pJvHlchq6OyA5JXB7q4iB2JbGVHujzm40eYEgSy0VCFCwOmj45eBW0c DI6QFwHzjrpEw3x4FjzuNzDLUu4JjPymURMsTsElPgzeWEMD7OVJ5/bqM7zVn5rIn1Ik 18x7vIeHToBNNJUm0XK8Jn3+4K7LI1cK1QLB16iIn3A9gV3LkvoJT+VxYZ8PJWhLnQ2f pZ4A== 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=AOQ/JghsezZs7Ufny6M2pOAmmpkrJ9huale32/MKLVk=; b=o+bd8iu76QZDNsDklxkpDwbTlHGariiIs9ZQvRf79KWMBPkmPlTmiLqqDkhkMqISVK NjccaRFXNgQ39PnGTMysEtUYybb9NwzsYm9dOIUM/WBSzZOMxkN7dxJqFpxQnUq8KEI5 Fr4REJXSUVmT9Zmn208f93zidoRF+W7c2i4o0qESY0kRRayGxxq3fdvvxf+0QXhefvV2 RNSlTI47AfHDCo4EtA9F6o5Fe+7EN/UNP8BR4L2HmOVwxIR0I1sjHijclvMg/I75i9PC UeL8ksQrBzwIDUHGunCoJin7XpG0bGjF8yA8+KbAEMhV4ncGroJlkJGKrl5+FNrMhemp tmng== 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 e4si2335293plh.392.2021.10.07.03.27.37; Thu, 07 Oct 2021 03:27:50 -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 S240920AbhJGK2G (ORCPT + 99 others); Thu, 7 Oct 2021 06:28:06 -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 S240899AbhJGK2B (ORCPT ); Thu, 7 Oct 2021 06:28:01 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10129"; a="249532674" X-IronPort-AV: E=Sophos;i="5.85,354,1624345200"; d="scan'208";a="249532674" 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:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,354,1624345200"; d="scan'208";a="657335528" Received: from nntpat99-84.inn.intel.com ([10.125.99.84]) by orsmga005.jf.intel.com with ESMTP; 07 Oct 2021 03:26:04 -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 6/8] perf session: Move event read code to separate function Date: Thu, 7 Oct 2021 13:25:41 +0300 Message-Id: <6ab47325fa261deca4ca55ecacf1ca2437abcd78.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 Separating reading code of single event into reader__read_event 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 | 44 ++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 6289fcafdc86..6b255b0b23e0 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -2259,31 +2259,21 @@ reader__mmap(struct reader *rd, struct perf_session *session) } static int -reader__process_events(struct reader *rd, struct perf_session *session, - struct ui_progress *prog) +reader__read_event(struct reader *rd, struct perf_session *session, + struct ui_progress *prog) { u64 size; int err = 0; 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); if (IS_ERR(event)) return PTR_ERR(event); if (!event) - goto remap; + return 1; session->active_decomp = &rd->decomp_data; size = event->header.size; @@ -2311,6 +2301,33 @@ reader__process_events(struct reader *rd, struct perf_session *session, ui_progress__update(prog, size); +out: + session->active_decomp = &session->decomp_data; + return err; +} + +static int +reader__process_events(struct reader *rd, struct perf_session *session, + struct ui_progress *prog) +{ + int err; + + err = reader__init(rd, &session->one_mmap); + if (err) + goto out; + +remap: + err = reader__mmap(rd, session); + if (err) + goto out; + +more: + err = reader__read_event(rd, session, prog); + if (err < 0) + goto out; + else if (err == 1) + goto remap; + if (session_done()) goto out; @@ -2318,7 +2335,6 @@ reader__process_events(struct reader *rd, struct perf_session *session, goto more; out: - session->active_decomp = &session->decomp_data; return err; } -- 2.19.0