Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jie Zhan <zhanjie9@hisilicon.com>
To: Yaxiong Tian <tianyaxiong@kylinos.cn>, <cwchoi00@gmail.com>,
	<cw00.choi@samsung.com>, <myungjoo.ham@samsung.com>,
	<kyungmin.park@samsung.com>, <linux-pm@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>
Cc: <linuxarm@huawei.com>, <zhenglifeng1@huawei.com>,
	<zhangpengjie2@huawei.com>, <lihuisong@huawei.com>,
	<prime.zeng@hisilicon.com>
Subject: Re: [PATCH v2 4/6] devfreq: Add module owner to devfreq governor
Date: Fri, 15 May 2026 18:32:26 +0800	[thread overview]
Message-ID: <b1c5e72f-6b8f-4601-b51c-c9aee56be8a4@hisilicon.com> (raw)
In-Reply-To: <fdcac90b-b253-45f2-81fa-81c980671f28@kylinos.cn>



On 5/14/2026 2:14 PM, Yaxiong Tian wrote:
> 
> 在 2026/5/13 17:38, Jie Zhan 写道:
>> Add an 'owner' member to struct devfreq_governor, such that we can find
>> the module that holds the governor code when it's compiled as a kernel
>> module.  This allows the devfreq core to properly manage the lifecycle
>> of governors.
>>
>> Update devfreq_add_governor() and devm_devfreq_add_governor() to
>> automatically set 'owner' to THIS_MODULE via helper macros.
>>
>> This is a prerequisite for implementing governor reference counting to
>> prevent a governor module from being unloaded (except for force unload)
>> while a governor is in use.
>>
>> Signed-off-by: Jie Zhan <zhanjie9@hisilicon.com>
>> ---
>>   drivers/devfreq/devfreq.c        | 26 +++++++++-----------------
>>   include/linux/devfreq-governor.h | 26 +++++++++++++++++++++++---
>>   2 files changed, 32 insertions(+), 20 deletions(-)
>>
>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>> index 9e3e6a7348f8..e1363ab69173 100644
>> --- a/drivers/devfreq/devfreq.c
>> +++ b/drivers/devfreq/devfreq.c
>> @@ -1301,11 +1301,8 @@ void devfreq_resume(void)
>>       mutex_unlock(&devfreq_list_lock);
>>   }
>>   -/**
>> - * devfreq_add_governor() - Add devfreq governor
>> - * @governor:    the devfreq governor to be added
>> - */
>> -int devfreq_add_governor(struct devfreq_governor *governor)
>> +int __devfreq_add_governor(struct devfreq_governor *governor,
>> +               struct module *mod)
>>   {
>>       struct devfreq_governor *g;
>>   @@ -1322,37 +1319,32 @@ int devfreq_add_governor(struct devfreq_governor *governor)
>>           return -EINVAL;
>>       }
>>   +    governor->owner = mod;
>>       list_add(&governor->node, &devfreq_governor_list);
>>         return 0;
>>   }
>> -EXPORT_SYMBOL(devfreq_add_governor);
>> +EXPORT_SYMBOL(__devfreq_add_governor);
> 
> It's a bit strange to use the __ symbol here. Generally speaking, functions exported with EXPORT_SYMBOL are public, while __ indicates internal.
> 
> The same applies below.
> 
Actually it's common (typically in some kernel core code) to do this for
keeping the API the same while extending an existing ABI with more
parameters, such that those callers (in our case, governor code) don't have
to change.

If this is not favoured, we can also touch the existing governors and make
them assign 'governor->owner'.

I'm happy with both.

Thanks,
Jie

[ ... ]


  reply	other threads:[~2026-05-15 10:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-15 10:32     ` Jie Zhan
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-15 10:32     ` Jie Zhan [this message]
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-15 10:39     ` Jie Zhan
2026-05-13  9:38 ` [PATCH v2 6/6] devfreq: Get module refcount in try_then_request_governor() Jie Zhan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b1c5e72f-6b8f-4601-b51c-c9aee56be8a4@hisilicon.com \
    --to=zhanjie9@hisilicon.com \
    --cc=cw00.choi@samsung.com \
    --cc=cwchoi00@gmail.com \
    --cc=kyungmin.park@samsung.com \
    --cc=lihuisong@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=myungjoo.ham@samsung.com \
    --cc=prime.zeng@hisilicon.com \
    --cc=tianyaxiong@kylinos.cn \
    --cc=zhangpengjie2@huawei.com \
    --cc=zhenglifeng1@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox