Module: xenomai-forge Branch: master Commit: 167f7dcbbe65e33073e9fd62d2befef3e6316317 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=167f7dcbbe65e33073e9fd62d2befef3e6316317
Author: Philippe Gerum <r...@xenomai.org> Date: Tue Jul 30 16:42:09 2013 +0200 cobalt/sched: turn scheduler slot into a per-cpu variable --- include/cobalt/kernel/pod.h | 10 ++++------ include/cobalt/kernel/sched.h | 3 +++ kernel/cobalt/pod.c | 2 +- kernel/cobalt/sched.c | 3 +++ 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/cobalt/kernel/pod.h b/include/cobalt/kernel/pod.h index e8f69e4..5b8af19 100644 --- a/include/cobalt/kernel/pod.h +++ b/include/cobalt/kernel/pod.h @@ -59,8 +59,7 @@ struct xnsynch; struct xnpod { unsigned long status; /*!< Status bitmask. */ - xnsched_t sched[NR_CPUS]; /*!< Per-cpu scheduler slots. */ - struct list_head threadq; /*!< All existing threads. */ + struct list_head threadq; /*!< All existing threads. */ int nrthreads; #ifdef CONFIG_XENO_OPT_VFILE struct xnvfile_rev_tag threadlist_tag; @@ -92,16 +91,15 @@ void __xnpod_schedule(struct xnsched *sched); void __xnpod_schedule_handler(void); - /* -- Beginning of the exported interface */ - static inline struct xnsched *xnpod_sched_slot(int cpu) { - return nkpod->sched + cpu; + return &per_cpu(nksched, cpu); } static inline struct xnsched *xnpod_current_sched(void) { - return xnpod_sched_slot(ipipe_processor_id()); + /* IRQs off */ + return __this_cpu_ptr(&nksched); } static inline int xnpod_active_p(void) diff --git a/include/cobalt/kernel/sched.h b/include/cobalt/kernel/sched.h index a5acc16..be3f2c5 100644 --- a/include/cobalt/kernel/sched.h +++ b/include/cobalt/kernel/sched.h @@ -28,6 +28,7 @@ /*! \addtogroup sched *@{*/ +#include <linux/percpu.h> #include <cobalt/kernel/thread.h> #include <cobalt/kernel/schedqueue.h> #include <cobalt/kernel/sched-tp.h> @@ -93,6 +94,8 @@ typedef struct xnsched { #endif } xnsched_t; +DECLARE_PER_CPU(struct xnsched, nksched); + union xnsched_policy_param; struct xnsched_class { diff --git a/kernel/cobalt/pod.c b/kernel/cobalt/pod.c index c4c8ea3..bb79139 100644 --- a/kernel/cobalt/pod.c +++ b/kernel/cobalt/pod.c @@ -260,7 +260,7 @@ int xnpod_init(void) xnheap_set_label(&kheap, "main heap"); for_each_online_cpu(cpu) { - sched = &pod->sched[cpu]; + sched = &per_cpu(nksched, cpu); xnsched_init(sched, cpu); if (xnarch_cpu_supported(cpu)) { list_add_tail(&sched->rootcb.glink, &pod->threadq); diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c index 1769586..c353674 100644 --- a/kernel/cobalt/sched.c +++ b/kernel/cobalt/sched.c @@ -30,6 +30,9 @@ #include <cobalt/kernel/arith.h> #include <asm/xenomai/thread.h> +DEFINE_PER_CPU(struct xnsched, nksched); +EXPORT_PER_CPU_SYMBOL(nksched); + static struct xnsched_class *xnsched_class_highest; #define for_each_xnsched_class(p) \ _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git