Module: xenomai-forge
Branch: next
Commit: e34443e9e3f19c4b3d9708fa2590444cbd7b830a
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=e34443e9e3f19c4b3d9708fa2590444cbd7b830a

Author: Philippe Gerum <r...@xenomai.org>
Date:   Thu Aug  1 15:45:11 2013 +0200

cobalt/kernel: restrict CPU enumerations to Xenomai-enabled ones

Since we only initialize scheduler slots for Xenomai-enabled CPUs,
we'd better consider only those from Xenomai's cpu_supported mask,
which may be a subset of the cpu_online mask.

We define for_each_realtime_cpu() for enumerating these
Xenomai-enabled CPUs.

---

 include/cobalt/kernel/sys.h |    2 +-
 kernel/cobalt/assert.c      |    2 +-
 kernel/cobalt/clock.c       |    6 +++---
 kernel/cobalt/intr.c        |   12 ++++++------
 kernel/cobalt/procfs.c      |   13 ++++++-------
 kernel/cobalt/sys.c         |    8 ++++----
 6 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/include/cobalt/kernel/sys.h b/include/cobalt/kernel/sys.h
index 00c63e9..c95f9d9 100644
--- a/include/cobalt/kernel/sys.h
+++ b/include/cobalt/kernel/sys.h
@@ -66,7 +66,7 @@ static inline int xnsys_supported_cpu(int cpu)
 
 #endif /* !CONFIG_SMP */
 
-#define for_each_xenomai_cpu(cpu)              \
+#define for_each_realtime_cpu(cpu)             \
        for_each_online_cpu(cpu)                \
                if (xnsys_supported_cpu(cpu))   \
 
diff --git a/kernel/cobalt/assert.c b/kernel/cobalt/assert.c
index 8032c02..b346b8d 100644
--- a/kernel/cobalt/assert.c
+++ b/kernel/cobalt/assert.c
@@ -62,7 +62,7 @@ void __xnsys_fatal(const char *format, ...)
         * NOTE: &nkthreadq can't be empty, we have the root thread(s)
         * linked there at least.
         */
-       for_each_online_cpu(cpu) {
+       for_each_realtime_cpu(cpu) {
                sched = xnsched_struct(cpu);
                list_for_each_entry(thread, &nkthreadq, glink) {
                        if (thread->sched != sched)
diff --git a/kernel/cobalt/clock.c b/kernel/cobalt/clock.c
index fd7c176..369de88 100644
--- a/kernel/cobalt/clock.c
+++ b/kernel/cobalt/clock.c
@@ -252,7 +252,7 @@ static void adjust_clock_timers(struct xnclock *clock, 
xnsticks_t delta)
        INIT_LIST_HEAD(&adjq);
        delta = xnclock_ns_to_ticks(clock, delta);
 
-       for_each_online_cpu(cpu) {
+       for_each_realtime_cpu(cpu) {
                sched = xnsched_struct(cpu);
                q = &xnclock_percpu_timerdata(clock, cpu)->q;
 
@@ -496,7 +496,7 @@ int xnclock_register(struct xnclock *clock)
        if (clock->timerdata == NULL)
                return -ENOMEM;
 
-       for_each_online_cpu(cpu) {
+       for_each_realtime_cpu(cpu) {
                tmd = xnclock_percpu_timerdata(clock, cpu);
                xntimerq_init(&tmd->q);
        }
@@ -540,7 +540,7 @@ void xnclock_deregister(struct xnclock *clock)
 
        cleanup_clock_proc(clock);
 
-       for_each_online_cpu(cpu) {
+       for_each_realtime_cpu(cpu) {
                tmd = xnclock_percpu_timerdata(clock, cpu);
                XENO_BUGON(NUCLEUS, !xntimerq_empty(&tmd->q));
                xntimerq_destroy(&tmd->q);
diff --git a/kernel/cobalt/intr.c b/kernel/cobalt/intr.c
index cb5761b..36bf647 100644
--- a/kernel/cobalt/intr.c
+++ b/kernel/cobalt/intr.c
@@ -62,7 +62,7 @@ static inline void sync_stat_references(struct xnintr *intr)
        struct xnsched *sched;
        int cpu;
 
-       for_each_online_cpu(cpu) {
+       for_each_realtime_cpu(cpu) {
                sched = xnsched_struct(cpu);
                statp = per_cpu_ptr(intr->stats, cpu);
                /* Synchronize on all dangling references to go away. */
@@ -511,7 +511,7 @@ static void clear_irqstats(struct xnintr *intr)
        struct xnirqstat *p;
        int cpu;
 
-       for_each_online_cpu(cpu) {
+       for_each_realtime_cpu(cpu) {
                p = per_cpu_ptr(intr->stats, cpu);
                memset(p, 0, sizeof(*p));
        }
@@ -882,7 +882,7 @@ static inline int xnintr_is_timer_irq(int irq)
 {
        int cpu;
 
-       for_each_online_cpu(cpu)
+       for_each_realtime_cpu(cpu)
                if (irq == per_cpu(ipipe_percpu.hrtimer_irq, cpu))
                        return 1;
 
@@ -986,7 +986,7 @@ static inline int format_irq_proc(unsigned int irq,
        spl_t s;
        int cpu;
 
-       for_each_online_cpu(cpu)
+       for_each_realtime_cpu(cpu)
                if (xnintr_is_timer_irq(irq)) {
                        xnvfile_printf(it, "         [timer/%d]", cpu);
                        return 0;
@@ -1038,7 +1038,7 @@ static int irq_vfile_show(struct xnvfile_regular_iterator 
*it,
 
        xnvfile_puts(it, "  IRQ ");
 
-       for_each_online_cpu(cpu)
+       for_each_realtime_cpu(cpu)
                xnvfile_printf(it, "        CPU%d", cpu);
 
        for (irq = 0; irq < IPIPE_NR_IRQS; irq++) {
@@ -1047,7 +1047,7 @@ static int irq_vfile_show(struct xnvfile_regular_iterator 
*it,
 
                xnvfile_printf(it, "\n%5d:", irq);
 
-               for_each_online_cpu(cpu) {
+               for_each_realtime_cpu(cpu) {
                        xnvfile_printf(it, "%12lu",
                                       
__ipipe_cpudata_irq_hits(&xnarch_machdata.domain, cpu,
                                                                irq));
diff --git a/kernel/cobalt/procfs.c b/kernel/cobalt/procfs.c
index b48facc..89ddf9b 100644
--- a/kernel/cobalt/procfs.c
+++ b/kernel/cobalt/procfs.c
@@ -35,8 +35,7 @@ static int lock_vfile_show(struct xnvfile_regular_iterator 
*it, void *data)
        spl_t s;
        int cpu;
 
-       for_each_online_cpu(cpu) {
-
+       for_each_realtime_cpu(cpu) {
                xnlock_get_irqsave(&nklock, s);
                lockinfo = per_cpu(xnlock_stats, cpu);
                xnlock_put_irqrestore(&nklock, s);
@@ -73,7 +72,7 @@ static ssize_t lock_vfile_store(struct xnvfile_input *input)
        if (val != 0)
                return -EINVAL;
 
-       for_each_online_cpu(cpu) {
+       for_each_realtime_cpu(cpu) {
                xnlock_get_irqsave(&nklock, s);
                memset(&per_cpu(xnlock_stats, cpu), '\0', sizeof(struct 
xnlockinfo));
                xnlock_put_irqrestore(&nklock, s);
@@ -145,7 +144,7 @@ static int faults_vfile_show(struct 
xnvfile_regular_iterator *it, void *data)
 
        xnvfile_puts(it, "TRAP ");
 
-       for_each_online_cpu(cpu)
+       for_each_realtime_cpu(cpu)
                xnvfile_printf(it, "        CPU%d", cpu);
 
        for (trap = 0; xnarch_machdesc.fault_labels[trap]; trap++) {
@@ -154,7 +153,7 @@ static int faults_vfile_show(struct 
xnvfile_regular_iterator *it, void *data)
 
                xnvfile_printf(it, "\n%3d: ", trap);
 
-               for_each_online_cpu(cpu)
+               for_each_realtime_cpu(cpu)
                        xnvfile_printf(it, "%12u",
                                       per_cpu(xnarch_percpu_machdata, 
cpu).faults[trap]);
 
@@ -183,7 +182,7 @@ static int apc_vfile_show(struct xnvfile_regular_iterator 
*it, void *data)
 
        xnvfile_puts(it, "APC ");
 
-       for_each_online_cpu(cpu)
+       for_each_realtime_cpu(cpu)
                xnvfile_printf(it, "         CPU%d", cpu);
 
        for (apc = 0; apc < BITS_PER_LONG; apc++) {
@@ -192,7 +191,7 @@ static int apc_vfile_show(struct xnvfile_regular_iterator 
*it, void *data)
 
                xnvfile_printf(it, "\n%3d: ", apc);
 
-               for_each_online_cpu(cpu)
+               for_each_realtime_cpu(cpu)
                        xnvfile_printf(it, "%12lu",
                                       per_cpu(xnarch_percpu_machdata, 
cpu).apc_shots[apc]);
 
diff --git a/kernel/cobalt/sys.c b/kernel/cobalt/sys.c
index 9329a83..df6fc93 100644
--- a/kernel/cobalt/sys.c
+++ b/kernel/cobalt/sys.c
@@ -54,7 +54,7 @@ static int enable_timesource(void)
        nkclock.wallclock_offset =
                xnclock_get_host_time() - xnclock_read_monotonic(&nkclock);
 
-       for_each_xenomai_cpu(cpu) {
+       for_each_realtime_cpu(cpu) {
                htickval = xntimer_grab_hardware(cpu);
                if (htickval < 0) {
                        while (--cpu >= 0)
@@ -149,7 +149,7 @@ int xnsys_init(void)
        }
        xnheap_set_label(&kheap, "main heap");
 
-       for_each_xenomai_cpu(cpu) {
+       for_each_realtime_cpu(cpu) {
                sched = &per_cpu(nksched, cpu);
                xnsched_init(sched, cpu);
        }
@@ -185,7 +185,7 @@ static void disable_timesource(void)
         * timer, since this could cause deadlock situations to arise
         * on SMP systems.
         */
-       for_each_xenomai_cpu(cpu)
+       for_each_realtime_cpu(cpu)
                xntimer_release_hardware(cpu);
 
 #ifdef CONFIG_XENO_OPT_STATS
@@ -235,7 +235,7 @@ void xnsys_shutdown(void)
 
        xnsched_run();
 
-       for_each_online_cpu(cpu) {
+       for_each_realtime_cpu(cpu) {
                sched = xnsched_struct(cpu);
                xnsched_destroy(sched);
        }


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to