Power Capping Framework and RAPL Driver
Subsystems (5)
v2 cover Power Capping Framework and RAPL Driver
Overview
With the evolution of technologies, which enables power monitoring and limiting, more and more devices are able to constrain their power consumption under certain limits. There are several use cases for such technologies:
- Power monitoring: Each device can report its power consumption.
- Power Limiting: Setting power limits on the devices allows users to guard against platform reaching max system power level.
- Maximize performance: While staying below a power limit, it allows devices to automatically adjust performance to meet demands
- Dynamic control and re-budgeting: If each device can be constrained to some power, extra power can redistributed to other devices, which needs additional performance.
One such example of technologies is RAPL (Running Average Power Limit) mechanism available in the latest Intel processors. Intel is slowly adding many devices under RAPL control. Also there are other technologies available, for power capping various devices. Soon it is very likely that other vendors are also adding or considering such implementation.
Power Capping framework is an effort to have a uniform interface available to Linux drivers, which will enable
- A uniform sysfs interface for all devices which can offer power capping
- A common API for drivers, which will avoid code duplication and easy implementation of client drivers.
Also submitting Intel RAPL driver using power capping framework.
History:
v2
As suggested, added BIT_ULL_MASK and BIT_ULL_WORD
v1
Incorporated changes suggested during RFC stage
Jacob Pan (2):
x86/msr: add 64bit _on_cpu access functions
Introduce Intel RAPL power capping driver
Srinivas Pandruvada (4):
PowerCap: Documentation
PowerCap: Add class driver
PowerCap: Added to drivers build
bitops: Introduce BIT_ULL
Documentation/ABI/testing/sysfs-class-powercap | 152 +++ Documentation/power/powercap/powercap.txt | 236 ++++ arch/x86/include/asm/msr.h | 22 + arch/x86/lib/msr-smp.c | 62 ++ drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/powercap/Kconfig | 31 + drivers/powercap/Makefile | 2 + drivers/powercap/intel_rapl.c | 1395 ++++++++++++++++++++++++ drivers/powercap/powercap_sys.c | 699 ++++++++++++ include/linux/bitops.h | 3 + include/linux/powercap.h | 325 ++++++ 12 files changed, 2930 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-powercap create mode 100644 Documentation/power/powercap/powercap.txt create mode 100644 drivers/powercap/Kconfig create mode 100644 drivers/powercap/Makefile create mode 100644 drivers/powercap/intel_rapl.c create mode 100644 drivers/powercap/powercap_sys.c create mode 100644 include/linux/powercap.h
Signature · 1 line
1.8.3.1
PATCH v2 1/6 PowerCap: Documentation
Added power cap framework documentation. This explains the use of power capping framework, sysfs and programming interface.
There are two documents:Documentation/power/powercap/powercap.txt : Explains use case and APIs. Documentation/ABI/testing/sysfs-class-powercap: Explains ABIs.
--- Documentation/ABI/testing/sysfs-class-powercap | 152 ++++++++++++++++ Documentation/power/powercap/powercap.txt | 236 +++++++++++++++++++++++++ 2 files changed, 388 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-powercap create mode 100644 Documentation/power/powercap/powercap.txt
Documentation/ABI/testing/sysfs-class-powercap new file +152 -0
@@ -0,0 +1,152 @@ +What: /sys/class/powercap/ +Date: September 2013 +KernelVersion: 3.13 +Contact: [email protected] +Description: + The powercap/ class sub directory belongs to the power cap + subsystem. Refer to + Documentation/power/powercap/powercap.txt for details. + +What: /sys/class/powercap/<control type> +Date: September 2013 +KernelVersion: 3.13 +Contact: [email protected] +Description: + A <control type> is a unique name under /sys/class/powercap. + Here <control type> determines how the power is going to be + controlled. A <control type> can contain multiple power zones. + +What: /sys/class/powercap/<control type>/enabled +Date: September 2013 +KernelVersion: 3.13 +Contact: [email protected] +Description: + This allows to enable/disable power capping for a "control type". + This status affects every power zone using this "control_type. + +What: /sys/class/powercap/<control type>/<power zone> +Date: September 2013 +KernelVersion: 3.13 +Contact: [email protected] +Description: + A power zone is a single or a collection of devices, which can + be independently monitored and controlled. A power zone sysfs + entry is qualified with the name of the <control type>. + E.g. intel-rapl:0:1:1. + +What: /sys/class/powercap/<control type>/<power zone>/<child power zone> +Date: September 2013 +KernelVersion: 3.13 +Contact: [email protected] +Description: + Power zones may be organized in a hierarchy in which child + power zones provide monitoring and control for a subset of + devices under the parent. For example, if there is a parent + power zone for a whole CPU package, each CPU core in it can + be a child power zone. + +What: /sys/class/powercap/.../<power zone>/name +Date: September 2013 +KernelVersion: 3.13 +Contact: [email protected] +Description: + Specifies the name of this power zone. + +What: /sys/class/powercap/.../<power zone>/energy_uj +Date: September 2013 +KernelVersion: 3.13 +Contact: [email protected] +Description: + Current energy counter in micro-joules. Write "0" to reset. + If the counter can not be reset, then this attribute is + read-only. + +What: /sys/class/powercap/.../<power zone>/max_energy_range_uj +Date: September 2013 +KernelVersion: 3.13 +Contact: [email protected] +Description: + Range of the above energy counter in micro-joules. + + +What: /sys/class/powercap/.../<power zone>/power_uw +Date: September 2013 +KernelVersion: 3.13 +Contact: [email protected] +Description: + Current power in micro-watts. + +What: /sys/class/powercap/.../<power zone>/max_power_range_uw +Date: September 2013 +KernelVersion: 3.13 +Contact: [email protected] +Description: + Range of the above power value in micro-watts. + +What: /sys/class/powercap/.../<power zone>/constraint_X_name +Date: September 2013 +KernelVersion: 3.13 +Contact: [email protected] +Description: + Each power zone can define one or more constraints. Each + constraint can have an optional name. Here "X" can have values + from 0 to max integer. + +What: /sys/class/powercap/.../<power zone>/constraint_X_power_limit_uw +Date: September 2013 +KernelVersion: 3.13 +Contact: [email protected] +Description: + Power limit in micro-watts should be applicable for + the time window specified by "constraint_X_time_window_us". + Here "X" can have values from 0 to max integer. + +What: /sys/class/powercap/.../<power zone>/constraint_X_time_window_us +Date: September 2013 +KernelVersion: 3.13 +Contact: [email protected] +Description: + Time window in micro seconds. This is used along with + constraint_X_power_limit_uw to define a power constraint. + Here "X" can have values from 0 to max integer. + + +What: /sys/class/powercap/<control type>/.../constraint_X_max_power_uw +Date: September 2013 +KernelVersion: 3.13 +Contact: [email protected] +Description: + Maximum allowed power in micro watts for this constraint. + Here "X" can have values from 0 to max integer. + +What: /sys/class/powercap/<control type>/.../constraint_X_min_power_uw +Date: September 2013 +KernelVersion: 3.13 +Contact: [email protected] +Description: + Minimum allowed power in micro watts for this constraint. + Here "X" can have values from 0 to max integer. + +What: /sys/class/powercap/.../<power zone>/constraint_X_max_time_window_us +Date: September 2013 +KernelVersion: 3.13 +Contact: [email protected] +Description: + Maximum allowed time window in micro seconds for this + constraint. Here "X" can have values from 0 to max integer. + +What: /sys/class/powercap/.../<power zone>/constraint_X_min_time_window_us +Date: September 2013 +KernelVersion: 3.13 +Contact: [email protected] +Description: + Minimum allowed time window in micro seconds for this + constraint. Here "X" can have values from 0 to max integer. + +What: /sys/class/powercap/.../<power zone>/enabled +Date: September 2013 +KernelVersion: 3.13 +Contact: [email protected] +Description + This allows to enable/disable power capping at power zone level. + This applies to current power zone and its children.
Documentation/power/powercap/powercap.txt new file +236 -0
236 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 2/6 PowerCap: Add class driver
In reply to Srinivas PandruvadaThe power capping framework providing a consistent interface between the kernel and user space that allows power capping drivers to expose their settings to user space in a uniform way.
The overall design of the framework is described in the documentation added by the previous patch in this series.
--- drivers/powercap/Kconfig | 19 ++ drivers/powercap/Makefile | 1 + drivers/powercap/powercap_sys.c | 699 ++++++++++++++++++++++++++++++++++++++++ include/linux/powercap.h | 325 +++++++++++++++++++ 4 files changed, 1044 insertions(+) create mode 100644 drivers/powercap/Kconfig create mode 100644 drivers/powercap/Makefile create mode 100644 drivers/powercap/powercap_sys.c create mode 100644 include/linux/powercap.h
drivers/powercap/Kconfig new file +19 -0
@@ -0,0 +1,19 @@ +# +# Generic power capping sysfs interface configuration +# + +menuconfig POWERCAP + bool "Generic powercap sysfs driver" + help + The power capping sysfs interface allows kernel subsystems to expose power + capping settings to user space in a consistent way. Usually, it consists + of multiple control types that determine which settings may be exposed and + power zones representing parts of the system that can be subject to power + capping. + + If you want this code to be compiled in, say Y here. + +if POWERCAP +# Client driver configurations go here. + +endif
drivers/powercap/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_POWERCAP) += powercap_sys.o
include/linux/powercap.h new file +325 -0
325 lines not on this page · raw message
drivers/powercap/powercap_sys.c new file +699 -0
699 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 3/6 PowerCap: Added to drivers build
In reply to Srinivas PandruvadaAdded changes to Makefile and Kconfig to include in driver build.
--- drivers/Kconfig | 2 ++ drivers/Makefile | 1 + 2 files changed, 3 insertions(+)
drivers/Kconfig +2 -0
@@ -166,4 +166,6 @@ source "drivers/reset/Kconfig" source "drivers/fmc/Kconfig" +source "drivers/powercap/Kconfig" + endmenu
drivers/Makefile +1 -0
@@ -152,3 +152,4 @@ obj-$(CONFIG_VME_BUS) += vme/ obj-$(CONFIG_IPACK_BUS) += ipack/ obj-$(CONFIG_NTB) += ntb/ obj-$(CONFIG_FMC) += fmc/ +obj-$(CONFIG_POWERCAP) += powercap/
Signature · 1 line
1.8.3.1
PATCH v2 4/6 x86/msr: add 64bit _on_cpu access functions
In reply to Srinivas PandruvadaFrom: Jacob Pan <[email protected]>
Having 64-bit MSR access methods on given CPU can avoid shifting and simplify MSR content manipulation. We already have other combinations of rdmsrl_xxx and wrmsrl_xxx but missing the _on_cpu version.
--- arch/x86/include/asm/msr.h | 22 ++++++++++++++++ arch/x86/lib/msr-smp.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+)
arch/x86/include/asm/msr.h +22 -0
@@ -218,10 +218,14 @@ void msrs_free(struct msr *msrs);#ifdef CONFIG_SMP int rdmsr_on_cpu (unsigned int cpu,u32 msr_no,u32 *l,u32 *h);int wrmsr_on_cpu (unsigned int cpu,u32 msr_no,u32 l,u32 h); +int rdmsrl_on_cpu (unsigned int cpu,u32 msr_no,u64 *q); +int wrmsrl_on_cpu (unsigned int cpu,u32 msr_no,u64 q);void rdmsr_on_cpus (const struct cpumask *mask,u32 msr_no,struct msr *msrs);void wrmsr_on_cpus (const struct cpumask *mask,u32 msr_no,struct msr *msrs);int rdmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u32 *l,u32 *h);int wrmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u32 l,u32 h); +int rdmsrl_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 *q); +int wrmsrl_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 q);int rdmsr_safe_regs_on_cpu (unsigned int cpu,u32 regs[8 ]);int wrmsr_safe_regs_on_cpu (unsigned int cpu,u32 regs[8 ]);#else /* CONFIG_SMP */
@@ -235,6 +239,16 @@ static inline int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)wrmsr (msr_no, l, h);return 0 ; } +static inline int rdmsrl_on_cpu (unsigned int cpu,u32 msr_no,u64 *q) +{ +rdmsrl (msr_no, *q); +return 0 ; +} +static inline int wrmsrl_on_cpu (unsigned int cpu,u32 msr_no,u64 q) +{ +wrmsrl (msr_no, q); +return 0 ; +}static inline void rdmsr_on_cpus (const struct cpumask *m,u32 msr_no,struct msr *msrs) {
@@ -254,6 +268,14 @@ static inline int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) {return wrmsr_safe (msr_no, l, h); } +static inline int rdmsrl_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 *q) +{ +return rdmsrl_safe (msr_no, q); +} +static inline int wrmsrl_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 q) +{ +return wrmsrl_safe (msr_no, q); +}static inline int rdmsr_safe_regs_on_cpu (unsigned int cpu,u32 regs[8 ]) {return rdmsr_safe_regs (regs);
arch/x86/lib/msr-smp.c +62 -0
80 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 6/6 Introduce Intel RAPL power capping driver
In reply to Srinivas PandruvadaFrom: Jacob Pan <[email protected]>
The Intel Running Average Power Limit(RAPL) technology provides platform software with the ability to monitor, control, and get notifications on power usage.
This feature is present in all Sandy Bridge and later Intel processors. Newer models allow more fine grained controls to be applied. In RAPL, power control is divided into domains, which include package, DRAM controller, CPU core (Power Plane 0), graphics uncore (power plane 1), etc.
The purpose of this driver is to expose the RAPL settings to userspace. Overall, RAPL fits in the new powercap class driver in
that platform level power capping controls are exposed via this generic interface.
This driver is based on an earlier patch from Zhang Rui.
https://lkml.org/lkml/2011/5/26/93
However, while the previous work was mainly focused on thermal monitoring the focus here is on the usability from user space perspective.
--- drivers/powercap/Kconfig | 12 + drivers/powercap/Makefile | 1 + drivers/powercap/intel_rapl.c | 1395 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1408 insertions(+) create mode 100644 drivers/powercap/intel_rapl.c
drivers/powercap/Kconfig +12 -0
@@ -15,5 +15,17 @@ menuconfig POWERCAP if POWERCAP # Client driver configurations go here. +config INTEL_RAPL + tristate "Intel RAPL Support" + default n + ---help--- + This enables support for the Intel Running Average Power Limit (RAPL) + technology which allows power limits to be enforced and monitored on + modern Intel processors (Sandy Bridge and later). + + In RAPL, the platform level settings are divided into domains for + fine grained control. These domains include processor package, DRAM + controller, CPU core (Power Plance 0), graphics uncore (Power Plane + 1), etc. endif
drivers/powercap/Makefile +1 -0
@@ -1 +1,2 @@ obj-$(CONFIG_POWERCAP) += powercap_sys.o +obj-$(CONFIG_INTEL_RAPL) += intel_rapl.o
drivers/powercap/intel_rapl.c new file +1395 -0
1,395 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 5/6 bitops: Introduce BIT_ULL
In reply to Srinivas PandruvadaAdding BIT(x) equivalent for unsigned long long type, BIT_ULL(x). Also added BIT_ULL_MASK and BIT_ULL_WORD.
--- include/linux/bitops.h | 3 +++ 1 file changed, 3 insertions(+)
include/linux/bitops.h +3 -0
@@ -4,8 +4,11 @@#ifdef __KERNEL__#define BIT (nr) (1UL << (nr)) +#define BIT_ULL (nr) (1ULL << (nr))#define BIT_MASK (nr) (1UL << ((nr) % BITS_PER_LONG))#define BIT_WORD (nr) ((nr) / BITS_PER_LONG) +#define BIT_ULL_MASK (nr) (1ULL << ((nr) % BITS_PER_LONG_LONG)) +#define BIT_ULL_WORD (nr) ((nr) / BITS_PER_LONG_LONG)#define BITS_PER_BYTE 8#define BITS_TO_LONGS (nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))#endif
Signature · 1 line
1.8.3.1
Re: [PATCH v2 2/6] PowerCap: Add class driver
In reply to Srinivas PandruvadaQuoted 5 lines · Srinivas Pandruvada
drivers/powercap/powercap_sys.c new file +5
-0+/* Power zone ro attributes define */ +#define powercap_attr_ro (_name) \ + static DEVICE_ATTR(_name, 0444, show_##_name, NULL) + +/* Power zone rw attributes define */
drivers/powercap/powercap_sys.c line 39
Quoted 10 lines
drivers/powercap/powercap_sys.c new file +10
-0+#define powercap_attr_rw (_name) \ + static DEVICE_ATTR(_name, 0644, show_##_name, store_##_name) + +/* constraint attributes define rw */ +#define powercap_const_attr_rw (_name) \ + static DEVICE_ATTR(_name, 0644, show_constraint_##_name, \ + store_constraint_##_name) +/* constraint attributes define ro */ +#define powercap_const_attr_ro (_name) \ + static DEVICE_ATTR(_name, 0644, show_constraint_##_name, NULL)
Minor nit:
Why are you using your own defines, why not just use the DEVICE_ATTR_RO() and DEVICE_ATTR_RW() macros? That way it makes it easier to grep for attributes, and ensure they have set the mode bits properly.
thanks,
greg k-h
Re: [PATCH v2 6/6] Introduce Intel RAPL power capping driver
In reply to Srinivas PandruvadaQuoted 3 lines · Srinivas Pandruvada
The Intel Running Average Power Limit(RAPL) technology provides platform software with the ability to monitor, control, and get notifications on power usage.
[]
drivers/powercap/Makefile
Quoted 1 line
drivers/powercap/Makefile +0
-0
[]
Quoted 5 lines
drivers/powercap/Makefile +5
-0+/* bitmasks for RAPL MSRs, used by primitive access functions */ +#define ENERGY_STATUS_MASK 0xffffffff + +#define POWER_LIMIT1_MASK 0x7FFF +#define POWER_LIMIT1_ENABLE BIT(15)
drivers/powercap/Makefile
Quoted 10 lines
drivers/powercap/Makefile +10
-0+#define POWER_LIMIT1_CLAMP BIT(16) + +#define POWER_LIMIT2_MASK (0x7FFFULL<<32) +#define POWER_LIMIT2_ENABLE BIT_ULL(47) +#define POWER_LIMIT2_CLAMP BIT_ULL(48) +#define POWER_PACKAGE_LOCK BIT_ULL(63) +#define POWER_PP_LOCK BIT(31) + +#define TIME_WINDOW1_MASK (0x7F<<17) +#define TIME_WINDOW2_MASK (0x7FULL<<49)
Is there a reason why these masks aren't all ULL?
Re: [PATCH v2 3/6] PowerCap: Added to drivers build
In reply to Srinivas PandruvadaQuoted 26 lines · Srinivas Pandruvada
Added changes to
MakefileandKconfigto include in driver build.Signed-off-by Srinivas Pandruvada <[email protected]>Signed-off-by Jacob Pan <[email protected]>---
drivers/Kconfig| 2 ++drivers/Makefile| 1 +2 files changed, 3 insertions(+)drivers/Kconfig +0
-0@@ -166,4 +166,6 @@ source "drivers/reset/Kconfig"source "
drivers/fmc/Kconfig"drivers/Kconfig +2
-0+source "drivers/powercap/Kconfig" +endmenu
drivers/Makefile +0
-0@@ -152,3 +152,4 @@ obj-$(CONFIG_VME_BUS) += vme/
Quoted 4 lines
obj-$(CONFIG_IPACK_BUS) += ipack/
obj-$(CONFIG_NTB) += ntb/
obj-$(CONFIG_FMC) += fmc/
+obj-$(CONFIG_POWERCAP) += powercap/
I would object to this whole premise if it is not under the absolute control of the users program. Linuxcnc for instance is intimately married to a parport whose status for writes is absolutely stable from write to write, and whose status may be in some cases, read at sub 20 u-second intervals. Anything which would imped this, puts the operator of a 50+ ton piece of machinery's life in jeopardy because its status is not readable in as close to real time as possible as it may be required to initiate a stop from some alarm condition before it has moved far enough to injure, maim or kill. 50 thousandths of an inch in further movement while moving a 70 ton milling machines table at 150 inches a minute is not an unreasonable expectation for us.
Cheers, Gene
Signature · 9 lines
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Q: What does the CE in Windows CE stand for?
A: Caveat Emptor.
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
law-abiding citizens.Re: [PATCH v2 3/6] PowerCap: Added to drivers build
Quoted 34 lines · Gene Heskett
Quoted 26 lines · Srinivas Pandruvada
Added changes to
MakefileandKconfigto include in driver build.Signed-off-by Srinivas Pandruvada <[email protected]>Signed-off-by Jacob Pan <[email protected]>---
drivers/Kconfig| 2 ++drivers/Makefile| 1 +2 files changed, 3 insertions(+)drivers/Kconfig +0
-0@@ -166,4 +166,6 @@ source "drivers/reset/Kconfig"source "
drivers/fmc/Kconfig"drivers/Kconfig +2
-0+source "drivers/powercap/Kconfig" +endmenu
drivers/Makefile +0
-0@@ -152,3 +152,4 @@ obj-$(CONFIG_VME_BUS) += vme/Quoted 4 lines
obj-$(CONFIG_IPACK_BUS) += ipack/
obj-$(CONFIG_NTB) += ntb/
obj-$(CONFIG_FMC) += fmc/
+obj-$(CONFIG_POWERCAP) += powercap/I would object to this whole premise if it is not under the absolute control of the users program. Linuxcnc for instance is intimately married to a parport whose status for writes is absolutely stable from write to
Quoted 8 lines
write, and whose status may be in some cases, read at sub 20 u-second intervals. Anything which would imped this, puts the operator of a 50+ ton piece of machinery's life in jeopardy because its status is not readable in as close to real time as possible as it may be required to initiate a stop from some alarm condition before it has moved far enough to injure, maim or kill. 50 thousandths of an inch in further movement while moving a 70 ton milling machines table at 150 inches a minute is not an unreasonable expectation for us.
<Sorry, I didn't understand. Are you pointing any problem in this patch or patch-set in general? This change added powercap directory to the kernel build. Is something wrong with it or any other way to do that?
Quoted 2 lines
Cheers, Gene
Re: [PATCH v2 2/6] PowerCap: Add class driver
In reply to Greg KHQuoted 18 lines · Greg KH
Quoted 5 lines · Srinivas Pandruvada
drivers/powercap/powercap_sys.c new file +5
-0+/* Power zone ro attributes define */ +#define powercap_attr_ro (_name) \ + static DEVICE_ATTR(_name, 0444, show_##_name, NULL) + +/* Power zone rw attributes define */ drivers/powercap/powercap_sys.c line 39
Quoted 10 lines
drivers/powercap/powercap_sys.c new file +10
-0+#define powercap_attr_rw (_name) \ + static DEVICE_ATTR(_name, 0644, show_##_name, store_##_name) + +/* constraint attributes define rw */ +#define powercap_const_attr_rw (_name) \ + static DEVICE_ATTR(_name, 0644, show_constraint_##_name, \ + store_constraint_##_name) +/* constraint attributes define ro */ +#define powercap_const_attr_ro (_name) \ + static DEVICE_ATTR(_name, 0644, show_constraint_##_name, NULL)Minor nit:
Quoted 4 lines
Why are you using your own defines, why not just use the
DEVICE_ATTR_RO()andDEVICE_ATTR_RW()macros? That way it makes it easier to grep for attributes, and ensure they have set the mode bits properly.
I will replace in the next patchset.
Thanks,
Srinivas
Re: [PATCH v2 6/6] Introduce Intel RAPL power capping driver
In reply to Joe PerchesQuoted 17 lines · On Fri, 04 Oct 2013 11:07:45 -0700 Joe Perches <[email protected]> wrote:
Quoted 3 lines · Srinivas Pandruvada
The Intel Running Average Power Limit(RAPL) technology provides platform software with the ability to monitor, control, and get notifications on power usage.
[]
drivers/powercap/Makefile
Quoted 1 line
drivers/powercap/Makefile +0
-0[]
Quoted 10 lines
drivers/powercap/Makefile +10
-0+/* bitmasks for RAPL MSRs, used by primitive access functions */ +#define ENERGY_STATUS_MASK 0xffffffff + +#define POWER_LIMIT1_MASK 0x7FFF +#define POWER_LIMIT1_ENABLE BIT(15) +#define POWER_LIMIT1_CLAMP BIT(16) + +#define POWER_LIMIT2_MASK (0x7FFFULL<<32) +#define POWER_LIMIT2_ENABLE BIT_ULL(47) +#define POWER_LIMIT2_CLAMP BIT_ULL(48)
Quoted 10 lines
drivers/powercap/Makefile
Quoted 5 lines
drivers/powercap/Makefile +5
-0+#define POWER_PACKAGE_LOCK BIT_ULL(63) +#define POWER_PP_LOCK BIT(31) + +#define TIME_WINDOW1_MASK (0x7F<<17) +#define TIME_WINDOW2_MASK (0x7FULL<<49)Is there a reason why these masks aren't all ULL?
are you referring to this line below not being ULL?
Quoted 1 line
Quoted 1 line
+#define
TIME_WINDOW1_MASK(0x7F<<17)
if this is the case, I did that because it is not more than 32 bit.
Thanks,
Jacob
Re: [PATCH v2 3/6] PowerCap: Added to drivers build
In reply to a message not in the archiveQuoted 67 lines · Gene Heskett
Quoted 44 lines · Srinivas Pandruvada
Quoted 35 lines · Gene Heskett
Quoted 27 lines · Srinivas Pandruvada
Added changes to
MakefileandKconfigto include in driver build.Signed-off-by: Srinivas Pandruvada <[email protected]> Signed-off-by: Jacob Pan <[email protected]>
---
drivers/Kconfig| 2 ++drivers/Makefile| 1 +2 files changed, 3 insertions(+)drivers/Kconfig +0
-0@@ -166,4 +166,6 @@ source "drivers/reset/Kconfig"source "
drivers/fmc/Kconfig"drivers/Kconfig +2
-0+source "drivers/powercap/Kconfig" +endmenu
drivers/Makefile +0
-0@@ -152,3 +152,4 @@ obj-$(CONFIG_VME_BUS) += vme/Quoted 4 lines
obj-$(CONFIG_IPACK_BUS) += ipack/
obj-$(CONFIG_NTB) += ntb/
obj-$(CONFIG_FMC) += fmc/
+obj-$(CONFIG_POWERCAP) += powercap/I would object to this whole premise if it is not under the absolute control of the users program. Linuxcnc for instance is intimately married to a parport whose status for writes is absolutely stable from
Quoted 8 lines
write to write, and whose status may be in some cases, read at sub 20 u-second intervals. Anything which would imped this, puts the operator of a 50+ ton piece of machinery's life in jeopardy because its status is not readable in as close to real time as possible as it may be required to initiate a stop from some alarm condition before it has moved far enough to injure, maim or kill. 50 thousandths of an inch in further movement while moving a 70 ton milling machines table at 150 inches a minute is not an unreasonable expectation for us.
Quoted 2 lines
<Sorry, I didn't understand. Are you pointing any problem in this patch or patch-set in general?
Not that my relatively untrained eyes can spot.
Quoted 2 lines
This change added powercap directory to the kernel build. Is something wrong with it or any other way to do that?
The prospect of having a poorly configured way to power down a port that is running heavy machinery under real time control scares me. And that is what this patch series seems to be leading up to if I am reading the patch headers correctly. If I am not reading it correctly, then assume I am issuing a pre-emptive strike just to make sure you folks trying to save a milliwatt here and there, and there is not a thing wrong with the basic idea, are made aware of the potential for maiming mischief should you decide to power down a port just because its last access was 5 milliseconds ago. Even a completely servo driven configuration will tickle it faster than that, however an e-stop condition, which might shut down a charge pump pulse generator must be maintained until cleared by the operator, which means the control channel to the machine, whatever port it is, must be kept alive to be human safe around the machine. The capability to do that to a given port should therefore be made a kernel .config selection incapable of being overridden by some other perceived dependency in kconfig.
Quoted 1 line
I hope this is a better explanation. :)
The idea of power capping is to cap total power not power down and also need root level access to modify. There is a minimum and maximum values is also defined, which should make sure that the system is running with reduced performance, not power down.
This patch is not affecting Linux PM. Power down a port trigger generated by PM framework in coordination with the driver controlling the port.
If some port is capable of powercapping and implemented a client driver for this, they can disable the whole power capping by setting CONFIG_POWERCAP=n for such systems.
Quoted 2 lines
And please, lets keep such discussion on the list where it belongs.
I am still doing reply to all to keep everyone in the mailing list in loop.
Thanks,
Srinivas
Re: [PATCH v2 6/6] Introduce Intel RAPL power capping driver
In reply to Jacob PanQuoted 31 lines · Jacob Pan
Quoted 17 lines · On Fri, 04 Oct 2013 11:07:45 -0700 Joe Perches <[email protected]> wrote:
Quoted 3 lines · Srinivas Pandruvada
The Intel Running Average Power Limit(RAPL) technology provides platform software with the ability to monitor, control, and get notifications on power usage.
[]
drivers/powercap/Makefile
Quoted 1 line
drivers/powercap/Makefile +0
-0[]
Quoted 10 lines
drivers/powercap/Makefile +10
-0+/* bitmasks for RAPL MSRs, used by primitive access functions */ +#define ENERGY_STATUS_MASK 0xffffffff + +#define POWER_LIMIT1_MASK 0x7FFF +#define POWER_LIMIT1_ENABLE BIT(15) +#define POWER_LIMIT1_CLAMP BIT(16) + +#define POWER_LIMIT2_MASK (0x7FFFULL<<32) +#define POWER_LIMIT2_ENABLE BIT_ULL(47) +#define POWER_LIMIT2_CLAMP BIT_ULL(48)Quoted 10 lines
drivers/powercap/Makefile
Quoted 5 lines
drivers/powercap/Makefile +5
-0+#define POWER_PACKAGE_LOCK BIT_ULL(63) +#define POWER_PP_LOCK BIT(31) + +#define TIME_WINDOW1_MASK (0x7F<<17) +#define TIME_WINDOW2_MASK (0x7FULL<<49)Is there a reason why these masks aren't all ULL?
Quoted 7 lines
are you referring to this line below not being ULL?
Quoted 1 line
Quoted 1 line
+#define
TIME_WINDOW1_MASK(0x7F<<17)if this is the case, I did that because it is not more than 32 bit.
Thanks,
Jacob
Isn't LIMIT1/WINDOW1 used as ull anyway?
It doesn't hurt to show that the value is also ull.
Re: [PATCH v2 3/6] PowerCap: Added to drivers build
In reply to Srinivas PandruvadaQuoted 1 line · Srinivas Pandruvada
On 10/04/2013 01:22 PM, Gene Heskett wrote:
[and snipped]
Quoted 26 lines
Quoted 26 lines
Quoted 2 lines
<Sorry, I didn't understand. Are you pointing any problem in this patch or patch-set in general?
Not that my relatively untrained eyes can spot.
Quoted 2 lines
This change added powercap directory to the kernel build. Is something wrong with it or any other way to do that?
The prospect of having a poorly configured way to power down a port that is running heavy machinery under real time control scares me. And that is what this patch series seems to be leading up to if I am reading the patch headers correctly. If I am not reading it correctly, then assume I am issuing a pre-emptive strike just to make sure you folks trying to save a milliwatt here and there, and there is not a thing wrong with the basic idea, are made aware of the potential for maiming mischief should you decide to power down a port just because its last access was 5 milliseconds ago. Even a completely servo driven configuration will tickle it faster than that, however an e-stop condition, which might shut down a charge pump pulse generator must be maintained until cleared by the operator, which means the control channel to the machine, whatever port it is, must be kept alive to be human safe around the machine. The capability to do that to a given port should therefore be made a kernel .config selection incapable of being overridden by some other perceived dependency in kconfig.
Quoted 4 lines
Quoted 1 line
I hope this is a better explanation. :)
The idea of power capping is to cap total power not power down and also need root level access to modify.
No. Restricting it to root control only is NOT an option. There has to be some mechanism whereby the users non-root program can control it. We don't run this software as root, ever. And the part of this software that needs the parport (or a pci card access) is running on a cpu core that has been isolated for its use by an isocpus= statement, not visible to top or any other system monitoring utility, so you would never know we are pounding on that port, both reads and multiple writes, at least 3 times every 23 microseconds. So you might see it as idle and turn it off.
Quoted 3 lines
There is a minimum and maximum values is also defined, which should make sure that the system is
running with reduced performance, not power down.
When cutting steel, or anything else for that matter, power used is not a consideration as long as there is enough, so in this case, reduced performance is not a viable option particularly if stepper motors are involved as they need a very steady heartbeat. And its just as important in the cpu driving the machine as it is in the motors driving the machine. Right now, there are only about 4 or 5 motherboards on the planet that can do this job fairly well for stepper based systems.
2 of them are your atom powered boards. One of them is the BeagleBone Black but we are still designing the I/O cape for that so its not cutting steel daily, yet. Had you not disco'd the D-525-MW boards, the market channel for those could easily absorb 10 or more per week for a nearly indefinite period. You accidentally made the nearly ideal board and its not a power hog. The BIG Reason? IRQ latency is 2 to 3 microseconds, and there is nothing else x86 based that can touch that figure that we have found so far.
When I say you, I am of course referring to Intel, since you are coming in from an Intel address. :)
Quoted 3 lines
This patch is not affecting Linux PM. Power down a port trigger generated by PM framework in coordination
with the driver controlling the port.
But what if you cannot detect that driver, and its port use, because its behind an isolcpus=0 statement on the kernel command line in grub?
This is what scares me spitless. It could get somebody injured/killed, or wreck a $500,000 machine.
Quoted 3 lines
If some port is capable of powercapping and implemented a client driver for this, they can disable the whole
power capping by settingCONFIG_POWERCAP=nfor such systems.
Good.
Quoted 1 line
Quoted 1 line
And please, lets keep such discussion on the list where it belongs.
I clicked on reply to list and got no To: line contents at all. KMail does that to me when its a PM. Only been using it since '98, I really should learn to use it right someday. :)
Quoted 2 lines
I am still doing reply to all to keep everyone in the mailing list in loop.
So am I, now.
Quoted 5 lines
Thanks,
Srinivas
Cheers, Gene
Signature · 10 lines
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Of course power tools and alcohol don't mix. Everyone knows power
tools aren't soluble in alcohol...
-- Crazy Nigel
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
law-abiding citizens.Re: [PATCH v2 6/6] Introduce Intel RAPL power capping driver
In reply to Joe PerchesQuoted 2 lines · On Fri, 04 Oct 2013 15:14:22 -0700 Joe Perches <[email protected]> wrote:
Isn't LIMIT1/WINDOW1 used as ull anyway?
It doesn't hurt to show that the value is also ull.
sure, I will make that change in the next set.
thanks,
Jacob
Re: [PATCH v2 3/6] PowerCap: Added to drivers build
In reply to Gene HeskettQuoted 5 lines · Gene Heskett
Quoted 4 lines
Quoted 1 line
I hope this is a better explanation. :)
The idea of power capping is to cap total power not power down and also need root level access to modify.
Quoted 8 lines
No. Restricting it to root control only is NOT an option. There has to be some mechanism whereby the users non-root program can control it. We don't run this software as root, ever. And the part of this software that needs the parport (or a pci card access) is running on a cpu core that has been isolated for its use by an isocpus= statement, not visible to top or any other system monitoring utility, so you would never know we are pounding on that port, both reads and multiple writes, at least 3 times every 23 microseconds. So you might see it as idle and turn it off.
I understand that you do not want to see powercapping in effect. I think I mostly understand the realtime angle you're coming from as well.
However, powercapping is not done for energy savings, it is done for SURVIVAL. It is not something optional that you can just turn off and ignore;
if you ignore it... something either has a thermal meltdown or trips a circuit breaker... or in the case of a laptop/tablet kind of shape, you give the user burn blisters.
(the thermal meltdown effect can be either damage to the system or a hard reset done by a hardware safety mechanism.. neither is what you want for your realtime workload)
The solution to not use powercapping in combination with realtime is to make sure there is ample cooling for the system, and to make sure the circuit breakers are big enough... .... not ways to try to turn it off from non-root.
(and note that powerclamp for example takes realtime priority into account by only running at "half priority"... ... but if the real realtime prevents clamping altogether, other, more dracionian things will kick in)
and if you wonder what linux does today without the framework; there are mechanisms that kick in at the very end of the range, that are very draconian like taking the 3.0Ghz processor down to effectively 100MHz, or even a system reboot. The point of what Jacob and Srinivas are trying to add is to intervene slightly earlier (these failsafe mechanisms are still there) but much much more gently.
Re: [PATCH v2 3/6] PowerCap: Added to drivers build
Quoted 4 lines · Arjan van de Ven
Quoted 3 lines · Gene Heskett
Quoted 3 lines
Quoted 1 line
I hope this is a better explanation. :)
The idea of power capping is to cap total power not power down
What is the difference to us if it wrecks a $1000 part, or a $100,000 machine?
Quoted 17 lines
Quoted 12 lines
Quoted 2 lines
and
also need root level access to modify.No. Restricting it to root control only is NOT an option. There has to be some mechanism whereby the users non-root program can control it. We don't run this software as root, ever. And the part of this software that needs the parport (or a pci card access) is running on a cpu core that has been isolated for its use by an isocpus= statement, not visible to top or any other system monitoring utility, so you would never know we are pounding on that port, both reads and multiple writes, at least 3 times every 23 microseconds. So you might see it as idle and turn it off.
I understand that you do not want to see powercapping in effect. I think I mostly understand the realtime angle you're coming from as well.
Quoted 5 lines
However, powercapping is not done for energy savings, it is done for SURVIVAL. It is not something optional that you can just turn off and ignore; if you ignore it... something either has a thermal meltdown or trips a circuit breaker... or in the case of a laptop/tablet kind of shape, you give the user burn blisters.
Nobody puts an accessible I/O port, in this case an EPP capable parport, or except for the card slot on some of them, any port we can use for real time control, so obviously we aren't using any laptops or netbooks in such a system, so those concerns are completely out of our playing field. They simply don't apply.
Quoted 3 lines
(the thermal meltdown effect can be either damage to the system or a hard reset done by a hardware safety mechanism.. neither is what you want for your realtime workload)
No it surely isn't, but we are comparing the worth of replacing a failed motherboard that sells for less than 100 bucks, with the worth of a machine that may be carving a Toyota O.R.R. engine block at the time of the failure. We can buy a couple cases of those motherboards without raising the price of that engine block to the racer, its simply not that big a factor. The ruined but 99% finished engine block now is, so it had better not be a weekly occurrence. It is also not something that any of our group has ever experienced and gone public with.
Quoted 11 lines
The solution to not use powercapping in combination with realtime is to make sure there is ample cooling for the system, and to make sure the circuit breakers are big enough... .... not ways to try to turn it off from non-root.
(and note that powerclamp for example takes realtime priority into account by only running at "half priority"... ... but if the real realtime prevents clamping altogether, other, more dracionian things will kick in)
Quoted 6 lines
and if you wonder what linux does today without the framework; there are mechanisms that kick in at the very end of the range, that are very draconian like taking the 3.0Ghz processor down to effectively 100MHz, or even a system reboot. The point of what Jacob and Srinivas are trying to add is to intervene slightly earlier (these failsafe mechanisms are still there) but much much more gently.
First off, we are not using the type of boards for controllers that would burn anything up sans its normal cooling, which is entirely passive on an atom powered board as you well know. So there is no fan to fail and start your doomsday scenario in abut 30% of the cases now, but there are a rather dukes mixture of other boards being used yet. Those will be replaced in due time as they fail, or the IRQ latency finally starts costing the shop owner money because the machine can't be run at the optimum speed with that poorly architect-ed board, probably with Atoms or BBB's.
So, let me ask, will your patches initiate a parport hardware shutdown, when that port is in fact being used at 1 millisecond intervals best case, 20 u-sec worst case, by a process you can't see because it is behind an isolcpus= statement naming the processor core that is using it?
We can't see past that isolcpus=statement to see how hard that core is running, nor can we see the port activity without wasting a pin to drive an enabling charge pump.
If you insist on doing this, in the face of ample evidence its nothing but a feel good action on your part, then the least we ask is for a tally signal output, far enough in advance, say 0.25 seconds, to do a graceful, controlled e-stop before the machine self-destructs, or kills somebody standing just past the normal travel turn around and goes 2 meters past that turn around point because we didn't have time to run all the servo outputs to 0.000 volts, stopping the machine in a reasonable time frame that doesn't sheer the 3" bolts anchoring it to the floor. We wouldn't care if the seismographs 20 miles away record that stop, which they will & have done quite a few times already in the Cincinnati area, but its a safe stop except for the potential damages to the workpiece on the table because the cutting motions during the stop would be out of the normal path tolerance window.
In fact, I'd go so far as to say that any hardware capable of self- destructing in normal operation, does not need to guarded by this proposed function, but blacklisted instead, it is patently a defective design from square one regardless of the brand name on the box. Or just let it burn up, the warranty returns will educate the maker/designer soon enough.
Maybe the best compromise is to just put a switch, either on the kernel command line, or in kconfig, allowing us to shut this function off on installs where this would be dangerous.
Linuxcnc, because of the truly invasive RTAI patches that often takes months to properly apply, do not build a new kernel very often, but we could shut it off either of those places and be happy. We are currently running 90% of the machines on a 2.6.32-128-RTAI patched kernel, but recent experiments with the 3.4.xx + xenomai patch kit have also shown promise.
Cheers, Gene
Signature · 9 lines
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Love is the delusion that one woman differs from another.
-- H. L. Mencken
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
law-abiding citizens.Re: [PATCH v2 3/6] PowerCap: Added to drivers build
Quoted 7 lines · Gene Heskett
Quoted 6 lines
and if you wonder what linux does today without the framework; there are mechanisms that kick in at the very end of the range, that are very draconian like taking the 3.0Ghz processor down to effectively 100MHz, or even a system reboot. The point of what Jacob and Srinivas are trying to add is to intervene slightly earlier (these failsafe mechanisms are still there) but much much more gently.
Quoted 8 lines
First off, we are not using the type of boards for controllers that would burn anything up sans its normal cooling, which is entirely passive on an atom powered board as you well know. So there is no fan to fail and start your doomsday scenario in abut 30% of the cases now, but there are a rather dukes mixture of other boards being used yet. Those will be replaced in due time as they fail, or the IRQ latency finally starts costing the shop owner money because the machine can't be run at the optimum speed with that poorly architect-ed board, probably with Atoms or BBB's.
so if your system today never hits the thermal shutdown... ... you're not going to hit anything powercapping either.
Quoted 3 lines
If you insist on doing this, in the face of ample evidence its nothing but a feel good action on your part, then the least we ask is for a tally signal output, far enough in advance, say 0.25 seconds, to do a graceful,
btw one thing to note that this is just the kernel mechanism; the actual knobs that it provides get turned by some userspace daemon..
I would fully expect that if you even ship such a daemon on your realtime device, that you build in the notification for sure.
Quoted 5 lines
In fact, I'd go so far as to say that any hardware capable of self- destructing in normal operation, does not need to guarded by this proposed function, but blacklisted instead, it is patently a defective design from square one regardless of the brand name on the box. Or just let it burn up, the warranty returns will educate the maker/designer soon enough.
self-destruct or reboot... either case you will not like it.