Skip to content

Update setPL.sh#3

Open
Betaminos wants to merge 2 commits intohorshack-dpreview:masterfrom
Betaminos:master
Open

Update setPL.sh#3
Betaminos wants to merge 2 commits intohorshack-dpreview:masterfrom
Betaminos:master

Conversation

@Betaminos
Copy link

  • Add read-only mode (run without arguments) for reading from the various registers
  • Add additional output in case the MMIO limit reg is not locked
  • Minor rephrasing to emphasize state (ENabled and DISabled)
  • Remove duplicate variable

Add read-only mode (run without arguments) for reading from the various registers
Add additional output in case the MMIO limit reg is not locked
Minor rephrasing to emphasize state (ENabled and DISabled)
Remove duplicate variable
INTEL_PL1_ENABLE_BITS_LOW=0x00008000
INTEL_PL2_ENABLE_BITS_HIGH=0x00008000
INTEL_PL1_PL2_ENABLE_BITS=$((INTEL_PL1_ENABLE_BITS_LOW | (INTEL_PL2_ENABLE_BITS_HIGH<<32)))
INTEL_PL_ENABLE_BITS=0x00008000 #identical for PL1_ENABLE_BITS_LOW and PL2_ENABLE_BITS_HIGH
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact these two register halves incidental values for the desired field is incidental. They should still be kept separate for clarity and for future maintenance.

if [ "$#" != "2" ]; then
if [ "$#" == "0" ]; then
echo "!! Running SetPL in read-only mode !!"
readOnly=$TRUE
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's please refer to this as "showOnly" instead of "readOnly", which makes the intention clearer.

#
if [ "$#" != "2" ]; then
if [ "$#" == "0" ]; then
echo "!! Running SetPL in read-only mode !!"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This echo can be removed - it'll be implied from the context of how the user invoked the utility.

echo "!! Running SetPL in read-only mode !!"
readOnly=$TRUE

elif [ "$#" != "2" ]; then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the new zero-arg invocation description in this help message.

echo "**** Setting PL1=$PL1 and PL2=$PL2 in /sys/class/powercap/intel-rapl/intel-rapl:0/constraint_*_power_limit_uw"
echo "$PL1" > /sys/class/powercap/intel-rapl/intel-rapl:0/constraint_0_power_limit_uw
echo "$PL2" > /sys/class/powercap/intel-rapl/intel-rapl:0/constraint_1_power_limit_uw
if [ $readOnly -ne $TRUE ]; then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than having the showOnly checks distributed throughout the logic, please add a block here to specifically handle the read-only case by printing the value of the MMIO (lock status + PL1/PL2 values), then exit. Everything beyond this point will then be only for the set case. You can place the logic in the function to make it reusable for both the showOnly and regular cases.

msr=$((msr | INTEL_PL1_PL2_ENABLE_BITS))
writeMsr $INTEL_MSR_PKG_POWER_LIMIT $msr
else
echo "**** PL1 and PL2 are DISabled in MSR_PKG_POWER_LIMIT"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

turbostat's strange capitalization of "DISabled" and "ENabled" doesn't need to be matched in setPL.

- corrected typo
- added reference to devmem2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants