Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3254154pxb; Wed, 13 Oct 2021 02:10:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUFsAzpQTgZbdzQ5Xuv+7OeRNbFw5JxPRzae8VIG2m1rTmYYLR5NlzZ0lFzYz+tr+zRJ/G X-Received: by 2002:a17:90a:9289:: with SMTP id n9mr12072126pjo.27.1634116217933; Wed, 13 Oct 2021 02:10:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634116217; cv=none; d=google.com; s=arc-20160816; b=DLM9sRPJalZHY4NnIcwX7OYa9o/L7IKjgRPwnjovVS5f8vEL5Wft4+he0u3ClAUrmg WWU7RWqE68kXTOWgcRQ1b9+9sYSvnPjsH/B3VgYFB1Df+ZabJV+/XMuYC2Vf1dC89Qgc Iryxn4jUat5zg30BEIXtjq7Dim/P5LBf+upb6JleQnlCh4RIEBGlhJeGL4m+juMscpwh NRjkHkTabj3hfR6NJOzeM5AGzbiiYBq3ELJmQzfucdAVckGmOIBrldT2yZi8NPU6OajX XO+uapZ1HVi2O5Z+SWzUKbQJ9NVVs7f1RyUf+m1kq2rkraj14ONZhfwqh+IvfOSvmZVu MNAg== 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=fUjwzPRFQB0eRx8WL4DIU8kuojG8lbalbmUz/86vxWo=; b=Pg02g/EHcrBz0IXQK3oIzXS729yFNi/kUzLHthTImLkYO0M8KnFhtroXOdvDSCLVXG WhPDIoBIwBK7SQiMkw0SodOuDUJkf77LaXREg3lKDgdiFRIPRF1JNmwaERTE7V8qfMcu dpYE+QIBjtf8KQyp4VclOZBmT216vZkxrFzbgL3ieceUdOYn9+z2wgEPqcHfsd6D2+jE FiJte6blpbO3+tcr6bmieXN96t9JD5IaaxldaejydBw7diCScvOYWE3xahCh0UvrJcfA FwYVr7VAW7b4i30WpY4HuGS+vw+zzfidJ+JzLdlpcru8m8qwVubwK6awVoXAgn8DBQFQ VyQQ== 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 g187si3553783pgc.477.2021.10.13.02.10.04; Wed, 13 Oct 2021 02:10:17 -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 S239032AbhJMJJ1 (ORCPT + 99 others); Wed, 13 Oct 2021 05:09:27 -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 S238895AbhJMJJZ (ORCPT ); Wed, 13 Oct 2021 05:09:25 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10135"; a="290877026" X-IronPort-AV: E=Sophos;i="5.85,370,1624345200"; d="scan'208";a="290877026" 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="460706033" Received: from nntpat99-84.inn.intel.com ([10.125.99.84]) by orsmga002.jf.intel.com with ESMTP; 13 Oct 2021 02:07:15 -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 6/8] perf session: Move event read code to separate function Date: Wed, 13 Oct 2021 12:06:40 +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 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 | 46 ++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index d7b008837fd6..68d130fe51c2 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -2259,33 +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; - - 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); if (IS_ERR(event)) return PTR_ERR(event); if (!event) - goto remap; + return 1; size = event->header.size; @@ -2312,6 +2300,34 @@ reader__process_events(struct reader *rd, struct perf_session *session, ui_progress__update(prog, size); +out: + 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; + + session->active_decomp = &rd->decomp_data; + +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; -- 2.19.0