Module: xenomai-3
Branch: master
Commit: bc761d8cf25c21944620a2f6f0d67c1b8fce9bed
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=bc761d8cf25c21944620a2f6f0d67c1b8fce9bed

Author: Philippe Gerum <r...@xenomai.org>
Date:   Thu Feb  5 13:22:24 2015 +0100

cobalt/kernel: distinguish u/k/i latencies in Kconfig

---

 kernel/cobalt/Kconfig                              |   60 +++++++++++++++-----
 .../arch/arm/include/asm/xenomai/calibration.h     |   30 +++++-----
 .../blackfin/include/asm/xenomai/calibration.h     |   12 ++--
 .../arch/nios2/include/asm/xenomai/calibration.h   |   13 ++---
 .../arch/powerpc/include/asm/xenomai/calibration.h |   12 ++--
 .../arch/sh/include/asm/xenomai/calibration.h      |   11 ++--
 .../arch/x86/include/asm/xenomai/calibration.h     |   18 +++---
 kernel/cobalt/clock.c                              |   10 ++--
 8 files changed, 102 insertions(+), 64 deletions(-)

diff --git a/kernel/cobalt/Kconfig b/kernel/cobalt/Kconfig
index 2e49d37..9c754f5 100644
--- a/kernel/cobalt/Kconfig
+++ b/kernel/cobalt/Kconfig
@@ -173,19 +173,6 @@ config XENO_OPT_AUTOTUNE
        adjusting the core timing services to the intrinsic latency of
        the platform.
 
-config XENO_OPT_TIMING_SCHEDLAT
-       int "Scheduling latency (ns)"
-       default 0
-       help
-       Scheduling latency is the time between the termination of an
-       interrupt handler and the execution of the first instruction
-       of the real-time thread this handler resumes. A default value
-       of 0 (recommended) will cause a pre-calibrated value to be
-       used.
-
-       If the auto-tuner is enabled, this value will be used as the
-       factory default when running "autotune --reset".
-
 config XENO_OPT_SCALABLE_SCHED
        bool "O(1) scheduler"
        help
@@ -344,6 +331,53 @@ config XENO_OPT_DEBUG_TRACE_LOGSZ
 
 endmenu
 
+menu "Latency settings"
+
+config XENO_OPT_TIMING_SCHEDLAT
+       int "User scheduling latency (ns)"
+       default 0
+       help
+       The user scheduling latency is the time between the
+       termination of an interrupt handler and the execution of the
+       first instruction of the real-time application thread this
+       handler resumes. A default value of 0 (recommended) will cause
+       a pre-calibrated value to be used.
+
+       If the auto-tuner is enabled, this value will be used as the
+       factory default when running "autotune --reset".
+
+config XENO_OPT_TIMING_KSCHEDLAT
+       int "Intra-kernel scheduling latency (ns)"
+       default 0
+       help
+       The intra-kernel scheduling latency is the time between the
+       termination of an interrupt handler and the execution of the
+       first instruction of the RTDM kernel thread this handler
+       resumes. A default value of 0 (recommended) will cause a
+       pre-calibrated value to be used.
+
+       Intra-kernel latency is usually significantly lower than user
+       scheduling latency on MMU-enabled platforms, due to CPU cache
+       latency.
+
+       If the auto-tuner is enabled, this value will be used as the
+       factory default when running "autotune --reset".
+
+config XENO_OPT_TIMING_IRQLAT
+       int "Interrupt latency (ns)"
+       default 0
+       help
+
+       The interrupt latency is the time between the occurrence of an
+       IRQ and the first instruction of the interrupt handler which
+       will service it. A default value of 0 (recommended) will cause
+       a pre-calibrated value to be used.
+
+       If the auto-tuner is enabled, this value will be used as the
+       factory default when running "autotune --reset".
+
+endmenu
+
 menuconfig XENO_OPT_DEBUG
        depends on XENO_OPT_VFILE
        bool "Debug support"
diff --git a/kernel/cobalt/arch/arm/include/asm/xenomai/calibration.h 
b/kernel/cobalt/arch/arm/include/asm/xenomai/calibration.h
index 6f8f3bf..82ff68d 100644
--- a/kernel/cobalt/arch/arm/include/asm/xenomai/calibration.h
+++ b/kernel/cobalt/arch/arm/include/asm/xenomai/calibration.h
@@ -22,30 +22,34 @@
 #ifndef _COBALT_ARM_ASM_CALIBRATION_H
 #define _COBALT_ARM_ASM_CALIBRATION_H
 
-extern unsigned omap_rev(void);
+unsigned int omap_rev(void);
 #define cpu_is_omap44xx() ((omap_rev() & 0xff) == 0x44)
 
-static inline unsigned long xnarch_get_sched_latency (void)
+static inline void xnarch_get_latencies(struct xnclock_gravity *p)
 {
+       unsigned int ulat;
 #if CONFIG_XENO_OPT_TIMING_SCHEDLAT != 0
-       return CONFIG_XENO_OPT_TIMING_SCHEDLAT;
-#else
-#if defined(CONFIG_ARCH_AT91RM9200)
-       return 8500;
+       ulat = CONFIG_XENO_OPT_TIMING_SCHEDLAT;
+#elif defined(CONFIG_ARCH_AT91RM9200)
+       ulat = 8500;
 #elif defined(CONFIG_ARCH_AT91SAM9263)
-       return 11000;
+       ulat = 11000;
+#elif defined(CONFIG_SOC_IMX6Q)
+       ulat = 6000;
 #elif defined(CONFIG_ARCH_MX51)
-       return 5000;
+       ulat = 5000;
 #elif defined(CONFIG_ARCH_MX53)
-       return 5000;
+       ulat = 5000;
 #elif defined(CONFIG_ARCH_MX6)
-       return 2000;
+       ulat = 2000;
 #elif defined(CONFIG_ARCH_OMAP)
-       return cpu_is_omap44xx() ? 2500 : 5000;
+       ulat = cpu_is_omap44xx() ? 2500 : 5000;
 #else
-       return 9500;    /* XXX sane ? */
-#endif
+       ulat = 9500;    /* XXX sane? */
 #endif
+       p->user = xnclock_ns_to_ticks(&nkclock, ulat);
+       p->kernel = xnclock_ns_to_ticks(&nkclock, 
CONFIG_XENO_OPT_TIMING_KSCHEDLAT);
+       p->irq = xnclock_ns_to_ticks(&nkclock, CONFIG_XENO_OPT_TIMING_IRQLAT);
 }
 
 #endif /* !_COBALT_ARM_ASM_CALIBRATION_H */
diff --git a/kernel/cobalt/arch/blackfin/include/asm/xenomai/calibration.h 
b/kernel/cobalt/arch/blackfin/include/asm/xenomai/calibration.h
index b1f6464..08895e8 100644
--- a/kernel/cobalt/arch/blackfin/include/asm/xenomai/calibration.h
+++ b/kernel/cobalt/arch/blackfin/include/asm/xenomai/calibration.h
@@ -19,13 +19,11 @@
 #ifndef _COBALT_BLACKFIN_ASM_CALIBRATION_H
 #define _COBALT_BLACKFIN_ASM_CALIBRATION_H
 
-static inline unsigned long xnarch_get_sched_latency (void)
-
+static inline void xnarch_get_latencies(struct xnclock_gravity *p)
 {
 #if CONFIG_XENO_OPT_TIMING_SCHEDLAT != 0
 #define __sched_latency CONFIG_XENO_OPT_TIMING_SCHEDLAT
-#else
-#ifdef CONFIG_BF533
+#elif defined(CONFIG_BF533)
 #define __sched_latency 5000
 #elif defined(CONFIG_BF537)
 #define __sched_latency 4800
@@ -48,9 +46,9 @@ static inline unsigned long xnarch_get_sched_latency (void)
 #else
 #error "unsupported Blackfin processor"
 #endif
-#endif /* CONFIG_XENO_OPT_TIMING_SCHEDLAT */
-
-    return __sched_latency;
+       p->user = __sched_latency;
+       p->kernel = CONFIG_XENO_OPT_TIMING_KSCHEDLAT;
+       p->irq = CONFIG_XENO_OPT_TIMING_IRQLAT;
 }
 
 #undef __sched_latency
diff --git a/kernel/cobalt/arch/nios2/include/asm/xenomai/calibration.h 
b/kernel/cobalt/arch/nios2/include/asm/xenomai/calibration.h
index 0366754..36cc2a5 100644
--- a/kernel/cobalt/arch/nios2/include/asm/xenomai/calibration.h
+++ b/kernel/cobalt/arch/nios2/include/asm/xenomai/calibration.h
@@ -19,21 +19,20 @@
 #ifndef _COBALT_NIOS2_ASM_CALIBRATION_H
 #define _COBALT_NIOS2_ASM_CALIBRATION_H
 
-static inline unsigned long xnarch_get_sched_latency (void)
+static inline void xnarch_get_latencies(struct xnclock_gravity *p)
 {
 #if CONFIG_XENO_OPT_TIMING_SCHEDLAT != 0
 #define __sched_latency CONFIG_XENO_OPT_TIMING_SCHEDLAT
-#else
-#ifdef CONFIG_ALTERA_DE2
+#elif defined(CONFIG_ALTERA_DE2)
 #define __sched_latency  10000
-#elif CONFIG_NEEK
+#elif defined(CONFIG_NEEK)
 #define __sched_latency  10000
 #else
 #error "unsupported NIOS2 platform"
 #endif
-#endif /* CONFIG_XENO_OPT_TIMING_SCHEDLAT */
-
-    return __sched_latency;
+       p->user = __sched_latency;
+       p->kernel = CONFIG_XENO_OPT_TIMING_KSCHEDLAT;
+       p->irq = CONFIG_XENO_OPT_TIMING_IRQLAT;
 }
 
 #undef __sched_latency
diff --git a/kernel/cobalt/arch/powerpc/include/asm/xenomai/calibration.h 
b/kernel/cobalt/arch/powerpc/include/asm/xenomai/calibration.h
index b801759..e849e41 100644
--- a/kernel/cobalt/arch/powerpc/include/asm/xenomai/calibration.h
+++ b/kernel/cobalt/arch/powerpc/include/asm/xenomai/calibration.h
@@ -22,12 +22,11 @@
 #ifndef _COBALT_POWERPC_ASM_CALIBRATION_H
 #define _COBALT_POWERPC_ASM_CALIBRATION_H
 
-static inline unsigned long xnarch_get_sched_latency(void)
+static inline void xnarch_get_latencies(struct xnclock_gravity *p)
 {
 #if CONFIG_XENO_OPT_TIMING_SCHEDLAT != 0
 #define __sched_latency CONFIG_XENO_OPT_TIMING_SCHEDLAT
-#else
-#if defined(CONFIG_PPC_PASEMI)
+#elif defined(CONFIG_PPC_PASEMI)
 #define __sched_latency 1000
 #elif defined(CONFIG_WALNUT)
 #define __sched_latency 11000
@@ -99,10 +98,9 @@ static inline unsigned long xnarch_get_sched_latency(void)
 #define __sched_latency 4000
 #endif
 #endif
-
-#endif /* CONFIG_XENO_OPT_TIMING_SCHEDLAT */
-
-       return __sched_latency;
+       p->user = xnclock_ns_to_ticks(&nkclock, __sched_latency);
+       p->kernel = xnclock_ns_to_ticks(&nkclock, 
CONFIG_XENO_OPT_TIMING_KSCHEDLAT);
+       p->irq = xnclock_ns_to_ticks(&nkclock, CONFIG_XENO_OPT_TIMING_IRQLAT);
 }
 
 #undef __sched_latency
diff --git a/kernel/cobalt/arch/sh/include/asm/xenomai/calibration.h 
b/kernel/cobalt/arch/sh/include/asm/xenomai/calibration.h
index 1ce64e6..834febf 100644
--- a/kernel/cobalt/arch/sh/include/asm/xenomai/calibration.h
+++ b/kernel/cobalt/arch/sh/include/asm/xenomai/calibration.h
@@ -19,19 +19,18 @@
 #ifndef _COBALT_SH_ASM_CALIBRATION_H
 #define _COBALT_SH_ASM_CALIBRATION_H
 
-static inline unsigned long xnarch_get_sched_latency (void)
+static inline void xnarch_get_latencies(struct xnclock_gravity *p)
 {
 #if CONFIG_XENO_OPT_TIMING_SCHEDLAT != 0
 #define __sched_latency CONFIG_XENO_OPT_TIMING_SCHEDLAT
-#else
-#ifdef CONFIG_SH_ST_MB442
+#elif defined(CONFIG_SH_ST_MB442)
 #define __sched_latency  5000
 #else
 #define __sched_latency  7000
 #endif
-#endif /* CONFIG_XENO_OPT_TIMING_SCHEDLAT */
-
-       return __sched_latency;
+       p->user = __sched_latency;
+       p->kernel = CONFIG_XENO_OPT_TIMING_KSCHEDLAT;
+       p->irq = CONFIG_XENO_OPT_TIMING_IRQLAT;
 }
 
 #undef __sched_latency
diff --git a/kernel/cobalt/arch/x86/include/asm/xenomai/calibration.h 
b/kernel/cobalt/arch/x86/include/asm/xenomai/calibration.h
index 95f6506..a9190e1 100644
--- a/kernel/cobalt/arch/x86/include/asm/xenomai/calibration.h
+++ b/kernel/cobalt/arch/x86/include/asm/xenomai/calibration.h
@@ -21,7 +21,12 @@
 
 #include <asm/processor.h>
 
-static inline unsigned long xnarch_get_sched_latency (void)
+static inline unsigned long __get_bogomips(void)
+{
+       return this_cpu_read(cpu_info.loops_per_jiffy)/(500000/HZ);
+}
+
+static inline void xnarch_get_latencies(struct xnclock_gravity *p)
 {
        unsigned long sched_latency;
 
@@ -48,19 +53,18 @@ static inline unsigned long xnarch_get_sched_latency (void)
                sched_latency = 1000;
 #endif /* !SMP */
        } else {
-#define __bogomips (this_cpu_read(cpu_info.loops_per_jiffy)/(500000/HZ))
-               sched_latency = (__bogomips < 250 ? 17000 :
-                                __bogomips < 2500 ? 4200 :
+               sched_latency = (__get_bogomips() < 250 ? 17000 :
+                                __get_bogomips() < 2500 ? 4200 :
                                 3500);
-#undef __bogomips
-
 #ifdef CONFIG_SMP
                sched_latency += 1000;
 #endif /* CONFIG_SMP */
        }
 #endif /* !CONFIG_XENO_OPT_TIMING_SCHEDLAT */
 
-       return sched_latency;
+       p->user = sched_latency;
+       p->kernel = CONFIG_XENO_OPT_TIMING_KSCHEDLAT;
+       p->irq = CONFIG_XENO_OPT_TIMING_IRQLAT;
 }
 
 #endif /* !_COBALT_X86_ASM_CALIBRATION_H */
diff --git a/kernel/cobalt/clock.c b/kernel/cobalt/clock.c
index 2c1219b..31b6fae 100644
--- a/kernel/cobalt/clock.c
+++ b/kernel/cobalt/clock.c
@@ -786,12 +786,14 @@ static int set_core_clock_gravity(struct xnclock *clock,
 
 static void reset_core_clock_gravity(struct xnclock *clock)
 {
-       xnticks_t schedlat = xnarch_get_sched_latency();
        struct xnclock_gravity gravity;
 
-       gravity.user = xnclock_ns_to_ticks(&nkclock, schedlat) + nktimerlat;
-       gravity.kernel = gravity.user;
-       gravity.irq = nktimerlat;
+       xnarch_get_latencies(&gravity);
+       gravity.user += nktimerlat;
+       if (gravity.kernel == 0)
+               gravity.kernel = gravity.user;
+       if (gravity.irq == 0)
+               gravity.irq = nktimerlat;
        set_core_clock_gravity(clock, &gravity);
 }
 


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

Reply via email to