Re: [RFC PATCH v4 05/12] sched/topology: Reference the Energy Model of CPUs when available
From: Peter Zijlstra
Date: Thu Jul 05 2018 - 13:29:40 EST
On Thu, Jun 28, 2018 at 12:40:36PM +0100, Quentin Perret wrote:
> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> index 61a1125c1ae4..357eff55c1a7 100644
> --- a/kernel/sched/topology.c
> +++ b/kernel/sched/topology.c
> @@ -201,6 +201,19 @@ sd_parent_degenerate(struct sched_domain *sd, struct sched_domain *parent)
> return 1;
> }
>
> +#ifdef CONFIG_ENERGY_MODEL
> +static void free_fd(struct freq_domain *fd)
> +{
> + struct freq_domain *tmp;
> +
> + while (fd) {
> + tmp = fd->next;
> + kfree(fd);
> + fd = tmp;
> + }
> +}
> +#endif
> +
> static void free_rootdomain(struct rcu_head *rcu)
> {
> struct root_domain *rd = container_of(rcu, struct root_domain, rcu);
> @@ -211,6 +224,9 @@ static void free_rootdomain(struct rcu_head *rcu)
> free_cpumask_var(rd->rto_mask);
> free_cpumask_var(rd->online);
> free_cpumask_var(rd->span);
> +#ifdef CONFIG_ENERGY_MODEL
> + free_fd(rd->fd);
> +#endif
If you provide a stub function, you can reduce #ifdef.
> kfree(rd);
> }
>
> @@ -1635,6 +1651,104 @@ static struct sched_domain *build_sched_domain(struct sched_domain_topology_leve
> return sd;
> }
>
> +#ifdef CONFIG_ENERGY_MODEL
< snip content >
> +#endif
And is there any reason this #ifdef cannot be merged with the one above?
That is, try and do a pass of #ifdef reduction on this file.