[patch 04/11] powerpc/spufs: add atomic busy_spus counter to struct cbe_spu_info

Benjamin Herrenschmidt benh at kernel.crashing.org
Mon Jul 7 15:19:01 EST 2008


On Fri, 2008-07-04 at 21:05 +0200, arnd at arndb.de wrote:
> plain text document attachment
> (0004-powerpc-spufs-add-atomic-busy_spus-counter-to-struc.patch)
> As nr_active counter includes also spus waiting for syscalls to return
> we need a seperate counter that only counts spus that are currently running
> on spu side. This counter shall be used by a cpufreq governor that targets
> a frequency dependent from the number of running spus.
> 
> From: Maxim Shchetynin <maxim at de.ibm.com>
> Signed-off-by: Christian Krafft <krafft at de.ibm.com>

This needs your S-O-B, Arnd, and should go via jk.

Cheers,
Ben.

> ---
>  arch/powerpc/platforms/cell/spufs/sched.c |    6 ++++++
>  include/asm-powerpc/spu.h                 |    1 +
>  2 files changed, 7 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c
> index e929e70..be77910 100644
> --- a/arch/powerpc/platforms/cell/spufs/sched.c
> +++ b/arch/powerpc/platforms/cell/spufs/sched.c
> @@ -993,6 +993,7 @@ void spuctx_switch_state(struct spu_context *ctx,
>  	struct timespec ts;
>  	struct spu *spu;
>  	enum spu_utilization_state old_state;
> +	int node;
>  
>  	ktime_get_ts(&ts);
>  	curtime = timespec_to_ns(&ts);
> @@ -1014,6 +1015,11 @@ void spuctx_switch_state(struct spu_context *ctx,
>  		spu->stats.times[old_state] += delta;
>  		spu->stats.util_state = new_state;
>  		spu->stats.tstamp = curtime;
> +		node = spu->node;
> +		if (old_state == SPU_UTIL_USER)
> +			atomic_dec(&cbe_spu_info[node].busy_spus);
> +		if (new_state == SPU_UTIL_USER);
> +			atomic_inc(&cbe_spu_info[node].busy_spus);
>  	}
>  }
>  
> diff --git a/include/asm-powerpc/spu.h b/include/asm-powerpc/spu.h
> index 99348c1..8b2eb04 100644
> --- a/include/asm-powerpc/spu.h
> +++ b/include/asm-powerpc/spu.h
> @@ -191,6 +191,7 @@ struct cbe_spu_info {
>  	struct list_head spus;
>  	int n_spus;
>  	int nr_active;
> +	atomic_t busy_spus;
>  	atomic_t reserved_spus;
>  };
>  
> -- 
> 1.5.4.3
> 




More information about the Linuxppc-dev mailing list