Re: [PATCH v4] PM / devfreq: use _visible attribute to replace create/remove_sysfs_files()

From: Jie Zhan
Date: Mon Dec 08 2025 - 22:41:55 EST




On 12/5/2025 4:37 PM, Pengjie Zhang wrote:
> Previously, non-generic attributes (polling_interval, timer) used separate
> create/delete logic, leading to race conditions during concurrent access in
> creation/deletion. Multi-threaded operations also caused inconsistencies
> between governor capabilities and attribute states.
>
> 1.Use is_visible + sysfs_update_group() to unify management of these
> attributes, eliminating creation/deletion races.
> 2.Add locks and validation to these attributes, ensuring consistency
> between current governor capabilities and attribute operations in
> multi-threaded environments.
>
> Signed-off-by: Pengjie Zhang <zhangpengjie2@xxxxxxxxxx>
Other than a few minor things that Jonathan posted,
Reviewed-by: Jie Zhan <zhanjie9@xxxxxxxxxxxxx>

Thanks!
> ---
> changes in v4:
> -Remove the DEFINE_SYSFS_GROUP_VISIBLE macro and directly set the is_visible function.
> -Remove unnecessary ret variables
> Link to v3:https://lore.kernel.org/lkml/20251107031706.1698396-1-zhangpengjie2@xxxxxxxxxx/
>
> changes in v3:
> - Use guard() to simplify lock acquisition and destruction.
> - Eliminate redundant checks for df.
> Link to v2:https://lore.kernel.org/lkml/20251028022458.2824872-1-zhangpengjie2@xxxxxxxxxx/
>
> Changes in v2:
> - Fix one problem reported by the kernel test robot.
> - Redirect all error paths in timer_store() to out to ensure locks are not
> left unReleased.
> Link to v1:https://lore.kernel.org/lkml/20251025135238.3576861-1-zhangpengjie2@xxxxxxxxxx/
>
> drivers/devfreq/devfreq.c | 99 +++++++++++++++++++++++----------------
> 1 file changed, 58 insertions(+), 41 deletions(-)
...