Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2831636pxv; Mon, 12 Jul 2021 03:02:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQ2ijZtgVtl/xRioNw2QUpL/S1/nNOCIV4G5FbdKxlej1DCRU0hMCQ3Y6jB3Kst0Ay/922 X-Received: by 2002:a6b:f41a:: with SMTP id i26mr38548984iog.162.1626084164033; Mon, 12 Jul 2021 03:02:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626084164; cv=none; d=google.com; s=arc-20160816; b=PIJMqUpkhnLIbEC5AL4beXl0yq9jgbKGqORcVpFqhfvXCWYbCbTdYO1HYvc0uaRJZZ J/XYjoKwbMrTTlScWDPqKd5k5GS0lMOQzGlkELV1ZT8sYbnwXMXL59zng1Y3/MgIe1nV TgzHE/Arrq9QaXDTAQbcURpK9RzMcu4s8ay+5WmsKr7adoY+X9VVYzFLa6LgrHBQfGZh /G7GcsWAHxftJs9uzpwFK9jiCM4YWU6Hqo8NCHPQDo7c/bUfb8RI+aG0BA82VEqMdmkA pOLwD1g3jH6NK+ZAtfx/SqnbwD1XTYR2DCWLVKDldh5QQBJiGsaPRB/AdcIHKOXNCe5Z CGUw== 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=C1IJSBlYMUMXEYer4Nn4SlorqNf0jAGDmXuthrSUm0o=; b=TBlNB8t+vr9DEaBW8D4z1eh1Ua1KchlJ+GUvTNTN8xjxOZ2CUoepoTY0mcUko9WpNF BUwlBFWRtsUW424WqiiMCWC787gf6xNkS8Xp2qs4864yqgLFW4UOOojL5/UJu0aLjZsf DaCNehDFzhY2amccm9AHdCEhzxadfHsgHGw+dmC6+lOFXpME7QRdWRrb0IBPnRRseUvc uq0KCEKpM3UgP9QDL7BQIbW0DbCTRf91UfN9zcHcOpcxiwu7KIRbig4aiGhPoa9dqbT6 zNQIl0NEGFNKQifCabZam5AfQEGrW25Q788kdIS/V4+Ju7uYZlOCGCFDy47tjtvYSTU5 ir5Q== 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 v14si15868597ilj.0.2021.07.12.03.02.31; Mon, 12 Jul 2021 03:02:44 -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 S244040AbhGLHRV (ORCPT + 99 others); Mon, 12 Jul 2021 03:17:21 -0400 Received: from mga03.intel.com ([134.134.136.65]:25899 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240070AbhGLGup (ORCPT ); Mon, 12 Jul 2021 02:50:45 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10042"; a="209973421" X-IronPort-AV: E=Sophos;i="5.84,232,1620716400"; d="scan'208";a="209973421" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2021 23:47:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,232,1620716400"; d="scan'208";a="491916342" Received: from nntpat99-84.inn.intel.com ([10.125.99.84]) by FMSMGA003.fm.intel.com with ESMTP; 11 Jul 2021 23:47:35 -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 v10 19/24] perf session: Introduce reader objects in session object Date: Mon, 12 Jul 2021 09:46:19 +0300 Message-Id: <287e59dc1940a5855984eea644a55de96988f5ab.1626072009.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 Allow to allocate multiple reader objects, so we could load multiple data files located in data directory at the same time. Design and implementation are based on the prototype [1], [2]. [1] git clone https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git -b perf/record_threads [2] https://lore.kernel.org/lkml/20180913125450.21342-1-jolsa@kernel.org/ Suggested-by: Jiri Olsa Acked-by: Namhyung Kim Signed-off-by: Alexey Bayduraev --- tools/perf/util/session.c | 33 +++++++++++++++++++++------------ tools/perf/util/session.h | 3 +++ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index da39ce4acb5a..cf8491bc398b 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -342,6 +342,10 @@ void perf_session__delete(struct perf_session *session) auxtrace_index__free(&session->auxtrace_index); perf_session__destroy_kernel_maps(session); perf_session__delete_threads(session); + if (session->readers) { + zfree(&session->readers); + session->nr_readers = 0; + } perf_session__release_decomp_events(session); perf_env__exit(&session->header.env); machines__exit(&session->machines); @@ -2301,14 +2305,7 @@ static s64 process_simple(struct perf_session *session, 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, - .path = session->data->file.path, - .in_place_update = session->data->in_place_update, - }; + struct reader *rd; struct ordered_events *oe = &session->ordered_events; struct perf_tool *tool = session->tool; struct ui_progress prog; @@ -2316,12 +2313,24 @@ static int __perf_session__process_events(struct perf_session *session) perf_tool__fill_defaults(tool); - if (rd.data_size == 0) - return -1; + rd = session->readers = zalloc(sizeof(struct reader)); + if (!rd) + return -ENOMEM; + + session->nr_readers = 1; + + *rd = (struct reader) { + .fd = perf_data__fd(session->data), + .data_size = session->header.data_size, + .data_offset = session->header.data_offset, + .process = process_simple, + .path = session->data->file.path, + .in_place_update = session->data->in_place_update, + }; - ui_progress__init_size(&prog, rd.data_size, "Processing events..."); + ui_progress__init_size(&prog, rd->data_size, "Processing events..."); - err = reader__process_events(&rd, session, &prog); + err = reader__process_events(rd, session, &prog); if (err) goto out_err; /* do the final flush for ordered samples */ diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 551aec427a5b..a03e028d09e8 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -19,6 +19,7 @@ struct thread; struct auxtrace; struct itrace_synth_opts; +struct reader; struct perf_session { struct perf_header header; @@ -41,6 +42,8 @@ struct perf_session { struct zstd_data zstd_data; struct decomp *decomp; struct decomp *decomp_last; + struct reader *readers; + int nr_readers; }; struct decomp { -- 2.19.0