Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2849801yba; Sat, 18 May 2019 04:26:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaXGF0bGfqDO+rXPLwZoa+i6bijmDITq86IhoaBNlIoUs/0pBBfASnJPNYkKztqNQ+1oTF X-Received: by 2002:a62:2c17:: with SMTP id s23mr36072620pfs.51.1558178784500; Sat, 18 May 2019 04:26:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558178784; cv=none; d=google.com; s=arc-20160816; b=bMEd2vw7wCc97mDk1y3fVfvyBGr9oD/guJyYNDZAzm8GbUbaHxDIHPpT0VTeOEQR9q hak+UlVrtoJwcI1qdHywd67itK6er7Isu17rAxBRqqmjzZHGtWiveZ1VQ343z0FcQZGy HujFI5txxRA7x38Ut+/L5je+PgP/+pktnUcvsr1ylb5b13pqaZFNzge80Jy+3aXKkIxl 0s4patdYXJFh6XgABkxU+knMLnP4wmHcBaIZ6rSssjdC89FEEMduH1rIjOMBBguWTCMv fnVD9Do0zgGeQrkUwlgVbCbRcUBIF67M8vd4NtkGVG3zB0gvRHvx8UJOsppNjbUHwiNf hRcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=ZuR5mryf/9XZpkdbYGq7ot7oDGB5hixWx7cfapN/bz8=; b=mEJuoNH6aa+TMKuZo883ltBfAsiTk58pKh0RSp+BA0rVMIstUPY6KDRYWFiOnKXJ0R u+07sLWPkXsBLEnj18n6zu4+U8v6+u9a6BntOIxESrkrW510D0HVmBTBpVnSDi38uxrM zsRw0Z2ReT0r1ZrW9DlRVsPhIxjWS0wUSNFoqdWPKt4dZoQ0S3JPcBPdeP8OHkE7tseq IfG4D/ybuMSL5zoPWLLYZmv08wG+rcBNRALL0sO70kWIF4dnMSYxQ3Xk8gXr6CM14GM+ YHSXIzALIKSOdUCK527mb0LO60sFGCZQllB2pRHjEO0MhZ/CyqVfBJHH3iuNVGFGCcmN R+ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019041745 header.b=PLEhvTrY; 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=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c9si4229697pls.381.2019.05.18.04.26.06; Sat, 18 May 2019 04:26:24 -0700 (PDT) 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; dkim=pass header.i=@zytor.com header.s=2019041745 header.b=PLEhvTrY; 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=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729898AbfERJYp (ORCPT + 99 others); Sat, 18 May 2019 05:24:45 -0400 Received: from terminus.zytor.com ([198.137.202.136]:47793 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725268AbfERJYo (ORCPT ); Sat, 18 May 2019 05:24:44 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x4I9OV7Y1741121 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sat, 18 May 2019 02:24:31 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x4I9OV7Y1741121 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019041745; t=1558171471; bh=ZuR5mryf/9XZpkdbYGq7ot7oDGB5hixWx7cfapN/bz8=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=PLEhvTrYCCAEjF1IdMvs+Mqi4jECUBJvU8gs0pbJw0CNGXl8FqxkgWdXz8ESGTEKm JroE8yv6mKgRKEF8UED+oxUp4dbQsxPQ5zkhUCrCqM4LG6KdIBexpnGeTeN/02g//z 2i918+/YxutfYRH5418BcsRIyLh1mJrOuZRslfgJq4OXvxpCa6jERSI64JA7ly1dnJ hi8zLXLiigkTqso1pFLOYS2jzf6yxlMwE6tx48BvRD910/K6K5WSS5Ilc7r41kBVZv cJiM2xia2Mh/SHkT2pP491eLAui2rrDEQ6YdWjem4i8S0lp2pn/DHdH18MYc85H3Fw kZyZwgeULcOKQ== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x4I9OUKs1741117; Sat, 18 May 2019 02:24:30 -0700 Date: Sat, 18 May 2019 02:24:30 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Alexey Budankov Message-ID: Cc: alexey.budankov@linux.intel.com, linux-kernel@vger.kernel.org, mingo@kernel.org, peterz@infradead.org, jolsa@kernel.org, tglx@linutronix.de, namhyung@kernel.org, hpa@zytor.com, ak@linux.intel.com, acme@redhat.com, alexander.shishkin@linux.intel.com Reply-To: alexey.budankov@linux.intel.com, peterz@infradead.org, tglx@linutronix.de, namhyung@kernel.org, ak@linux.intel.com, mingo@kernel.org, linux-kernel@vger.kernel.org, jolsa@kernel.org, hpa@zytor.com, acme@redhat.com, alexander.shishkin@linux.intel.com In-Reply-To: <9ff06518-ae63-a908-e44d-5d9e56dd66d9@linux.intel.com> References: <9ff06518-ae63-a908-e44d-5d9e56dd66d9@linux.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf record: Implement -z,--compression_level[=] option Git-Commit-ID: 504c1ad11691d1a16e92285bb961728a80c06014 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-3.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 504c1ad11691d1a16e92285bb961728a80c06014 Gitweb: https://git.kernel.org/tip/504c1ad11691d1a16e92285bb961728a80c06014 Author: Alexey Budankov AuthorDate: Mon, 18 Mar 2019 20:44:42 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 15 May 2019 16:36:49 -0300 perf record: Implement -z,--compression_level[=] option Implemented -z,--compression_level[=] option that enables compression of mmaped kernel data buffers content in runtime during perf record mode collection. Default option value is 1 (fastest compression). Compression overhead has been measured for serial and AIO streaming when profiling matrix multiplication workload: ------------------------------------------------------------- | SERIAL | AIO-1 | ----------------------------------------------------------------| |-z | OVH(x) | ratio(x) size(MiB) | OVH(x) | ratio(x) size(MiB) | |---------------------------------------------------------------| | 0 | 1,00 | 1,000 179,424 | 1,00 | 1,000 187,527 | | 1 | 1,04 | 8,427 181,148 | 1,01 | 8,474 188,562 | | 2 | 1,07 | 8,055 186,953 | 1,03 | 7,912 191,773 | | 3 | 1,04 | 8,283 181,908 | 1,03 | 8,220 191,078 | | 5 | 1,09 | 8,101 187,705 | 1,05 | 7,780 190,065 | | 8 | 1,05 | 9,217 179,191 | 1,12 | 6,111 193,024 | ----------------------------------------------------------------- OVH = (Execution time with -z N) / (Execution time with -z 0) ratio - compression ratio size - number of bytes that was compressed size ~= trace size x ratio Committer notes: Testing it I noticed that it failed to disable build id processing when compression is enabled, and as we'd have to uncompress everything to look for the PERF_RECORD_{MMAP,SAMPLE,etc} to figure out which build ids to read from DSOs, we better disable build id processing when compression is enabled, logging with pr_debug() when doing so: Original patch: # perf record -z2 ^C[ perf record: Woken up 1 times to write data ] 0x1746e0 [0x76]: failed to process type: 81 [Invalid argument] [ perf record: Captured and wrote 1.568 MB perf.data, compressed (original 0.452 MB, ratio is 3.995) ] # After auto-disabling build id processing when compression is enabled: $ perf record -z2 sleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.001 MB perf.data, compressed (original 0.001 MB, ratio is 2.292) ] $ perf record -v -z2 sleep 1 Compression enabled, disabling build id collection at the end of the session. [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.001 MB perf.data, compressed (original 0.001 MB, ratio is 2.305) ] $ Also, with parts of the patch originally after this one moved to just before this one we get: $ perf record -z2 sleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.001 MB perf.data, compressed (original 0.001 MB, ratio is 2.371) ] $ perf report -D | grep COMPRESS 0 0x1b8 [0x155]: PERF_RECORD_COMPRESSED: unhandled! 0 0x30d [0x80]: PERF_RECORD_COMPRESSED: unhandled! COMPRESSED events: 2 COMPRESSED events: 0 $ I.e. when faced with PERF_RECORD_COMPRESSED that we still have no code to process, we just show it as not being handled, skip them and continue, while before we had: $ perf report -D | grep COMPRESS 0x1b8 [0x169]: failed to process type: 81 [Invalid argument] Error: failed to process sample 0 0x1b8 [0x169]: PERF_RECORD_COMPRESSED $ Signed-off-by: Alexey Budankov Reviewed-by: Jiri Olsa Tested-by: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: Andi Kleen Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/9ff06518-ae63-a908-e44d-5d9e56dd66d9@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/perf-record.txt | 5 +++++ tools/perf/builtin-record.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index 58986f4cc190..27b37624c376 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt @@ -478,6 +478,11 @@ Also at some cases executing less output write syscalls with bigger data size can take less time than executing more output write syscalls with smaller data size thus lowering runtime profiling overhead. +-z:: +--compression-level[=n]:: +Produce compressed trace using specified level n (default: 1 - fastest compression, +22 - smallest trace) + --all-kernel:: Configure all used events to run in kernel space. diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index a0bd9104fae6..861395753c25 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -443,6 +443,25 @@ static int record__mmap_flush_parse(const struct option *opt, return 0; } +#ifdef HAVE_ZSTD_SUPPORT +static unsigned int comp_level_default = 1; + +static int record__parse_comp_level(const struct option *opt, const char *str, int unset) +{ + struct record_opts *opts = opt->value; + + if (unset) { + opts->comp_level = 0; + } else { + if (str) + opts->comp_level = strtol(str, NULL, 0); + if (!opts->comp_level) + opts->comp_level = comp_level_default; + } + + return 0; +} +#endif static unsigned int comp_level_max = 22; static int record__comp_enabled(struct record *rec) @@ -2200,6 +2219,11 @@ static struct option __record_options[] = { OPT_CALLBACK(0, "affinity", &record.opts, "node|cpu", "Set affinity mask of trace reading thread to NUMA node cpu mask or cpu of processed mmap buffer", record__parse_affinity), +#ifdef HAVE_ZSTD_SUPPORT + OPT_CALLBACK_OPTARG('z', "compression-level", &record.opts, &comp_level_default, + "n", "Compressed records using specified level (default: 1 - fastest compression, 22 - greatest compression)", + record__parse_comp_level), +#endif OPT_END() }; @@ -2259,6 +2283,12 @@ int cmd_record(int argc, const char **argv) "cgroup monitoring only available in system-wide mode"); } + + if (rec->opts.comp_level != 0) { + pr_debug("Compression enabled, disabling build id collection at the end of the session.\n"); + rec->no_buildid = true; + } + if (rec->opts.record_switch_events && !perf_can_record_switch_events()) { ui__error("kernel does not support recording context switch events\n");