From 97399f8e048f3fe76bc9fe179546990b8ba54562 Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Tue, 24 May 2011 22:01:46 -0500 Subject: Kernel support for processor affinity. Change-Id: Ie84a805bad58032085208a98b1b31393def681cb Reviewed-on: http://gfwr801.rchland.ibm.com:8080/gerrit/100 Tested-by: Jenkins Server Reviewed-by: Douglas R. Gilbert Reviewed-by: Andrew J. Geissler Reviewed-by: Nicholas E. Bofferding --- src/include/kernel/cpu.H | 23 +++++++++++++++++++++-- src/include/kernel/scheduler.H | 3 ++- src/include/kernel/task.H | 23 ++++++++++++++++++++++- 3 files changed, 45 insertions(+), 4 deletions(-) (limited to 'src/include') diff --git a/src/include/kernel/cpu.H b/src/include/kernel/cpu.H index 4d5134114..0fb794989 100644 --- a/src/include/kernel/cpu.H +++ b/src/include/kernel/cpu.H @@ -1,3 +1,8 @@ +/** @file cpu.H + * @brief Defines kernel information and functions about CPUs. + * + * In this kernel the term CPU refers to a hardware thread (SMT), not core. + */ #ifndef __KERNEL_CPU_H #define __KERNEL_CPU_H @@ -10,17 +15,31 @@ class Scheduler; +/** @struct cpu_t + * @brief Stores per-CPU kernel information. + */ struct cpu_t { + /** Stack to use while in kernel mode. */ void* kernel_stack; + /** ID of the CPU (PIR value) */ cpuid_t cpu; - + + /** Pointer to the scheduler for this CPU (may not be unique) */ Scheduler* scheduler; + /** Location for scheduler to store per-CPU data, currently used + * for the local run-queue for processor affinity. + */ + void* scheduler_extra; + /** Pointer to the idle task for this CPU */ task_t* idle_task; }; +/** @fn getCpuId + * @brief Read the PIR value to determine the cpuid_t of this CPU. + */ ALWAYS_INLINE -inline uint64_t getCpuId() +inline cpuid_t getCpuId() { return getPIR() & (KERNEL_MAX_SUPPORTED_CPUS - 1); } diff --git a/src/include/kernel/scheduler.H b/src/include/kernel/scheduler.H index 71b21559a..9cbf83d39 100644 --- a/src/include/kernel/scheduler.H +++ b/src/include/kernel/scheduler.H @@ -23,7 +23,8 @@ class Scheduler ~Scheduler() {}; private: - Util::Locked::Queue iv_taskList; + typedef Util::Locked::Queue Runqueue_t; + Runqueue_t iv_taskList; }; #endif diff --git a/src/include/kernel/task.H b/src/include/kernel/task.H index c27c7e8ce..6cd49028d 100644 --- a/src/include/kernel/task.H +++ b/src/include/kernel/task.H @@ -1,8 +1,16 @@ +/** @file task.H + * @brief Defines kernel information about tasks. + */ #ifndef __KERNEL_TASK_H #define __KERNEL_TASK_H #include +/** @struct context_t + * @brief Defines the save-restore context for the task. + * + * See PowerISA for information on registers listed. + */ struct context_t { void* stack_ptr; @@ -14,12 +22,25 @@ struct context_t uint64_t xer; }; +/** @struct task_t + * @brief The kernel-level task structure. + */ struct task_t { + /** Pointer to the CPU this task is assigned to. */ cpu_t* cpu; + /** Context information. This MUST stay here due to + * save-restore asm code. */ context_t context; - + + /** Task ID */ tid_t tid; + /** Determines if user-space would like this task pinned to a CPU. + * This value is considered a count of the number of times the pinned + * as been requested, so pinning can be used recursively. */ + uint64_t affinity_pinned; + + // Pointers for queue containers. task_t* prev; task_t* next; }; -- cgit v1.2.1