Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp710075pxb; Sat, 16 Jan 2021 04:55:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJyCwlMI6t9i/XiWzIjXjLtb61Y2oO2qouq5PJXIjhyztaYBcgoDfYh3vYEFGgD/ozy9QtIB X-Received: by 2002:a17:906:a851:: with SMTP id dx17mr136387ejb.537.1610801730027; Sat, 16 Jan 2021 04:55:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610801730; cv=none; d=google.com; s=arc-20160816; b=fxVPkMthHmy6Kj0wu86Kz+hQKyRFU35IFp/Y5hIbq7zbWBtQqVQhSJoxz+2KgcSkJM kuLhE86kYLYg5+HYqp0A1CyIThL/qTUYmG7C3UmdEOS5n8ZC/74yR5B1ES6vUPAdx0Gm nptzxwP/DrumFksdNo6d0bhrz2oQ7z4ltrPLspPKRTeFYYjC62HH9SBwExPv5rgvFwpe HQZb9d7sOxhN+MiRQkQ1hK/Cxs48BKb0CQbJPc8C66FUpt9+kVqjr8AtPsU0RvcOCMHb V/oup5tRCUIN3VBetAYJYrJonG5AS5Sx8ARshajVm0UArCUDtK6D8d2ay+kQ+HNOrDWB nDFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=X4YEUW17kBdpspVxo0YSx9FEO0A/vnfADhbD1A91oJE=; b=SF5pe/SUpCtw2zrKJO6mI29FvRC2AY2qDSsvxGvPuUQe1zD4/UkgkudIFHbeKPfGW8 aXQXxGYwDAlVTRRYEwU8b1wvYnKxVfgHYu3UELfRXWgEx5kuoKetr9LbYhJ0I9Xbtf5f 5KbXqkoRhCbhiZqsCja78XEoy5Siz3S6nWnyE6SEsbYoT0Gl8tiGMGosGUqKiUm8TdTF +EsK4d5Mz0MgHXWvbm3voOPuz81EoW2l5w+NPUDQYMT3gUtJQLq6PdRGsQH9qA3vy+5d sqTh23ZuTu6DUHmCHHkvNsLW2qeRjjMM5DHvO5l4jNQwfgO/3cXhE7aB4SqbmkgH0SwF Cd0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=PbS7quIh; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gz7si438262ejc.87.2021.01.16.04.55.06; Sat, 16 Jan 2021 04:55:30 -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=@infradead.org header.s=merlin.20170209 header.b=PbS7quIh; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727009AbhAPMvF (ORCPT + 99 others); Sat, 16 Jan 2021 07:51:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725979AbhAPMvE (ORCPT ); Sat, 16 Jan 2021 07:51:04 -0500 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 580B4C061757 for ; Sat, 16 Jan 2021 04:50:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=X4YEUW17kBdpspVxo0YSx9FEO0A/vnfADhbD1A91oJE=; b=PbS7quIhRV7+72+c2gs+1J/zho /1AFiqa7vDUiQrOWA/aVFzzhzT7/hEe0aGQeGNscJlzW29zJ6f0T9j7e3uwLgZ7sSvUl7TbdGHhFU iluqP3RolB8l3bH7EWiEGn/SNQ3y5+dw3wvfAV9XaEtRiddaP4uktNQIAW2AWen1HUCnK2U8hRdNb Uoh7Ugeglcs77fzvpnyEgh1T+n8Nmvh9+KrmtOMxKunSH0SzgqtfTh0RsqCFtrwbwsI8D9yBNNdmu Po4FP3y3kT80gbbDdwUvCeStOwqUkCJflybjF1FkYN23nNXSXvfP8iZkYm+fOmwwlIP2ThIJxTjbz pGwjzX6w==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0l1w-0005oI-3b; Sat, 16 Jan 2021 12:50:12 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 804BB30377D; Sat, 16 Jan 2021 13:50:10 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 6F28420299B4E; Sat, 16 Jan 2021 13:50:10 +0100 (CET) Date: Sat, 16 Jan 2021 13:50:10 +0100 From: Peter Zijlstra To: Zhang Rui Cc: mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, kan.liang@linux.intel.com, ak@linux.intel.com Subject: Re: [PATCH 3/3] perf/x86/rapl: Fix psys-energy event on Intel SPR platform Message-ID: References: <20210115092208.20866-1-rui.zhang@intel.com> <20210115092208.20866-3-rui.zhang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210115092208.20866-3-rui.zhang@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 15, 2021 at 05:22:08PM +0800, Zhang Rui wrote: > There are several things special for the RAPL Psys energy counter, on > Intel Sapphire Rapids platform. > 1. it contains one Psys master package, and only CPUs on the master > package can read valid value of the Psys energy counter, reading the > MSR on CPUs in the slave package returns 0. > 2. The master package does not have to be Physical package 0. And when > all the CPUs on the Psys master package are offlined, we lose the Psys > energy counter, at runtime. > 3. The Psys energy counter can be disabled by BIOS, while all the other > energy counters are not affected. > > It is not easy to handle all of these in the current RAPL PMU design > because > a) perf_msr_probe() validates the MSR on some random CPU, which may either > be in the Psys master package or in the Psys slave package. > b) all the RAPL events share the same PMU, and there is not API to remove > the psys-energy event cleanly, without affecting the other events in > the same PMU. > > This patch addresses the problems in a simple way. > > First, by setting .no_check bit for RAPL Psys MSR, the psys-energy event > is always added, so we don't have to check the Psys ENERGY_STATUS MSR on > master package. > > Then, rapl_not_visible() is removed because > 1. it is useless for RAPL MSRs with .no_check cleared, because the > .is_visible() callbacks is always overridden in perf_msr_probe(). > 2. it is useless for RAPL MSRs with .no_check set, because we actually > want the sysfs attributes always be visible for those MSRs. > > With the above changes, we always probe the psys-energy event on Intel SPR > platform. Difference is that the event counter returns 0 when the Psys > RAPL Domain is disabled by BIOS, or the Psys master package is offlined. Maybe I'm too tired, but I cannot follow. How does this cure the fact that the rapl_cpu_mask might not include that master thing. And how can software detect what the master thing is to begin with?