Skip to content

Commit 3af0ada

Browse files
Gautham R. Shenoympe
authored andcommitted
cpuidle: pseries: Set the latency-hint before entering CEDE
As per the PAPR, each H_CEDE call is associated with a latency-hint to be passed in the VPA field "cede_latency_hint". The CEDE states that we were implicitly entering so far is CEDE with latency-hint = 0. This patch explicitly sets the latency hint corresponding to the CEDE state that we are currently entering. While at it, we save the previous hint, to be restored once we wakeup from CEDE. This will be required in the future when we expose extended-cede states through the cpuidle framework, where each of them will have a different cede-latency hint. Signed-off-by: Gautham R. Shenoy <[email protected]> [mpe: Make cede_latency_hint static] Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent dfa03ff commit 3af0ada

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/cpuidle/cpuidle-pseries.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,27 @@ static void check_and_cede_processor(void)
8686
}
8787
}
8888

89+
#define NR_DEDICATED_STATES 2 /* snooze, CEDE */
90+
91+
static u8 cede_latency_hint[NR_DEDICATED_STATES];
92+
8993
static int dedicated_cede_loop(struct cpuidle_device *dev,
9094
struct cpuidle_driver *drv,
9195
int index)
9296
{
97+
u8 old_latency_hint;
9398

9499
pseries_idle_prolog();
95100
get_lppaca()->donate_dedicated_cpu = 1;
101+
old_latency_hint = get_lppaca()->cede_latency_hint;
102+
get_lppaca()->cede_latency_hint = cede_latency_hint[index];
96103

97104
HMT_medium();
98105
check_and_cede_processor();
99106

100107
local_irq_disable();
101108
get_lppaca()->donate_dedicated_cpu = 0;
109+
get_lppaca()->cede_latency_hint = old_latency_hint;
102110

103111
pseries_idle_epilog();
104112

@@ -130,7 +138,7 @@ static int shared_cede_loop(struct cpuidle_device *dev,
130138
/*
131139
* States for dedicated partition case.
132140
*/
133-
static struct cpuidle_state dedicated_states[] = {
141+
static struct cpuidle_state dedicated_states[NR_DEDICATED_STATES] = {
134142
{ /* Snooze */
135143
.name = "snooze",
136144
.desc = "snooze",
@@ -233,7 +241,7 @@ static int pseries_idle_probe(void)
233241
max_idle_state = ARRAY_SIZE(shared_states);
234242
} else {
235243
cpuidle_state_table = dedicated_states;
236-
max_idle_state = ARRAY_SIZE(dedicated_states);
244+
max_idle_state = NR_DEDICATED_STATES;
237245
}
238246
} else
239247
return -ENODEV;

0 commit comments

Comments
 (0)