Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1288522 > unrolled thread

Re: [RFC PATCH 5/8] arm64: parse cpu capacity from DT

Started byDietmar Eggemann <dietmar.eggemann@arm.com>
First post2015-12-10 15:20 +0100
Last post2015-12-11 11:10 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [RFC PATCH 5/8] arm64: parse cpu capacity from DT Dietmar Eggemann <dietmar.eggemann@arm.com> - 2015-12-10 15:20 +0100
    Re: [RFC PATCH 5/8] arm64: parse cpu capacity from DT Juri Lelli <juri.lelli@arm.com> - 2015-12-11 11:10 +0100

#1288522 — Re: [RFC PATCH 5/8] arm64: parse cpu capacity from DT

FromDietmar Eggemann <dietmar.eggemann@arm.com>
Date2015-12-10 15:20 +0100
SubjectRe: [RFC PATCH 5/8] arm64: parse cpu capacity from DT
Message-ID<qEaeB-7jl-7@gated-at.bofh.it>
On 23/11/15 14:28, Juri Lelli wrote:
> With the introduction of cpu capacity bindings, CPU capacities can now be
> extracted from DT. Add parsing of such information at boot time. Also,
> store such information using per CPU variables, as we do for arm.
> 
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Mark Brown <broonie@linaro.org>
> Cc: Sudeep Holla <sudeep.holla@arm.com>
> Signed-off-by: Juri Lelli <juri.lelli@arm.com>
> ---
>  arch/arm64/kernel/topology.c | 46 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 46 insertions(+)

A lot of code disappears if you get rid of capacity-scale.

> 
> diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c
> index 694f6de..4423cc5 100644
> --- a/arch/arm64/kernel/topology.c
> +++ b/arch/arm64/kernel/topology.c
> @@ -23,6 +23,45 @@
>  #include <asm/cputype.h>
>  #include <asm/topology.h>
>  
> +static DEFINE_PER_CPU(unsigned long, cpu_scale) = SCHED_CAPACITY_SCALE;
> +
> +unsigned long arch_scale_cpu_capacity(struct sched_domain *sd, int cpu)
> +{
> +	return per_cpu(cpu_scale, cpu);
> +}
> +
> +static void set_capacity_scale(unsigned int cpu, unsigned long capacity)
> +{
> +	per_cpu(cpu_scale, cpu) = capacity;
> +}
> +
> +static u32 capacity_scale = SCHED_CAPACITY_SCALE;
> +
> +static void __init parse_cpu_capacity(struct device_node *cpu_node, int cpu)
> +{
> +	int ret;
> +	u32 cpu_capacity;
> +
> +	ret = of_property_read_u32(cpu_node,
> +				   "capacity",
> +				   &cpu_capacity);
> +	if (!ret) {
> +		u64 capacity;
> +
> +		/*
> +		 * Enforce capacity <= capacity-scale.
> +		 */
> +		cpu_capacity = cpu_capacity <= capacity_scale ? cpu_capacity :
> +			capacity_scale;
> +		capacity = (cpu_capacity << SCHED_CAPACITY_SHIFT) /
> +			capacity_scale;
> +
> +		set_capacity_scale(cpu, capacity);
> +		pr_info("CPU%d: DT cpu_capacity %lu\n",
> +			cpu, arch_scale_cpu_capacity(NULL, cpu));
> +	}
> +}
> +
>  static int __init get_cpu_for_node(struct device_node *node)
>  {
>  	struct device_node *cpu_node;
> @@ -34,6 +73,7 @@ static int __init get_cpu_for_node(struct device_node *node)
>  
>  	for_each_possible_cpu(cpu) {
>  		if (of_get_cpu_node(cpu, NULL) == cpu_node) {
> +			parse_cpu_capacity(cpu_node, cpu);
>  			of_node_put(cpu_node);
>  			return cpu;
>  		}
> @@ -173,6 +213,12 @@ static int __init parse_dt_topology(void)
>  		return 0;
>  	}
>  
> +	if (!of_property_read_u32(cn, "capacity-scale", &capacity_scale))
> +		pr_info("DT cpus capacity-scale %u\n", capacity_scale);
> +	else
> +		pr_debug("DT cpus capacity-scale not found: assuming %u\n",
> +			capacity_scale);
> +
>  	/*
>  	 * When topology is provided cpu-map is essentially a root
>  	 * cluster with restricted subnodes.
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1289383

FromJuri Lelli <juri.lelli@arm.com>
Date2015-12-11 11:10 +0100
Message-ID<qEsOe-2Os-11@gated-at.bofh.it>
In reply to#1288522
Hi,

On 10/12/15 14:15, Dietmar Eggemann wrote:
> On 23/11/15 14:28, Juri Lelli wrote:
> > With the introduction of cpu capacity bindings, CPU capacities can now be
> > extracted from DT. Add parsing of such information at boot time. Also,
> > store such information using per CPU variables, as we do for arm.
> > 
> > Cc: Catalin Marinas <catalin.marinas@arm.com>
> > Cc: Will Deacon <will.deacon@arm.com>
> > Cc: Mark Brown <broonie@linaro.org>
> > Cc: Sudeep Holla <sudeep.holla@arm.com>
> > Signed-off-by: Juri Lelli <juri.lelli@arm.com>
> > ---
> >  arch/arm64/kernel/topology.c | 46 ++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 46 insertions(+)
> 
> A lot of code disappears if you get rid of capacity-scale.
> 

Some code disappears yes, but I'll have to put some other code to
normalize capacities w.r.t. the highest capacity amongst CPUs. Not
a problem, though :-).

Thanks,

- Juri

> > 
> > diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c
> > index 694f6de..4423cc5 100644
> > --- a/arch/arm64/kernel/topology.c
> > +++ b/arch/arm64/kernel/topology.c
> > @@ -23,6 +23,45 @@
> >  #include <asm/cputype.h>
> >  #include <asm/topology.h>
> >  
> > +static DEFINE_PER_CPU(unsigned long, cpu_scale) = SCHED_CAPACITY_SCALE;
> > +
> > +unsigned long arch_scale_cpu_capacity(struct sched_domain *sd, int cpu)
> > +{
> > +	return per_cpu(cpu_scale, cpu);
> > +}
> > +
> > +static void set_capacity_scale(unsigned int cpu, unsigned long capacity)
> > +{
> > +	per_cpu(cpu_scale, cpu) = capacity;
> > +}
> > +
> > +static u32 capacity_scale = SCHED_CAPACITY_SCALE;
> > +
> > +static void __init parse_cpu_capacity(struct device_node *cpu_node, int cpu)
> > +{
> > +	int ret;
> > +	u32 cpu_capacity;
> > +
> > +	ret = of_property_read_u32(cpu_node,
> > +				   "capacity",
> > +				   &cpu_capacity);
> > +	if (!ret) {
> > +		u64 capacity;
> > +
> > +		/*
> > +		 * Enforce capacity <= capacity-scale.
> > +		 */
> > +		cpu_capacity = cpu_capacity <= capacity_scale ? cpu_capacity :
> > +			capacity_scale;
> > +		capacity = (cpu_capacity << SCHED_CAPACITY_SHIFT) /
> > +			capacity_scale;
> > +
> > +		set_capacity_scale(cpu, capacity);
> > +		pr_info("CPU%d: DT cpu_capacity %lu\n",
> > +			cpu, arch_scale_cpu_capacity(NULL, cpu));
> > +	}
> > +}
> > +
> >  static int __init get_cpu_for_node(struct device_node *node)
> >  {
> >  	struct device_node *cpu_node;
> > @@ -34,6 +73,7 @@ static int __init get_cpu_for_node(struct device_node *node)
> >  
> >  	for_each_possible_cpu(cpu) {
> >  		if (of_get_cpu_node(cpu, NULL) == cpu_node) {
> > +			parse_cpu_capacity(cpu_node, cpu);
> >  			of_node_put(cpu_node);
> >  			return cpu;
> >  		}
> > @@ -173,6 +213,12 @@ static int __init parse_dt_topology(void)
> >  		return 0;
> >  	}
> >  
> > +	if (!of_property_read_u32(cn, "capacity-scale", &capacity_scale))
> > +		pr_info("DT cpus capacity-scale %u\n", capacity_scale);
> > +	else
> > +		pr_debug("DT cpus capacity-scale not found: assuming %u\n",
> > +			capacity_scale);
> > +
> >  	/*
> >  	 * When topology is provided cpu-map is essentially a root
> >  	 * cluster with restricted subnodes.
> > 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web