Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp4112930ybt; Sun, 5 Jul 2020 17:49:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxn0EVJLborSQjDNEXU3EZ2f5B6SASM0HjFGIzKrSd6wuTpq5u86yXw/vjDIeFwKvZCoDk7 X-Received: by 2002:a05:6402:1a3c:: with SMTP id be28mr43279744edb.140.1593996569560; Sun, 05 Jul 2020 17:49:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593996569; cv=none; d=google.com; s=arc-20160816; b=dCsBO5s862Sb00N8Y9EdIMkVlFQAmLVNVnAKTsP4UF+GSR1oE39Ik2WKTBLEkr5qHp 0J9cKgSNr/+k17l0q9fhyy23StGC1Q/HDH+Fx+yEfO2creiJl9HNUvPKHAaRQVd9YAy3 6tgIMpFB/3a8DFJZXcGfEk66CI3IGU9d4KmZyV+Wxv9D8u9ox2ictLjCTRx1TMcoideO dbG1/sQ+WgHdE9yUsUJ+p3IoYORua7gSb3c6qP74+UKoR24Ib3pi5KmB6gnN7Q/hYv7O aYU1E7cIZ/KY02qqBVCKWOH2N6DSM4zfDoj1D6gJPfnBtuUyry996aEpRl17e9zMubXN JC8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=goHlgbvpDIuR7E3z6NGEZAskx5ZrdgD3sWmyQqLPgdE=; b=EpvcN9GPF0TgDiImfmDNM/mDPi59CBeEL4YYN2wa1HEBebQMCu+xdMOlRZuQODMFmQ MZA3g2dPyY8YIvdc/SLtcHY0kXCvHOanm8fzkJAiq9z3BzmDoK05b5JhRtekZDETPJ6P tTbO5T48CSyBtnn9E2w6X7+K6A+/h9joyN9rED1z0/jEaFEyrqOXbkQPuprlM7gaFiuJ PCh0cA8QYOZB2lX98kezfwFKGeRnRVJ85jgbQ53+w4t48Q8eWflD0Z/a2WxDjCobTbMB 8HMlH4RiBUsEOflDTmfjxs+q14ccplU7UBNIDKbGFFRIkW6RpEShvl98JPVrlNw9XqZT V+og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=hYPsVPNB; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i20si12043353edy.277.2020.07.05.17.49.06; Sun, 05 Jul 2020 17:49:29 -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=@google.com header.s=20161025 header.b=hYPsVPNB; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728299AbgGFAr5 (ORCPT + 99 others); Sun, 5 Jul 2020 20:47:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728053AbgGFAr4 (ORCPT ); Sun, 5 Jul 2020 20:47:56 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48F42C061794 for ; Sun, 5 Jul 2020 17:47:56 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id 22so37526964wmg.1 for ; Sun, 05 Jul 2020 17:47:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=goHlgbvpDIuR7E3z6NGEZAskx5ZrdgD3sWmyQqLPgdE=; b=hYPsVPNBDPR0kEiQdqHh4bAp4LC1E52HtgKWKVwwbe/S3Q3y162XYqBUfvDQzH6XKb ImH+tARQiCApb5aiiRnNAS7D0U64+rYzhHGPJPLuSwD6az/C+jfdIiQN+wtS+04RA+c6 mTJ0ZkDQMsCNf4TdWIfMZdvxZ+KpuPkVrw63N6UpMRvL2LT3eHjN1wbcrY2vFGXCADCB 1aQpcZL6M9mAGWRbzmqyJAlTJlsvKX1cL0b/JrvLQh6F/XIO4SDUCQtk2jsH2utTF3ul GucC9k/HDR2sj/18bfkUwrBqwmfWdGatDsGWkg9VcCF4bQuHaF1uHzEx8x6LtgxsEL+o lsRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=goHlgbvpDIuR7E3z6NGEZAskx5ZrdgD3sWmyQqLPgdE=; b=qJKWxNfWE085MLsR60uFEakG3n+TFnjec6qW+flT5PHMmR6KEWFLGPj9fSMhBv3mYc wn7kbzqKT1EUPTIzvdpDe0DXAPY8KHnxgDmq0Fb5FB96XfUWZLWIWr90tOW5YgGznNUg 2KDk++CT1RQ47S2wOAToioOyQz+rZ+vBzxwGa+8jLeITqVxd2votGu19tTU9zSfq94T4 /TofJzHox3KxtReK37CZvbxvE+IAnWqSPlDgcwy6NBRkLJIBAMhhyeMhKO4luZgSEY9L yBRBjfhtfyf8Ez9YTtGj5s3xq/VQRcQC7VAZnIUZcaddtPBunCDFQ+wdIjNIhzVF/FZj P+aQ== X-Gm-Message-State: AOAM5335fSDNa0J35qGGslAoZBQd6A67Rq3YNzOY6prWBt10l0g3dbLr Le9B5gmvz5bOjyXdBHeFyJdoTa3SyDcE7D4VhmNkWw== X-Received: by 2002:a1c:398b:: with SMTP id g133mr45278087wma.76.1593996473791; Sun, 05 Jul 2020 17:47:53 -0700 (PDT) MIME-Version: 1.0 References: <20200703004215.24418-1-yao.jin@linux.intel.com> <20200703110042.GA3282312@krava> <9fa0bd83-b21e-7bc2-af81-799f8e99f73b@linux.intel.com> In-Reply-To: <9fa0bd83-b21e-7bc2-af81-799f8e99f73b@linux.intel.com> From: Ian Rogers Date: Sun, 5 Jul 2020 17:47:42 -0700 Message-ID: Subject: Re: [PATCH] perf evsel: Don't set sample_regs_intr/sample_regs_user for dummy event To: "Jin, Yao" Cc: Jiri Olsa , Arnaldo Carvalho de Melo , Jiri Olsa , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , LKML , Andi Kleen , kan.liang@intel.com, "Jin, Yao" , Adrian Hunter Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 3, 2020 at 5:31 PM Jin, Yao wrote: > > Hi Jiri, > > On 7/3/2020 7:00 PM, Jiri Olsa wrote: > > On Fri, Jul 03, 2020 at 08:42:15AM +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' > >> Sorry for the breakage caused by modifying the dummy event. Could we add a test to cover the issue? Perhaps in tools/perf/tests/shell/. Trying to reproduce with a register on my skylakex on a 5.6.14 kernel with: $ perf record -e cycles:p -IAX -a -- sleep 1 succeeds. Thanks, Ian > >> 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 pieces. > >> > >> /* 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 be not set with > >> PERF_PMU_CAP_EXTENDED_REGS. But unfortunately in current code, 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. > >> > >> 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) ] > > > > LGTM, Adrian (cc-ed) just added another check to the same place, > > but it looks like both of them should be there: > > > > https://lore.kernel.org/lkml/20200630133935.11150-2-adrian.hunter@intel.com/ > > > > jirka > > > > Thanks Jiri! Yes, it looks like both of checks should be added here. > > So do I post v2 (just rebase) once Adrian's patch gets merged? > > Thanks > Jin Yao > > >> > >> Fixes: 0a892c1c9472 ("perf record: Add dummy event during system wide synthesis") > >> Signed-off-by: Jin Yao > >> --- > >> tools/perf/util/evsel.c | 4 ++-- > >> 1 file changed, 2 insertions(+), 2 deletions(-) > >> > >> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c > >> index 96e5171dce41..df3315543e86 100644 > >> --- a/tools/perf/util/evsel.c > >> +++ b/tools/perf/util/evsel.c > >> @@ -1020,12 +1020,12 @@ 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) { > >> + if (opts->sample_intr_regs && !is_dummy_event(evsel)) { > >> attr->sample_regs_intr = opts->sample_intr_regs; > >> evsel__set_sample_bit(evsel, REGS_INTR); > >> } > >> > >> - if (opts->sample_user_regs) { > >> + if (opts->sample_user_regs && !is_dummy_event(evsel)) { > >> attr->sample_regs_user |= opts->sample_user_regs; > >> evsel__set_sample_bit(evsel, REGS_USER); > >> } > >> -- > >> 2.17.1 > >> > >