Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp313606pxb; Wed, 3 Feb 2021 06:19:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwLgahvb5m1Va+AKcZnC0lRBZJ/4A+vq4MuYOa/2/OKMdrfzaokk2uY1J1YkpJHHbBsQUvJ X-Received: by 2002:a17:907:2805:: with SMTP id eb5mr3363786ejc.277.1612361963472; Wed, 03 Feb 2021 06:19:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612361963; cv=none; d=google.com; s=arc-20160816; b=N4C9ZR560KMgdL7lka7ajTDaL/anEU/oZHFvos4mKMa5/QpNoBQ8eEGjWK1Hcozp88 aVbXyrpveWDEHfg991WOZUtvKEoQ+q3wZMBlA/3iiEzhZ0frayXJq4TeFm+LI9Pd/B0A Q9B9OtwFMcz/d7DAlRiTawbQmdV0lSM0Ax+BB+3ZLj75hoz6ott/D8MY3rSTW37kEspK 8yxmflzi8WKPihcRF5TO1xYAPNIyNLxBsmAouxxIVH63vw8265055b3Tuw3Bhl9/3Ln/ SaZPR+ZBk8PnlSQlZeyqbkjcKkVXFQIrCTL7fkeuL2BZGRq7/8Z4kTn8p+K9O84AOb6P vonA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :dlp-version:dlp-reaction:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=HdvZOO6EeJnOxUw90zBWUElAMiUnSoyf+TIabfSgRXE=; b=ZMscdHbTQEqXdZqiAP0PxdL/wkN/mdR/s3xNmfaw4V7XdfN3zjZBwWNHgO4eNj8Rya s+BIJHRJVF5/96lvuL27eQklxbXJXxJrVPh3pXzDZujE4kC7mK7VwAMR3FsSgkI2X3as fOM3l5wxmZTH97EpTTZbhlAx+lXVlJIKaYW8syLkElSRk87DxfjHkypsX+7UXb5q7YxU E6d1lkmgFSsjRmbl7owcZLnytjvxkMYaogeGBCj3ZKAeq3kBpndTgUDxhUAjBuj8kgf0 m8eyLwyd5Nntgr4enmZrbXdUDvaOc6nU1T52GeCyyJvUyy6NaO2cBNypz5uF104+NgHG jalA== 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 p7si1256290ejf.627.2021.02.03.06.18.57; Wed, 03 Feb 2021 06:19:23 -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; 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 S232819AbhBCOSA convert rfc822-to-8bit (ORCPT + 99 others); Wed, 3 Feb 2021 09:18:00 -0500 Received: from mga11.intel.com ([192.55.52.93]:53896 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232192AbhBCORz (ORCPT ); Wed, 3 Feb 2021 09:17:55 -0500 IronPort-SDR: jEmnbIgjgKYb7hh4EvKXFpk5kNf+NdDRTSFL8wHU0VUSmeYTI53/VHFzzK1RjdwKzQT5cssYxy FghkTcRWg6pQ== X-IronPort-AV: E=McAfee;i="6000,8403,9883"; a="177539360" X-IronPort-AV: E=Sophos;i="5.79,398,1602572400"; d="scan'208";a="177539360" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2021 06:17:14 -0800 IronPort-SDR: un7CTrH3340njg5E1Tn51sO2+G9e5bhwpiANqUermFVnVzW6+n8IzGqk0yE+F6wub3Vf6wUX0n smKxUt2xiMbA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,398,1602572400"; d="scan'208";a="433430524" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga001.jf.intel.com with ESMTP; 03 Feb 2021 06:17:14 -0800 Received: from shsmsx604.ccr.corp.intel.com (10.109.6.214) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Wed, 3 Feb 2021 06:17:13 -0800 Received: from shsmsx603.ccr.corp.intel.com (10.109.6.143) by SHSMSX604.ccr.corp.intel.com (10.109.6.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 3 Feb 2021 22:17:11 +0800 Received: from shsmsx603.ccr.corp.intel.com ([10.109.6.143]) by SHSMSX603.ccr.corp.intel.com ([10.109.6.143]) with mapi id 15.01.1713.004; Wed, 3 Feb 2021 22:17:11 +0800 From: "Zhang, Rui" To: Peter Zijlstra 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 Thread-Topic: [PATCH 3/3] perf/x86/rapl: Fix psys-energy event on Intel SPR platform Thread-Index: AQHW7AYrkGH2U5eXgkirITO4BW5mdaorx78AgAwaqQCADrMocA== Date: Wed, 3 Feb 2021 14:17:11 +0000 Message-ID: References: <20210115092208.20866-1-rui.zhang@intel.com> <20210115092208.20866-3-rui.zhang@intel.com> <70b71922e7f84234be70c7104969331f@intel.com> <03e5815f89d749a18b47bdf986181f1f@intel.com> In-Reply-To: <03e5815f89d749a18b47bdf986181f1f@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 x-originating-ip: [10.239.127.36] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Peter, > -----Original Message----- > From: Zhang, Rui > Sent: Monday, January 25, 2021 2:11 PM > To: 'Peter Zijlstra' > 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' 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 > > Hi, Peter, > > > -----Original Message----- > > From: Zhang, Rui > > Sent: Sunday, January 17, 2021 10:34 PM > > To: 'Peter Zijlstra' > > 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 > > > > Hi, Peter, > > > > > -----Original Message----- > > > From: Peter Zijlstra > > > Sent: Saturday, January 16, 2021 8:50 PM > > > 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 > > > Importance: High > > > > > > 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? > > > > To make things simple, I ignore the master thing, and probe the > > psys-energy counter blindly on SPR. > > So rapl_cpu_mask still includes all the online CPUs. > > This means that psys-energy is "valid" on all packages, and it just > > returns different values on different packages. > > AKA, whole system power consumption on Psys master package, and Zero > > on Psys slave packages. > > > In short, the current code does not allow RAPL energy counter to return 0. > And all the work I do is to allow Psys energy counter to return 0. > In this way, the Psys event is "valid" on all CPUs, so we don't need to handle > the master thing. > The drawback is that we still see psys-energy event, but with 0 readout, > when Psys counter is not available (master package offlined, or psys > disabled). > > TBH, I'm not quite sure if I understand your original question correctly or not, > so please let me know if there is still something unclear. > Sorry to bother, may I know your concern about this patch series? Thanks, rui > Thanks, > rui > > > > Thanks, > > rui