Message ID | 20240131142335.84218-1-rui.zhang@intel.com |
---|---|
Headers |
Return-Path: <linux-kernel+bounces-46591-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1923109dyb; Wed, 31 Jan 2024 06:24:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IHfxpCNkDGP/kIXuPg1s50AkunDE2TpfN/vLcaNL3G8WxE+CwgiCNs2zy1eXHb0XRJxdTdN X-Received: by 2002:a05:6a00:1803:b0:6db:acb2:a95d with SMTP id y3-20020a056a00180300b006dbacb2a95dmr1783264pfa.21.1706711086158; Wed, 31 Jan 2024 06:24:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706711086; cv=pass; d=google.com; s=arc-20160816; b=S+t4eSpEpWjX0xhI321cqAHYo92XBCK5n+H3KXjjvwvpBPTsy3sMNRSPOO1C0JKIOf xiVJ8lITAdHcvcyoth3R7EtiJGrJ5zCahuTNb9NEPnRdgwYmHXb9+aztT/BVoV4Py1Wu gGak1AIiMYMmmmu6QPB5qEQZAkD4EL1W6uFER3qX/nek5Hohu6aSnp14GXfO9g2OGmjR RYkfnzyOdHMbILaxHqU6BZ0Sixunvkx175ISNKatYRTBqR1ANZRuetY9KoizYCMDietk hkODs/cwD33TlY5wqtfNU0e1K7qioXaFfmIAN4omNZC/DJFTv13imAZ/AlqQEejoaWzB toyw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=kHf71RfSoDkMnXcTK7uX+Kg1tfdZX2nUwU8HpWrYyN8=; fh=vrNc8ix2EoFy9IXfwOSk8eMu94kcSBkFAdNl1uthOMY=; b=ZP9gpE90LoD2YoSCH/+iH/VunDWmUgMtsqgYcA46e6oo+HVo3IHJbqnrj81uzc98yt L+AtLrC+x7dKJz/Z81JFUYp/+w4qnRgsmmRWDGVOFvI7pVbVe2oTQPcBt+GIpeIjOHkI q0AqpBXYBNyyhRjmnry7G7KHcHrfxT7dQ2eqv5hS13ZD1CPqItT/KF2yBMk8IcjazsDI hKU9cND0mu3JUeJnObwEnfRJ3idUiUEIprHyJVSXDKPv3xN6NdDc05wETLCytYlt/Vse +Uz32PZVg02ZcoDN4mR2RRUuGsk9pm4SGumwa/ne6GdRGbVq1CSY7DzF9LeI1pvBis+8 J+SQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TUQ5sMjx; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-46591-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46591-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCVj188wjOKcdlt4y2eBAxCCDu7cPZUzNyFTZxc4rau+3uNqx8Bc1b1EEJ/5XzmgnVVij6S0auqpn3yaoJtYy47p/mwj3Q== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i14-20020a63e44e000000b005d8b3138f64si7891385pgk.279.2024.01.31.06.24.46 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 06:24:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46591-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TUQ5sMjx; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-46591-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46591-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id BDAD9289CCA for <ouuuleilei@gmail.com>; Wed, 31 Jan 2024 14:24:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2BDA383CA1; Wed, 31 Jan 2024 14:23:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TUQ5sMjx" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F12C80BFC; Wed, 31 Jan 2024 14:23:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706711031; cv=none; b=ur2DvJJYkz7FjAfQHNTNnZQcnHy2Wu7Yj9fwW4U07g4OpJh6qlvLePaBzl8VnRr3mb54/nAS9ORd5i3jGIvlwh8KsGIcTYiPbYopoWlm9SEsKilzFef3b7rQrhi0fIjun1niJtNPeppmF1TTYTXzmD0oX0AR49fU4vF0Br+vQvY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706711031; c=relaxed/simple; bh=ze9vWIEOghvdhXjX52j98Xc6K8ccnY1OjzwxcPEufSM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=CIK3PrXv28/VJZgDEiDoH6dzJ+gP3fytil/QA/rvXMCCaQXJrzkqvgGtYg6ZNKKUFQwbbBmK5vnqAjdC1p0PYrJ0lA9/SgeeR0Uel502Ep25URBrwRqsdkXV9/YX8LOBFtc8R9G4ppLhbqgwqMYxemlU1CbwKZz+/1aYw8se/So= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=TUQ5sMjx; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706711029; x=1738247029; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ze9vWIEOghvdhXjX52j98Xc6K8ccnY1OjzwxcPEufSM=; b=TUQ5sMjxjAaCzlWZvtcDN0mlEw2B1vGg1u/A0h6aacSpadzE3RT0ojXZ A/DlMe1Ulq4l05Mu96B5Yhu57a2/fS8FheHJMVA+1Tu4Akzq9Yq31tVzt PYpQFTtHB9LpL8FInA9PadvdSw7f31MfuDvRMLSK/GiGumSVyZma8cb1j BTDpExxAP+L2xYWNl1Y6FDZpGH7Cx3VuZzUixwTnFCtYbB/VFUZTILGaY WIBX37ZumTgJ5GiC66ZTkwzg8Xd/hY/2jIA4dsWR8eY3vavLBgcJk55ef JL3I34Tt5KjTnsqp5pic/D/wkmx0+g3Wl8REnDMMbBVRZNnGmcGGCdEWg g==; X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="10995795" X-IronPort-AV: E=Sophos;i="6.05,231,1701158400"; d="scan'208";a="10995795" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2024 06:23:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,231,1701158400"; d="scan'208";a="4068676" Received: from puhongt-mobl2.ccr.corp.intel.com (HELO rzhang1-mobl7.ccr.corp.intel.com) ([10.255.29.147]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2024 06:23:45 -0800 From: Zhang Rui <rui.zhang@intel.com> To: rafael.j.wysocki@intel.com, peterz@infradead.org Cc: mingo@redhat.com, kan.liang@linux.intel.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, x86@kernel.org Subject: [PATCH 0/5] intel_rapl & perf rapl: combine PMU support Date: Wed, 31 Jan 2024 22:23:30 +0800 Message-Id: <20240131142335.84218-1-rui.zhang@intel.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789616283920290745 X-GMAIL-MSGID: 1789616283920290745 |
Series |
intel_rapl & perf rapl: combine PMU support
|
|
Message
Zhang, Rui
Jan. 31, 2024, 2:23 p.m. UTC
This patch series is made based on the patch series posted at https://lore.kernel.org/all/20240131113713.74779-1-rui.zhang@intel.com/ Problem statement ----------------- MSR RAPL powercap sysfs is done in drivers/powercap/intel_rapl_msr.c. MSR RAPL PMU is done in arch/x86/events/rapl.c. They maintain two separate CPU model lists, describing the same feature available on the same set of hardware. This increases unnecessary maintenance burden a lot. Now we need to introduce TPMI RAPL PMU support, which again shares most of the logic with MSR RAPL PMU. Solution -------- Introducing PMU support as part of RAPL framework and remove current MSR RAPL PMU code. The idea is that, if a RAPL Package device is registered to RAPL framework, and is ready for energy reporting and control via powercap sysfs, then it is also ready for PMU. So introducing PMU support in RAPL framework that works for all registered RAPL Package devices. With this, we can remove current MSR RAPL PMU completely. Given that MSR RAPL and TPMI RAPL driver won't funtion on the same platform, the new RAPL PMU can be fully compatible with current MSR RAPL PMU, including using the same PMU name and events name/id/unit/scale. For example, on platforms use either MSR or TPMI, use the same command perf stat -e power/energy-pkg/ -e power/energy-ram/ -e power/energy-cores/ FOO to get the energy consumption when the events are in "perf list" output. Notes ----- There are indeed some functional changes introduced, due to the divergency between the two CPU model lists. This includes, 1. Fix BROADWELL_D in intel_rapl driver to use fixed Dram domain energy unit. 2. Enable PMU for some Intel platforms, which were missing in arch/x86/events/rapl.c. This includes ICELAKE_NNPI ROCKETLAKE LUNARLAKE_M LAKEFIELD ATOM_SILVERMONT ATOM_SILVERMONT_MID ATOM_AIRMONT ATOM_AIRMONT_MID ATOM_TREMONT ATOM_TREMONT_D ATOM_TREMONT_L 3. Change the logic for enumerating AMD/HYGON platforms Previously, it was X86_MATCH_FEATURE(X86_FEATURE_RAPL, &model_amd_hygon) And now it is X86_MATCH_VENDOR_FAM(AMD, 0x17, &rapl_defaults_amd) X86_MATCH_VENDOR_FAM(AMD, 0x19, &rapl_defaults_amd) X86_MATCH_VENDOR_FAM(HYGON, 0x18, &rapl_defaults_amd) Any comments/concerns are welcome. thanks, rui ---------------------------------------------------------------- Zhang Rui (5): powercap: intel_rapl: Sort header files powercap: intel_rapl: Add PMU support powercap: intel_rapl_tpmi: Enable PMU support for TPMI RAPL powercap: intel_rapl: Fix BROADWELL_D powercap: intel_rapl_msr: Enable PMU support for MSR RAPL arch/x86/events/Kconfig | 8 - arch/x86/events/Makefile | 1 - arch/x86/events/rapl.c | 871 ----------------------------------- drivers/powercap/intel_rapl_common.c | 562 +++++++++++++++++++++- drivers/powercap/intel_rapl_msr.c | 2 + drivers/powercap/intel_rapl_tpmi.c | 1 + include/linux/intel_rapl.h | 17 + 7 files changed, 569 insertions(+), 893 deletions(-) delete mode 100644 arch/x86/events/rapl.c
Comments
On Wed, Jan 31, 2024 at 3:24 PM Zhang Rui <rui.zhang@intel.com> wrote: > > This patch series is made based on the patch series posted at > https://lore.kernel.org/all/20240131113713.74779-1-rui.zhang@intel.com/ > > Problem statement > ----------------- > MSR RAPL powercap sysfs is done in drivers/powercap/intel_rapl_msr.c. > MSR RAPL PMU is done in arch/x86/events/rapl.c. > > They maintain two separate CPU model lists, describing the same feature > available on the same set of hardware. This increases unnecessary > maintenance burden a lot. > > Now we need to introduce TPMI RAPL PMU support, which again shares most > of the logic with MSR RAPL PMU. > > Solution > -------- > Introducing PMU support as part of RAPL framework and remove current MSR > RAPL PMU code. > > The idea is that, if a RAPL Package device is registered to RAPL > framework, and is ready for energy reporting and control via powercap > sysfs, then it is also ready for PMU. > > So introducing PMU support in RAPL framework that works for all > registered RAPL Package devices. With this, we can remove current MSR > RAPL PMU completely. > > Given that MSR RAPL and TPMI RAPL driver won't funtion on the same > platform, the new RAPL PMU can be fully compatible with current MSR RAPL > PMU, including using the same PMU name and events name/id/unit/scale. > > For example, on platforms use either MSR or TPMI, use the same command > perf stat -e power/energy-pkg/ -e power/energy-ram/ -e power/energy-cores/ FOO > to get the energy consumption when the events are in "perf list" output. > > Notes > ----- > There are indeed some functional changes introduced, due to the > divergency between the two CPU model lists. This includes, > 1. Fix BROADWELL_D in intel_rapl driver to use fixed Dram domain energy > unit. > 2. Enable PMU for some Intel platforms, which were missing in > arch/x86/events/rapl.c. This includes > ICELAKE_NNPI > ROCKETLAKE > LUNARLAKE_M > LAKEFIELD > ATOM_SILVERMONT > ATOM_SILVERMONT_MID > ATOM_AIRMONT > ATOM_AIRMONT_MID > ATOM_TREMONT > ATOM_TREMONT_D > ATOM_TREMONT_L > 3. Change the logic for enumerating AMD/HYGON platforms > Previously, it was > X86_MATCH_FEATURE(X86_FEATURE_RAPL, &model_amd_hygon) > And now it is > X86_MATCH_VENDOR_FAM(AMD, 0x17, &rapl_defaults_amd) > X86_MATCH_VENDOR_FAM(AMD, 0x19, &rapl_defaults_amd) > X86_MATCH_VENDOR_FAM(HYGON, 0x18, &rapl_defaults_amd) > > Any comments/concerns are welcome. Say the first patch in the series is applied and the last one is not. Will anything break? Regardless of the above. if any existing code is moved unmodified by this series to a new location, it would be nice to be able to see that in the patches. Otherwise, some subtle differences may be missed.
On Wed, 2024-01-31 at 15:40 +0100, Rafael J. Wysocki wrote: > On Wed, Jan 31, 2024 at 3:24 PM Zhang Rui <rui.zhang@intel.com> > wrote: > > > > This patch series is made based on the patch series posted at > > https://lore.kernel.org/all/20240131113713.74779-1-rui.zhang@intel.com/ > > > > Problem statement > > ----------------- > > MSR RAPL powercap sysfs is done in > > drivers/powercap/intel_rapl_msr.c. > > MSR RAPL PMU is done in arch/x86/events/rapl.c. > > > > They maintain two separate CPU model lists, describing the same > > feature > > available on the same set of hardware. This increases unnecessary > > maintenance burden a lot. > > > > Now we need to introduce TPMI RAPL PMU support, which again shares > > most > > of the logic with MSR RAPL PMU. > > > > Solution > > -------- > > Introducing PMU support as part of RAPL framework and remove > > current MSR > > RAPL PMU code. > > > > The idea is that, if a RAPL Package device is registered to RAPL > > framework, and is ready for energy reporting and control via > > powercap > > sysfs, then it is also ready for PMU. > > > > So introducing PMU support in RAPL framework that works for all > > registered RAPL Package devices. With this, we can remove current > > MSR > > RAPL PMU completely. > > > > Given that MSR RAPL and TPMI RAPL driver won't funtion on the same > > platform, the new RAPL PMU can be fully compatible with current MSR > > RAPL > > PMU, including using the same PMU name and events > > name/id/unit/scale. > > > > For example, on platforms use either MSR or TPMI, use the same > > command > > perf stat -e power/energy-pkg/ -e power/energy-ram/ -e > > power/energy-cores/ FOO > > to get the energy consumption when the events are in "perf list" > > output. > > > > Notes > > ----- > > There are indeed some functional changes introduced, due to the > > divergency between the two CPU model lists. This includes, > > 1. Fix BROADWELL_D in intel_rapl driver to use fixed Dram domain > > energy > > unit. > > 2. Enable PMU for some Intel platforms, which were missing in > > arch/x86/events/rapl.c. This includes > > ICELAKE_NNPI > > ROCKETLAKE > > LUNARLAKE_M > > LAKEFIELD > > ATOM_SILVERMONT > > ATOM_SILVERMONT_MID > > ATOM_AIRMONT > > ATOM_AIRMONT_MID > > ATOM_TREMONT > > ATOM_TREMONT_D > > ATOM_TREMONT_L > > 3. Change the logic for enumerating AMD/HYGON platforms > > Previously, it was > > X86_MATCH_FEATURE(X86_FEATURE_RAPL, > > &model_amd_hygon) > > And now it is > > X86_MATCH_VENDOR_FAM(AMD, 0x17, &rapl_defaults_amd) > > X86_MATCH_VENDOR_FAM(AMD, 0x19, &rapl_defaults_amd) > > X86_MATCH_VENDOR_FAM(HYGON, 0x18, &rapl_defaults_amd) > > > > Any comments/concerns are welcome. > > Say the first patch in the series is applied and the last one is not. > Will anything break? No. Without the last patch 1. for platforms using TPMI RAPL, .enable_pmu flag is set and PMU is registered via RAPL framework 2. for platforms using MSR RAPL, it doesn't set .enable_pmu flag, and the PMU is registered by arch/x86/events/rapl.c > > Regardless of the above. if any existing code is moved unmodified by > this series to a new location, intel_rapl PMU support shares a lot of code with arch/x86/events/rapl.c, but still there are quite a lot of differences. Including 1. dynamic PMU probing 2. using intel_rapl wrappers to get energy units and read energy counter etc. thanks, rui > it would be nice to be able to see that > in the patches. Otherwise, some subtle differences may be missed.