Merge branch 'pm-cpuidle'

Merge cpuidle updates for 6.9-rc1:

 - Prevent the haltpoll cpuidle governor from shrinking guest
   poll_limit_ns below grow_start (Parshuram Sangle).

 - Avoid potential overflow in integer multiplication when computing
   cpuidle state parameters (C Cheng).

 - Adjust MWAIT hint target C-state computation in the ACPI cpuidle
   driver and in intel_idle to return a correct value for C0 (He
   Rongguang).

* pm-cpuidle:
  cpuidle: ACPI/intel: fix MWAIT hint target C-state computation
  cpuidle: Avoid potential overflow in integer multiplication
  cpuidle: haltpoll: do not shrink guest poll_limit_ns below grow_start
This commit is contained in:
Rafael J. Wysocki 2024-03-11 15:49:18 +01:00
commit 7a8d578350
4 changed files with 13 additions and 6 deletions

View File

@ -131,8 +131,8 @@ static long acpi_processor_ffh_cstate_probe_cpu(void *_cx)
cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx);
/* Check whether this particular cx_type (in CST) is supported or not */
cstate_type = ((cx->address >> MWAIT_SUBSTATE_SIZE) &
MWAIT_CSTATE_MASK) + 1;
cstate_type = (((cx->address >> MWAIT_SUBSTATE_SIZE) &
MWAIT_CSTATE_MASK) + 1) & MWAIT_CSTATE_MASK;
edx_part = edx >> (cstate_type * MWAIT_SUBSTATE_SIZE);
num_cstate_subtype = edx_part & MWAIT_SUBSTATE_MASK;

View File

@ -16,6 +16,7 @@
#include <linux/cpumask.h>
#include <linux/tick.h>
#include <linux/cpu.h>
#include <linux/math64.h>
#include "cpuidle.h"
@ -187,7 +188,7 @@ static void __cpuidle_driver_init(struct cpuidle_driver *drv)
s->target_residency = div_u64(s->target_residency_ns, NSEC_PER_USEC);
if (s->exit_latency > 0)
s->exit_latency_ns = s->exit_latency * NSEC_PER_USEC;
s->exit_latency_ns = mul_u32_u32(s->exit_latency, NSEC_PER_USEC);
else if (s->exit_latency_ns < 0)
s->exit_latency_ns = 0;
else

View File

@ -98,10 +98,15 @@ static void adjust_poll_limit(struct cpuidle_device *dev, u64 block_ns)
unsigned int shrink = guest_halt_poll_shrink;
val = dev->poll_limit_ns;
if (shrink == 0)
if (shrink == 0) {
val = 0;
else
} else {
val /= shrink;
/* Reset value to 0 if shrunk below grow_start */
if (val < guest_halt_poll_grow_start)
val = 0;
}
trace_guest_halt_poll_ns_shrink(val, dev->poll_limit_ns);
dev->poll_limit_ns = val;
}

View File

@ -1934,7 +1934,8 @@ static void __init spr_idle_state_table_update(void)
static bool __init intel_idle_verify_cstate(unsigned int mwait_hint)
{
unsigned int mwait_cstate = MWAIT_HINT2CSTATE(mwait_hint) + 1;
unsigned int mwait_cstate = (MWAIT_HINT2CSTATE(mwait_hint) + 1) &
MWAIT_CSTATE_MASK;
unsigned int num_substates = (mwait_substates >> mwait_cstate * 4) &
MWAIT_SUBSTATE_MASK;