Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1375747ybh; Sun, 19 Jul 2020 18:02:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVHcRm8j65qv/qWwv9G5LZGdJTk4xcHcSLKYtFszJgWJyrLp/Bh3TuqGDV3BGeLSesHkgp X-Received: by 2002:a17:906:94c4:: with SMTP id d4mr18260058ejy.232.1595206942215; Sun, 19 Jul 2020 18:02:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595206942; cv=none; d=google.com; s=arc-20160816; b=dbn5YSTURyOv1TP1FlLwxlTXOMDERrp89T3+TgumfJ+tHPFWAguQyu4seIFpKVMOLF DEqiAG6/6hE2tmFE/93XGolDYeXyGMFt4fm/1jSP0v10Lcq0pfTo5VR2cf9lhiGYNGc2 7YHAmdEfBMa80whaYknNLSytfJT7cHgkMcFh8qKXUf0lxgpV0uzoP5pzfDBB+NgWQn8C SviSVasAO2EzsTsHLvnom92mS4zviu3rCZ/wEynd8Reu4ypsUOmPefemsnpwkZYHA84i 12iv3kbmQsSz5Z4VIGYjRPzNk4LhXP353mHtt03IIdOr/l8qzKWV2psctE76Y4jfr4Jf E9dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=MWOOpnRFf3nfuAY/Y7UJa8zarbSO+zOjcp949GqKNLw=; b=CaEMZHejQGI4gSKHWjeZhgUUL7nD176bM9Nv9hErZ0cJ9MfG2s2TI76uyuXFyV03PK BTobAVUV9blyeVUPILcK5Onpq2BIn9Pwh9bk2sBfDE2/rQt8APY+DLIfijh/uGsLzUrr EYk+m1okZzKywl+8yA7OXFoogRCGRiNFZt1DNsQCRnCWMOKb4eY5wwayPgPw2hfz2ZRM SmCskoqBqA1dmS8JA/AgjNdggKXwdT3e5SyuyACZ2tmqs/inYLKSvVftVSQ09s67cfP+ 2Bp7V07K/2lO224W5U74V8wJcCJcab7NxbvKSOxr8LKhTSBjG6TYvBvMZeEMhlaFzY7W uZ+w== 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 p2si9364412edj.167.2020.07.19.18.01.44; Sun, 19 Jul 2020 18:02:22 -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 S1726736AbgGTBBZ (ORCPT + 99 others); Sun, 19 Jul 2020 21:01:25 -0400 Received: from mga11.intel.com ([192.55.52.93]:57743 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726510AbgGTBBZ (ORCPT ); Sun, 19 Jul 2020 21:01:25 -0400 IronPort-SDR: KX4oMZDfJaA0DE3gvvUnMWrNIUIiyleZ4fcwDhJ66pUNwMgLdVZS/inKWyCMasYU/O3ckfgp6d p7ZuQY0f+p0Q== X-IronPort-AV: E=McAfee;i="6000,8403,9687"; a="147794510" X-IronPort-AV: E=Sophos;i="5.75,373,1589266800"; d="scan'208";a="147794510" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jul 2020 18:01:24 -0700 IronPort-SDR: 5RjyWleyqjZxby5dn7u5oLQX4oF+jAuWMu0S0SMrVF7v121GpFQteB1Zc7BSfsckFI8/R/LVJl B1g35I6FoOvA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,373,1589266800"; d="scan'208";a="319363759" Received: from kbl-ppc.sh.intel.com ([10.239.159.118]) by fmsmga002.fm.intel.com with ESMTP; 19 Jul 2020 18:01:21 -0700 From: Jin Yao To: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com Cc: Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com, irogers@google.com, Jin Yao Subject: [PATCH v2] perf evsel: Don't set sample_regs_intr/sample_regs_user for dummy event Date: Mon, 20 Jul 2020 09:00:13 +0800 Message-Id: <20200720010013.18238-1-yao.jin@linux.intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since commit 0a892c1c9472 ("perf record: Add dummy event during system wide synthesis"), a dummy event is added to capture mmaps. But if we run perf-record as, # perf record -e cycles:p -IXMM0 -a -- sleep 1 Error: dummy:HG: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat' The issue is, if we enable the extended regs (-IXMM0), but the pmu->capabilities is not set with PERF_PMU_CAP_EXTENDED_REGS, the kernel will return -EOPNOTSUPP error. See following code: /* in kernel/events/core.c */ static int perf_try_init_event(struct pmu *pmu, struct perf_event *event) { .... if (!(pmu->capabilities & PERF_PMU_CAP_EXTENDED_REGS) && has_extended_regs(event)) ret = -EOPNOTSUPP; .... } For software dummy event, the PMU should not be set with PERF_PMU_CAP_EXTENDED_REGS. But unfortunately now, the dummy event has possibility to be set with PERF_REG_EXTENDED_MASK bit. In evsel__config, /* tools/perf/util/evsel.c */ if (opts->sample_intr_regs) { attr->sample_regs_intr = opts->sample_intr_regs; } If we use -IXMM0, the attr>sample_regs_intr will be set with PERF_REG_EXTENDED_MASK bit. It doesn't make sense to set attr->sample_regs_intr for a software dummy event. This patch adds dummy event checking before setting attr->sample_regs_intr and attr->sample_regs_user. After: # ./perf record -e cycles:p -IXMM0 -a -- sleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.413 MB perf.data (45 samples) ] v2: --- Rebase to perf/core Fixes: 0a892c1c9472 ("perf record: Add dummy event during system wide synthesis") Signed-off-by: Jin Yao --- tools/perf/util/evsel.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 9aa51a65593d..11794d3b7879 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1014,12 +1014,14 @@ void evsel__config(struct evsel *evsel, struct record_opts *opts, if (callchain && callchain->enabled && !evsel->no_aux_samples) evsel__config_callchain(evsel, opts, callchain); - if (opts->sample_intr_regs && !evsel->no_aux_samples) { + if (opts->sample_intr_regs && !evsel->no_aux_samples && + !evsel__is_dummy_event(evsel)) { attr->sample_regs_intr = opts->sample_intr_regs; evsel__set_sample_bit(evsel, REGS_INTR); } - if (opts->sample_user_regs && !evsel->no_aux_samples) { + if (opts->sample_user_regs && !evsel->no_aux_samples && + !evsel__is_dummy_event(evsel)) { attr->sample_regs_user |= opts->sample_user_regs; evsel__set_sample_bit(evsel, REGS_USER); } -- 2.17.1