Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4117778ybg; Fri, 25 Oct 2019 13:36:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkqVh22oNDldfVtO9fE8QLB0eBXt6Kdrk0RVDQOR+AhmLaKsho0KCRAFSwwgTVtZGLbS9i X-Received: by 2002:a17:906:d72:: with SMTP id s18mr5398264ejh.29.1572035785664; Fri, 25 Oct 2019 13:36:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572035785; cv=none; d=google.com; s=arc-20160816; b=AI+W3bMLKahxHq6HtlU0qaTqManfa5qf6RXM28JwdEOf9ImWrHFTO3OQNOBOY3yZrn fURtsmbbvwSwQVd+XR0ICiaTONn0pyZaGff3L1sfjE404/YQwACY9QCFMRcIlKSAyHim WImPnkYAyRe3cPqI3uqpc5R3sOHON2X31tGKetkTHik5UUNoPE6ITUtmW2eN+i5QB8wu Er2MkXq28chRCDMrLsSBxQTBFFRDfpt/P1PR4H/3NSxLxMT3ZYt6mWdP8V/vQd7q0c8l 039HkBPd4Ge98EyKGz+eKzf8gQ1TyTYd+JDQSkw0ewTs3QgD854F0R9JBiEknBDsiuRi JnPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=DIYiAaLzSjhzLnWRd8SukOKgvrpirFsWNm/h2Ss3gS0=; b=iWlUx0qBgvCiAbeI9GUFDoBcahvOQghjDe6Gui7CmRXeIblGbqb8naQBjsl+Az+Bhg ESLq177C74l+GZCflWfEm+RmLB3bB8joh4DHeoDufKZw50l0A/JlqESRMzdbg/GV1EnO HtxaDXj8iEByFfZ3cPZVz1eSwPqBSV+QBCw+OA7cwEtTNexbxSAIGq3uXRyqlH7DNlT+ 6qW5sTsRjcRdJ/y10YhuI03KWj40g4WXSVBZlDh7W3+W3i5eE6y2Tgw7R72vKeaY95nW jZagED3TuHwrNMlT1to46N3IoVYYS38eJ4Ak2jmL1xVZGp6eRkrVEHd0NAuj9cHo9JY7 aEZA== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u59si2297307edc.193.2019.10.25.13.36.02; Fri, 25 Oct 2019 13:36:25 -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; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436800AbfJYOIx (ORCPT + 99 others); Fri, 25 Oct 2019 10:08:53 -0400 Received: from mga11.intel.com ([192.55.52.93]:57127 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405748AbfJYOIx (ORCPT ); Fri, 25 Oct 2019 10:08:53 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Oct 2019 07:08:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,228,1569308400"; d="scan'208";a="350035369" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 25 Oct 2019 07:08:48 -0700 From: Alexander Shishkin To: Peter Zijlstra Cc: Arnaldo Carvalho de Melo , Ingo Molnar , linux-kernel@vger.kernel.org, jolsa@redhat.com, adrian.hunter@intel.com, mathieu.poirier@linaro.org, mark.rutland@arm.com, Alexander Shishkin Subject: [PATCH v3 0/3] perf: Add AUX data sampling Date: Fri, 25 Oct 2019 17:08:32 +0300 Message-Id: <20191025140835.53665-1-alexander.shishkin@linux.intel.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Peter, Here's another version of the AUX sampling, addressing all the comments from the previous one [5]: fixed group leader refcount leak if both aux_source and aux_sample_size are set, changed aux_sample_size to u32 in the ABI and removed the pointless sample init bit. Also dropped 4/4 from this series, will send separately. This one has a context dependency on the attr.__reserved_2 fix [6], as it adds one more reserved bit. Changes since version one [3]: it addresses the issues of NMI-safety and sampling hardware events. The former is addressed by adding a new PMU callback, the latter by making use of grouping. It also depends on the AUX output stop fix [4] to work correctly. I decided to post them separately, because [4] is also a candidate for perf/urgent. This series introduces AUX data sampling for perf events, which in case of our instruction/branch tracing PMUs like Intel PT, BTS, CS ETM means execution flow history leading up to a perf event's overflow. In case of Intel PT, this can be used as an alternative to LBR, with virtually as many as you like branches per sample. It doesn't support some of the LBR features (branch prediction indication, basic block level timing, etc [1]) and it can't be exposed as BRANCH_STACK, because that would require decoding PT stream in kernel space, which is not practical. Instead, we deliver the PT data to userspace as is, for offline processing. The PT decoder already supports presenting PT as virtual LBR. AUX sampling is different from the snapshot mode in that it doesn't require instrumentation (for when to take a snapshot) and is better for generic data collection, when you don't yet know what you are looking for. It's also useful for automated data collection, for example, for feedback-driven compiler optimizaitions. It's also different from the "full trace mode" in that it produces much less data and, consequently, takes up less I/O bandwidth and storage space, and takes less time to decode. The bulk of code is in 1/4, which adds the user interface bits and the code to measure and copy out AUX data. 3/4 adds PT side support for sampling. 4/4 is not strictly related, but makes an improvement to the PT's snapshot mode by implementing a simpler buffer management that would also benefit the sampling. The tooling support is ready, although I'm not including it here to save the bandwidth. Adrian or I will post it separately. Meanwhile, it can be found here [2], updated to reflect the ABI change. [1] https://marc.info/?l=linux-kernel&m=147467007714928&w=2 [2] https://git.kernel.org/cgit/linux/kernel/git/ash/linux.git/log/?h=perf-aux-sampling [3] https://marc.info/?l=linux-kernel&m=152878999928771 [4] https://marc.info/?l=linux-kernel&m=157172999231707 [5] https://marc.info/?l=linux-kernel&m=157173832302445 [6] https://marc.info/?l=linux-kernel&m=157200581818800 Alexander Shishkin (3): perf: Allow using AUX data in perf samples perf/x86/intel/pt: Factor out starting the trace perf/x86/intel/pt: Add sampling support arch/x86/events/intel/pt.c | 76 ++++++++++++-- include/linux/perf_event.h | 19 ++++ include/uapi/linux/perf_event.h | 10 +- kernel/events/core.c | 172 +++++++++++++++++++++++++++++++- kernel/events/internal.h | 1 + kernel/events/ring_buffer.c | 36 +++++++ 6 files changed, 303 insertions(+), 11 deletions(-) -- 2.23.0