[Xenomai-git] Philippe Gerum : lib/cobalt: clear u_window when releasing TSD
Module: xenomai-3 Branch: wip/dovetail Commit: 4275a98b3a730f5d246a72ee31c9f83a7560d4e7 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4275a98b3a730f5d246a72ee31c9f83a7560d4e7 Author: Philippe Gerum Date: Fri Mar 18 21:33:36 2016 +0100 lib/cobalt: clear u_window when releasing TSD --- lib/cobalt/current.c |2 ++ lib/cobalt/umm.c |2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/cobalt/current.c b/lib/cobalt/current.c index a085456..7d6ee9f 100644 --- a/lib/cobalt/current.c +++ b/lib/cobalt/current.c @@ -47,6 +47,7 @@ static inline void __cobalt_set_tsd(xnhandle_t current, __u32 u_winoff) static inline void __cobalt_clear_tsd(void) { cobalt_current = XN_NO_HANDLE; + cobalt_current_window = NULL; } static void init_current_keys(void) @@ -75,6 +76,7 @@ static inline void __cobalt_set_tsd(xnhandle_t current, static inline void __cobalt_clear_tsd(void) { pthread_setspecific(cobalt_current_key, NULL); + pthread_setspecific(cobalt_current_window_key, NULL); } static void init_current_keys(void) diff --git a/lib/cobalt/umm.c b/lib/cobalt/umm.c index 5772256..944620f 100644 --- a/lib/cobalt/umm.c +++ b/lib/cobalt/umm.c @@ -88,7 +88,7 @@ void cobalt_unmap_umm(void) * On machines without an MMU, there is no such thing as fork. * * We replace former mappings with an invalid one, to detect -* any spuriously late access from the fastsync code. +* any spurious late access. */ addr = __STD(mmap(cobalt_umm_private, private_size, PROT_NONE, ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : boilerplate/libc: provide placeholders for prioceiling ops
Module: xenomai-3 Branch: wip/dovetail Commit: e22c3d3b4f624cee9fc476260bb8269b94cf8507 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e22c3d3b4f624cee9fc476260bb8269b94cf8507 Author: Philippe Gerum Date: Sun Mar 20 17:20:58 2016 +0100 boilerplate/libc: provide placeholders for prioceiling ops --- configure.ac |2 ++ include/boilerplate/libc.h | 19 +++ 2 files changed, 21 insertions(+) diff --git a/configure.ac b/configure.ac index 18f3be0..0cbe8b8 100644 --- a/configure.ac +++ b/configure.ac @@ -511,6 +511,8 @@ AC_CHECK_FUNCS([pthread_mutexattr_setprotocol \ pthread_mutexattr_getprioceiling \ pthread_mutexattr_setprioceiling \ pthread_mutexattr_setrobust_np \ + pthread_mutex_getprioceiling\ + pthread_mutex_setprioceiling\ pthread_condattr_getclock \ pthread_condattr_setclock \ pthread_spin_lock fork \ diff --git a/include/boilerplate/libc.h b/include/boilerplate/libc.h index 3a5af8c..2f356a9 100644 --- a/include/boilerplate/libc.h +++ b/include/boilerplate/libc.h @@ -127,6 +127,25 @@ int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t * } #endif /* !HAVE_PTHREAD_MUTEXATTR_GETPRIOCEILING */ +#ifndef HAVE_PTHREAD_MUTEX_SETPRIOCEILING +static inline +int pthread_mutex_setprioceiling(pthread_mutex_t *__restrict attr, +int prioceiling, +int *__restrict old_ceiling) +{ + return ENOSYS; +} +#endif /* !HAVE_PTHREAD_MUTEXATTR_SETPRIOCEILING */ + +#ifndef HAVE_PTHREAD_MUTEX_GETPRIOCEILING +static inline +int pthread_mutex_getprioceiling(pthread_mutex_t *__restrict attr, +int *__restrict prioceiling) +{ + return ENOSYS; +} +#endif /* !HAVE_PTHREAD_MUTEXATTR_GETPRIOCEILING */ + #ifndef HAVE_PTHREAD_ATTR_SETAFFINITY_NP #include static inline ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/synch: add support for priority ceiling protocol
Module: xenomai-3 Branch: wip/dovetail Commit: 2e1dc6e9221201b592061a2b323a669ca1707f28 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2e1dc6e9221201b592061a2b323a669ca1707f28 Author: Philippe Gerum Date: Tue Feb 16 10:12:55 2016 +0100 cobalt/synch: add support for priority ceiling protocol --- include/cobalt/kernel/heap.h | 11 + include/cobalt/kernel/sched-idle.h | 12 +- include/cobalt/kernel/sched-rt.h | 55 ++- include/cobalt/kernel/sched.h | 94 +++- include/cobalt/kernel/synch.h | 51 ++- include/cobalt/kernel/thread.h | 54 ++- include/cobalt/uapi/asm-generic/features.h | 27 +- include/cobalt/uapi/kernel/synch.h |8 +- include/cobalt/uapi/kernel/thread.h|3 +- include/cobalt/uapi/kernel/types.h |5 +- include/cobalt/uapi/mutex.h|1 + include/cobalt/uapi/thread.h |1 + kernel/cobalt/posix/cond.c |2 +- kernel/cobalt/posix/memory.h |6 + kernel/cobalt/posix/monitor.c | 29 +- kernel/cobalt/posix/mqueue.c |4 +- kernel/cobalt/posix/mutex.c| 103 +++-- kernel/cobalt/posix/process.c | 21 +- kernel/cobalt/posix/process.h |3 +- kernel/cobalt/posix/syscall.c |6 +- kernel/cobalt/posix/timerfd.c |2 +- kernel/cobalt/rtdm/drvlib.c|2 +- kernel/cobalt/sched-idle.c | 12 +- kernel/cobalt/sched-quota.c| 24 +- kernel/cobalt/sched-rt.c | 14 +- kernel/cobalt/sched-sporadic.c | 35 +- kernel/cobalt/sched-tp.c | 42 +- kernel/cobalt/sched-weak.c | 16 +- kernel/cobalt/sched.c | 126 +- kernel/cobalt/synch.c | 636 +++- kernel/cobalt/thread.c | 115 ++--- 31 files changed, 1038 insertions(+), 482 deletions(-) diff --git a/include/cobalt/kernel/heap.h b/include/cobalt/kernel/heap.h index a1cea69..d89f25d 100644 --- a/include/cobalt/kernel/heap.h +++ b/include/cobalt/kernel/heap.h @@ -147,6 +147,17 @@ void xnheap_free(struct xnheap *heap, void *block); int xnheap_check_block(struct xnheap *heap, void *block); +static inline void *xnheap_zalloc(struct xnheap *heap, u32 size) +{ + void *p; + + p = xnheap_alloc(heap, size); + if (p) + memset(p, 0, size); + + return p; +} + static inline char *xnstrdup(const char *s) { char *p; diff --git a/include/cobalt/kernel/sched-idle.h b/include/cobalt/kernel/sched-idle.h index 732ff84..75efdec 100644 --- a/include/cobalt/kernel/sched-idle.h +++ b/include/cobalt/kernel/sched-idle.h @@ -33,11 +33,11 @@ extern struct xnsched_class xnsched_class_idle; -static inline void __xnsched_idle_setparam(struct xnthread *thread, +static inline bool __xnsched_idle_setparam(struct xnthread *thread, const union xnsched_policy_param *p) { xnthread_clear_state(thread, XNWEAK); - thread->cprio = p->idle.prio; + return xnsched_set_effective_priority(thread, p->idle.prio); } static inline void __xnsched_idle_getparam(struct xnthread *thread, @@ -50,11 +50,17 @@ static inline void __xnsched_idle_trackprio(struct xnthread *thread, const union xnsched_policy_param *p) { if (p) - __xnsched_idle_setparam(thread, p); + /* Inheriting a priority-less class makes no sense. */ + XENO_WARN_ON_ONCE(COBALT, 1); else thread->cprio = XNSCHED_IDLE_PRIO; } +static inline void __xnsched_idle_protectprio(struct xnthread *thread, int prio) +{ + XENO_WARN_ON_ONCE(COBALT, 1); +} + static inline int xnsched_idle_init_thread(struct xnthread *thread) { return 0; diff --git a/include/cobalt/kernel/sched-rt.h b/include/cobalt/kernel/sched-rt.h index ffb7223..992a5ba 100644 --- a/include/cobalt/kernel/sched-rt.h +++ b/include/cobalt/kernel/sched-rt.h @@ -67,20 +67,33 @@ static inline void __xnsched_rt_dequeue(struct xnthread *thread) xnsched_delq(&thread->sched->rt.runnable, thread); } -static inline void __xnsched_rt_setparam(struct xnthread *thread, -const union xnsched_policy_param *p) +static inline void __xnsched_rt_track_weakness(struct xnthread *thread) { - thread->cprio = p->rt.prio; - if (!xnthread_test_state(thread, XNBOOST)) { -#ifdef CONFIG_XENO_OPT_SCHED_WEAK + /* +* We have to track threads exiting weak scheduling, i.e. any +* thread leaving the WEAK class code if compiled in, or +* assigned a zero priority if weak threads are hosted by the +* RT class. +* +* CAUTION: since we need to check
[Xenomai-git] Philippe Gerum : cobalt/thread: fix join request handling from non-Xenomai context
Module: xenomai-3 Branch: wip/dovetail Commit: 57fa6d9c669528adcbe21b7b8760b9c70e13cd5a URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=57fa6d9c669528adcbe21b7b8760b9c70e13cd5a Author: Philippe Gerum Date: Fri Mar 18 18:20:50 2016 +0100 cobalt/thread: fix join request handling from non-Xenomai context --- kernel/cobalt/thread.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c index 7983165..e5580b5 100644 --- a/kernel/cobalt/thread.c +++ b/kernel/cobalt/thread.c @@ -1678,7 +1678,7 @@ int xnthread_join(struct xnthread *thread, bool uninterruptible) xnthread_set_state(thread, XNJOINED); tpid = xnthread_host_pid(thread); - if (!xnthread_test_state(curr, XNRELAX|XNROOT)) { + if (curr && !xnthread_test_state(curr, XNRELAX)) { xnlock_put_irqrestore(&nklock, s); xnthread_relax(0, 0); switched = 1; ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : include/boilerplate: add shorthand for deprecated calls
Module: xenomai-3 Branch: wip/dovetail Commit: e0b71cfaa084e8ea784cab2ab1425761f52a56fa URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e0b71cfaa084e8ea784cab2ab1425761f52a56fa Author: Philippe Gerum Date: Fri Mar 18 13:01:38 2016 +0100 include/boilerplate: add shorthand for deprecated calls --- include/boilerplate/compiler.h |4 include/cobalt/stdio.h |3 +-- include/cobalt/wrappers.h |2 ++ include/trank/native/misc.h|4 ++-- include/trank/native/task.h|2 +- include/trank/native/timer.h |2 +- include/trank/trank.h |4 ++-- 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/boilerplate/compiler.h b/include/boilerplate/compiler.h index e27d165..e558f73 100644 --- a/include/boilerplate/compiler.h +++ b/include/boilerplate/compiler.h @@ -54,4 +54,8 @@ #define __aligned(__n) __attribute__((aligned (__n))) #endif +#ifndef __deprecated +#define __deprecated __attribute__((__deprecated__)) +#endif + #endif /* _BOILERPLATE_COMPILER_H */ diff --git a/include/cobalt/stdio.h b/include/cobalt/stdio.h index 0d97b83..81486d5 100644 --- a/include/cobalt/stdio.h +++ b/include/cobalt/stdio.h @@ -114,8 +114,7 @@ void rt_print_flush_buffers(void); void assert_nrt(void); -__attribute__((__deprecated__)) -void assert_nrt_fast(void); +__deprecated void assert_nrt_fast(void); #ifdef __cplusplus } diff --git a/include/cobalt/wrappers.h b/include/cobalt/wrappers.h index 975f7a3..7e061ca 100644 --- a/include/cobalt/wrappers.h +++ b/include/cobalt/wrappers.h @@ -18,6 +18,8 @@ #ifndef _COBALT_WRAPPERS_H #define _COBALT_WRAPPERS_H +#include + #define __stringify_1(x...)#x #define __stringify(x...) __stringify_1(x) diff --git a/include/trank/native/misc.h b/include/trank/native/misc.h index bf0ed17..ea242d2 100644 --- a/include/trank/native/misc.h +++ b/include/trank/native/misc.h @@ -32,7 +32,7 @@ typedef struct rt_ioregion { extern "C" { #endif -__attribute__((__deprecated__)) +__deprecated static inline int rt_io_get_region(RT_IOREGION *iorn, const char *name, uint64_t start, @@ -43,7 +43,7 @@ static inline int rt_io_get_region(RT_IOREGION *iorn, return -ENOSYS; } -__attribute__((__deprecated__)) +__deprecated int rt_io_put_region(RT_IOREGION *iorn) { trank_warning("service should be provided by a RTDM driver"); diff --git a/include/trank/native/task.h b/include/trank/native/task.h index 5c4d354..85c3cd4 100644 --- a/include/trank/native/task.h +++ b/include/trank/native/task.h @@ -35,7 +35,7 @@ extern "C" { #endif -__attribute__((__deprecated__)) +__deprecated static inline int rt_task_notify(RT_TASK *task, rt_sigset_t sigs) { trank_warning("in-kernel native API is gone, rebase over RTDM"); diff --git a/include/trank/native/timer.h b/include/trank/native/timer.h index 7ccba1c..9cb606d 100644 --- a/include/trank/native/timer.h +++ b/include/trank/native/timer.h @@ -28,7 +28,7 @@ extern "C" { #endif -__attribute__((__deprecated__)) +__deprecated static inline int rt_timer_set_mode(RTIME nstick) { #ifdef CONFIG_XENO_LORES_CLOCK_DISABLED diff --git a/include/trank/trank.h b/include/trank/trank.h index 693c015..2477d45 100644 --- a/include/trank/trank.h +++ b/include/trank/trank.h @@ -18,6 +18,8 @@ #ifndef _XENOMAI_TRANK_TRANK_H #define _XENOMAI_TRANK_TRANK_H +#include + #ifdef __XENO_COMPAT__ void warning(const char *fmt, ...); @@ -32,8 +34,6 @@ void warning(const char *fmt, ...); #else /* !__XENO_COMPAT__ */ -#include - #define __CURRENT(call)call #define COMPAT_DECL(T, P) ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : utils/autotune: protect against SIGHUP in background mode
Module: xenomai-3 Branch: wip/dovetail Commit: 20d6ae1796c510ab0494962f4c65b8a2c1df9015 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=20d6ae1796c510ab0494962f4c65b8a2c1df9015 Author: Philippe Gerum Date: Sat Mar 19 08:44:34 2016 +0100 utils/autotune: protect against SIGHUP in background mode --- utils/autotune/autotune.c |2 ++ 1 file changed, 2 insertions(+) diff --git a/utils/autotune/autotune.c b/utils/autotune/autotune.c index 5c3e0fe..f52733b 100644 --- a/utils/autotune/autotune.c +++ b/utils/autotune/autotune.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -285,6 +286,7 @@ int main(int argc, char *const argv[]) error(1, errno, "cannot set CPU affinity"); if (background) { + signal(SIGHUP, SIG_IGN); ret = daemon(0, 0); if (ret) error(1, errno, "cannot daemonize"); ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : lib/cobalt: use lazy schedparam propagation
Module: xenomai-3 Branch: wip/dovetail Commit: 3fbb01e1e0bbf0dd479f8905912fdf4bcc770dd2 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3fbb01e1e0bbf0dd479f8905912fdf4bcc770dd2 Author: Philippe Gerum Date: Fri Mar 18 12:12:27 2016 +0100 lib/cobalt: use lazy schedparam propagation Do not switch to secondary mode upon schedparam updates for propagating changes to the regular kernel, if the caller runs in primary mode when entering pthread_setschedparam*() or sched_setscheduler(). In such a case, the update request to the regular kernel is left pending until the target thread resumes execution in relaxed mode, at which point it is committed. CAUTION: This mechanism won't update the schedparams cached by the glibc for the caller in user-space, but this is the deal: we don't relax threads which issue pthread_setschedparam[_ex]() from primary mode anymore, but then only the kernel side (Cobalt and the host kernel) will be aware of the change, and glibc might cache obsolete information. If the caller already runs in relaxed mode on entry to these services, the update request takes place immediately, via the regular (g)libc calls. In any case, the new scheduling parameters for the target thread are immediately applied by Cobalt, regardless of the update path followed for the regular kernel. --- lib/cobalt/internal.c | 44 ++ lib/cobalt/sched.c | 13 lib/cobalt/sigshadow.c |8 + lib/cobalt/thread.c| 80 +--- 4 files changed, 87 insertions(+), 58 deletions(-) diff --git a/lib/cobalt/internal.c b/lib/cobalt/internal.c index 5b89db5..cb1d53b 100644 --- a/lib/cobalt/internal.c +++ b/lib/cobalt/internal.c @@ -514,3 +514,47 @@ int cobalt_sched_weighted_prio(int policy, { return XENOMAI_SYSCALL2(sc_cobalt_sched_weightprio, policy, param_ex); } + +int cobalt_xlate_schedparam(int policy, + const struct sched_param_ex *param_ex, + struct sched_param *param) +{ + int std_policy, priority; + + /* +* Translates Cobalt scheduling parameters to native ones, +* based on a best approximation for Cobalt policies which are +* not available from the host kernel. +*/ + std_policy = policy; + priority = param_ex->sched_priority; + + switch (policy) { + case SCHED_WEAK: + std_policy = priority ? SCHED_FIFO : SCHED_OTHER; + break; + default: + std_policy = SCHED_FIFO; + /* falldown wanted. */ + case SCHED_OTHER: + case SCHED_FIFO: + case SCHED_RR: + /* +* The Cobalt priority range is larger than those of +* the native SCHED_FIFO/RR classes, so we have to cap +* the priority value accordingly. We also remap +* "weak" (negative) priorities - which are only +* meaningful for the Cobalt core - to regular values. +*/ + if (priority > __cobalt_std_fifo_maxpri) + priority = __cobalt_std_fifo_maxpri; + } + + if (priority < 0) + priority = -priority; + + memset(param, 0, sizeof(*param)); + param->sched_priority = priority; + + return std_policy; +} diff --git a/lib/cobalt/sched.c b/lib/cobalt/sched.c index b0292b5..87b9235 100644 --- a/lib/cobalt/sched.c +++ b/lib/cobalt/sched.c @@ -26,7 +26,6 @@ #include #include #include -#include "current.h" #include "internal.h" /** @@ -297,11 +296,13 @@ int sched_setscheduler_ex(pid_t pid, return EINVAL; /* See pthread_setschedparam_ex(). */ - - std_policy = cobalt_xlate_schedparam(policy, param_ex, &std_param); - ret = __STD(sched_setscheduler(pid, std_policy, &std_param)); - if (ret) - return errno; + + if (cobalt_is_relaxed()) { + std_policy = cobalt_xlate_schedparam(policy, param_ex, &std_param); + ret = __STD(sched_setscheduler(pid, std_policy, &std_param)); + if (ret) + return errno; + } ret = -XENOMAI_SYSCALL5(sc_cobalt_sched_setscheduler_ex, pid, policy, param_ex, diff --git a/lib/cobalt/sigshadow.c b/lib/cobalt/sigshadow.c index 3f4e9c5..48d5a81 100644 --- a/lib/cobalt/sigshadow.c +++ b/lib/cobalt/sigshadow.c @@ -59,6 +59,14 @@ int cobalt_sigshadow_handler(int sig, siginfo_t *si, void *ctxt) skip = nr > 3 ? 3 : 0; XENOMAI_SYSCALL3(sc_cobalt_backtrace, nr - skip, frames + skip, arg); break; + case SIGSHADOW_ACTION_HOME: + /* +* We have been asked to call home from the current +* context: sending a query for retrieving our handle +* will just do this. +*/ +
[Xenomai-git] Philippe Gerum : lib/cobalt: add config switch to enable lazy setsched update mode
Module: xenomai-3 Branch: wip/dovetail Commit: 867070475384652b4e3d4a25f5ad983732a59a7e URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=867070475384652b4e3d4a25f5ad983732a59a7e Author: Philippe Gerum Date: Sun Mar 20 17:58:33 2016 +0100 lib/cobalt: add config switch to enable lazy setsched update mode --enable-lazy-setsched should be given for enabling lazy propagation of scheduling parameters upon calls to pthread_setschedparam*(), sched_setscheduler(). Defaults to off. --- configure.ac | 19 +++ lib/cobalt/internal.h | 12 lib/cobalt/sched.c|2 +- lib/cobalt/thread.c |3 ++- 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 0cbe8b8..cd9f047 100644 --- a/configure.ac +++ b/configure.ac @@ -284,6 +284,25 @@ if test x$workaround_condvar_pi = xy; then fi fi +dnl Lazy schedparam propagation for Cobalt (default: off) + +unset lazy_setsched_update +AC_MSG_CHECKING(whether to enable lazy scheduling parameter update) +AC_ARG_ENABLE(lazy-setsched, + AS_HELP_STRING([--enable-lazy-setsched], [Enable lazy scheduling parameter update]), + [case "$enableval" in + y | yes) lazy_setsched_update=y ;; + *) unset lazy_setsched_update ;; + esac]) +AC_MSG_RESULT(${lazy_setsched_update:-no}) +if test x$lazy_setsched_update = xy; then + if test x$rtcore_type = xcobalt; then + AC_DEFINE(CONFIG_XENO_LAZY_SETSCHED,1,[config]) + else +AC_MSG_WARN([No lazy scheduling parameter updates over Mercury - ignoring]) + fi +fi + dnl Enable shared multi-processing (default: off) use_pshared= diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h index 4b8252b..1531901 100644 --- a/lib/cobalt/internal.h +++ b/lib/cobalt/internal.h @@ -32,6 +32,18 @@ static inline int cobalt_is_relaxed(void) return cobalt_get_current_mode() & XNRELAX; } +#ifdef CONFIG_XENO_LAZY_SETSCHED +static inline int cobalt_eager_setsched(void) +{ + return cobalt_is_relaxed(); +} +#else +static inline int cobalt_eager_setsched(void) +{ + return 1; +} +#endif + static inline struct cobalt_mutex_state *mutex_get_state(struct cobalt_mutex_shadow *shadow) { diff --git a/lib/cobalt/sched.c b/lib/cobalt/sched.c index 87b9235..94f3323 100644 --- a/lib/cobalt/sched.c +++ b/lib/cobalt/sched.c @@ -297,7 +297,7 @@ int sched_setscheduler_ex(pid_t pid, /* See pthread_setschedparam_ex(). */ - if (cobalt_is_relaxed()) { + if (cobalt_eager_setsched()) { std_policy = cobalt_xlate_schedparam(policy, param_ex, &std_param); ret = __STD(sched_setscheduler(pid, std_policy, &std_param)); if (ret) diff --git a/lib/cobalt/thread.c b/lib/cobalt/thread.c index 8b4568d..908516f 100644 --- a/lib/cobalt/thread.c +++ b/lib/cobalt/thread.c @@ -629,7 +629,8 @@ int pthread_setschedparam_ex(pthread_t thread, * threads should refrain from mixing APIs for managing * scheduling parameters, and only rely on libcobalt for this. */ - if (cobalt_is_relaxed()) { /* True if shadow not mapped yet. */ + if (cobalt_eager_setsched()) { + /* True if disabled or shadow not mapped yet. */ std_policy = cobalt_xlate_schedparam(policy, param_ex, &std_param); ret = __STD(pthread_setschedparam(thread, std_policy, &std_param)); if (ret) ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : lib/cobalt: simplify checks for secondary mode
Module: xenomai-3 Branch: wip/dovetail Commit: e0f1cd9568e3f00b2a148b6902327fc36346c25d URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e0f1cd9568e3f00b2a148b6902327fc36346c25d Author: Philippe Gerum Date: Fri Mar 18 12:00:55 2016 +0100 lib/cobalt: simplify checks for secondary mode Whether a current thread is currently running in primary/secondary mode can be checked by inspecting the status of the XNRELAX bit in the thread's u_window. The lack of u_window denotes a non-Xenomai, regular thread which for which the current mode is always relaxed. A thread's handle and its u_window area are tightly coupled: the latter has to be valid for any thread with a valid handle. Introduce cobalt_is_relaxed() for testing the current mode, and fixup all open coded versions of this routine. In addition, assert_nrt_fast() is marked as deprecated, since assert_nrt() is not a slow call anymore. --- include/cobalt/stdio.h |1 + lib/cobalt/assert_context.c | 14 +++--- lib/cobalt/internal.c |4 +--- lib/cobalt/internal.h |7 ++- lib/cobalt/printf.c | 27 +-- 5 files changed, 20 insertions(+), 33 deletions(-) diff --git a/include/cobalt/stdio.h b/include/cobalt/stdio.h index f0c289d..0d97b83 100644 --- a/include/cobalt/stdio.h +++ b/include/cobalt/stdio.h @@ -114,6 +114,7 @@ void rt_print_flush_buffers(void); void assert_nrt(void); +__attribute__((__deprecated__)) void assert_nrt_fast(void); #ifdef __cplusplus diff --git a/lib/cobalt/assert_context.c b/lib/cobalt/assert_context.c index da5f2b0..2085953 100644 --- a/lib/cobalt/assert_context.c +++ b/lib/cobalt/assert_context.c @@ -45,21 +45,13 @@ static void assert_nrt_inner(void) void assert_nrt(void) { - if (cobalt_get_current() != XN_NO_HANDLE && -!(cobalt_get_current_mode() & XNRELAX)) + if (!cobalt_is_relaxed()) assert_nrt_inner(); } -/* - * Note: Works without syscalls but may not catch all errors when used inside - * TSD destructors (as registered via pthread_key_create) when TLS support - * (__thread) is disabled. - */ -void assert_nrt_fast(void) +void assert_nrt_fast(void) /* OBSOLETE */ { - if (cobalt_get_current_fast() != XN_NO_HANDLE && -!(cobalt_get_current_mode() & XNRELAX)) - assert_nrt_inner(); + assert_nrt(); } /* Memory allocation services */ diff --git a/lib/cobalt/internal.c b/lib/cobalt/internal.c index 9220237..5b89db5 100644 --- a/lib/cobalt/internal.c +++ b/lib/cobalt/internal.c @@ -54,9 +54,7 @@ void cobalt_thread_harden(void) void cobalt_thread_relax(void) { - int status = cobalt_get_current_mode(); - - if ((status & XNRELAX) == 0) + if (!cobalt_is_relaxed()) XENOMAI_SYSCALL1(sc_cobalt_migrate, COBALT_SECONDARY); } diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h index 69ec7d1..fee3fe1 100644 --- a/lib/cobalt/internal.h +++ b/lib/cobalt/internal.h @@ -27,7 +27,10 @@ extern void *cobalt_umm_private; extern void *cobalt_umm_shared; -void cobalt_sigshadow_install_once(void); +static inline int cobalt_is_relaxed(void) +{ + return cobalt_get_current_mode() & XNRELAX; +} static inline struct cobalt_mutex_state *mutex_get_state(struct cobalt_mutex_shadow *shadow) @@ -43,6 +46,8 @@ static inline atomic_t *mutex_get_ownerp(struct cobalt_mutex_shadow *shadow) return &mutex_get_state(shadow)->owner; } +void cobalt_sigshadow_install_once(void); + void cobalt_thread_init(void); int cobalt_thread_probe(pid_t pid); diff --git a/lib/cobalt/printf.c b/lib/cobalt/printf.c index 797a9b5..87cd5e2 100644 --- a/lib/cobalt/printf.c +++ b/lib/cobalt/printf.c @@ -730,8 +730,7 @@ done: COBALT_IMPL(int, vfprintf, (FILE *stream, const char *fmt, va_list args)) { - if (cobalt_get_current() != XN_NO_HANDLE && -!(cobalt_get_current_mode() & XNRELAX)) + if (!cobalt_is_relaxed()) return rt_vfprintf(stream, fmt, args); else { rt_print_flush_buffers(); @@ -770,8 +769,7 @@ COBALT_IMPL(int, printf, (const char *fmt, ...)) COBALT_IMPL(int, fputs, (const char *s, FILE *stream)) { - if (cobalt_get_current() != XN_NO_HANDLE && -!(cobalt_get_current_mode() & XNRELAX)) + if (!cobalt_is_relaxed()) return rt_fputs(s, stream); else { rt_print_flush_buffers(); @@ -781,8 +779,7 @@ COBALT_IMPL(int, fputs, (const char *s, FILE *stream)) COBALT_IMPL(int, puts, (const char *s)) { - if (cobalt_get_current() != XN_NO_HANDLE && -!(cobalt_get_current_mode() & XNRELAX)) + if (!cobalt_is_relaxed()) return rt_puts(s); else { rt_print_flush_buffers(); @@ -794,8 +791,7 @@ COBALT_IMPL(int, puts, (const char *s)) COBALT_IMPL(int, fputc, (int c, FILE *stream)) { - if (cobalt_get_curre
[Xenomai-git] Philippe Gerum : config: bump version info to 3.1-devel
Module: xenomai-3 Branch: wip/dovetail Commit: dc0fd746ea6ad2d17b5ccf2217a6dfa56087d396 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=dc0fd746ea6ad2d17b5ccf2217a6dfa56087d396 Author: Philippe Gerum Date: Sun Mar 20 18:51:17 2016 +0100 config: bump version info to 3.1-devel --- config/version-code |2 +- config/version-label |2 +- config/version-name |2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/version-code b/config/version-code index cb2b00e..ddd61cc 100644 --- a/config/version-code +++ b/config/version-code @@ -1 +1 @@ -3.0.1 +3.0.90 diff --git a/config/version-label b/config/version-label index cb2b00e..302fdd0 100644 --- a/config/version-label +++ b/config/version-label @@ -1 +1 @@ -3.0.1 +3.1-devel diff --git a/config/version-name b/config/version-name index 272395d..8c51501 100644 --- a/config/version-name +++ b/config/version-name @@ -1 +1 @@ -Exact Zero +Xenomai -next ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Gilles Chanteperdrix : cobalt/config: disallow page migration
Module: xenomai-3 Branch: wip/dovetail Commit: 54b978b71311dbc33afa3a9f7363aceec98927f8 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=54b978b71311dbc33afa3a9f7363aceec98927f8 Author: Gilles Chanteperdrix Date: Wed Mar 23 11:01:12 2016 +0100 cobalt/config: disallow page migration --- scripts/Kconfig.frag |6 ++ 1 file changed, 6 insertions(+) diff --git a/scripts/Kconfig.frag b/scripts/Kconfig.frag index a952d88..61398ed 100644 --- a/scripts/Kconfig.frag +++ b/scripts/Kconfig.frag @@ -1,4 +1,5 @@ menuconfig XENOMAI + depends on !MIGRATION depends on X86_TSC || !X86 bool "Xenomai/cobalt" select IPIPE @@ -19,6 +20,11 @@ if XENOMAI source "arch/$SRCARCH/xenomai/Kconfig" endif +if MIGRATION +comment "Xenomai requires disabling page migration/memory compaction" +comment "(Support for transparent hugepages requires memory compaction)" +endif + if APM || CPU_FREQ || ACPI_PROCESSOR || INTEL_IDLE comment "WARNING! You enabled APM, CPU Frequency scaling, ACPI 'processor'" comment "or Intel cpuidle option. These options are known to cause troubles" ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/config: relax requirement on CONFIG_MIGRATION
Module: xenomai-3 Branch: wip/dovetail Commit: 3be465cfa327f79fdde1f986df370744663d6467 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3be465cfa327f79fdde1f986df370744663d6467 Author: Philippe Gerum Date: Fri Mar 25 10:40:25 2016 +0100 cobalt/config: relax requirement on CONFIG_MIGRATION Some configurations may need page migration enabled for resolving indirect dependencies on other features they might need (e.g. CMA), and are fine with the additional latency that might cause. Just warn loudly when CONFIG_MIGRATION is detected. --- scripts/Kconfig.frag | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/Kconfig.frag b/scripts/Kconfig.frag index 61398ed..2f327bb 100644 --- a/scripts/Kconfig.frag +++ b/scripts/Kconfig.frag @@ -1,5 +1,4 @@ menuconfig XENOMAI - depends on !MIGRATION depends on X86_TSC || !X86 bool "Xenomai/cobalt" select IPIPE @@ -21,14 +20,14 @@ source "arch/$SRCARCH/xenomai/Kconfig" endif if MIGRATION -comment "Xenomai requires disabling page migration/memory compaction" -comment "(Support for transparent hugepages requires memory compaction)" +comment "WARNING! Page migration (CONFIG_MIGRATION) may increase" +comment "latency." endif if APM || CPU_FREQ || ACPI_PROCESSOR || INTEL_IDLE -comment "WARNING! You enabled APM, CPU Frequency scaling, ACPI 'processor'" -comment "or Intel cpuidle option. These options are known to cause troubles" -comment "with Xenomai, disable them." +comment "WARNING! At least one of APM, CPU frequency scaling, ACPI 'processor'" +comment "or CPU idle features is enabled. Any of these options may" +comment "cause troubles with Xenomai. You should disable them." endif if !GENERIC_CLOCKEVENTS ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : doc: prebuild
Module: xenomai-3 Branch: wip/dovetail Commit: e07ef441d0069f16364eeaa6b4c8a5680f6abf57 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e07ef441d0069f16364eeaa6b4c8a5680f6abf57 Author: Philippe Gerum Date: Sun Mar 20 19:34:22 2016 +0100 doc: prebuild --- doc/asciidoc/README.INSTALL.adoc | 26 +- doc/asciidoc/TROUBLESHOOTING.COBALT.adoc | 11 +- doc/prebuilt/html/MIGRATION/index.html |6 +- doc/prebuilt/html/README.APPLICATIONS/index.html |2 +- doc/prebuilt/html/README.INSTALL/index.html| 32 +- .../html/TROUBLESHOOTING.COBALT/index.html | 15 +- .../html/TROUBLESHOOTING.MERCURY/index.html|2 +- doc/prebuilt/html/man1/autotune/index.html |2 +- doc/prebuilt/html/man1/clocktest/index.html|2 +- doc/prebuilt/html/man1/corectl/index.html |2 +- doc/prebuilt/html/man1/dohell/index.html |2 +- doc/prebuilt/html/man1/latency/index.html |2 +- doc/prebuilt/html/man1/rtcanconfig/index.html |2 +- doc/prebuilt/html/man1/rtcanrecv/index.html|2 +- doc/prebuilt/html/man1/rtcansend/index.html|2 +- doc/prebuilt/html/man1/slackspot/index.html|2 +- doc/prebuilt/html/man1/switchtest/index.html |2 +- doc/prebuilt/html/man1/xeno-config/index.html |2 +- doc/prebuilt/html/man1/xeno-test/index.html|2 +- doc/prebuilt/html/man1/xeno/index.html |2 +- .../html/xeno3prm/16550A__io_8h_source.html| 10 +- .../html/xeno3prm/16550A__pci_8h_source.html | 10 +- .../html/xeno3prm/16550A__pnp_8h_source.html | 10 +- doc/prebuilt/html/xeno3prm/8255_8h_source.html | 10 +- doc/prebuilt/html/xeno3prm/af__inet_8h_source.html | 10 +- .../html/xeno3prm/alchemy_2compat_8h_source.html | 10 +- doc/prebuilt/html/xeno3prm/analogy_2driver_8h.html | 48 +- .../html/xeno3prm/analogy_2driver_8h__incl.map | 58 +- .../html/xeno3prm/analogy_2driver_8h__incl.md5 |2 +- .../html/xeno3prm/analogy_2driver_8h__incl.png | Bin 271875 -> 289554 bytes .../html/xeno3prm/analogy_2driver_8h_source.html | 10 +- doc/prebuilt/html/xeno3prm/analogy_8h.html | 33 +- doc/prebuilt/html/xeno3prm/analogy_8h__incl.map| 26 +- doc/prebuilt/html/xeno3prm/analogy_8h__incl.md5|2 +- doc/prebuilt/html/xeno3prm/analogy_8h__incl.png| Bin 66461 -> 69464 bytes doc/prebuilt/html/xeno3prm/analogy_8h_source.html | 10 +- doc/prebuilt/html/xeno3prm/annotated.html | 10 +- doc/prebuilt/html/xeno3prm/annotated_dup.js| 54 + doc/prebuilt/html/xeno3prm/apc_8h_source.html | 10 +- doc/prebuilt/html/xeno3prm/api-tags.html | 10 +- ..._2include_2asm_2xenomai_2machine_8h_source.html | 149 ++ ...include_2asm_2xenomai_2syscall32_8h_source.html | 133 ++ ..._2include_2asm_2xenomai_2machine_8h_source.html | 10 +- ...include_2asm_2xenomai_2syscall32_8h_source.html | 10 +- ..._2include_2asm_2xenomai_2machine_8h_source.html | 10 +- ...include_2asm_2xenomai_2syscall32_8h_source.html | 10 +- ..._2include_2asm_2xenomai_2machine_8h_source.html | 10 +- ...include_2asm_2xenomai_2syscall32_8h_source.html | 10 +- ..._2include_2asm_2xenomai_2machine_8h_source.html | 10 +- ...include_2asm_2xenomai_2syscall32_8h_source.html | 10 +- ...4_2include_2asm_2xenomai_2fptest_8h_source.html | 156 ++ ...lude_2asm_2xenomai_2uapi_2fptest_8h_source.html | 214 ++ ...m_2include_2asm_2xenomai_2fptest_8h_source.html | 10 +- ...lude_2asm_2xenomai_2uapi_2fptest_8h_source.html | 10 +- doc/prebuilt/html/xeno3prm/arp_8h_source.html | 10 +- doc/prebuilt/html/xeno3prm/assert_8h_source.html | 57 +- doc/prebuilt/html/xeno3prm/async_8c.html | 34 +- doc/prebuilt/html/xeno3prm/async_8c__incl.map | 44 +- doc/prebuilt/html/xeno3prm/async_8c__incl.md5 |2 +- doc/prebuilt/html/xeno3prm/async_8c__incl.png | Bin 117906 -> 139291 bytes doc/prebuilt/html/xeno3prm/atomic_8h_source.html | 10 +- doc/prebuilt/html/xeno3prm/bheap_8h_source.html| 10 +- ...n_2include_2asm_2xenomai_2fptest_8h_source.html | 10 +- ...lude_2asm_2xenomai_2uapi_2fptest_8h_source.html | 10 +- .../boilerplate_2ancillaries_8h_source.html| 217 +- .../html/xeno3prm/boilerplate_2list_8h_source.html | 10 +- .../html/xeno3prm/boilerplate_2lock_8h_source.html | 393 ++-- .../html/xeno3prm/boilerplate_2time_8h_source.html | 10 +- .../xeno3prm/boilerplate_2tunables_8h_source.html | 34 +- doc/prebuilt/html/xeno3prm/bufd_8h_source.html | 10 +- .../html/xeno3prm/bufp-label_8c-example.html | 10 +- .../html/xeno3prm/bufp-readwrite_8c-example.html | 10 +- doc/prebuilt/html/xeno3prm/c1e_8h_source.html | 10 +- doc/prebuilt/html/xeno3prm/calibration_8c.html | 28 +- .../html/xeno3prm/calibration_8c__incl.map | 32 +- .../html/xeno
[Xenomai-git] Philippe Gerum : lib/cobalt/mutex: add support for priority ceiling protocol
Module: xenomai-3 Branch: wip/dovetail Commit: 2eb540f0cd221e3c341e5b1fb9d3571b0560794d URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2eb540f0cd221e3c341e5b1fb9d3571b0560794d Author: Philippe Gerum Date: Tue Feb 16 10:13:03 2016 +0100 lib/cobalt/mutex: add support for priority ceiling protocol --- configure.ac |2 + include/boilerplate/libc.h | 19 +++ include/cobalt/pthread.h |7 ++ lib/cobalt/cobalt.wrappers |2 + lib/cobalt/init.c |1 + lib/cobalt/internal.h |8 ++ lib/cobalt/mutex.c | 301 +++- lib/cobalt/sched.c | 33 - lib/cobalt/thread.c|7 +- 9 files changed, 311 insertions(+), 69 deletions(-) diff --git a/configure.ac b/configure.ac index d71aa38..18f3be0 100644 --- a/configure.ac +++ b/configure.ac @@ -508,6 +508,8 @@ save_LIBS="$LIBS" LIBS="$LIBS -lrt -lpthread" AC_CHECK_FUNCS([pthread_mutexattr_setprotocol \ pthread_mutexattr_getprotocol \ + pthread_mutexattr_getprioceiling \ + pthread_mutexattr_setprioceiling \ pthread_mutexattr_setrobust_np \ pthread_condattr_getclock \ pthread_condattr_setclock \ diff --git a/include/boilerplate/libc.h b/include/boilerplate/libc.h index 0e51b86..3a5af8c 100644 --- a/include/boilerplate/libc.h +++ b/include/boilerplate/libc.h @@ -108,6 +108,25 @@ int pthread_mutexattr_getprotocol(const pthread_mutexattr_t * } #endif /* !HAVE_PTHREAD_MUTEXATTR_GETPROTOCOL */ +#ifndef HAVE_PTHREAD_MUTEXATTR_SETPRIOCEILING +static inline +int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr, +int prioceiling) +{ + return ENOSYS; +} +#endif /* !HAVE_PTHREAD_MUTEXATTR_SETPRIOCEILING */ + +#ifndef HAVE_PTHREAD_MUTEXATTR_GETPRIOCEILING +static inline +int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t * + __restrict attr, +int *__restrict prioceiling) +{ + return ENOSYS; +} +#endif /* !HAVE_PTHREAD_MUTEXATTR_GETPRIOCEILING */ + #ifndef HAVE_PTHREAD_ATTR_SETAFFINITY_NP #include static inline diff --git a/include/cobalt/pthread.h b/include/cobalt/pthread.h index 386c337..f1b1c8a 100644 --- a/include/cobalt/pthread.h +++ b/include/cobalt/pthread.h @@ -67,6 +67,13 @@ COBALT_DECL(int, pthread_mutex_trylock(pthread_mutex_t *mutex)); COBALT_DECL(int, pthread_mutex_unlock(pthread_mutex_t *mutex)); +COBALT_DECL(int, pthread_mutex_setprioceiling(pthread_mutex_t *__restrict mutex, + int prioceiling, + int *__restrict old_ceiling)); + +COBALT_DECL(int, pthread_mutex_getprioceiling(pthread_mutex_t *__restrict mutex, + int *__restrict old_ceiling)); + COBALT_DECL(int, pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *attr)); diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index 9480f34..75f29d6 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -32,6 +32,8 @@ --wrap pthread_mutex_trylock --wrap pthread_mutex_timedlock --wrap pthread_mutex_unlock +--wrap pthread_mutex_setprioceiling +--wrap pthread_mutex_getprioceiling --wrap pthread_cond_init --wrap pthread_cond_destroy --wrap pthread_cond_wait diff --git a/lib/cobalt/init.c b/lib/cobalt/init.c index f260744..69d4763 100644 --- a/lib/cobalt/init.c +++ b/lib/cobalt/init.c @@ -177,6 +177,7 @@ static void __cobalt_init(void) sizeof(struct cobalt_sem_shadow)); cobalt_mutex_init(); + cobalt_sched_init(); cobalt_thread_init(); cobalt_print_init(); } diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h index fee3fe1..4b8252b 100644 --- a/lib/cobalt/internal.h +++ b/lib/cobalt/internal.h @@ -52,6 +52,8 @@ void cobalt_thread_init(void); int cobalt_thread_probe(pid_t pid); +void cobalt_sched_init(void); + void cobalt_print_init(void); void cobalt_print_init_atfork(void); @@ -73,4 +75,10 @@ void cobalt_check_features(struct cobalt_featinfo *finfo); extern struct sigaction __cobalt_orig_sigdebug; +extern int __cobalt_std_fifo_minpri, + __cobalt_std_fifo_maxpri; + +extern int __cobalt_std_rr_minpri, + __cobalt_std_rr_maxpri; + #endif /* _LIB_COBALT_INTERNAL_H */ diff --git a/lib/cobalt/mutex.c b/lib/cobalt/mutex.c index 9d8a914..1456099 100644 --- a/lib/cobalt/mutex.c +++ b/lib/cobalt/mutex.c @@ -99,6 +99,9 @@ void cobalt_mutex_init(void) * mutex, increase CONFIG_XENO_OPT_SHARED_HEAPSZ for a process-shared * mutex, or CONFIG_XENO_OPT_PRIVATE_HEAPSZ for a process-private mutex. * - EAGAIN, no registry slot available, check/raise CONFIG_XENO_OPT_REGISTRY_NRSLOTS. + * - ENOSYS, @a attr mentions priority p
[Xenomai-git] Philippe Gerum : cobalt/intr: remove unused label
Module: xenomai-3 Branch: wip/dovetail Commit: 06ec6e19338d6b4edf2b634502fb0c4f0642 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=06ec6e19338d6b4edf2b634502fb0c4f0642 Author: Philippe Gerum Date: Sun Jan 10 18:41:51 2016 +0100 cobalt/intr: remove unused label --- kernel/cobalt/intr.c |4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/kernel/cobalt/intr.c b/kernel/cobalt/intr.c index 14dc0b3..5123363 100644 --- a/kernel/cobalt/intr.c +++ b/kernel/cobalt/intr.c @@ -625,9 +625,7 @@ static void xnintr_irq_handler(unsigned int irq, void *cookie) if (s & XN_IRQ_DISABLE) set_bit(XN_IRQSTAT_DISABLED, &intr->status); -#ifdef CONFIG_SMP -done: -#endif + xnlock_put(&vec->lock); if (s & XN_IRQ_DISABLE) ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : smokey/posix-mutex: Fix test case /wrt mutex object reuse
Module: xenomai-3 Branch: wip/dovetail Commit: 5393de43e60bab0682f84733174c4fc089a7fd42 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5393de43e60bab0682f84733174c4fc089a7fd42 Author: Jan Kiszka Date: Thu Feb 25 11:29:00 2016 +0100 smokey/posix-mutex: Fix test case /wrt mutex object reuse Mutex objects created on the stack must be properly destroyed after use. Otherwise, succeeding tests that use the same stack layout will consider them busy and refuse to recreate the mutexes. Signed-off-by: Jan Kiszka --- testsuite/smokey/posix-mutex/posix-mutex.c | 26 +- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/testsuite/smokey/posix-mutex/posix-mutex.c b/testsuite/smokey/posix-mutex/posix-mutex.c index ae82fc1..151c2f3 100644 --- a/testsuite/smokey/posix-mutex/posix-mutex.c +++ b/testsuite/smokey/posix-mutex/posix-mutex.c @@ -623,7 +623,10 @@ static int protect_raise(void) if (!__Tassert(get_effective_prio() == THREAD_PRIO_MEDIUM)) return -EINVAL; - + + if (!__T(ret, pthread_mutex_destroy(&mutex))) + return ret; + return 0; } @@ -651,7 +654,10 @@ static int protect_lower(void) if (!__Tassert(get_effective_prio() == THREAD_PRIO_MEDIUM)) return -EINVAL; - + + if (!__T(ret, pthread_mutex_destroy(&mutex))) + return ret; + return 0; } @@ -699,7 +705,10 @@ static int protect_weak(void) if (!__T(ret, pthread_setschedparam(pthread_self(), old_policy, &old_param))) return ret; - + + if (!__T(ret, pthread_mutex_destroy(&mutex))) + return ret; + return 0; } @@ -745,7 +754,11 @@ static int protect_nesting_protect(void) if (!__Tassert(get_effective_prio() == THREAD_PRIO_MEDIUM)) return -EINVAL; - + + if (!__T(ret, pthread_mutex_destroy(&mutex_high)) || + !__T(ret, pthread_mutex_destroy(&mutex_very_high))) + return ret; + return 0; } @@ -782,7 +795,10 @@ static int protect_nesting_pi(void) /* PP boost just dropped: HIGH -> MEDIUM. */ if (!__Tassert(get_effective_prio() == THREAD_PRIO_MEDIUM)) return -EINVAL; - + + if (!__T(ret, pthread_mutex_destroy(&mutex_pp))) + return ret; + return 0; } ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation
Module: xenomai-3 Branch: wip/dovetail Commit: 4eee0136b4bcb744b9dfdc195f18dd839b3e2198 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4eee0136b4bcb744b9dfdc195f18dd839b3e2198 Author: Philippe Gerum Date: Fri Mar 18 12:12:50 2016 +0100 cobalt/thread: add schedparam lazy propagation Provide a mechanism for carrying out a lazy propagation of schedparam updates to the regular kernel, so that userland does not have to switch to secondary mode for this. When userland issues sc_cobalt_thread_setschedparam_ex for updating the scheduling parameters of a Xenomai thread, a request for propagating this change to the regular kernel is made pending. Such request will be committed later, either when: - the thread relaxes if it is running in primary mode when the update request is received; - next time the thread calls back into the Cobalt core as a result of receiving a HOME action from a SIGSHADOW notification, which is sent if such thread was relaxed at the time of the update request. As a result, the target thread will have propagated the schedparams update to the regular kernel as soon as it resumes (relaxed) execution in user-space. --- include/cobalt/kernel/thread.h |8 + include/cobalt/uapi/kernel/thread.h |1 + include/cobalt/uapi/signal.h|1 + kernel/cobalt/posix/syscall.c |9 -- kernel/cobalt/thread.c | 55 +++ 5 files changed, 72 insertions(+), 2 deletions(-) diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h index 07b6996..a4d826e 100644 --- a/include/cobalt/kernel/thread.h +++ b/include/cobalt/kernel/thread.h @@ -567,6 +567,14 @@ int xnthread_set_schedparam(struct xnthread *thread, int xnthread_killall(int grace, int mask); +void __xnthread_propagate_schedparam(struct xnthread *curr); + +static inline void xnthread_propagate_schedparam(struct xnthread *curr) +{ + if (xnthread_test_info(curr, XNSCHEDP)) + __xnthread_propagate_schedparam(curr); +} + extern struct xnthread_personality xenomai_personality; /** @} */ diff --git a/include/cobalt/uapi/kernel/thread.h b/include/cobalt/uapi/kernel/thread.h index 0cfc5c8..8d26f16 100644 --- a/include/cobalt/uapi/kernel/thread.h +++ b/include/cobalt/uapi/kernel/thread.h @@ -71,6 +71,7 @@ #define XNROBBED 0x0020 /**< Robbed from resource ownership */ #define XNCANCELD 0x0040 /**< Cancellation request is pending */ #define XNPIALERT 0x0080 /**< Priority inversion alert (SIGDEBUG sent) */ +#define XNSCHEDP 0x0100 /**< schedparam propagation is pending */ /* Local information flags (private to current thread) */ diff --git a/include/cobalt/uapi/signal.h b/include/cobalt/uapi/signal.h index b5483d7..8a7ea15 100644 --- a/include/cobalt/uapi/signal.h +++ b/include/cobalt/uapi/signal.h @@ -47,6 +47,7 @@ /* SIGSHADOW action codes. */ #define SIGSHADOW_ACTION_HARDEN1 #define SIGSHADOW_ACTION_BACKTRACE 2 +#define SIGSHADOW_ACTION_HOME 3 #define SIGSHADOW_BACKTRACE_DEPTH 16 #define SIGDEBUG SIGXCPU diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c index a2e87ab..9893b30 100644 --- a/kernel/cobalt/posix/syscall.c +++ b/kernel/cobalt/posix/syscall.c @@ -717,11 +717,16 @@ restart: goto ret_handled; } switched = 1; - } else + } else { /* -* We want to run the syscall in the Linux domain. +* We want to run the syscall in the current Linux +* domain. This is a slow path, so proceed with any +* pending schedparam update on the fly. */ switched = 0; + if (thread) + xnthread_propagate_schedparam(thread); + } ret = handler(__xn_reg_arglist(regs)); if (ret == -ENOSYS && (sysflags & __xn_exec_adaptive) != 0) { diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c index 0ea746d..cabc6b8 100644 --- a/kernel/cobalt/thread.c +++ b/kernel/cobalt/thread.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -1974,6 +1975,11 @@ int __xnthread_set_schedparam(struct xnthread *thread, thread->lock_count == 0) xnsched_putback(thread); + xnthread_set_info(thread, XNSCHEDP); + /* Ask the target thread to call back if relaxed. */ + if (xnthread_test_state(thread, XNRELAX)) + xnthread_signal(thread, SIGSHADOW, SIGSHADOW_ACTION_HOME); + return ret; } @@ -2095,6 +2101,40 @@ static void post_wakeup(struct task_struct *p) ipipe_post_work_root(&wakework, work); } +void __xnthread_propagate_schedparam(struct xnthread *curr) +{ + int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret; + struct task_struct *p = current; + struct sched_p
[Xenomai-git] Philippe Gerum : testsuite/smokey: mutex: simplify, introduce PP tests
Module: xenomai-3 Branch: wip/dovetail Commit: a05e5fd457a2a7b7a21ac842ff36616ddf34bdfe URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a05e5fd457a2a7b7a21ac842ff36616ddf34bdfe Author: Philippe Gerum Date: Wed Feb 17 09:21:27 2016 +0100 testsuite/smokey: mutex: simplify, introduce PP tests At this chance, the lock stealing test is also fixed. --- testsuite/smokey/posix-mutex/posix-mutex.c | 1357 ++-- 1 file changed, 670 insertions(+), 687 deletions(-) diff --git a/testsuite/smokey/posix-mutex/posix-mutex.c b/testsuite/smokey/posix-mutex/posix-mutex.c index ac71b31..ae82fc1 100644 --- a/testsuite/smokey/posix-mutex/posix-mutex.c +++ b/testsuite/smokey/posix-mutex/posix-mutex.c @@ -4,6 +4,7 @@ * Copyright (C) Gilles Chanteperdrix , * Marion Deveaud , * Jan Kiszka + * Philippe Gerum * * Released under the terms of GPLv2. */ @@ -17,8 +18,6 @@ #include #include #include -#include -#include "lib/cobalt/current.h" #include smokey_test_plugin(posix_mutex, @@ -26,886 +25,870 @@ smokey_test_plugin(posix_mutex, "Check POSIX mutex services" ); -#define MUTEX_CREATE 1 -#define MUTEX_LOCK 2 -#define MUTEX_TRYLOCK 3 -#define MUTEX_TIMED_LOCK 4 -#define MUTEX_UNLOCK 5 -#define MUTEX_DESTROY 6 -#define COND_CREATE7 -#define COND_SIGNAL8 -#define COND_WAIT 9 -#define COND_DESTROY 10 -#define THREAD_DETACH 11 -#define THREAD_CREATE 12 -#define THREAD_JOIN13 -#define THREAD_RENICE 14 - -#define NS_PER_MS 100 - static const char *reason_str[] = { - [SIGDEBUG_UNDEFINED] = "undefined", + [SIGDEBUG_UNDEFINED] = "received SIGDEBUG for unknown reason", [SIGDEBUG_MIGRATE_SIGNAL] = "received signal", [SIGDEBUG_MIGRATE_SYSCALL] = "invoked syscall", [SIGDEBUG_MIGRATE_FAULT] = "triggered fault", [SIGDEBUG_MIGRATE_PRIOINV] = "affected by priority inversion", - [SIGDEBUG_NOMLOCK] = "missing mlockall", - [SIGDEBUG_WATCHDOG] = "runaway thread", + [SIGDEBUG_NOMLOCK] = "process memory not locked", + [SIGDEBUG_WATCHDOG] = "watchdog triggered (period too short?)", + [SIGDEBUG_LOCK_BREAK] = "scheduler lock break", }; static void sigdebug(int sig, siginfo_t *si, void *context) { + const char fmt[] = "%s, this is unexpected.\n" + "(enabling CONFIG_XENO_OPT_DEBUG_TRACE_RELAX may help)\n"; unsigned int reason = sigdebug_reason(si); + int n __attribute__ ((unused)); + static char buffer[256]; - smokey_trace("\nSIGDEBUG received, reason %d: %s\n", reason, -reason <= SIGDEBUG_WATCHDOG ? reason_str[reason] : ""); -} + if (reason > SIGDEBUG_WATCHDOG) + reason = SIGDEBUG_UNDEFINED; -static inline unsigned long long timer_get_tsc(void) -{ - return clockobj_get_tsc(); + n = snprintf(buffer, sizeof(buffer), fmt, reason_str[reason]); + n = write(STDERR_FILENO, buffer, n); } -static inline unsigned long long timer_tsc2ns(unsigned long long tsc) -{ - return clockobj_tsc_to_ns(tsc); -} +#define THREAD_PRIO_WEAK 0 +#define THREAD_PRIO_LOW1 +#define THREAD_PRIO_MEDIUM 2 +#define THREAD_PRIO_HIGH 3 +#define THREAD_PRIO_VERY_HIGH 4 -static void add_timespec(struct timespec *ts, unsigned long long value) -{ - ts->tv_sec += value / 10; - ts->tv_nsec += value % 10; - if (ts->tv_nsec > 10) { - ts->tv_sec++; - ts->tv_nsec -= 10; - } -} +#define MAX_100_MS 1ULL + +struct locker_context { + pthread_mutex_t *mutex; + struct smokey_barrier *barrier; + int lock_acquired; +}; -static void ms_sleep(int time) +static void sleep_ms(unsigned int ms) /* < 1000 */ { struct timespec ts; - + ts.tv_sec = 0; - ts.tv_nsec = time*NS_PER_MS; - - nanosleep(&ts, NULL); + ts.tv_nsec = ms * 100; + clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, NULL); } -static void check_current_prio(int expected_prio) +static int get_effective_prio(void) { struct cobalt_threadstat stat; int ret; ret = cobalt_thread_stat(0, &stat); - if (ret) { - fprintf(stderr, - "FAILURE: cobalt_threadstat (%s)\n", strerror(-ret)); - exit(EXIT_FAILURE); - } + if (ret) + return ret; - if (stat.cprio != expected_prio) { - fprintf(stderr, - "FAILURE: current prio (%d) != expected prio (%d)\n", - stat.cprio, expected_prio); - exit(EXIT_FAILURE); - } + return stat.cprio; } -static void __check_current_mode(const char *file, int line, -