Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp657716ybg; Thu, 19 Mar 2020 06:32:00 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuP7Isosb1l21ikQwqx3nDRFhEoif9sTiPAmoGQsau3wLv1VVeAHDwyyvZdWeSYZkdQRvvI X-Received: by 2002:aca:cf8a:: with SMTP id f132mr2210679oig.151.1584624720770; Thu, 19 Mar 2020 06:32:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584624720; cv=none; d=google.com; s=arc-20160816; b=EN5dZhJ1Kx2N814IvufQfSFFWk714mJUYHwMZrQvueRNI6+Rni4eCL5CwYRKR1Ycv2 sZS8lLyomHslLweLHLm1GUkBiXj3d+TWV3SFblWCK6rpIlle5uvvsiz1GPPEsyi8e3cw XnsmSsu+9K+3bY9ZrhjeZChdKTd/8DKCKzUm18zBoAaZ8PrAPQw43q1R/7zoZXCzHLUZ vHZy4fqpN74zcaHZmi8P4hvLX+GOlaZr1hACUByJ/rhrMpN93uFCuq++3Fge0IHFT7ib k3SEQKO85nbqszOyoy+3kfaBVMipQWOUKbjfT8DOVRINxvFIduRsvndAcMsx53yU+TYC Inkw== 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:dkim-signature; bh=B9qgDwK9162aT12H6l9y3QVkDEzSDyAK73ZjFuhR1fw=; b=X/usGXD+cJxIrf7BCzZ0U15uiDgvYBN+Vt/NJBWkqrcUOVPQOKVR/TvA1bzhL4/K9t 7Wl5NyK/a9f4vR7LyoeaoYoV219XJKLMKUL/HTqXk5lGcTwZzZMF97HYMVuoHsOhWh26 5UaLjr/ez6N3MeVN0mQtb24JwBSWexlKhbee/c3NZzCHCep5+elYWGBjgeKNKR7ftG4/ mRiwPLwDBBYD8X91kJZ9zVcclp7GDaRdFJ0rjE/w/gCMpklReVoMU108OfGn1XQJBCol Z7sG5vXMCm9L40qTwqMkZ6BPeGr1QRb1KesVQLndiqNVYZ5bxxBblgwqNTHDYx98Yta2 sBWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ah+uBNz1; 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 48si1326354otv.320.2020.03.19.06.31.48; Thu, 19 Mar 2020 06:32:00 -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; dkim=pass header.i=@kernel.org header.s=default header.b=ah+uBNz1; 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 S1729714AbgCSNRx (ORCPT + 99 others); Thu, 19 Mar 2020 09:17:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:39448 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729669AbgCSNRv (ORCPT ); Thu, 19 Mar 2020 09:17:51 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 710B8214D8; Thu, 19 Mar 2020 13:17:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584623869; bh=xpF/oJrCEXUxvt+0y7Lo8jkFhhTZdOsK+QynZE3xPvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ah+uBNz1up8wfNdCT6E/NSrn03X8495ZUfwetsGiNOrzjOndaxdWrwC20+s9SC91H EEauz5PKX0Q2pmzDafOF7b7OVbWMX7ZZcMMkgaIXAQcwujGpwyoopJtu4z9QImoZ8N GCkrH9FrZj/QY8BY3eoE050HL5Yy6XlfVy0CqGfk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kim Phillips , Borislav Petkov , Peter Zijlstra , Sasha Levin Subject: [PATCH 4.14 82/99] perf/amd/uncore: Replace manual sampling check with CAP_NO_INTERRUPT flag Date: Thu, 19 Mar 2020 14:04:00 +0100 Message-Id: <20200319124005.115184451@linuxfoundation.org> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200319123941.630731708@linuxfoundation.org> References: <20200319123941.630731708@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Kim Phillips [ Upstream commit f967140dfb7442e2db0868b03b961f9c59418a1b ] Enable the sampling check in kernel/events/core.c::perf_event_open(), which returns the more appropriate -EOPNOTSUPP. BEFORE: $ sudo perf record -a -e instructions,l3_request_g1.caching_l3_cache_accesses true Error: The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (l3_request_g1.caching_l3_cache_accesses). /bin/dmesg | grep -i perf may provide additional information. With nothing relevant in dmesg. AFTER: $ sudo perf record -a -e instructions,l3_request_g1.caching_l3_cache_accesses true Error: l3_request_g1.caching_l3_cache_accesses: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat' Fixes: c43ca5091a37 ("perf/x86/amd: Add support for AMD NB and L2I "uncore" counters") Signed-off-by: Kim Phillips Signed-off-by: Borislav Petkov Acked-by: Peter Zijlstra Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20200311191323.13124-1-kim.phillips@amd.com Signed-off-by: Sasha Levin --- arch/x86/events/amd/uncore.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c index baa7e36073f90..604a8558752d1 100644 --- a/arch/x86/events/amd/uncore.c +++ b/arch/x86/events/amd/uncore.c @@ -193,20 +193,18 @@ static int amd_uncore_event_init(struct perf_event *event) /* * NB and Last level cache counters (MSRs) are shared across all cores - * that share the same NB / Last level cache. Interrupts can be directed - * to a single target core, however, event counts generated by processes - * running on other cores cannot be masked out. So we do not support - * sampling and per-thread events. + * that share the same NB / Last level cache. On family 16h and below, + * Interrupts can be directed to a single target core, however, event + * counts generated by processes running on other cores cannot be masked + * out. So we do not support sampling and per-thread events via + * CAP_NO_INTERRUPT, and we do not enable counter overflow interrupts: */ - if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) - return -EINVAL; /* NB and Last level cache counters do not have usr/os/guest/host bits */ if (event->attr.exclude_user || event->attr.exclude_kernel || event->attr.exclude_host || event->attr.exclude_guest) return -EINVAL; - /* and we do not enable counter overflow interrupts */ hwc->config = event->attr.config & AMD64_RAW_EVENT_MASK_NB; hwc->idx = -1; @@ -314,6 +312,7 @@ static struct pmu amd_nb_pmu = { .start = amd_uncore_start, .stop = amd_uncore_stop, .read = amd_uncore_read, + .capabilities = PERF_PMU_CAP_NO_INTERRUPT, }; static struct pmu amd_llc_pmu = { @@ -324,6 +323,7 @@ static struct pmu amd_llc_pmu = { .start = amd_uncore_start, .stop = amd_uncore_stop, .read = amd_uncore_read, + .capabilities = PERF_PMU_CAP_NO_INTERRUPT, }; static struct amd_uncore *amd_uncore_alloc(unsigned int cpu) -- 2.20.1