Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] devfreq: Add refcounts for governor modules
@ 2026-05-13  9:38 Jie Zhan
  2026-05-13  9:38 ` [PATCH v2 1/6] devfreq: Use mutex guard in governor_store() Jie Zhan
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Jie Zhan @ 2026-05-13  9:38 UTC (permalink / raw)
  To: cwchoi00, cw00.choi, myungjoo.ham, kyungmin.park, linux-pm,
	linux-arm-kernel
  Cc: linuxarm, tianyaxiong, zhanjie9, zhenglifeng1, zhangpengjie2,
	lihuisong, prime.zeng

A governor module can be dynamically inserted or removed if compiled as a
kernel module.  'devfreq->governor' would become NULL if the governor
module is removed when it's in use.

For user-friendliness, get and put the module refcount of a governor module
when it's in use.  As a result, unloading a governor module in use returns
an error, e.g.:

$ cat governor
performance
$ rmmod governor_performance
rmmod: ERROR: Module governor_performance is in use

Note that this can't stop force unload, so it's more of a
user-friendliness improvement rather than strict protection.  The
existing code that keeps devfreq working when 'devfreq->governor' is
NULL should still be there.

Patch 1-3 clean up mutex with guards and factor out a common governor
setting function, so as to prepare for implementing governor reference
counting.  They can be applied separately.

Patch 4-6 add the reference counting mechanism for devfreq governor modules.

Changelog:
v2:
- Rebase on devfreq-next of 7.1-rc1.
- Drop the patches related to the NULL pointer deference issue of
  'devfreq->governor', which has been solved and merged recently.
- Remove the dedicated mutex for 'devfreq_governor_list' because the
  refcount changes don't depend on that.
- Some minor cleanups and fixes.

v1:
https://lore.kernel.org/all/20260326123428.800407-1-zhanjie9@hisilicon.com/

Jie Zhan (6):
  devfreq: Use mutex guard in governor_store()
  devfreq: Use mutex guard in devfreq_add/remove_governor()
  devfreq: Factor out devfreq_set_governor()
  devfreq: Add module owner to devfreq governor
  devfreq: Get and put module refcount when switching governor
  devfreq: Get module refcount in try_then_request_governor()

 drivers/devfreq/devfreq.c        | 210 +++++++++++++++----------------
 include/linux/devfreq-governor.h |  26 +++-
 2 files changed, 127 insertions(+), 109 deletions(-)

-- 
2.43.0



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-05-14  6:50 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-13  9:38 [PATCH v2 0/6] devfreq: Add refcounts for governor modules Jie Zhan
2026-05-13  9:38 ` [PATCH v2 1/6] devfreq: Use mutex guard in governor_store() Jie Zhan
2026-05-14  6:02   ` Yaxiong Tian
2026-05-13  9:38 ` [PATCH v2 2/6] devfreq: Use mutex guard in devfreq_add/remove_governor() Jie Zhan
2026-05-14  6:02   ` Yaxiong Tian
2026-05-13  9:38 ` [PATCH v2 3/6] devfreq: Factor out devfreq_set_governor() Jie Zhan
2026-05-14  6:09   ` Yaxiong Tian
2026-05-13  9:38 ` [PATCH v2 4/6] devfreq: Add module owner to devfreq governor Jie Zhan
2026-05-14  6:14   ` Yaxiong Tian
2026-05-13  9:38 ` [PATCH v2 5/6] devfreq: Get and put module refcount when switching governor Jie Zhan
2026-05-14  6:50   ` Yaxiong Tian
2026-05-13  9:38 ` [PATCH v2 6/6] devfreq: Get module refcount in try_then_request_governor() Jie Zhan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox