Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp4117065ybt; Sun, 5 Jul 2020 17:59:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzlbVFGrzYi0jPgNViE/+VKJAOKnCU0h58gxOwS5nkTEv9AlEPj4hSVP0+hWoJwdAKUMwG X-Received: by 2002:a17:906:2304:: with SMTP id l4mr40481355eja.104.1593997151536; Sun, 05 Jul 2020 17:59:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593997151; cv=none; d=google.com; s=arc-20160816; b=KJnn1KQ0h3TuMAJVJrD89qwJkwFImgIoCR24mJkMrfpMHqcMBE4/Kot8IU4ttuftES iKFDNqTk3rh84JWIt9lAoMI4NZnkYu23/bMA/wvAH0UNy8nrL6XEvnL2vAJNW3K58+JG vV7LpMZIUuFTqzV693Q3poHLwOn49c6E9dOsq22tXNdl8fg7YYJ6EpZfoyPifLS4ou1C vRT82pW1PxkK+xRI5MT8jjdsh5C8esEPUJHcIJpRdS6ZD+oAhC12x+pC3B3UG2yeZmVj +vMC+CUzOHp10f/pCAup9T6SBrfOA8qikxEv++f03nmN31ve4GV97XWzWy3QC8qY8+4O H3WQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=bf1lQv0BwpeiB2KlyRqwoMGPNqZvXYh4AiqozFrULiU=; b=pMRBT/km3Dwt5p+Cx46OPNdbSRhQQ/zW5WEglR4wMF5ocQJ6ky0CgOOAkBx0j15jj1 VCTutVwdro/swnc9aaT2a7RjwFjh3w9aZTRmslRfzjdiIPdazY5/y3/PwLRvFPk0CrG+ mlU31NF9hFiBwwrwQo5Kgm+KOuenylHvwmGXxzS3yGoAvpexhldF0nb6zqcl2DD/eVAO RdJzkp+Ue9tuz/gGRlIgmnNOB6Q+NVAWilKLL1h0SkvLQciUr/EQfJLXG/NHV6LkwT4y C6pXfa5RsEZ+2GAckj09yqxvqq/jvooQQJKYKGyd0qB27yGcVqFPJRuYQS4DYIVKKG2+ dcMA== 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 z13si12060056edr.106.2020.07.05.17.58.49; Sun, 05 Jul 2020 17:59:11 -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 S1728275AbgGFAzt (ORCPT + 99 others); Sun, 5 Jul 2020 20:55:49 -0400 Received: from mga03.intel.com ([134.134.136.65]:30752 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726760AbgGFAzt (ORCPT ); Sun, 5 Jul 2020 20:55:49 -0400 IronPort-SDR: H6Hcs5pmxn8/C4QG0Loy1TM6/rt9cD/uGS4vR2X6RfGvsRNqsqn1ewXfnhnW59iHJZxlBrQQhd tUt7+4pPXRlQ== X-IronPort-AV: E=McAfee;i="6000,8403,9673"; a="147348967" X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="147348967" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jul 2020 17:55:48 -0700 IronPort-SDR: JjVn+QePLaCqIjzKVGFYymSLVGMPcabbJb/CjKaWxECDuqoZ7q17Pbb04lxEEoYsScXsqIHY5f elmz2SWLvasQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="388057428" Received: from yjin15-mobl1.ccr.corp.intel.com (HELO [10.238.5.239]) ([10.238.5.239]) by fmsmga001.fm.intel.com with ESMTP; 05 Jul 2020 17:55:45 -0700 Subject: Re: [PATCH] perf evsel: Don't set sample_regs_intr/sample_regs_user for dummy event To: Ian Rogers 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 References: <20200703004215.24418-1-yao.jin@linux.intel.com> <20200703110042.GA3282312@krava> <9fa0bd83-b21e-7bc2-af81-799f8e99f73b@linux.intel.com> From: "Jin, Yao" Message-ID: Date: Mon, 6 Jul 2020 08:55:44 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ian, On 7/6/2020 8:47 AM, Ian Rogers wrote: > 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 > -IAX should be no problem. The issue only occurs on the platform with extended regs supports, such as ICL. So I don't know if it's suitable to add it to perf test suite. Thanks Jin Yao >>>> 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 >>>> >>>