* [PATCH v2 0/2] cpuidle: Do not return from cpuidle_play_dead() on callback failures @ 2024-11-15 20:57 Rafael J. Wysocki 2024-11-15 20:58 ` [PATCH v2 1/2] " Rafael J. Wysocki 2024-11-15 21:00 ` [PATCH v2 2/2] cpuidle: Change :enter_dead() driver callback return type to void Rafael J. Wysocki 0 siblings, 2 replies; 7+ messages in thread From: Rafael J. Wysocki @ 2024-11-15 20:57 UTC (permalink / raw) To: Linux PM, Peter Zijlstra Cc: LKML, x86 Maintainers, Patryk Wlazlyn, Gautham R. Shenoy, Artem Bityutskiy, Mario Limonciello, Linux ACPI Hi Everyone, This series of 2 patches supersedes https://lore.kernel.org/linux-pm/4992010.31r3eYUQgx@rjwysocki.net/ in order to address review feedback. Patch [1/2] modifies cpuidle_play_dead() as per the subject and patch [2/2] changes the :enter_dead() cpuidle state callback return type to void. Thanks! ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/2] cpuidle: Do not return from cpuidle_play_dead() on callback failures 2024-11-15 20:57 [PATCH v2 0/2] cpuidle: Do not return from cpuidle_play_dead() on callback failures Rafael J. Wysocki @ 2024-11-15 20:58 ` Rafael J. Wysocki 2024-11-19 14:04 ` Gautham R. Shenoy 2024-11-15 21:00 ` [PATCH v2 2/2] cpuidle: Change :enter_dead() driver callback return type to void Rafael J. Wysocki 1 sibling, 1 reply; 7+ messages in thread From: Rafael J. Wysocki @ 2024-11-15 20:58 UTC (permalink / raw) To: Linux PM, Peter Zijlstra Cc: LKML, x86 Maintainers, Patryk Wlazlyn, Gautham R. Shenoy, Artem Bityutskiy, Mario Limonciello, Linux ACPI From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> If the :enter_dead() idle state callback fails for a certain state, there may be still a shallower state for which it will work. Because the only caller of cpuidle_play_dead(), native_play_dead(), falls back to hlt_play_dead() if it returns an error, it should better try all of the idle states for which :enter_dead() is present before failing, so change it accordingly. Also notice that the :enter_dead() state callback is not expected to return on success (the CPU should be "dead" then), so make cpuidle_play_dead() ignore its return value. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Tested-by: Mario Limonciello <mario.limonciello@amd.com> # 6.12-rc7 --- v1 -> v2: * Make cpuidle_play_dead() never return 0. * Add tags from Mario (I have added them because the change of the patch should not make a practical difference, but if you want them to be dropped, please let me know). --- drivers/cpuidle/cpuidle.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) Index: linux-pm/drivers/cpuidle/cpuidle.c =================================================================== --- linux-pm.orig/drivers/cpuidle/cpuidle.c +++ linux-pm/drivers/cpuidle/cpuidle.c @@ -69,11 +69,15 @@ int cpuidle_play_dead(void) if (!drv) return -ENODEV; - /* Find lowest-power state that supports long-term idle */ - for (i = drv->state_count - 1; i >= 0; i--) + for (i = drv->state_count - 1; i >= 0; i--) { if (drv->states[i].enter_dead) - return drv->states[i].enter_dead(dev, i); + drv->states[i].enter_dead(dev, i); + } + /* + * If :enter_dead() is successful, it will never return, so reaching + * here means that all of them failed above or were not present. + */ return -ENODEV; } ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] cpuidle: Do not return from cpuidle_play_dead() on callback failures 2024-11-15 20:58 ` [PATCH v2 1/2] " Rafael J. Wysocki @ 2024-11-19 14:04 ` Gautham R. Shenoy 0 siblings, 0 replies; 7+ messages in thread From: Gautham R. Shenoy @ 2024-11-19 14:04 UTC (permalink / raw) To: Rafael J. Wysocki Cc: Linux PM, Peter Zijlstra, LKML, x86 Maintainers, Patryk Wlazlyn, Artem Bityutskiy, Mario Limonciello, Linux ACPI Hello Rafael, On Fri, Nov 15, 2024 at 09:58:31PM +0100, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > If the :enter_dead() idle state callback fails for a certain state, > there may be still a shallower state for which it will work. > > Because the only caller of cpuidle_play_dead(), native_play_dead(), > falls back to hlt_play_dead() if it returns an error, it should > better try all of the idle states for which :enter_dead() is present > before failing, so change it accordingly. > > Also notice that the :enter_dead() state callback is not expected > to return on success (the CPU should be "dead" then), so make > cpuidle_play_dead() ignore its return value. > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> > Tested-by: Mario Limonciello <mario.limonciello@amd.com> # 6.12-rc7 Thanks for fixing this. Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com> -- Thanks and Regards gautham. > --- > > v1 -> v2: > * Make cpuidle_play_dead() never return 0. > * Add tags from Mario (I have added them because the change of the patch > should not make a practical difference, but if you want them to be > dropped, please let me know). > > --- > drivers/cpuidle/cpuidle.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > Index: linux-pm/drivers/cpuidle/cpuidle.c > =================================================================== > --- linux-pm.orig/drivers/cpuidle/cpuidle.c > +++ linux-pm/drivers/cpuidle/cpuidle.c > @@ -69,11 +69,15 @@ int cpuidle_play_dead(void) > if (!drv) > return -ENODEV; > > - /* Find lowest-power state that supports long-term idle */ > - for (i = drv->state_count - 1; i >= 0; i--) > + for (i = drv->state_count - 1; i >= 0; i--) { > if (drv->states[i].enter_dead) > - return drv->states[i].enter_dead(dev, i); > + drv->states[i].enter_dead(dev, i); > + } > > + /* > + * If :enter_dead() is successful, it will never return, so reaching > + * here means that all of them failed above or were not present. > + */ > return -ENODEV; > } > > > > ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] cpuidle: Change :enter_dead() driver callback return type to void 2024-11-15 20:57 [PATCH v2 0/2] cpuidle: Do not return from cpuidle_play_dead() on callback failures Rafael J. Wysocki 2024-11-15 20:58 ` [PATCH v2 1/2] " Rafael J. Wysocki @ 2024-11-15 21:00 ` Rafael J. Wysocki 2024-11-19 15:09 ` Gautham R. Shenoy 1 sibling, 1 reply; 7+ messages in thread From: Rafael J. Wysocki @ 2024-11-15 21:00 UTC (permalink / raw) To: Linux PM, Peter Zijlstra Cc: LKML, x86 Maintainers, Patryk Wlazlyn, Gautham R. Shenoy, Artem Bityutskiy, Mario Limonciello, Linux ACPI From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> After a previous change, cpuidle_play_dead(), which is the only caller of idle state :enter_dead() callbacks, ignores their return values, so they may as well be void. Suggested-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> --- v1 -> v2: New patch Interestingly enough, the only user of :enter_dead() idle state callbacks in the current mainline turns out to be ACPI idle. --- drivers/acpi/processor_idle.c | 7 ++----- include/linux/cpuidle.h | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) Index: linux-pm/include/linux/cpuidle.h =================================================================== --- linux-pm.orig/include/linux/cpuidle.h +++ linux-pm/include/linux/cpuidle.h @@ -61,7 +61,7 @@ struct cpuidle_state { struct cpuidle_driver *drv, int index); - int (*enter_dead) (struct cpuidle_device *dev, int index); + void (*enter_dead) (struct cpuidle_device *dev, int index); /* * CPUs execute ->enter_s2idle with the local tick or entire timekeeping Index: linux-pm/drivers/acpi/processor_idle.c =================================================================== --- linux-pm.orig/drivers/acpi/processor_idle.c +++ linux-pm/drivers/acpi/processor_idle.c @@ -578,7 +578,7 @@ static void __cpuidle acpi_idle_do_entry * @dev: the target CPU * @index: the index of suggested state */ -static int acpi_idle_play_dead(struct cpuidle_device *dev, int index) +static void acpi_idle_play_dead(struct cpuidle_device *dev, int index) { struct acpi_processor_cx *cx = per_cpu(acpi_cstate[index], dev->cpu); @@ -591,11 +591,8 @@ static int acpi_idle_play_dead(struct cp else if (cx->entry_method == ACPI_CSTATE_SYSTEMIO) { io_idle(cx->address); } else - return -ENODEV; + return; } - - /* Never reached */ - return 0; } static __always_inline bool acpi_idle_fallback_to_c1(struct acpi_processor *pr) ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] cpuidle: Change :enter_dead() driver callback return type to void 2024-11-15 21:00 ` [PATCH v2 2/2] cpuidle: Change :enter_dead() driver callback return type to void Rafael J. Wysocki @ 2024-11-19 15:09 ` Gautham R. Shenoy 2024-11-19 16:05 ` Mario Limonciello 2024-11-19 17:13 ` Rafael J. Wysocki 0 siblings, 2 replies; 7+ messages in thread From: Gautham R. Shenoy @ 2024-11-19 15:09 UTC (permalink / raw) To: Rafael J. Wysocki Cc: Linux PM, Peter Zijlstra, LKML, x86 Maintainers, Patryk Wlazlyn, Artem Bityutskiy, Mario Limonciello, Linux ACPI Hello Rafael, On Fri, Nov 15, 2024 at 10:00:25PM +0100, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > After a previous change, cpuidle_play_dead(), which is the only caller > of idle state :enter_dead() callbacks, ignores their return values, so > they may as well be void. > > Suggested-by: Peter Zijlstra <peterz@infradead.org> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > --- > > v1 -> v2: New patch > > Interestingly enough, the only user of :enter_dead() idle state callbacks > in the current mainline turns out to be ACPI idle. For that matter, the only user of cpuidle_play_dead() is the native_play_dead(). Was that always the case? Some of the other architectures select the deepest available idle state at boot time, and enter that state when a CPU is offlined. In any case I am ok with this. Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com> -- Thanks and Regards gautham. > > --- > drivers/acpi/processor_idle.c | 7 ++----- > include/linux/cpuidle.h | 2 +- > 2 files changed, 3 insertions(+), 6 deletions(-) > > Index: linux-pm/include/linux/cpuidle.h > =================================================================== > --- linux-pm.orig/include/linux/cpuidle.h > +++ linux-pm/include/linux/cpuidle.h > @@ -61,7 +61,7 @@ struct cpuidle_state { > struct cpuidle_driver *drv, > int index); > > - int (*enter_dead) (struct cpuidle_device *dev, int index); > + void (*enter_dead) (struct cpuidle_device *dev, int index); > > /* > * CPUs execute ->enter_s2idle with the local tick or entire timekeeping > Index: linux-pm/drivers/acpi/processor_idle.c > =================================================================== > --- linux-pm.orig/drivers/acpi/processor_idle.c > +++ linux-pm/drivers/acpi/processor_idle.c > @@ -578,7 +578,7 @@ static void __cpuidle acpi_idle_do_entry > * @dev: the target CPU > * @index: the index of suggested state > */ > -static int acpi_idle_play_dead(struct cpuidle_device *dev, int index) > +static void acpi_idle_play_dead(struct cpuidle_device *dev, int index) > { > struct acpi_processor_cx *cx = per_cpu(acpi_cstate[index], dev->cpu); > > @@ -591,11 +591,8 @@ static int acpi_idle_play_dead(struct cp > else if (cx->entry_method == ACPI_CSTATE_SYSTEMIO) { > io_idle(cx->address); > } else > - return -ENODEV; > + return; > } > - > - /* Never reached */ > - return 0; > } > > static __always_inline bool acpi_idle_fallback_to_c1(struct acpi_processor *pr) > > > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] cpuidle: Change :enter_dead() driver callback return type to void 2024-11-19 15:09 ` Gautham R. Shenoy @ 2024-11-19 16:05 ` Mario Limonciello 2024-11-19 17:13 ` Rafael J. Wysocki 1 sibling, 0 replies; 7+ messages in thread From: Mario Limonciello @ 2024-11-19 16:05 UTC (permalink / raw) To: Gautham R. Shenoy, Rafael J. Wysocki Cc: Linux PM, Peter Zijlstra, LKML, x86 Maintainers, Patryk Wlazlyn, Artem Bityutskiy, Linux ACPI On 11/19/2024 09:09, Gautham R. Shenoy wrote: > Hello Rafael, > > On Fri, Nov 15, 2024 at 10:00:25PM +0100, Rafael J. Wysocki wrote: >> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> >> >> After a previous change, cpuidle_play_dead(), which is the only caller >> of idle state :enter_dead() callbacks, ignores their return values, so >> they may as well be void. >> >> Suggested-by: Peter Zijlstra <peterz@infradead.org> >> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > >> --- >> >> v1 -> v2: New patch >> >> Interestingly enough, the only user of :enter_dead() idle state callbacks >> in the current mainline turns out to be ACPI idle. > > For that matter, the only user of cpuidle_play_dead() is the > native_play_dead(). Was that always the case? > > Some of the other architectures select the deepest available idle > state at boot time, and enter that state when a CPU is offlined. > > In any case I am ok with this. > > Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> > -- > Thanks and Regards > gautham. >> >> --- >> drivers/acpi/processor_idle.c | 7 ++----- >> include/linux/cpuidle.h | 2 +- >> 2 files changed, 3 insertions(+), 6 deletions(-) >> >> Index: linux-pm/include/linux/cpuidle.h >> =================================================================== >> --- linux-pm.orig/include/linux/cpuidle.h >> +++ linux-pm/include/linux/cpuidle.h >> @@ -61,7 +61,7 @@ struct cpuidle_state { >> struct cpuidle_driver *drv, >> int index); >> >> - int (*enter_dead) (struct cpuidle_device *dev, int index); >> + void (*enter_dead) (struct cpuidle_device *dev, int index); >> >> /* >> * CPUs execute ->enter_s2idle with the local tick or entire timekeeping >> Index: linux-pm/drivers/acpi/processor_idle.c >> =================================================================== >> --- linux-pm.orig/drivers/acpi/processor_idle.c >> +++ linux-pm/drivers/acpi/processor_idle.c >> @@ -578,7 +578,7 @@ static void __cpuidle acpi_idle_do_entry >> * @dev: the target CPU >> * @index: the index of suggested state >> */ >> -static int acpi_idle_play_dead(struct cpuidle_device *dev, int index) >> +static void acpi_idle_play_dead(struct cpuidle_device *dev, int index) >> { >> struct acpi_processor_cx *cx = per_cpu(acpi_cstate[index], dev->cpu); >> >> @@ -591,11 +591,8 @@ static int acpi_idle_play_dead(struct cp >> else if (cx->entry_method == ACPI_CSTATE_SYSTEMIO) { >> io_idle(cx->address); >> } else >> - return -ENODEV; >> + return; >> } >> - >> - /* Never reached */ >> - return 0; >> } >> >> static __always_inline bool acpi_idle_fallback_to_c1(struct acpi_processor *pr) >> >> >> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] cpuidle: Change :enter_dead() driver callback return type to void 2024-11-19 15:09 ` Gautham R. Shenoy 2024-11-19 16:05 ` Mario Limonciello @ 2024-11-19 17:13 ` Rafael J. Wysocki 1 sibling, 0 replies; 7+ messages in thread From: Rafael J. Wysocki @ 2024-11-19 17:13 UTC (permalink / raw) To: Gautham R. Shenoy Cc: Rafael J. Wysocki, Linux PM, Peter Zijlstra, LKML, x86 Maintainers, Patryk Wlazlyn, Artem Bityutskiy, Mario Limonciello, Linux ACPI Hi Gautham, On Tue, Nov 19, 2024 at 4:09 PM Gautham R. Shenoy <gautham.shenoy@amd.com> wrote: > > Hello Rafael, > > On Fri, Nov 15, 2024 at 10:00:25PM +0100, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > > > After a previous change, cpuidle_play_dead(), which is the only caller > > of idle state :enter_dead() callbacks, ignores their return values, so > > they may as well be void. > > > > Suggested-by: Peter Zijlstra <peterz@infradead.org> > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > > --- > > > > v1 -> v2: New patch > > > > Interestingly enough, the only user of :enter_dead() idle state callbacks > > in the current mainline turns out to be ACPI idle. > > For that matter, the only user of cpuidle_play_dead() is the > native_play_dead(). Was that always the case? At least as long ago as of 4.20. > Some of the other architectures select the deepest available idle > state at boot time, and enter that state when a CPU is offlined. That's fine as long as the state to use is already known at that time. > In any case I am ok with this. > > Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com> > -- > Thanks and Regards > gautham. > > > > --- > > drivers/acpi/processor_idle.c | 7 ++----- > > include/linux/cpuidle.h | 2 +- > > 2 files changed, 3 insertions(+), 6 deletions(-) > > > > Index: linux-pm/include/linux/cpuidle.h > > =================================================================== > > --- linux-pm.orig/include/linux/cpuidle.h > > +++ linux-pm/include/linux/cpuidle.h > > @@ -61,7 +61,7 @@ struct cpuidle_state { > > struct cpuidle_driver *drv, > > int index); > > > > - int (*enter_dead) (struct cpuidle_device *dev, int index); > > + void (*enter_dead) (struct cpuidle_device *dev, int index); > > > > /* > > * CPUs execute ->enter_s2idle with the local tick or entire timekeeping > > Index: linux-pm/drivers/acpi/processor_idle.c > > =================================================================== > > --- linux-pm.orig/drivers/acpi/processor_idle.c > > +++ linux-pm/drivers/acpi/processor_idle.c > > @@ -578,7 +578,7 @@ static void __cpuidle acpi_idle_do_entry > > * @dev: the target CPU > > * @index: the index of suggested state > > */ > > -static int acpi_idle_play_dead(struct cpuidle_device *dev, int index) > > +static void acpi_idle_play_dead(struct cpuidle_device *dev, int index) > > { > > struct acpi_processor_cx *cx = per_cpu(acpi_cstate[index], dev->cpu); > > > > @@ -591,11 +591,8 @@ static int acpi_idle_play_dead(struct cp > > else if (cx->entry_method == ACPI_CSTATE_SYSTEMIO) { > > io_idle(cx->address); > > } else > > - return -ENODEV; > > + return; > > } > > - > > - /* Never reached */ > > - return 0; > > } > > > > static __always_inline bool acpi_idle_fallback_to_c1(struct acpi_processor *pr) > > > > > > > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-11-19 17:13 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-11-15 20:57 [PATCH v2 0/2] cpuidle: Do not return from cpuidle_play_dead() on callback failures Rafael J. Wysocki 2024-11-15 20:58 ` [PATCH v2 1/2] " Rafael J. Wysocki 2024-11-19 14:04 ` Gautham R. Shenoy 2024-11-15 21:00 ` [PATCH v2 2/2] cpuidle: Change :enter_dead() driver callback return type to void Rafael J. Wysocki 2024-11-19 15:09 ` Gautham R. Shenoy 2024-11-19 16:05 ` Mario Limonciello 2024-11-19 17:13 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox