cpuidle: pseries: Do not cap the CEDE0 latency in fixup_cede0_latency()

Currently in fixup_cede0_latency() code, we perform the fixup the
CEDE(0) exit latency value only if minimum advertized extended CEDE
latency values are less than 10us. This was done so as to not break
the expected behaviour on POWER8 platforms where the advertised
latency was higher than the default 10us, which would delay the SMT
folding on the core.

However, after the earlier patch "cpuidle/pseries: Fixup CEDE0 latency
only for POWER10 onwards", we can be sure that the fixup of CEDE0
latency is going to happen only from POWER10 onwards. Hence
unconditionally use the minimum exit latency provided by the platform.

Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/1626676399-15975-3-git-send-email-ego@linux.vnet.ibm.com
This commit is contained in:
Gautham R. Shenoy 2021-07-19 12:03:19 +05:30 committed by Michael Ellerman
parent 50741b70b0
commit 71737a6c2a
1 changed files with 31 additions and 30 deletions

View File

@ -346,11 +346,9 @@ static int pseries_cpuidle_driver_init(void)
static void __init fixup_cede0_latency(void)
{
struct xcede_latency_payload *payload;
u64 min_latency_us;
u64 min_xcede_latency_us = UINT_MAX;
int i;
min_latency_us = dedicated_states[1].exit_latency; // CEDE latency
if (parse_cede_parameters())
return;
@ -358,42 +356,45 @@ static void __init fixup_cede0_latency(void)
nr_xcede_records);
payload = &xcede_latency_parameter.payload;
/*
* The CEDE idle state maps to CEDE(0). While the hypervisor
* does not advertise CEDE(0) exit latency values, it does
* advertise the latency values of the extended CEDE states.
* We use the lowest advertised exit latency value as a proxy
* for the exit latency of CEDE(0).
*/
for (i = 0; i < nr_xcede_records; i++) {
struct xcede_latency_record *record = &payload->records[i];
u8 hint = record->hint;
u64 latency_tb = be64_to_cpu(record->latency_ticks);
u64 latency_us = DIV_ROUND_UP_ULL(tb_to_ns(latency_tb), NSEC_PER_USEC);
if (latency_us == 0)
pr_warn("cpuidle: xcede record %d has an unrealistic latency of 0us.\n", i);
/*
* We expect the exit latency of an extended CEDE
* state to be non-zero, it to since it takes at least
* a few nanoseconds to wakeup the idle CPU and
* dispatch the virtual processor into the Linux
* Guest.
*
* So we consider only non-zero value for performing
* the fixup of CEDE(0) latency.
*/
if (latency_us == 0) {
pr_warn("cpuidle: Skipping xcede record %d [hint=%d]. Exit latency = 0us\n",
i, hint);
continue;
}
if (latency_us < min_latency_us)
min_latency_us = latency_us;
if (latency_us < min_xcede_latency_us)
min_xcede_latency_us = latency_us;
}
/*
* By default, we assume that CEDE(0) has exit latency 10us,
* since there is no way for us to query from the platform.
*
* However, if the wakeup latency of an Extended CEDE state is
* smaller than 10us, then we can be sure that CEDE(0)
* requires no more than that.
*
* Perform the fix-up.
*/
if (min_latency_us < dedicated_states[1].exit_latency) {
/*
* We set a minimum of 1us wakeup latency for cede0 to
* distinguish it from snooze
*/
u64 cede0_latency = 1;
if (min_latency_us > cede0_latency)
cede0_latency = min_latency_us - 1;
dedicated_states[1].exit_latency = cede0_latency;
dedicated_states[1].target_residency = 10 * (cede0_latency);
if (min_xcede_latency_us != UINT_MAX) {
dedicated_states[1].exit_latency = min_xcede_latency_us;
dedicated_states[1].target_residency = 10 * (min_xcede_latency_us);
pr_info("cpuidle: Fixed up CEDE exit latency to %llu us\n",
cede0_latency);
min_xcede_latency_us);
}
}