lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <13c009f6-5fc9-41ef-aa94-acd99b9c774d@arm.com>
Date: Mon, 6 Oct 2025 16:14:38 +0100
From: Lukasz Luba <lukasz.luba@....com>
To: Changwoo Min <changwoo@...lia.com>
Cc: christian.loehle@....com, tj@...nel.org, pavel@...nel.org,
 len.brown@...el.com, rafael@...nel.org, kernel-dev@...lia.com,
 linux-pm@...r.kernel.org, sched-ext@...ts.linux.dev,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH RESEND v4 03/10] PM: EM: Add an iterator and accessor for
 the performance domain



On 9/21/25 04:19, Changwoo Min wrote:
> Add an iterator function (for_each_em_perf_domain) that iterates all the
> performance domains in the global list. A passed callback function (cb) is
> called for each performance domain.
> 
> Additionally, add a lookup function (em_perf_domain_get_by_id) that
> searches for a performance domain by matching the ID in the global list.
> 
> Signed-off-by: Changwoo Min <changwoo@...lia.com>
> ---
>   include/linux/energy_model.h | 15 +++++++++++++++
>   kernel/power/energy_model.c  | 34 ++++++++++++++++++++++++++++++++++
>   2 files changed, 49 insertions(+)
> 
> diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h
> index 43aa6153dc57..21279e779188 100644
> --- a/include/linux/energy_model.h
> +++ b/include/linux/energy_model.h
> @@ -344,6 +344,10 @@ struct em_perf_state *em_perf_state_from_pd(struct em_perf_domain *pd)
>   	return rcu_dereference(pd->em_table)->state;
>   }
>   
> +int for_each_em_perf_domain(int (*cb)(struct em_perf_domain*, void *),
> +			    void *data);
> +struct em_perf_domain *em_perf_domain_get_by_id(int id);
> +

This doesn't have to go into this header.

>   #else
>   struct em_data_callback {};
>   #define EM_ADV_DATA_CB(_active_power_cb, _cost_cb) { }
> @@ -420,6 +424,17 @@ int em_update_performance_limits(struct em_perf_domain *pd,
>   }
>   static inline void em_adjust_cpu_capacity(unsigned int cpu) {}
>   static inline void em_rebuild_sched_domains(void) {}
> +static inline
> +int for_each_em_perf_domain(int (*cb)(struct em_perf_domain*, void *),
> +			    void *data)
> +{
> +	return -EINVAL;
> +}
> +static inline
> +struct em_perf_domain *em_perf_domain_get_by_id(int id)
> +{
> +	return NULL;
> +}
>   #endif


Please create a local helpers header:
kernel/power/em_helpers.h

and add these two declarations there. In that new
local header there is no need to implement the empty
inline functions as well (so would be simpler).

>   
>   #endif
> diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
> index 8998a7f4910a..740076d24479 100644
> --- a/kernel/power/energy_model.c
> +++ b/kernel/power/energy_model.c
> @@ -1000,3 +1000,37 @@ void em_rebuild_sched_domains(void)
>   	 */
>   	schedule_work(&rebuild_sd_work);
>   }
> +
> +int for_each_em_perf_domain(int (*cb)(struct em_perf_domain*, void *),
> +			    void *data)
> +{
> +	struct em_perf_domain *pd;
> +
> +	lockdep_assert_not_held(&em_pd_mutex);
> +	guard(mutex)(&em_pd_list_mutex);
> +
> +	list_for_each_entry(pd, &em_pd_list, node) {
> +		int ret;
> +
> +		ret = cb(pd, data);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	return 0;
> +}
> +
> +struct em_perf_domain *em_perf_domain_get_by_id(int id)
> +{
> +	struct em_perf_domain *pd;
> +
> +	lockdep_assert_not_held(&em_pd_mutex);
> +	guard(mutex)(&em_pd_list_mutex);
> +
> +	list_for_each_entry(pd, &em_pd_list, node) {
> +		if (pd->id == id)
> +			return pd;
> +	}
> +
> +	return NULL;
> +}

That code looks good, you can keep it. Although, please
add the comments above these functions that they are
only used locally as helpers for the notifications.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ