Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5219652pxj; Wed, 26 May 2021 05:48:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZacikFlby9TrynYC7rUNDIf/U9zuIWSwV644BDtxKhZU7heiqBqj1jb1kL5dvHmZSBlHo X-Received: by 2002:a05:6402:35c4:: with SMTP id z4mr36785406edc.362.1622033320239; Wed, 26 May 2021 05:48:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622033320; cv=none; d=google.com; s=arc-20160816; b=HAboWY6cAX55kGXYV37WchADua5OF+qoWfY6r0eUtN6acln9AELLf6FK3zdr3fQsf6 V3t4OWzKV6HwR0S+GImgZNyXRdp0+OSo1+p2rYPQHodbtrkjLsmrid50tRaqg8fN0uHR FnzPi/q5Y4A6FjAo2lkLc7nFMLO+hOX1v/BoYETurLXAMyFE9Mv9qZ8/Wx5SSlwxB8AF IV6Lp1AXDIgYBzuu2ihvZuV0h76r5B4j8zfx5HFWvEGb1UNzsrTo8zNgoJ5x5z8lcMV4 qSaWHA83KoqYHoTW1/1tZhlATKPE88fgqCk6N/90cMwnZ0uFzaROsZ+Pteo5qBBCoHw7 69tA== 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 :ironport-sdr:ironport-sdr; bh=y8Xm5CcDsKCbOAah9A3xg/Z6kxTFIsIGczo4cTGt5oc=; b=G5T4BAC6YCzml5KQixS4WPrrPEOngIAdMe8G+mA21pFH3clRekv1RZODfVtqDPfAY0 8b8eIRQaxhJ/FpD83fyNSeg+5i7x8fS42OqqwXLE1dXFIq0LoOmup4XdnZAtBYViuZx7 /NfkO25I178dUb1E2BD1wk/PXnAA4HCHnr9v3LlK6aRULvxouF6j7YlPlnBa18OD/Wi1 wTJM7RseE77MLyGFW7pTY5DtSKKuMRN80Px+Co8OC44V9wDAz2bDgpKmgxjWssy4B7/b yZA1vX/6hz5HQXSZZbyapbbH3DL6lKnaAMMAhBHMwIj+zvsddviAujmI71IXZS/zU1Ek fsvQ== 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 g8si19320693edm.30.2021.05.26.05.48.11; Wed, 26 May 2021 05:48:40 -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 S234293AbhEZKza (ORCPT + 99 others); Wed, 26 May 2021 06:55:30 -0400 Received: from mga02.intel.com ([134.134.136.20]:1596 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234271AbhEZKzP (ORCPT ); Wed, 26 May 2021 06:55:15 -0400 IronPort-SDR: KWNUExTOyTklFua6YEZwN+WUmF9KjYFNZxm3QvuNiMw/xYaWYf8Rf+9ZIOHHtRcY4P561PysOb 9aOckgmchyjQ== X-IronPort-AV: E=McAfee;i="6200,9189,9995"; a="189556446" X-IronPort-AV: E=Sophos;i="5.82,331,1613462400"; d="scan'208";a="189556446" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2021 03:53:42 -0700 IronPort-SDR: A0BBwxnp0m3xG/zvGSg8Tl8vrRzcFRLSYzHIzQ9puTv9ClBjaqrJQjhPUFiaQW4jSqT8SWyIXy gM7u2xd7lA+w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,331,1613462400"; d="scan'208";a="436079250" Received: from nntpat99-84.inn.intel.com ([10.125.99.84]) by orsmga007.jf.intel.com with ESMTP; 26 May 2021 03:53:39 -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 Subject: [PATCH v6 08/20] perf record: Init data file at mmap buffer object Date: Wed, 26 May 2021 13:53:01 +0300 Message-Id: <11edf193339f629010b63f8eb600cad060f9eec8.1622025774.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 Initialize data files located at mmap buffer objects so trace data can be written into several data file located at data directory. Acked-by: Andi Kleen Signed-off-by: Alexey Bayduraev --- tools/perf/builtin-record.c | 41 ++++++++++++++++++++++++++++++------- tools/perf/util/record.h | 1 + 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 19e4f067b20a..e118efe21ba7 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -160,6 +160,11 @@ static const char *affinity_tags[PERF_AFFINITY_MAX] = { "SYS", "NODE", "CPU" }; +static int record__threads_enabled(struct record *rec) +{ + return rec->opts.threads_spec; +} + static bool switch_output_signal(struct record *rec) { return rec->switch_output.signal && @@ -1070,7 +1075,7 @@ static void record__free_thread_data(struct record *rec) static int record__mmap_evlist(struct record *rec, struct evlist *evlist) { - int ret; + int i, ret; struct record_opts *opts = &rec->opts; bool auxtrace_overwrite = opts->auxtrace_snapshot_mode || opts->auxtrace_sample_mode; @@ -1109,6 +1114,18 @@ static int record__mmap_evlist(struct record *rec, if (ret) return ret; + if (record__threads_enabled(rec)) { + ret = perf_data__create_dir(&rec->data, evlist->core.nr_mmaps); + if (ret) + return ret; + for (i = 0; i < evlist->core.nr_mmaps; i++) { + if (evlist->mmap) + evlist->mmap[i].file = &rec->data.dir.files[i]; + if (evlist->overwrite_mmap) + evlist->overwrite_mmap[i].file = &rec->data.dir.files[i]; + } + } + return 0; } @@ -1416,8 +1433,12 @@ static int record__mmap_read_evlist(struct record *rec, struct evlist *evlist, /* * Mark the round finished in case we wrote * at least one event. + * + * No need for round events in directory mode, + * because per-cpu maps and files have data + * sorted by kernel. */ - if (bytes_written != rec->bytes_written) + if (!record__threads_enabled(rec) && bytes_written != rec->bytes_written) rc = record__write(rec, NULL, &finished_round_event, sizeof(finished_round_event)); if (overwrite) @@ -1532,7 +1553,9 @@ static void record__init_features(struct record *rec) if (!rec->opts.use_clockid) perf_header__clear_feat(&session->header, HEADER_CLOCK_DATA); - perf_header__clear_feat(&session->header, HEADER_DIR_FORMAT); + if (!record__threads_enabled(rec)) + perf_header__clear_feat(&session->header, HEADER_DIR_FORMAT); + if (!record__comp_enabled(rec)) perf_header__clear_feat(&session->header, HEADER_COMPRESSED); @@ -1543,15 +1566,21 @@ static void record__finish_output(struct record *rec) { struct perf_data *data = &rec->data; - int fd = perf_data__fd(data); + int i, fd = perf_data__fd(data); if (data->is_pipe) return; rec->session->header.data_size += rec->bytes_written; data->file.size = lseek(perf_data__fd(data), 0, SEEK_CUR); + if (record__threads_enabled(rec)) { + for (i = 0; i < data->dir.nr; i++) + data->dir.files[i].size = lseek(data->dir.files[i].fd, 0, SEEK_CUR); + } if (!rec->no_buildid) { + /* this will be recalculated during process_buildids() */ + rec->samples = 0; process_buildids(rec); if (rec->buildid_all) @@ -2487,8 +2516,6 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) status = err; record__synthesize(rec, true); - /* this will be recalculated during process_buildids() */ - rec->samples = 0; if (!err) { if (!rec->timestamp_filename) { @@ -3275,7 +3302,7 @@ int cmd_record(int argc, const char **argv) rec->no_buildid = true; } - if (rec->opts.kcore) + if (rec->opts.kcore || record__threads_enabled(rec)) rec->data.is_dir = true; if (rec->opts.comp_level != 0) { diff --git a/tools/perf/util/record.h b/tools/perf/util/record.h index 68f471d9a88b..4d68b7e27272 100644 --- a/tools/perf/util/record.h +++ b/tools/perf/util/record.h @@ -77,6 +77,7 @@ struct record_opts { int ctl_fd; int ctl_fd_ack; bool ctl_fd_close; + int threads_spec; }; extern const char * const *record_usage; -- 2.19.0