arch/powerpc/platforms/cell/spufs/sched.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/cell/spufs/sched.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/cell/spufs/sched.c- Extension
.c- Size
- 29112 bytes
- Lines
- 1142
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/sched/signal.hlinux/sched/loadavg.hlinux/sched/rt.hlinux/kernel.hlinux/mm.hlinux/slab.hlinux/completion.hlinux/vmalloc.hlinux/smp.hlinux/stddef.hlinux/unistd.hlinux/numa.hlinux/mutex.hlinux/notifier.hlinux/kthread.hlinux/pid_namespace.hlinux/proc_fs.hlinux/seq_file.hasm/io.hasm/mmu_context.hasm/spu.hasm/spu_csa.hasm/spu_priv1.hspufs.hsputrace.h
Detected Declarations
struct spu_prio_arrayfunction msecsfunction __spu_update_sched_infofunction spu_update_sched_infofunction __node_allowedfunction node_allowedfunction do_notify_spus_activefunction list_for_each_entryfunction spu_bind_contextfunction sched_spufunction aff_merge_remaining_ctxsfunction list_for_each_entryfunction aff_set_offsetsfunction list_for_each_entryfunction list_for_each_entryfunction aff_set_ref_point_locationfunction list_for_each_entry_reversefunction list_for_each_entryfunction list_for_each_entry_reversefunction has_affinityfunction spu_unbind_contextfunction __spu_add_to_rqfunction spu_add_to_rqfunction __spu_del_from_rqfunction spu_del_from_rqfunction spu_prio_waitfunction list_for_each_entryfunction list_for_each_entryfunction __spu_schedulefunction spu_schedulefunction contextsfunction spu_activatefunction list_for_each_entryfunction __spu_deactivatefunction spu_deactivatefunction spu_yieldfunction spusched_tickfunction count_active_contextsfunction spu_calc_loadfunction spusched_wakefunction spuloadavg_wakefunction spusched_threadfunction list_for_each_entryfunction spuctx_switch_statefunction show_spu_loadavgfunction spu_sched_initfunction spu_sched_exit
Annotated Snippet
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.
*/
Annotation
- Immediate include surface: `linux/errno.h`, `linux/sched/signal.h`, `linux/sched/loadavg.h`, `linux/sched/rt.h`, `linux/kernel.h`, `linux/mm.h`, `linux/slab.h`, `linux/completion.h`.
- Detected declarations: `struct spu_prio_array`, `function msecs`, `function __spu_update_sched_info`, `function spu_update_sched_info`, `function __node_allowed`, `function node_allowed`, `function do_notify_spus_active`, `function list_for_each_entry`, `function spu_bind_context`, `function sched_spu`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.