Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1595277ybh; Mon, 20 Jul 2020 02:18:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVD5k/FBx0+3Zbo6GdpFas1OQ9lfTeU4PDw0RZWSoD0mHXBn75pSdFkHIN/Kcs3L08M3hT X-Received: by 2002:aa7:c398:: with SMTP id k24mr20196058edq.95.1595236727792; Mon, 20 Jul 2020 02:18:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595236727; cv=none; d=google.com; s=arc-20160816; b=PTw9L0kKgtKFFKUjOPiMBduvN0QrQ16R0JLmx5V6/JWQD6hu12W+ntNzfYoMCPtS+E iJWMtrdQz8h1EAtFOSJI/Ai7f8WQGVOyvgUmask0m7kpKr7F2ZTEzPQ1vHktaMI5Aub7 HX6B6Hr/YlhREz1NFe8yCZW2lNXSsGtBFeZod1xz6GfEkYr46CyHDD063xkjZ9tawDBg 62oO8/2wE0CXnAc3go/mqhJOVgLYCD8Y87S6tHmCCpekOn0HTkUnsGXF/IXgzHdu+7M/ rWctdS/lVxaZnicMiKcprynGMPBFmUNFvKNYQnpZYygun4tHXBrQSsmAQbisKHgQOvpM BCFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=U5qfFxwwSEo+sHv8EIt1ToPwApxh7XWdqe+2zXTQAJg=; b=YVhsTeTmD5DINHiakIr78ijaw93qfM77XRlwqSkA6XF1HlmvuOidW6SksTQ90JUx9i Y84hWxAZAm/UqAaH62lSkf0yNorh3SuSFMBHYSw/M5smOUL+koubgvXHDDAvNSpNcp89 9z8/wZnhz6n2Qc/JcBLriqd2IN9zCDf/sMW7u8zBmrCdMbngUFbo7V4tV/bohg2fAglx XCWk3wOvhW73/83dpiTVVSvjflOG4VRnk6ca4bummvVPs+9AJqmwq5Wz3vqM12zE/0bT SJN6UBLztgQ5/dFPNzm6hCE4PyO22WWP4P75W9RY4dgdYaY2tVnZ/4qP/00C/kBiShuE bWGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UIdaHUO+; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c6si10878797ejr.345.2020.07.20.02.18.24; Mon, 20 Jul 2020 02:18:47 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UIdaHUO+; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728163AbgGTJSA (ORCPT + 99 others); Mon, 20 Jul 2020 05:18:00 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:25960 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727120AbgGTJR7 (ORCPT ); Mon, 20 Jul 2020 05:17:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595236678; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=U5qfFxwwSEo+sHv8EIt1ToPwApxh7XWdqe+2zXTQAJg=; b=UIdaHUO+BoWcQ9GC7GX5DudWgvYXqmXWx3ZblX9PNNlDNq5NjSZBVh8+XGEwtXFmqW2A5w eYFYG4RjG/vqPYYX9wWJCGAsSegxrxQLj0cozTdsoDVIBIsnw+KmeqPsrvBiI01jHlx6PI ZigeeyOYWNYJJrbWgrStKa1JL2wt1C4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-23-Q8mviLGMNcKWn9sXq_rfdQ-1; Mon, 20 Jul 2020 05:17:54 -0400 X-MC-Unique: Q8mviLGMNcKWn9sXq_rfdQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1A6CF1081; Mon, 20 Jul 2020 09:17:52 +0000 (UTC) Received: from krava (unknown [10.40.195.115]) by smtp.corp.redhat.com (Postfix) with SMTP id 430707303C; Mon, 20 Jul 2020 09:17:49 +0000 (UTC) Date: Mon, 20 Jul 2020 11:17:48 +0200 From: Jiri Olsa To: Jin Yao Cc: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com, irogers@google.com, Adrian Hunter Subject: Re: [PATCH v2] perf evsel: Don't set sample_regs_intr/sample_regs_user for dummy event Message-ID: <20200720091748.GH760733@krava> References: <20200720010013.18238-1-yao.jin@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200720010013.18238-1-yao.jin@linux.intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 20, 2020 at 09:00:13AM +0800, Jin Yao wrote: > 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)) { hum, I thought it'd look something like this: if (opts->sample_intr_regs && (!evsel->no_aux_samples || !evsel__is_dummy_event(evsel)) but I'm not sure how no_aux_samples flag works exactly.. so it might be correct.. just making sure ;-) cc-ing Adrian jirka > 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 >