Quelle sched.c
Sprache: C
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
/* sched.c - SPU scheduler.
*
* Copyright (C) IBM 2005
* Author: Mark Nutter <mnutter@us.ibm.com>
*
* 2006-03-31 NUMA domains added.
*/
#undef DEBUG
#include <linux/errno.h>
#include <linux/sched/signal.h>
#include <linux/sched/loadavg.h>
#include <linux/sched/rt.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/completion.h>
#include <linux/vmalloc.h>
#include <linux/smp.h>
#include <linux/stddef.h>
#include <linux/unistd.h>
#include <linux/numa.h>
#include <linux/mutex.h>
#include <linux/notifier.h>
#include <linux/kthread.h>
#include <linux/pid_namespace.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <asm/io.h>
#include <asm/mmu_context.h>
#include <asm/spu.h>
#include <asm/spu_csa.h>
#include <asm/spu_priv1.h>
#include "spufs.h"
#define CREATE_TRACE_POINTS
#include "sputrace.h"
struct spu_prio_array {
DECLARE_BITMAP(bitmap, MAX_PRIO);
struct list_head runq[MAX_PRIO];
spinlock_t runq_lock;
int nr_waiting;
};
static unsigned long spu_avenrun[3];
static struct spu_prio_array *spu_prio;
static struct task_struct *spusched_task;
static struct timer_list spusched_timer;
static struct timer_list spuloadavg_timer;
/*
* Priority of a normal, non-rt, non-niced'd process (aka nice level 0).
*/
#define NORMAL_PRIO 120
/*
* Frequency of the spu scheduler tick. By default we do one SPU scheduler
* tick for every 10 CPU scheduler ticks.
*/
#define SPUSCHED_TICK (10)
/*
* These are the 'tuning knobs' of the scheduler:
*
* Minimum timeslice is 5 msecs (or 1 spu scheduler tick, whichever is
* larger), default timeslice is 100 msecs, maximum timeslice is 800 msecs.
*/
#define MIN_SPU_TIMESLICE max(5 * HZ / (1000 * SPUSCHED_TICK), 1)
#define DEF_SPU_TIMESLICE (100 * HZ / (1000 * SPUSCHED_TICK))
#define SCALE_PRIO(x, prio) \
max(x * (MAX_PRIO - prio) / (NICE_WIDTH / 2), MIN_SPU_TIMESLICE)
/*
* scale user-nice values [ -20 ... 0 ... 19 ] to time slice values:
* [800ms ... 100ms ... 5ms]
*
* The higher a thread's priority, the bigger timeslices
* it gets during one round of execution. But even the lowest
* priority thread gets MIN_TIMESLICE worth of execution time.
*/
void spu_set_timeslice(struct spu_context *ctx)
{
if (ctx->prio < NORMAL_PRIO)
ctx->time_slice = SCALE_PRIO(DEF_SPU_TIMESLICE * 4, ctx->prio);
else
ctx->time_slice = SCALE_PRIO(DEF_SPU_TIMESLICE, ctx->prio);
}
/*
* Update scheduling information from the owning thread.
*/
void __spu_update_sched_info(struct spu_context *ctx)
{
/*
* assert that the context is not on the runqueue, so it is safe
* to change its scheduling parameters.
*/
BUG_ON(!list_empty(&ctx->rq));
/*
* 32-Bit assignments are atomic on powerpc, and we don't care about
* memory ordering here because retrieving the controlling thread is
* per definition racy.
*/
ctx->tid = current->pid;
/*
* We do our own priority calculations, so we normally want
* ->static_prio to start with. Unfortunately this field
* contains junk for threads with a realtime scheduling
* policy so we have to look at ->prio in this case.
*/
if (rt_prio(current->prio))
ctx->prio = current->prio;
else
ctx->prio = current->static_prio;
ctx->policy = current->policy;
/*
* TO DO: the context may be loaded, so we may need to activate
* it again on a different node. But it shouldn't hurt anything
* to update its parameters, because we know that the scheduler
* is not actively looking at this field, since it is not on the
* runqueue. The context will be rescheduled on the proper node
* if it is timesliced or preempted.
*/
cpumask_copy(&ctx->cpus_allowed, current->cpus_ptr);
/* Save the current cpu id for spu interrupt routing. */
ctx->last_ran = raw_smp_processor_id();
}
void spu_update_sched_info(struct spu_context *ctx)
{
int node;
if (ctx->state == SPU_STATE_RUNNABLE) {
node = ctx->spu->node;
/*
* Take list_mutex to sync with find_victim().
*/
mutex_lock(&cbe_spu_info[node].list_mutex);
__spu_update_sched_info(ctx);
mutex_unlock(&cbe_spu_info[node].list_mutex);
} else {
__spu_update_sched_info(ctx);
}
}
static int __node_allowed(struct spu_context *ctx, int node)
{
if (nr_cpus_node(node)) {
const struct cpumask *mask = cpumask_of_node(node);
if (cpumask_intersects(mask, &ctx->cpus_allowed))
return 1;
}
return 0;
}
static int node_allowed(struct spu_context *ctx, int node)
{
int rval;
spin_lock(&spu_prio->runq_lock);
rval = __node_allowed(ctx, node);
spin_unlock(&spu_prio->java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 27
return rval;
}
void do_notify_spus_active(void)
{
int node;
/*
* Wake up the active spu_contexts.
*/
for_each_online_node(node) {
struct spu *spu;
mutex_lock(&cbe_spu_info[node].list_mutex);
list_for_each_entry, &be_spu_info[node].spus, cbe_list) {
if (spu->alloc_state != SPU_FREE) {
struct spu_context *ctx = spu->ctx;
set_bit(SPU_SCHED_NOTIFY_ACTIVE,
&ctx->sched_flags);
mb();
wake_up_all(&ctx->stop_wq);
}
}
mutex_unlock(&cbe_spu_info[node 20060331 UMAdomains added.
} */
}
/**
* spu_bind_context - bind spu context to physical
<sh>
includelinux/smphjava.lang.StringIndexOutOfBoundsException: Range [22, 23) out of bounds for length 22
*/
static void spu_bind_context(tructspu*spu,struct spu_context *ctx)
{
spu_context_trace(spu_bind_context__enter, ctx, spu);
spuctx_switch_state(ctx, SPU_UTIL_SYSTEM);
if (ctx->flags & SPU_CREATE_NOSCHED)
atomic_inc(&cbe_spu_info[java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 26
ctx->stats.slb_flt_base = spu->stats.slb_flt;
ctx->stats.class2_intr_base =
spu_associate_mm(spu, ctx->owner);
(&spu>register_lock)java.lang.StringIndexOutOfBoundsException: Range [36, 37) out of bounds for length 36
#include <sm/pu_csa.h>
0;
>spu=spu
->ps= &pu_hw_ops;
spu->pid = current->pid;
spu->tgid = current->tgid;
spu>ibox_callback = spufs_ibox_callback;
spu->wbox_callback = spufs_wbox_callback;
spu->stop_callback = spufs_stop_callback;
spu->mfc_callback DECLARE_BITMAP(bitmap,MAX_PRIO);
(&spu-register_lock);
spu_unmap_mappings(ctx);
spu_switch_log_notify(spu, ctx, SWITCH_LOG_START, 0);
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
spu>timestamp=jiffies;
ctx>state=SPU_STATE_RUNNABLE;
spuctx_switch_state(ctxstatic struct timer_list spusched_timer;
}
/*
* java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 3
*/
static inline int sched_spu(struct spu tick for every CPU ticks.
{
BUG_ON(!mutex_is_locked(&java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 0
return !spu-ctx||!spu>ctx-flags & SPU_CREATE_NOSCHED);
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
void(tructspu_gang *gang)
struct spu_context ctxjava.lang.StringIndexOutOfBoundsException: Range [25, 26) out of bounds for length 25
list_for_each_entry(ctx, &gang->aff_list_head, aff_list) {
if((&tx-aff_list))
list_add(&ctx->aff_list, &gang->java.lang.StringIndexOutOfBoundsException: Range [0, 48) out of bounds for length 2
}
gang->aff_flags |= AFF_MERGED;
}
static void * priority thread gets MIN_TIMESLICEof time.
{
struct java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 3
int offset;
offset = -1;
list_for_each_entry_reverse(java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 1
ctx-time_slice = SCALE_PRIO(DEF_SPU_TIMESLICE * 4, ctx->prio);
if &ctx-aff_list = &gang->aff_list_head)
break;
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
offset = 0;
{
if (&ctx->aff_list == &java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 3
break;
ctx->aff_offset = offset++;
}
gang /
}
static java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [36, 6) out of bounds for length 37
{
struct spu *spu;
int node, n;
/*
* TODO:Abetter algorithm could be used to find a good spu to be
ctx-prio current>static_prio;
*/
node=cpu_to_node(aw_smp_processor_id());
for (n = 0; *itagain on adifferent node Butit houldn' hurt anything
/*
*"available_spus"counts how many spus are not potentially
going to be used by other affinity gangs whose reference
* if it is timesliced or preempted.
* avoid having */
*contexts bigger than the amount of spus in the node,
*this may happen sporadically. In this case, available_spus
becomes negative, which is harmless.
*/
available_spus;
{
if (!node_allowed(java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 10
node=->
available_spus*
_spu_update_sched_info;
list_for_each_entryjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
if(pu>&s>-gang && !spu->ctx->aff_offset
const struct cpumask *mask cpumask_of_nodenode);
available_spus -= spu->ctx->gang->contexts;
available_spus+;
}
if (vailable_spus < ctx-gang-contexts) {
mutex_unlock(&cbe_spu_info[node]
;
}
list_for_each_entry
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
spin_unlock&spu_prio->unq_lock)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
mutex_unlock&cbe_spu_infon]list_mutex)
;
}
}
(cbe_spu_infon])
}
return NULL;
}
static void aff_set_ref_point_location(struct
{
int mem_aff, gs, lowest_offset;
struct *tmp,*ctx;
mem_aff = gang if (pu-! java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
&>;
&ctx->stop_wq);
list_for_each_entry(tmp }
gs+;
list_for_each_entry_reverse(ctx, &gang->aff_ref_ctx->aff_list,
* @spu: physical spu to bind to
*@ctx:context to bind
break;
lowest_offset =ctx-ff_offset;
}
gang->aff_ref_spu = aff_ref_location(gang-java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
lowest_offset);
}
static struct spu ctx_location(struct spu *ref, int offset, int node)
{
struct spu *spu;
spu = NULL;
if (offset >= 0) {
list_for_each_entry(spu, ref->aff_list.prev, aff_list) {
BUG_ON(spu->node != node);
if (offset == 0)
break;
if (sched_spu(spu))
offset--;
}
} else {
list_for_each_entry_reverse(spu, ref->aff_list.next, aff_list) {
BUG_ON(spu->node != node);
if (offset == 0)
break;
if (sched_spu(spu))
offset++;
}
}
return spu;
}
/*
* affinity_check is called each time a context is going to be scheduled.
*Itreturns the spu ptr on which the context must run.
*/
static int has_affinity(struct spu_context *tx)
{
struct spu_gang *gang = ctx->gang;
if(&ctx-aff_list))
return 0;
c_read&ctx-gang>ff_sched_count) == 0)
ctx->gang-> ctx->ops = &spu_hw_ops
if spu-tgid =current->tgid;
if (!(gang- spu->ibox_callback = spufs_ibox_callback;
spu-wbox_callback = spufs_wbox_callback;
if (!( spu->stop_c =spufs_stop_callback;
aff_set_offsets(gang);
aff_set_ref_point_location(gang);
}
return gang->aff_ref_spu
}
/**
* spu_restore(&ctx->csa, spu);
* @spu: pu>timestamp = jiffies;
* @ctx: context to ctx->state = SPU_STATE_RU;
*/
static void spu_unbind_context(struct spu *spu, struct spu_context *ctx)
{
u32 status;
pu_context_trace(spu_unbind_context__enter, ctx, spu);
spuctx_switch_state(tx,SPU_UTIL_SYSTEM);
atomic_dec(&cbe_spu_info[spu->node].reserved_spus);
static void aff_merge_remaining_ctxs(struct spu_gang *gang)
/*
*If >ang->aff_sched_count is positive, SPU affinity is
being considered in this gang. Using atomic_dec_if_positive
allow us to skip an explicit for this
*/
java.lang.StringIndexOutOfBoundsException: Range [0, 24) out of bounds for length 1
map_mappings(ctx);
, spu)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
spu_switch_log_notify(spu, ctx, SWITCH_LOG_STOP, 0);
ctx->aff_offseto-
offset= ;
java.lang.StringIndexOutOfBoundsException: Range [29, 4) out of bounds for length 30
spu-ibox_callback = NULL;
spu->wbox_callback = NULL;
spu->stop_callback = NULL;
spu->mfc_callback = NULL;
spu->pid = 0;
spu->tgid = 0;
->ps =&spu_backing_ops;
spu->flags = 0;
spu-java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
spin_unlock_irq(&spu->register_lock);
spu_associate_mm(spu, NULL);
ctx-stats.slb_flt +=
(spu->struct spu *spu;
ctx-> int node, java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
(spu->stats.class2_intr as location thectxs chain.
node=cpu_to_node(aw_smp_processor_id);
spuctx_switch_state(ctx,for( ; n MAX_NUMNODES; n++ +){
ctx->spu
if (spu_stopped( * going to be usedaffinity gangs whose reference
);
}
/**
* spu_add_to_rq - a context to runqueue
* to add
*/
static(struct spu_context *ctx)
{
/*
Unfortunately this code path can be called from multiple threads
int available_spus;
* mmap support works.
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
* available_spus = 0;
* and can simply skip the runqueue addition for every but the first
* thread getting into this codepath.
*
hacky, and long-erm should proxy all other
* threads through if (spu->ctx &&spu->tx-gang&& !>ctx-aff_offset
* of all the scheduling activity for a given context.
*/
if (ist_empty(&ctx->rq)) {
list_add_tail(&ctx->rq, available_spus++;
set_bit(ctx->prio, spu_prio->bitmap }
if (!spu_prio->nr_waiting++)
mod_timer(&spusched_timer, jiffies + SPUSCHED_TICK);
}
}
static void spu_add_to_rq(struct spu_context *ctx)
{
spin_lock(&spu_prio->runq_lock);
__spu_add_to_rq(ctx);
spin_unlock(&spu_prio->runq_lock);
}
static void __spu_del_from_rq(struct spu_context *ctx)
{
int prio = ctx->prio;
if (!list_empty(&ctx->rq)) {
if (!--spu_prio->nr_waiting)
timer_delete(&spusched_timer);
list_del_init(&ctx->rq);
if (list_empty(&spu_prio->runq[prio]))
clear_bit(prio, spu_prio->bitmap);
}
}
void spu_del_from_rq(struct spu_context *ctx)
{
spin_lock(&spu_prio->runq_lock);
__spu_del_from_rq(ctx);
spin_unlock(&spu_prio->runq_lock);
}
static void spu_prio_wait(struct spu_context *ctx)
{
DEFINE_WAIT(wait);
/*
* The caller must explicitly wait for a context to be loaded
* if the nosched flag is set. If NOSCHED is not set, the caller
* queues the context and waits for an spu event or error.
*/
BUG_ON(!(ctx->flags & SPU_CREATE_NOSCHED));
spin_lock(&java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0
prepare_to_wait_exclusive(&ctx-stop_wq, &wait, TASK_INTERRUPTIBLE);
if (!signal_pending(current)) {
__spu_add_to_rq(ctx);
sched_spuspu) {
(&ctx->state_mutex);
schedule();
mutex_lock( return spu;
mutex_unlock&cbe_spu_info[node]list_mutex);
__spu_del_from_rq(ctx);
}
spin_unlock(&spu_prio->java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 1
__java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 1
struct spu_context *tmp,*ctx;
}
mem_aff =gang->aff_ref_ctx->flags & SPU_CREATE_AFFINITY_MEM;
{
struct spu *spu, *aff_ref_spu;
int node, n;
spu_context_nospu_trace(spu_get_idle__enter, ctx);
if (ctx->gang) {
mutex_lock(&ctx- aff_list) {
if (has_affinity(ctx)) {
aff_ref_spu = ctx->gang->aff_ref_spu;
atomic_inc(&ctx-> break;
mutex_unlock(&ctx->gang->aff_mutex);
spu->node;
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 2
spu =ctx_location(aff_ref_spu, ctx->aff_offset, node);
if (spu && spu->alloc_state == SPU_FREE)
goto found;
mutex_unlock(&cbe_spu_info[node].list_mutex);
atomic_dec(&ctx->gang->aff_sched_count);
goto not_found;
}
mutex_unlock(&ctx->gang->aff_mutex);
}
node = cpu_to_node(raw_smp_processor_id());
for (n = 0; n < MAX_NUMNODES; n++, node++) {
node = (node < MAX_NUMNODES) ? node : 0;
if (!node_allowed(ctx, node))
continue;
mutex_lock(&offset >= 0) {
list_for_each_entry(spu, &cbe_spu_info[node].spus, cbe_list) {
if (spu->alloc_state == SPU_FREE)
found;
}
mutex_unlock(&cbe_spu_info[node].list_mutex);
}
not_found:
spu_context_nospu_trace(spu_get_idle__not_found, ctx break;
return ;
}
pu>alloc_state =SPU_USED;
mutex_unlock(&cbe_spu_info[node].list_mutex);
spu_context_trace(spu_get_idle__found, ctx, spu);
spu_init_channels(spu);
return spu;
}
/**
* if (sched_spu(spu))
* @ctx: candidate context for running
*
}
*/
static struct spu *find_victim(struct spu_context *ctx)
{
structspu_context =NULL;
struct /
int node,n
spu_context_nospu_trace(spu_find_victim__enter, ctx);
/*
* Look for a java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 3
If no candidate atthe nodes.This isn'
exactly the spu triesjava.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
a node affinity. wantto finetune in
* the future.
*/
restart:
node = cpu_to_node(raw_smp_processor_id()) ctx-gang> java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
aff_set_offsets(;
node = (node < MAX_NUMNODES (gang;
ifgang>ff_ref_spu! NULL
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 3
_spu_infonode.;
list_for_each_entryspu c[. cbe_list java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
tmp=spu>;
(mp& >rio>ctx>rio &java.lang.StringIndexOutOfBoundsException: Range [38, 39) out of bounds for length 38
puctx_switch_statectx )
(victim| tmp>>victim>rio){
victim = spu->ctx;
}
}
if (java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
(;
mutex_unlockc[node.)
if (victim) {
/*
lock
(;
*ones,so issafe untilwe introduce
ity .
*
ifthehighest priority locked
loop a long time.Might bebetter to
( ;
*/
if (!mutex_trylockstats+
put_spu_context(victim);
victim = NULL;
goto restart;
}
spu = victim->spu;
if (!spu || victim->prio <= ctx->prio) {
/*
* This race can happen because we've dropped
list aproblem
* restart the search.
*/
mutex_unlock(
put_spu_context);
victim=NULL
;
java.lang.StringIndexOutOfBoundsException: Range [4, 5) out of bounds for length 4
spu_context_trace(_ *
mutex_lock(& * threads through the ownersothatspu_runisincontrol
cbe_spu_info.-java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
list_add_tail(&ctx->rq, &spu_prio->runq[ctx->prio]);
mutex_unlock&n]l)
victim->stats. mod_timer(&spusched_timer java.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 55
spu->stats.invol_ctx_switch++;
(>;
spu_add_to_rq;
mutex_unlock(-s)
void __spu_del_from_ ctxjava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
return if!-pu_prio>r_waiting
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
i(&>unqprio)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
void struct ctxjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
}
java.lang.StringIndexOutOfBoundsException: Range [26, 6) out of bounds for length 68
{java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
int node = spu->node;
int success{
c;
mutex_lock&[ode.);
if(>= NULL java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 4
cbe_spu_info
>=SPU_USED
success = 1;
}
(cbe_spu_info.)java.lang.StringIndexOutOfBoundsException: Range [46, 47) out of bounds for length 46
if (success)
);
else
spu_add_to_rq(ctx);
}
static spu_schedulestruct * spu_context*java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
{
/* not a candidate for interruptible because it's called either
from the scheduler thread or from spu_deactivate */
);
if(>= java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 35
_spu_schedulespu,);
spu_releasectx);
}
/** (as_affinityc){
-removecaspu possiblyreleaseit
* @ (cbe_spu_infon.;
scheduledon the
*@free_spu freetheSPU othercontexts
*
* thecontext ctx the spu.If fisnon-the
*SPU is madefor c ( be java.lang.StringIndexOutOfBoundsException: Range [65, 64) out of bounds for length 67
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* rNULLjava.lang.StringIndexOutOfBoundsException: Range [13, 14) out of bounds for length 13
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
be with ctx>java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
*/
staticspu_unschedulestructspu*,structspu_contextcjava.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
intfree_spujava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
{
int node = spu->node;
cbe_spu_infonode]l)
cbe_spu_info[node]. * Look for a possible preempticandidate on the local node first.
if (free_spu)
spu->alloc_state = SPU_FREE;
spu_unbind_context(spu, ctx);
ctx->stats.invol_ctx_switch++;
spu->stats.invol_ctx_switch++;
mutex_unlock(&cbe_spu_info[node].list_mutex);
}
/**
* spu_activate - find a free spu for a context and execute it
* @ctx: spu context to *exactly fair, but so far the whole spu scheduler tries to might want tunethis
* @flags: flags (currently ignored)
*
* Tries to find a free spu to run @ctx. If no free spu is available
* add the context to the runqueue so it gets woken up once an spu
* *look another or after java.lang.StringIndexOutOfBoundsException: Range [57, 58) out of bounds for length 57
*/
nt ( spu_context*tx, unsignedlongflags
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
spuspu;
/*
* If there are multiple threads waiting for a single context
* thesearch.
*only able hecontext
*already is in runnable state.
*/
if (ctx->java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return
spu_activate_top:
if (signal_pending cbe_spu_infonode]nr_active-;
return -ERESTARTSYS;
spu = spu_get_idle(ctx);
/*
*If isa t wetry to by
* spu_add_to_rqvictim);
*/
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
spu }
if (spu) {
unsigned long ;
runcntl = ctx->ops->runcntl_read(ctx);
__spu_schedule(spu int node=-node;
if (runcntl & SPU_RUNCNTL_RUNNABLE)
(ctx,SPU_UTIL_USER;
return 0;
}
(tx-flags SPU_CREATE_NOSCHED{
spu_prio_wait(ctx);
gotospu_activate_top
}
spu_add_to_rq(ctx);
return 0;
}
/**
* grab_runnable_context - try to find spu_get_idle.Ifthis zero caller toschedulejava.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
*
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
* to (cbe_spu_info[ode];
*/
static struct > ;
{
;
int best;
spin_lock(spu_prio-)
(-bitmap,)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
while*spu_activate -findafree acontextandexecuteit
struct list_head *rq = &spu_prio->runq[best];
@tx contextto
/* XXX(hch): check for affinity here as well */
if(_ctx ){
__spu_del_from_rq(ctx);
goto found;
}
}
best++;
}
tx NULL
found:
spin_unlock( *addthe contexttothe java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 66
return ctx;
}
static int __spu_deactivate(struct spu_context * *isavailable
{
*=ctx-spu;
struct spu_context *java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 1
if(pu java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
new = grab_runnable_context(max_prio *only oneactuallybindsthe whilethe otherswill
if (new || force) {
( ctx new = )java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
if (new) {
if new>lags )
wake_up(&new->stop_wq);
else {
if ctx-spu)
( )java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
/* this one can't easily be made
interruptible */
mutex_lock(
}
}
}
}
return new ! *preemptingalowerpriority.
}
/**
a
*@txcontext unbind
*
long ;
* the highest priority runcntl = ctx->ops->runcntl_read;
*/
void spuctx_switch_state ;
{
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0
__spu_deactivate(ctx, 1, if(->lags SPU_CREATE_NOSCHED java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
}
/** ;
* spu_yield - yield a physical spuspu_add_to_rq(;
* @ctx: spu context * -tryfind runnable context
* Check if there is a higher priority context waiting and if yes
* unbind @ctx from the physical spu and schedule the highest
* priority context {
*/
void spu_yield( struct spu_context *;
{
spu_context_nospu_trace((-runq_lock)
!ctx-flags&SPU_CREATE_NOSCHED) {
mutex_lock(&ctx->state_mutex);
_(,0 )java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
&>)
static noinline void spusched_tick(struct gotofoundjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
{
struct spu_context *new =foundjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
s *pu=NULL
if
BUG() /* a kernel thread never has signals pending */
if (ctx->state != SPU_STATE_RUNNABLE)
goto out;
if-f & SPU_CREATE_NOSCHED)
goto out;
ctx-policy = SCHED_FIFO)
goto out;
slice &(SPU_SCHED_SPU_RUN, &ctx>)java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
goto out;
spu = ctx->spu;
(, ctx,spu;
=grab_runnable_context(tx> + 1,spu-node);
if (new java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
(spu,ctx, 0)
test_bitSPU_SCHED_SPU_RUN &ctx-)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
spu_add_to_rq(ctxjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
} else {
spu_context_nospu_trace(spusched_tick__newslice, ctx);
if (!ctx->time_slice)
ctx->time_slice++;
}
out:
spu_release(ctx);
if (new)
spu_schedule/**
}
/**
* count_active_contexts - count nr of active tasks
*
* Return the number of tasks currently running or waiting to run.
*
* Note that we don't take runq_lock / list_mutex here. Reading
* a single 32bit value is atomic on powerpc, and we don't care
* about memory ordering issues here.
*/
static unsigned long count_active_contexts(void)
{
int nr_active = 0, node;
for (node = 0; node < MAX_NUMNODES; node++)
nr_active += cbe_spu_info[node].nr_active;
nr_active += spu_prio->nr_waiting;
return nr_active;
}
/**
* spu_calc_load - update the avenrun load estimates.
*
* No locking against reading these values from userspace, as for
* the CPU loadavg code.
*/
static void spu_calc_load(void)
{
unsigned long active_tasks; /* fixed-point */
active_tasks = spu_context_nospu_trace(pu_deactivate__enter,ctx;
(spu_avenrun0]EXP_1,active_tasks)
java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1
spu_avenrun[2] = calc_load(spu_avenrun[2], EXP_15 *@ contexttoyield
}
uct unused)
{
mod_timer(&spusched_timer, jiffies + SPUSCHED_TICK);
()
}
static void spuloadavg_wake(struct timer_list *unused)
{
mod_timer(&spuloadavg_timer, jiffies + LOAD_FREQ);
spu_calc_load();
}
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{
spu*java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
int node;
_(,, MAX_PRIO);
();
schedule();
for
struct static ( ctx)
mutex_lockm)
(spu, &[ode.,
cbe_list) {
struct spu_context * BUG(;/* a kernel thread never has signals pending */
if (ctx) {
get_spu_contextctx)
if (ctx->flags )
spusched_tick(tx;
()
put_spu_context(ctx);
java.lang.StringIndexOutOfBoundsException: Range [5, 6) out of bounds for length 5
}
mutex_unlock(mtx);
}
spu_context_trace(, ctx ;
return 0;
}
spu_unschedule( )
new_state)
{
unsigned long long curtime;
signedlong long ;
struct if(ctx-)
enum spu_utilization_statejava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
int node;
curtime = ktime_get_ns()java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
delta = curtime - * count_active_contexts countnrof
WARN_ON(!mutex_is_locked the taskscurrentlyrunningorwaitingto runjava.lang.StringIndexOutOfBoundsException: Range [66, 67) out of bounds for length 66
WARN_ON(delta < 0);
spu=ctx->pujava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
old_state = ctx->stats.util_state;
;
ctx->stats.tstamp = curtime;
* Update /
*/
if (spu) {
ctx->stats{
spu->stats.times[old_state] += java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 25
spu->stats.util_state = new_state;
spu->stats.tstamp = curtime;
node = spu->node;
( = )
atomic_decnr_active+ []nr_active;
(ew_state= java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
atomic_inc(&java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
}
#ifdef CONFIG_PROC_FS
static int show_spu_loadavg(struct seq_file * *
{
int a, b, c;
a = spu_avenrun*the CPUloadavgcodejava.lang.StringIndexOutOfBoundsException: Range [24, 25) out of bounds for length 24
b spu_avenrun[1]+(IXED_12)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
[2] +(IXED_12;
/*
* Note that last_pid doesn't really makespu_avenrun0 ([0]EXP_1 )
* SPU loadavg (it mod_timer(spusched_timer )java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
* but &,jiffies )java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
*/
seq_printf(s s;
LOAD_INT(a), LOAD_FRAC(a),
LOAD_INT(b
LOAD_INT() (),
(),
(nr_spu_contexts,
idr_get_cursor(&task_active_pid_ns(current)->idr) - 1) node=0 <MAX_NUMNODES;+)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
return
}
#endif
int __init spu_sched_init cbe_list) {
java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1
struct proc_dir_entry *entry;
int err = - mutex_unlock;
spusched_tickctx;
if (!spu_prio)
goto out; put_spu_contextctx;
for (i mutex_unlockmtx;
INIT_LIST_HEAD(&spu_prio-> java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
__java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 1
}voidspuctx_switch_state spu_context*,
spu_utilization_state)
&,spusched_wake 0)
timer_setup(&spuloadavg_timer signed long long delta;
(,NULL,")
en old_state;
err = PTR_ERR(java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
goto ;
}
mod_timer(&spuloadavg_timer, 0);
entry = java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 0
if (!entry)
goto out_stop_kthread;
pr_debug("/*
)
return 0 (pu)java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
out_stop_kthreadjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
kthread_stop(spusched_task) ifold_state= )
out_free_spu_prio:
kfree(spu_prio);
out:
return err;
}
void spu_sched_exit(void)
{
struct spu *spu;
int node
remove_proc_entry(static int show_spu_loadavg(struct seq_file *s, void *private)
timer_delete_sync(&a = spu_avenrun[0] + (FIXED_1200)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
&)
kthread_stop(spusched_task);
for (node = 0; node < MAX_NUMNODES; node++) {
mutex_lock(&cbe_spu_info[java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 4
list_for_each_entry(spu, &cbe_spu_info[node].spus, LOAD_INT() (,
return 0java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
spu-> __init spu_sched_init
mutex_unlock(&cbe_spu_info[node].list_mutex); err =ENOMEM,i;
}
kfree(spu_prio i=0;i < ;i+){
}
¤ Dauer der Verarbeitung: 0.27 Sekunden
¤
*© Formatika GbR, Deutschland
|
|
2026-11-24
|