Skip to content

Commit

Permalink
[CELL] cell: add per BE structure with info about its SPUs
Browse files Browse the repository at this point in the history
Addition of a spufs-global "cbe_info" array. Each entry contains information
about one Cell/B.E. node, namelly:
* list of spus (both free and busy spus are in this list);
* list of free spus (replacing the static spu_list from spu_base.c)
* number of spus;
* number of reserved (non scheduleable) spus.

SPE affinity implementation actually requires only access to one spu per
BE node (since it implements its own pointer to walk through the other spus
of the ring) and the number of scheduleable spus (n_spus - non_sched_spus)
However having this more general structure can be useful for other
functionalities, concentrating per-cbe statistics / data.

Signed-off-by: Andre Detsch <adetsch@br.ibm.com>
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
  • Loading branch information
Arnd Bergmann authored and Arnd Bergmann committed Jul 20, 2007
1 parent 7e90b74 commit aa6d5b2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
21 changes: 14 additions & 7 deletions arch/powerpc/platforms/cell/spu_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ EXPORT_SYMBOL_GPL(spu_management_ops);

const struct spu_priv1_ops *spu_priv1_ops;

static struct list_head spu_list[MAX_NUMNODES];
static LIST_HEAD(spu_full_list);
static DEFINE_MUTEX(spu_mutex);
static DEFINE_SPINLOCK(spu_list_lock);
Expand Down Expand Up @@ -429,8 +428,9 @@ struct spu *spu_alloc_node(int node)
struct spu *spu = NULL;

mutex_lock(&spu_mutex);
if (!list_empty(&spu_list[node])) {
spu = list_entry(spu_list[node].next, struct spu, list);
if (!list_empty(&cbe_spu_info[node].free_spus)) {
spu = list_entry(cbe_spu_info[node].free_spus.next, struct spu,
list);
list_del_init(&spu->list);
pr_debug("Got SPU %d %d\n", spu->number, spu->node);
}
Expand Down Expand Up @@ -459,7 +459,7 @@ struct spu *spu_alloc(void)
void spu_free(struct spu *spu)
{
mutex_lock(&spu_mutex);
list_add_tail(&spu->list, &spu_list[spu->node]);
list_add_tail(&spu->list, &cbe_spu_info[spu->node].free_spus);
mutex_unlock(&spu_mutex);
}
EXPORT_SYMBOL_GPL(spu_free);
Expand Down Expand Up @@ -582,7 +582,9 @@ static int __init create_spu(void *data)

mutex_lock(&spu_mutex);
spin_lock_irqsave(&spu_list_lock, flags);
list_add(&spu->list, &spu_list[spu->node]);
list_add(&spu->list, &cbe_spu_info[spu->node].free_spus);
list_add(&spu->cbe_list, &cbe_spu_info[spu->node].spus);
cbe_spu_info[spu->node].n_spus++;
list_add(&spu->full_list, &spu_full_list);
spin_unlock_irqrestore(&spu_list_lock, flags);
mutex_unlock(&spu_mutex);
Expand Down Expand Up @@ -650,12 +652,17 @@ static ssize_t spu_stat_show(struct sys_device *sysdev, char *buf)

static SYSDEV_ATTR(stat, 0644, spu_stat_show, NULL);

struct cbe_spu_info cbe_spu_info[MAX_NUMNODES];
EXPORT_SYMBOL_GPL(cbe_spu_info);

static int __init init_spu_base(void)
{
int i, ret = 0;

for (i = 0; i < MAX_NUMNODES; i++)
INIT_LIST_HEAD(&spu_list[i]);
for (i = 0; i < MAX_NUMNODES; i++) {
INIT_LIST_HEAD(&cbe_spu_info[i].spus);
INIT_LIST_HEAD(&cbe_spu_info[i].free_spus);
}

if (!spu_management_ops)
goto out;
Expand Down
5 changes: 5 additions & 0 deletions arch/powerpc/platforms/cell/spufs/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ static void spu_bind_context(struct spu *spu, struct spu_context *ctx)
spu->number, spu->node);
spuctx_switch_state(ctx, SPU_UTIL_SYSTEM);

if (ctx->flags & SPU_CREATE_NOSCHED)
atomic_inc(&cbe_spu_info[spu->node].reserved_spus);

ctx->stats.slb_flt_base = spu->stats.slb_flt;
ctx->stats.class2_intr_base = spu->stats.class2_intr;

Expand Down Expand Up @@ -267,6 +270,8 @@ static void spu_unbind_context(struct spu *spu, struct spu_context *ctx)
spu->pid, spu->number, spu->node);
spuctx_switch_state(ctx, SPU_UTIL_SYSTEM);

if (spu->ctx->flags & SPU_CREATE_NOSCHED)
atomic_dec(&cbe_spu_info[spu->node].reserved_spus);
spu_switch_notify(spu, NULL);
spu_unmap_mappings(ctx);
spu_save(&ctx->csa, spu);
Expand Down
10 changes: 10 additions & 0 deletions include/asm-powerpc/spu.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ struct spu {
struct spu_problem __iomem *problem;
struct spu_priv2 __iomem *priv2;
struct list_head list;
struct list_head cbe_list;
struct list_head sched_list;
struct list_head full_list;
int number;
Expand Down Expand Up @@ -181,6 +182,15 @@ struct spu {
} stats;
};

struct cbe_spu_info {
struct list_head spus;
struct list_head free_spus;
int n_spus;
atomic_t reserved_spus;
};

extern struct cbe_spu_info cbe_spu_info[];

struct spu *spu_alloc(void);
struct spu *spu_alloc_node(int node);
void spu_free(struct spu *spu);
Expand Down

0 comments on commit aa6d5b2

Please sign in to comment.