Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1326768pxb; Wed, 10 Feb 2021 06:04:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXfeoxZ2XCUq2oPllgmF0LYGfoU9+Lwq6p2Pd4rxQAGj/xw5kJ9Di2lMSpkB02aRSUypTe X-Received: by 2002:a17:906:f8d4:: with SMTP id lh20mr3057115ejb.466.1612965889216; Wed, 10 Feb 2021 06:04:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612965889; cv=none; d=google.com; s=arc-20160816; b=BLg4itKO/gErinrSrxJruWaZGyyc3c2KWkCDA8DU/ZHE0yKL2VCmpivzzfihw6MbTz dqLHaqBUth+ZQSQsJS57oMzWtaavpVrRqpdtvWPlVWU1+jdldKVAR4YLiIz5fI3+GNZn ndGTY+Dq5rLTqwGGi7GT6fSjnAqmq2OfogdbAMiS7sJO4HE6zSzDaJIdHuh5I2bHKmtm mOCIPxPY76S6yAqKO45TAvih56OjFCLwBEw4fKGP16dB+Gl8J9bo0DMexwuEu0uG/A7o aA4SSiPxmhO7/hAU699tmwuUWP+dM9Ohunggsi+pwiGF+bkRb2kIw9+Fqg7QzTuQJv4O 6+RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=SXxaxPVmthlLPYH94L3qiYzVbFKur4bVfH0likKjx/I=; b=fZZT3VGQa4k8WO616PTFWVAzcJrdzNTejggFqYZobG/495Q5/ngYVmy4Zco/ALxz9w RVCHVIvxNxwVbAswcXpfrJBL+dWR0PwLaUEq84EQWpS2p+abe4NuoqV0y/FigQ76PZAS LQrVmBeHNZmJWqHOfgdyPsG/2FJ+Vt9veM0+B78CTVEkYud+5aBaOjoA7rk7kNSeb3wJ xdRrXCfih0sTrBq35PD5KKzSjycZHSpkoKfiJVkjtVjrII2VI7GL7zhhuCaPyL6/QDQq BMrUkWLAnBpx+Z96rzHDbSykoecIQg+EvASoTq4o45++7lmvUf68VbXEbVzvOx4gA4oi 3Ugg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=sLK9N5ci; dkim=neutral (no key) header.i=@linutronix.de header.b=cdMAdKlE; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o6si1303512ejg.674.2021.02.10.06.04.24; Wed, 10 Feb 2021 06:04:49 -0800 (PST) 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=@linutronix.de header.s=2020 header.b=sLK9N5ci; dkim=neutral (no key) header.i=@linutronix.de header.b=cdMAdKlE; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231962AbhBJOCg (ORCPT + 99 others); Wed, 10 Feb 2021 09:02:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231709AbhBJOAa (ORCPT ); Wed, 10 Feb 2021 09:00:30 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 645C8C06178B; Wed, 10 Feb 2021 05:59:32 -0800 (PST) Date: Wed, 10 Feb 2021 13:59:30 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1612965571; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SXxaxPVmthlLPYH94L3qiYzVbFKur4bVfH0likKjx/I=; b=sLK9N5civ3FNz/7ptJJWBIR6pfEzvSKguZo6TxTc4KjSbw6nieBPrWOciP1lUGWoJAF9pm P5O+TQXALUDrOlySBRpoBB3BedMjBrxUof/a2rABBu3vLNPJOsd9ljIj1RGJzhUVSgMbNF l88Qp5/iOTx9YKaIqu1ATX5CgoYv3dz3LN4smZr1QGHZANZ1jAgmlnvaFYTlEFLG9a3zIj 9VQPI+np9B45l5FbjO9nVLKCP89L+Jf2DhPDaoneWqdAvy0ZXX4p+ko9Vk+pP1gwv1BQ+3 757Yp4Kys3V7JtEkgxjtwRmIm1L/fIDm9Lk7MGUTln2klVmOefvgkmVvUMQUkw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1612965571; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SXxaxPVmthlLPYH94L3qiYzVbFKur4bVfH0likKjx/I=; b=cdMAdKlEGCgKacrNwSem3GP6inD1R6GeKhx4Y2VZZRQYyTJKXwDOjufEdBXDFko5S0ZVfb u6IYn+yMWt6bQpAw== From: "tip-bot2 for Zhang Rui" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/x86/rapl: Add msr mask support Cc: Zhang Rui , "Peter Zijlstra (Intel)" , Andi Kleen , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20210204161816.12649-1-rui.zhang@intel.com> References: <20210204161816.12649-1-rui.zhang@intel.com> MIME-Version: 1.0 Message-ID: <161296557037.23325.12133894476994706739.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/core branch of tip: Commit-ID: ffb20c2e52e8709b5fc9951e8863e31efb1f2cba Gitweb: https://git.kernel.org/tip/ffb20c2e52e8709b5fc9951e8863e31efb1f2cba Author: Zhang Rui AuthorDate: Fri, 05 Feb 2021 00:18:14 +08:00 Committer: Peter Zijlstra CommitterDate: Wed, 10 Feb 2021 14:44:54 +01:00 perf/x86/rapl: Add msr mask support In some cases, when probing a perf MSR, we're probing certain bits of the MSR instead of the whole register, thus only these bits should be checked. For example, for RAPL ENERGY_STATUS MSR, only the lower 32 bits represents the energy counter, and the higher 32bits are reserved. Introduce a new mask field in struct perf_msr to allow probing certain bits of a MSR. This change is transparent to the current perf_msr_probe() users. Signed-off-by: Zhang Rui Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Andi Kleen Link: https://lkml.kernel.org/r/20210204161816.12649-1-rui.zhang@intel.com --- arch/x86/events/probe.c | 7 ++++++- arch/x86/events/probe.h | 7 ++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/x86/events/probe.c b/arch/x86/events/probe.c index 136a1e8..600bf8d 100644 --- a/arch/x86/events/probe.c +++ b/arch/x86/events/probe.c @@ -28,6 +28,7 @@ perf_msr_probe(struct perf_msr *msr, int cnt, bool zero, void *data) for (bit = 0; bit < cnt; bit++) { if (!msr[bit].no_check) { struct attribute_group *grp = msr[bit].grp; + u64 mask; /* skip entry with no group */ if (!grp) @@ -44,8 +45,12 @@ perf_msr_probe(struct perf_msr *msr, int cnt, bool zero, void *data) /* Virt sucks; you cannot tell if a R/O MSR is present :/ */ if (rdmsrl_safe(msr[bit].msr, &val)) continue; + + mask = msr[bit].mask; + if (!mask) + mask = ~0ULL; /* Disable zero counters if requested. */ - if (!zero && !val) + if (!zero && !(val & mask)) continue; grp->is_visible = NULL; diff --git a/arch/x86/events/probe.h b/arch/x86/events/probe.h index 4c8e0af..261b9bd 100644 --- a/arch/x86/events/probe.h +++ b/arch/x86/events/probe.h @@ -4,10 +4,11 @@ #include struct perf_msr { - u64 msr; - struct attribute_group *grp; + u64 msr; + struct attribute_group *grp; bool (*test)(int idx, void *data); - bool no_check; + bool no_check; + u64 mask; }; unsigned long