Skip to content

PM / OPP: Use kref and move away from RCU locking

Viresh Kumar linux-arm-kernel linux-clk linux-omap linux-pm linux-samsung-soc linux-tegra lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest12 patches 2 repliesIn review
  2. v112 patches 24 repliesSuperseded

Changes in v2 from the cover letter

- Minor documentation fixes pointed out by Stephen
- dev_pm_opp_put() is called only if OPP is valid (in the 7th patch)

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12PM / OPP: Add per OPP table mutexdrivers/base/power/opp/core.c drivers/base/power/opp/opp.h+29 -40 replies
2/12PM / OPP: Add 'struct kref' to OPP tabledrivers/base/power/opp/core.c drivers/base/power/opp/opp.h include/linux/pm_opp.h+62 -20 replies
3/12PM / OPP: Return opp_table from dev_pm_opp_set_*() routinesdrivers/base/power/opp/core.c drivers/cpufreq/sti-cpufreq.c include/linux/pm_opp.h+74 -2170 replies
4/12PM / OPP: Take reference of the OPP table while adding/removing OPPsdrivers/base/power/opp/core.c+4 -50 replies
5/12PM / OPP: Use dev_pm_opp_get_opp_table() instead of _add_opp_table()drivers/base/power/opp/core.c drivers/base/power/opp/of.c drivers/base/power/opp/opp.h+29 -890 replies
6/12PM / OPP: Add 'struct kref' to struct dev_pm_oppdrivers/base/power/opp/core.c drivers/base/power/opp/opp.h include/linux/pm_opp.h+18 -150 replies
7/12PM / OPP: Update OPP users to put referencearch/arm/mach-omap2/pm.c drivers/base/power/opp/core.c drivers/base/power/opp/cpu.c +12 more+110 -1530 replies
8/12PM / OPP: Take kref from _find_opp_table()drivers/base/power/opp/core.c drivers/base/power/opp/cpu.c+95 -1220 replies
9/12PM / OPP: Move away from RCU lockingdrivers/base/power/opp/core.c drivers/base/power/opp/cpu.c drivers/base/power/opp/of.c +1 more+80 -2940 replies
10/12PM / OPP: Simplify _opp_set_availability()drivers/base/power/opp/core.c+5 -220 replies
11/12PM / OPP: Simplify dev_pm_opp_get_max_volt_latency()drivers/base/power/opp/core.c+9 -250 replies
12/12PM / OPP: Update Documentation to remove RCU specific bitsDocumentation/power/opp.txt+16 -360 replies

Reviews trailers per patch

All 12 patches have a Reviewed-by or Acked-by.

PatchStephen BoydChanwoo Choi
1/12R-b
2/12R-b
3/12R-b
4/12R-b
5/12R-b
6/12R-b
7/12R-b
8/12R-b
9/12R-b
10/12R-b
11/12R-b
12/12R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH V2 00/12] PM / OPP: Use kref and move away from RCU locking

Hi Rafael,

This series is based over the other OPP series [1] which is ready to be merged and is fully reviewed.

In this series, 11 out of 12 patches have Reviewed-by from Stephen. Only the 7th patch hasn't got any of those.

@Stephen: Can you see if you can do a generic review of it as well? Thanks for continuing to review this stuff.

The RCU locking isn't well suited for the OPP core. The RCU locking fits better for reader heavy stuff, while the OPP core have at max one or two readers only at a time.

Over that, it was getting very confusing the way RCU locking was used within the OPP core. The individual OPPs are mostly well handled, i.e. for an update a new structure was created and then that replaced the older one. But the OPP tables were updated directly all the time from various parts of the core. Though they were mostly used from within RCU locked region, they didn't had much to do with RCU and were governed by the mutex instead.

And that mixed with the 'opp_table_lock' has made the core even more confusing.

Similar concerns were shared by Stephen Boyd earlier [2].

This patchset simplifies the locking in OPP core to great extent using Kernel reference counting mechanism along with per OPP table mutex. And finally it gets rid of RCU locking as well.

Each and every patch of this series is individually:
- build tested
- boot tested with cpufreq-dt.ko module. Insmod and rmmod to make sure the OPPs and the OPP tables are getting freed.

More testing is also done by various build and boot bots for last few days. And they reported lots of issues (both build and boot time) that helped making this series more robust:
- Kernel CI (Linaro)
- Fengguang Wu's bot (Intel)

V1->V2:
- Minor documentation fixes pointed out by Stephen
- dev_pm_opp_put() is called only if OPP is valid (in the 7th patch)

--
viresh

[1] https://marc.info/?l=linux-kernel&m=148334828916156&w=2
[2] https://marc.info/?l=linux-kernel&m=147742717527548&w=2

Viresh Kumar (12):
PM / OPP: Add per OPP table mutex
PM / OPP: Add 'struct kref' to OPP table
PM / OPP: Return opp_table from dev_pm_opp_set_*() routines PM / OPP: Take reference of the OPP table while adding/removing OPPs PM / OPP: Use dev_pm_opp_get_opp_table() instead of _add_opp_table() PM / OPP: Add 'struct kref' to struct dev_pm_opp
PM / OPP: Update OPP users to put reference
PM / OPP: Take kref from _find_opp_table()
PM / OPP: Move away from RCU locking
PM / OPP: Simplify _opp_set_availability()
PM / OPP: Simplify dev_pm_opp_get_max_volt_latency()
PM / OPP: Update Documentation to remove RCU specific bits

 Documentation/power/opp.txt          |  52 +-
 arch/arm/mach-omap2/pm.c             |   5 +-
 drivers/base/power/opp/core.c        | 888 +++++++++++------------------------
 drivers/base/power/opp/cpu.c         |  66 +--
 drivers/base/power/opp/of.c          |  94 +---
 drivers/base/power/opp/opp.h         |  31 +-
 drivers/clk/tegra/clk-dfll.c         |  17 +-
 drivers/cpufreq/exynos5440-cpufreq.c |   5 +-
 drivers/cpufreq/imx6q-cpufreq.c      |  10 +-
 drivers/cpufreq/mt8173-cpufreq.c     |   8 +-
 drivers/cpufreq/omap-cpufreq.c       |   4 +-
 drivers/cpufreq/sti-cpufreq.c        |  13 +-
 drivers/devfreq/devfreq.c            |  14 +-
 drivers/devfreq/exynos-bus.c         |  14 +-
 drivers/devfreq/governor_passive.c   |   4 +-
 drivers/devfreq/rk3399_dmc.c         |  16 +-
 drivers/devfreq/tegra-devfreq.c      |   4 +-
 drivers/thermal/cpu_cooling.c        |  11 +-
 drivers/thermal/devfreq_cooling.c    |  15 +-
 include/linux/pm_opp.h               |  48 +-
 20 files changed, 433 insertions(+), 886 deletions(-)
Signature · 1 line
2.7.1.410.g6faf27b