Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp2877803ima; Sun, 3 Feb 2019 08:35:59 -0800 (PST) X-Google-Smtp-Source: AHgI3IZrHYdBfSOYvJMq2025vOT1Zwb4uEutChFU/QlUvopnWdkR7eqYXc2FgTL6Xj7+kKaKvUGU X-Received: by 2002:a63:85c6:: with SMTP id u189mr9584339pgd.156.1549211759337; Sun, 03 Feb 2019 08:35:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549211759; cv=none; d=google.com; s=arc-20160816; b=YCAsG8lInKTCqe389SW+xe0+hSFXgNmPxg0yS55hxSuM/R/i2oYw6kSXYSfRIAII9n 80ruzd2EDkcbpiqkI+Pu0gWfuwv5F3XeHe/ZRjCFrYy64z0MTXJWm5o0OmmLqRppe2f9 Qv7GyLWlr1u9qkUUZMZd4Z1E52AuMlh750eSU6xG9Cp8JvZTC8YOZULH3ROyFLqFlH9Y znWN02mO5Zz+gJ/WGYwrSRvTwdClmXjCMt2mTBIjfNb9LA2vmPtoYMiv7aZ51KQqzta9 bZaTYB7jq1nwoW7OLqDU+2CoDqO863ca/bDzx8OrMTX0SHWCk72dFvrl12ipsb/t/cEI blkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=wyDu+fwwCzhHDxSj1da7EGeHGIYDbJoOjEtMnue+N5Q=; b=QLiKCMgnAi5Ea8MP+onK2rH81JusyKiIFgoquY/ZmDEOyf61dVZSRNZoSeTtqg+syu njLSWUJz7deZBBF6OKpHg3XdYhYBcq0PKrpBNZX38JDtSmCcj/bmYmQ1CizGRUaMGCpj Fr6b0JCuvns6RYr5aToNGpkH36SAqtL0dmbDV8gx4q/vkEC4UdNAOvBNY/obO0r5QmVz dYA+cM+Q7d4cI+V8Zq1ppvgBDQ+4R/+IqrLtHveaEebsoA9wk99eI25r2ua3n7EwE4ig Q/hxviOQNeG2yRxjj8Pr7gZHn6YBdIPVb2hffPcwr3HlA1rdKxTjmXH0DmIm0aIf28Qz GrLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 6si12341132plc.241.2019.02.03.08.35.43; Sun, 03 Feb 2019 08:35:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728271AbfBCPac (ORCPT + 99 others); Sun, 3 Feb 2019 10:30:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32980 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726463AbfBCPa3 (ORCPT ); Sun, 3 Feb 2019 10:30:29 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 66A2FE77DB; Sun, 3 Feb 2019 15:30:28 +0000 (UTC) Received: from krava.redhat.com (ovpn-204-46.brq.redhat.com [10.40.204.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08F145C238; Sun, 3 Feb 2019 15:30:25 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Adrian Hunter , Andi Kleen , Stephane Eranian , Alexey Budankov Subject: [PATCH 02/14] perf session: Add process callback to reader object Date: Sun, 3 Feb 2019 16:30:06 +0100 Message-Id: <20190203153018.9650-3-jolsa@kernel.org> In-Reply-To: <20190203153018.9650-1-jolsa@kernel.org> References: <20190203153018.9650-1-jolsa@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 03 Feb 2019 15:30:28 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding callback function to reader object so callers can process data in different ways. Link: http://lkml.kernel.org/n/tip-8g1islzz6xkl36tz0z1nkuff@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/util/session.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 2012396abb7c..b81182b7602a 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1835,10 +1835,17 @@ fetch_mmaped_event(struct perf_session *session, #define NUM_MMAPS 128 #endif +struct reader; + +typedef s64 (*reader_cb_t)(struct perf_session *session, + union perf_event *event, + u64 file_offset); + struct reader { - int fd; - u64 data_size; - u64 data_offset; + int fd; + u64 data_size; + u64 data_offset; + reader_cb_t process; }; static int @@ -1909,7 +1916,7 @@ reader__process_events(struct reader *rd, struct perf_session *session, size = event->header.size; if (size < sizeof(struct perf_event_header) || - (skip = perf_session__process_event(session, event, file_pos)) < 0) { + (skip = rd->process(session, event, file_pos)) < 0) { pr_err("%#" PRIx64 " [%#x]: failed to process type: %d\n", file_offset + head, event->header.size, event->header.type); @@ -1935,12 +1942,20 @@ reader__process_events(struct reader *rd, struct perf_session *session, return err; } +static s64 process_simple(struct perf_session *session, + union perf_event *event, + u64 file_offset) +{ + return perf_session__process_event(session, event, file_offset); +} + static int __perf_session__process_events(struct perf_session *session) { struct reader rd = { .fd = perf_data__fd(session->data), .data_size = session->header.data_size, .data_offset = session->header.data_offset, + .process = process_simple, }; struct ordered_events *oe = &session->ordered_events; struct perf_tool *tool = session->tool; -- 2.17.2