Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4536450imm; Mon, 17 Sep 2018 16:04:28 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZQZTntHDAyoPsuMQKRXJaeE28bpj2z2Mj84Xy0e9x743AfKsK/iUByl7yq9aRkX0lxjvCj X-Received: by 2002:a63:4204:: with SMTP id p4-v6mr24699374pga.200.1537225468131; Mon, 17 Sep 2018 16:04:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537225468; cv=none; d=google.com; s=arc-20160816; b=xbF4es0n2rvrNruQKNwu8sKgjVAb62WHp441T/zetQthi1mW3t3/yNa9fKR/1Lfdmb FwEh+TdRk2kRymlQnjAVH6DVMfbUlOcUVQ5IvVIdrBL4g5dsLfY7zyWWsOdVRqAlzyZg IfS21XKtSDN3/bbw5xauZkpTfNMlIp6ACB6WmaOouaeFHeNhrGzPTVMVgVCLROu1+8HJ q3xnsmIRseCplO34qaYzd71bHv4YJkVt4DDpGhdOfKuzvj36z07bk49kTm5KTFWnkuVi /RRTmbt5eEcbf3lofe+w8w4UePVuf1dQHi+hgU2thyjlAeII+oburhOvHlnGXXuwYvO0 QGqQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=Dd246R0FGTm27seA9jEBZ4YZwhY/5W6nMnCASipvwk4=; b=NQ17EqH5X8QqrGLUakBfW2DCHwQDE6CeQrYHCR/eY+Wrc8q/+hl11dCwIdE30C/jQg PRwFBXPBZVB0IGenoJ0hDs2snw5wVCqEJqMEi0uN6giWfIfOHQwh+QPhxiwi+hTsA0R/ fJubtaEZij3/Yu8/KSXDBL0pVIaAq3hU8WdrK8b7gDigb9hZN56fBZHuJxIeLBaj4Rga 9FyXN371j3x9ezyVhphlfrQV6+ZCQ9ZgwmPe/CzxfCYpEYh+ViJK9D+1Q2tQNNCv9Cu6 ZyQsRnqYGiTL+rNQCe4uSWMPX8HGvrM+ay2nkEyKUc1ndzX6X41vnjesd444eWyjAIBs pQiA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a20-v6si15662987pgi.184.2018.09.17.16.04.13; Mon, 17 Sep 2018 16:04:28 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730724AbeIREd2 (ORCPT + 99 others); Tue, 18 Sep 2018 00:33:28 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:49032 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727202AbeIREd1 (ORCPT ); Tue, 18 Sep 2018 00:33:27 -0400 Received: from localhost (li1825-44.members.linode.com [172.104.248.44]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 75E9BC03; Mon, 17 Sep 2018 23:03:58 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sunil K Pandey , Kan Liang , Jiri Olsa , Arnaldo Carvalho de Melo , Andi Kleen , Namhyung Kim , Peter Zijlstra , Sasha Levin Subject: [PATCH 4.14 049/126] perf evlist: Fix error out while applying initial delay and LBR Date: Tue, 18 Sep 2018 00:41:37 +0200 Message-Id: <20180917211707.805701030@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180917211703.481236999@linuxfoundation.org> References: <20180917211703.481236999@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kan Liang [ Upstream commit 95035c5e167ae6e740b1ddd30210ae0eaf39a5db ] 'perf record' will error out if both --delay and LBR are applied. For example: # perf record -D 1000 -a -e cycles -j any -- sleep 2 Error: dummy:HG: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat' # A dummy event is added implicitly for initial delay, which has the same configurations as real sampling events. The dummy event is a software event. If LBR is configured, perf must error out. The dummy event will only be used to track PERF_RECORD_MMAP while perf waits for the initial delay to enable the real events. The BRANCH_STACK bit can be safely cleared for the dummy event. After applying the patch: # perf record -D 1000 -a -e cycles -j any -- sleep 2 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 1.054 MB perf.data (828 samples) ] # Reported-by: Sunil K Pandey Signed-off-by: Kan Liang Acked-by: Jiri Olsa Tested-by: Arnaldo Carvalho de Melo Cc: Andi Kleen Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1531145722-16404-1-git-send-email-kan.liang@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/evsel.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -824,6 +824,12 @@ static void apply_config_terms(struct pe } } +static bool is_dummy_event(struct perf_evsel *evsel) +{ + return (evsel->attr.type == PERF_TYPE_SOFTWARE) && + (evsel->attr.config == PERF_COUNT_SW_DUMMY); +} + /* * The enable_on_exec/disabled value strategy: * @@ -1054,6 +1060,14 @@ void perf_evsel__config(struct perf_evse else perf_evsel__reset_sample_bit(evsel, PERIOD); } + + /* + * For initial_delay, a dummy event is added implicitly. + * The software event will trigger -EOPNOTSUPP error out, + * if BRANCH_STACK bit is set. + */ + if (opts->initial_delay && is_dummy_event(evsel)) + perf_evsel__reset_sample_bit(evsel, BRANCH_STACK); } static int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)