PM: sleep: Handle async suppliers like parents and async consumers like children
Subsystems (4)
v4 cover PM: sleep: Handle async suppliers like parents and async consumers like children
Hi Everyone,
These two patches complement the recently made PM core changes related to the async suspend and resume of devices. They should apply on top of 6.16-rc3.
They were sent along with the other changes mentioned above:
https://lore.kernel.org/linux-pm/[email protected]/
https://lore.kernel.org/linux-pm/[email protected]/
(and this is v4 because they have been rebased in the meantime), but they don't make any difference on my test-bed x86 systems, so I'd appreciate a confirmation that they are actually needed on ARM (or another architecture using DT).
Thanks!
PATCH v4 1/2 PM: sleep: Make async resume handle consumers like children
From: Rafael J. Wysocki <[email protected]>
Avoid starting "async" resume processing upfront for devices that have suppliers and start "async" resume processing for a device's consumers right after resuming the device itself.
---
v3 -> v4: Rebase and update the changelog.
--- drivers/base/power/main.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-)
drivers/base/power/main.c +28 -8
@@ -647,14 +647,27 @@/* * Start processing "async" children of the device unless it's been * started already for them. -* -* This could have been done for the device's "async" consumers too, but -* they either need to wait for their parents or the processing has -* already started for them after their parents were processed. */ device_for_each_child (dev, func, dpm_async_with_cleanup); } +static void dpm_async_resume_subordinate (struct device *dev,async_func_t func) +{ +struct device_link *link; +int idx; + +dpm_async_resume_children (dev, func); + + idx =device_links_read_lock (); + +/* Start processing the device's "async" consumers. */ +list_for_each_entry_rcu (link, &dev->links.consumers, s_node) +if (READ_ONCE (link->status) !=DL_STATE_DORMANT ) +dpm_async_with_cleanup (link->consumer, func); + +device_links_read_unlock (idx); +} +static void dpm_clear_async_state (struct device *dev) {reinit_completion (&dev->power.completion);
@@ -663,7 +676,14 @@static bool dpm_root_device (struct device *dev) { -return !dev->parent; +lockdep_assert_held (&dpm_list_mtx); + +/* +* Since this function is required to run under dpm_list_mtx, the +* list_empty() below will only return true if the device's list of +* consumers is actually empty before calling it. +*/ +return !dev->parent &&list_empty (&dev->links.suppliers); }static void async_resume_noirq (void *data,async_cookie_t cookie);
@@ -752,7 +772,7 @@pm_dev_err (dev, state, async ?" async noirq" :" noirq" , error); } -dpm_async_resume_children (dev, async_resume_noirq); +dpm_async_resume_subordinate (dev, async_resume_noirq); }static void async_resume_noirq (void *data,async_cookie_t cookie)
@@ -895,7 +915,7 @@pm_dev_err (dev, state, async ?" async early" :" early" , error); } -dpm_async_resume_children (dev, async_resume_early); +dpm_async_resume_subordinate (dev, async_resume_early); }static void async_resume_early (void *data,async_cookie_t cookie)
@@ -1071,7 +1091,7 @@pm_dev_err (dev, state, async ?" async" :"" , error); } -dpm_async_resume_children (dev, async_resume); +dpm_async_resume_subordinate (dev, async_resume); }static void async_resume (void *data,async_cookie_t cookie)
PATCH v4 2/2 PM: sleep: Make async suspend handle suppliers like parents
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Avoid starting "async" suspend processing upfront for devices that have consumers and start "async" suspend processing for a device's suppliers right after suspending the device itself.
---
v3 -> v4: Rebase and update the changelog.
--- drivers/base/power/main.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-)
drivers/base/power/main.c +31 -6
@@ -1257,10 +1257,15 @@return false; } -return true; +/* +* Since this function is required to run under dpm_list_mtx, the +* list_empty() below will only return true if the device's list of +* consumers is actually empty before calling it. +*/ +return list_empty (&dev->links.consumers); } -static void dpm_async_suspend_parent (struct device *dev,async_func_t func) +static bool dpm_async_suspend_parent (struct device *dev,async_func_t func) {guard (mutex)(&dpm_list_mtx);
@@ -1272,11 +1277,31 @@* deleted before it. */ if (!device_pm_initialized (dev)) -return ; +return false;/* Start processing the device's parent if it is "async". */ if (dev->parent)dpm_async_with_cleanup (dev->parent, func); + +return true; +} + +static void dpm_async_suspend_superior (struct device *dev,async_func_t func) +{ +struct device_link *link; +int idx; + +if (!dpm_async_suspend_parent (dev, func)) +return ; + + idx =device_links_read_lock (); + +/* Start processing the device's "async" suppliers. */ +list_for_each_entry_rcu (link, &dev->links.suppliers, c_node) +if (READ_ONCE (link->status) !=DL_STATE_DORMANT ) +dpm_async_with_cleanup (link->supplier, func); + +device_links_read_unlock (idx); }/**
@@ -1400,7 +1425,7 @@if (error || async_error)return error; -dpm_async_suspend_parent (dev, async_suspend_noirq); +dpm_async_suspend_superior (dev, async_suspend_noirq);return 0 ; }
@@ -1596,7 +1621,7 @@if (error || async_error)return error; -dpm_async_suspend_parent (dev, async_suspend_late); +dpm_async_suspend_superior (dev, async_suspend_late);return 0 ; }
@@ -1887,7 +1912,7 @@if (error || async_error)return error; -dpm_async_suspend_parent (dev, async_suspend); +dpm_async_suspend_superior (dev, async_suspend);return 0 ; }
Quoted 9 lines · Rafael J. Wysocki
Hi Everyone,
These two patches complement the recently made PM core changes related to the async suspend and resume of devices. They should apply on top of 6.16-rc3.
They were sent along with the other changes mentioned above:
Quoted 8 lines
https://lore.kernel.org/linux-pm/[email protected]/
https://lore.kernel.org/linux-pm/[email protected]/(and this is v4 because they have been rebased in the meantime), but they don't make any difference on my test-bed x86 systems, so I'd appreciate a confirmation that they are actually needed on ARM (or another architecture using DT).
Thanks!
Hi Rafael,
I haven't yet got the time to test these, but the code looks good to me, so feel free to add for the series:
Kind regards
Uffe
Quoted 21 lines · Ulf Hansson
Quoted 9 lines · Rafael J. Wysocki
Hi Everyone,
These two patches complement the recently made PM core changes related to the async suspend and resume of devices. They should apply on top of 6.16-rc3.
They were sent along with the other changes mentioned above:
Quoted 8 lines
https://lore.kernel.org/linux-pm/[email protected]/
https://lore.kernel.org/linux-pm/[email protected]/(and this is v4 because they have been rebased in the meantime), but they don't make any difference on my test-bed x86 systems, so I'd appreciate a confirmation that they are actually needed on ARM (or another architecture using DT).
Thanks!
Hi Rafael,
Quoted 7 lines
I haven't yet got the time to test these, but the code looks good to me, so feel free to add for the series:
Reviewed-by Ulf Hansson <[email protected]>Kind regards
Uffe
I passed this series to some internal guys to test on a wide variety of AMD x86 hardware. The initial testing looks good. Will keep you apprised if anything pops up.
Rafael J. Wysocki
maintainerQuoted 26 lines · Mario Limonciello
Quoted 24 lines · Ulf Hansson
Quoted 9 lines · Rafael J. Wysocki
Hi Everyone,
These two patches complement the recently made PM core changes related to the async suspend and resume of devices. They should apply on top of 6.16-rc3.
They were sent along with the other changes mentioned above:
Quoted 8 lines
https://lore.kernel.org/linux-pm/[email protected]/
https://lore.kernel.org/linux-pm/[email protected]/(and this is v4 because they have been rebased in the meantime), but they don't make any difference on my test-bed x86 systems, so I'd appreciate a confirmation that they are actually needed on ARM (or another architecture using DT).
Thanks!
Hi Rafael,
I haven't yet got the time to test these, but the code looks good to me, so feel free to add for the series:
Quoted 8 lines
Quoted 4 lines
Reviewed-by Ulf Hansson <[email protected]>Kind regards
UffeI passed this series to some internal guys to test on a wide variety of AMD x86 hardware. The initial testing looks good.
Will keep you apprised if anything pops up.
Thanks!
It would also help if you could check whether or not there is any measurable performance (that is, system suspend and resume time) difference between "before" and "after".
Quoted 37 lines · Rafael J. Wysocki
Quoted 26 lines · Mario Limonciello
Quoted 24 lines · Ulf Hansson
Quoted 9 lines · Rafael J. Wysocki
Hi Everyone,
These two patches complement the recently made PM core changes related to the async suspend and resume of devices. They should apply on top of 6.16-rc3.
They were sent along with the other changes mentioned above:
Quoted 8 lines
https://lore.kernel.org/linux-pm/[email protected]/
https://lore.kernel.org/linux-pm/[email protected]/(and this is v4 because they have been rebased in the meantime), but they don't make any difference on my test-bed x86 systems, so I'd appreciate a confirmation that they are actually needed on ARM (or another architecture using DT).
Thanks!
Hi Rafael,
I haven't yet got the time to test these, but the code looks good to me, so feel free to add for the series:
Quoted 8 lines
Quoted 4 lines
Reviewed-by Ulf Hansson <[email protected]>Kind regards
UffeI passed this series to some internal guys to test on a wide variety of AMD x86 hardware. The initial testing looks good.
Will keep you apprised if anything pops up.
Quoted 5 lines
Thanks!
It would also help if you could check whether or not there is any measurable performance (that is, system suspend and resume time) difference between "before" and "after".
Sure thing.
Just to make sure we have an aligned measurement methodology:
I asked them to do this both with and without the patches.
* set /sys/power/pm_debug_messages before running and then capture all the timing prints.
* add up all suspend events and get a total
* add up all resume events and get a total
* repeat 5 times
* calculate averages for the 5 runs
Rafael J. Wysocki
maintainerQuoted 49 lines · Mario Limonciello
Quoted 37 lines · Rafael J. Wysocki
Quoted 26 lines · Mario Limonciello
Quoted 24 lines · Ulf Hansson
Quoted 9 lines · Rafael J. Wysocki
Hi Everyone,
These two patches complement the recently made PM core changes related to the async suspend and resume of devices. They should apply on top of 6.16-rc3.
They were sent along with the other changes mentioned above:
Quoted 8 lines
https://lore.kernel.org/linux-pm/[email protected]/
https://lore.kernel.org/linux-pm/[email protected]/(and this is v4 because they have been rebased in the meantime), but they don't make any difference on my test-bed x86 systems, so I'd appreciate a confirmation that they are actually needed on ARM (or another architecture using DT).
Thanks!
Hi Rafael,
I haven't yet got the time to test these, but the code looks good to me, so feel free to add for the series:
Quoted 8 lines
Quoted 4 lines
Reviewed-by Ulf Hansson <[email protected]>Kind regards
UffeI passed this series to some internal guys to test on a wide variety of AMD x86 hardware. The initial testing looks good.
Will keep you apprised if anything pops up.Quoted 5 lines
Thanks!
It would also help if you could check whether or not there is any measurable performance (that is, system suspend and resume time) difference between "before" and "after".
Sure thing.
Just to make sure we have an aligned measurement methodology:
Quoted 8 lines
I asked them to do this both with and without the patches.
* set
/sys/power/pm_debug_messagesbefore running and then capture all the timing prints.
* add up all suspend events and get a total
* add up all resume events and get a total
* repeat 5 times
* calculate averages for the 5 runs
Sounds good!
Quoted 53 lines · Rafael J. Wysocki
Quoted 51 lines · Mario Limonciello
Quoted 37 lines · Rafael J. Wysocki
Quoted 26 lines · Mario Limonciello
Quoted 24 lines · Ulf Hansson
Quoted 9 lines · Rafael J. Wysocki
Hi Everyone,
These two patches complement the recently made PM core changes related to the async suspend and resume of devices. They should apply on top of 6.16-rc3.
They were sent along with the other changes mentioned above:
Quoted 8 lines
https://lore.kernel.org/linux-pm/[email protected]/
https://lore.kernel.org/linux-pm/[email protected]/(and this is v4 because they have been rebased in the meantime), but they don't make any difference on my test-bed x86 systems, so I'd appreciate a confirmation that they are actually needed on ARM (or another architecture using DT).
Thanks!
Hi Rafael,
I haven't yet got the time to test these, but the code looks good to me, so feel free to add for the series:
Quoted 8 lines
Quoted 4 lines
Reviewed-by Ulf Hansson <[email protected]>Kind regards
UffeI passed this series to some internal guys to test on a wide variety of AMD x86 hardware. The initial testing looks good.
Will keep you apprised if anything pops up.Quoted 5 lines
Thanks!
It would also help if you could check whether or not there is any measurable performance (that is, system suspend and resume time) difference between "before" and "after".
Sure thing.
Just to make sure we have an aligned measurement methodology:
I asked them to do this both with and without the patches.
Quoted 8 lines
Quoted 6 lines
* set
/sys/power/pm_debug_messagesbefore running and then capture all the timing prints.
* add up all suspend events and get a total
* add up all resume events and get a total
* repeat 5 times
* calculate averages for the 5 runsSounds good!
This is across two different systems.
The first one didn't have a very large difference in average (20ms)
KRK No patch
Suspend 235.6862
Resume 2220.3976
KRK patch
Suspend 233.3544
Resume 2202.199
The second one had about a 15% drop in average suspend time; but I think I suspect this isn't a big enough data sample. I say that because both sides had one cycle take longer than the rest on avearge.
STX nopatch
Suspend 774.39638
Resume 1893.5252
STX patch
Suspend 651.9756
Resume 1895.725
If I exclude that long cycle on both (so average of 4) the drop is 10%
STX No patch
Suspend 319.353725
Resume 2256.0025
STX patch
Suspend 292.482
Resume 2257.27
I'm personally thinking 5 cycles isn't enough for showing "real" gains are there. Probably need a much larger sample size to get statistically relevant numbers.
Quoted 6 lines · Rafael J. Wysocki
Hi Everyone,
These two patches complement the recently made PM core changes related to the async suspend and resume of devices. They should apply on top of 6.16-rc3.
Quoted 9 lines
They were sent along with the other changes mentioned above:
https://lore.kernel.org/linux-pm/[email protected]/
https://lore.kernel.org/linux-pm/[email protected]/(and this is v4 because they have been rebased in the meantime), but they don't make any difference on my test-bed x86 systems, so I'd appreciate a confirmation that they are actually needed on ARM (or another architecture using DT).
All the changes LGTM.
I don't have platform to exercise this patch much ATM, so sorry can't do much testing though.
Signature · 2 lines
Regards, Sudeep
Rafael J. Wysocki
maintainerQuoted 13 lines · Sudeep Holla
Quoted 11 lines · Rafael J. Wysocki
Hi Everyone,
These two patches complement the recently made PM core changes related to the async suspend and resume of devices. They should apply on top of 6.16-rc3.
They were sent along with the other changes mentioned above:
https://lore.kernel.org/linux-pm/[email protected]/
https://lore.kernel.org/linux-pm/[email protected]/
Quoted 8 lines
Quoted 4 lines
(and this is v4 because they have been rebased in the meantime), but they don't make any difference on my test-bed x86 systems, so I'd appreciate a confirmation that they are actually needed on ARM (or another architecture using DT).
All the changes LGTM.
Reviewed-by Sudeep Holla <[email protected]>
Thank you!
Quoted 2 lines
I don't have platform to exercise this patch much ATM, so sorry can't do much testing though.
No worries.
Everyone seems to be liking this series, so I'm going to queue it up for 6.17 and we'll see how it goes.
Thanks!