[Xenomai-git] Philippe Gerum : cobalt/kernel: make most SIGDEBUG notifications depend on XNWARN
Module: xenomai-3 Branch: master Commit: 0cc5564c796480da5d3ae1515b0f97f0351ae9b7 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0cc5564c796480da5d3ae1515b0f97f0351ae9b7 Author: Philippe Gerum r...@xenomai.org Date: Sat Jul 11 17:25:15 2015 +0200 cobalt/kernel: make most SIGDEBUG notifications depend on XNWARN Only two situations are still unconditionally reported via SIGDEBUG, regardless of XNWARN being set or not: - lack of process memory locking when binding to the core - mayday trigger --- include/cobalt/kernel/thread.h |5 ++- include/cobalt/uapi/kernel/thread.h |5 +-- kernel/cobalt/rtdm/core.c |6 +-- kernel/cobalt/synch.c |4 +- kernel/cobalt/thread.c | 17 ++--- lib/cobalt/thread.c | 71 --- 6 files changed, 73 insertions(+), 35 deletions(-) diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h index ef7de04..8a9236a 100644 --- a/include/cobalt/kernel/thread.h +++ b/include/cobalt/kernel/thread.h @@ -502,9 +502,10 @@ static inline void xnthread_get_resource(struct xnthread *thread) static inline int xnthread_put_resource(struct xnthread *thread) { - if (xnthread_test_state(thread, XNWEAK|XNDEBUG)) { + if (xnthread_test_state(thread, XNWEAK) || + IS_ENABLED(CONFIG_XENO_OPT_DEBUG_USER)) { if (unlikely(thread-res_count == 0)) { - if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_USER)) + if (xnthread_test_state(thread, XNWARN)) xnthread_signal(thread, SIGDEBUG, SIGDEBUG_RESCNT_IMBALANCE); return -EPERM; diff --git a/include/cobalt/uapi/kernel/thread.h b/include/cobalt/uapi/kernel/thread.h index c053472..89853e8 100644 --- a/include/cobalt/uapi/kernel/thread.h +++ b/include/cobalt/uapi/kernel/thread.h @@ -94,11 +94,10 @@ * 'T' - Ptraced and stopped. * 'l' - Locks scheduler. * 'r' - Undergoes round-robin. - * 't' - Mode switches trapped. + * 't' - Runtime mode errors notified. * 'L' - Lock breaks trapped. - * 'd' - Debug mode turned on. */ -#define XNTHREAD_STATE_LABELS SWDRU..X.HbTlrt.Ld +#define XNTHREAD_STATE_LABELS SWDRU..X.HbTlrt.L. struct xnthread_user_window { __u32 state; diff --git a/kernel/cobalt/rtdm/core.c b/kernel/cobalt/rtdm/core.c index d00b0c4..fda3dab 100644 --- a/kernel/cobalt/rtdm/core.c +++ b/kernel/cobalt/rtdm/core.c @@ -104,12 +104,12 @@ open_devnode(struct rtdm_device *dev, const char *path, int oflag) struct file *filp; char *filename; -#ifdef CONFIG_XENO_OPT_DEBUG_USER - if (strncmp(path, /dev/rtdm/, 10)) + if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_USER) + strncmp(path, /dev/rtdm/, 10)) printk(XENO_WARNING %s[%d] opens obsolete device path: %s\n, current-comm, current-pid, path); -#endif + filename = kasprintf(GFP_KERNEL, /dev/rtdm/%s, dev-name); if (filename == NULL) return ERR_PTR(-ENOMEM); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 536e0a7..f3c9d31 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -171,7 +171,9 @@ int xnsynch_sleep_on(struct xnsynch *synch, xnticks_t timeout, thread = xnthread_current(); - if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_USER) thread-res_count 0) + if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_USER) + thread-res_count 0 + xnthread_test_state(thread, XNWARN)) xnthread_signal(thread, SIGDEBUG, SIGDEBUG_RESCNT_SLEEP); xnlock_get_irqsave(nklock, s); diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c index fa2fffd..acaf1a3 100644 --- a/kernel/cobalt/thread.c +++ b/kernel/cobalt/thread.c @@ -166,6 +166,11 @@ int __xnthread_init(struct xnthread *thread, ksformat(thread-name, sizeof(thread-name), @%p, thread); + /* +* We mirror the global user debug state into the per-thread +* state, to speed up branch taking in lib/cobalt wherever +* this needs to be tested. +*/ if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_USER)) flags |= XNDEBUG; @@ -706,8 +711,8 @@ EXPORT_SYMBOL_GPL(xnthread_start); * * - XNLOCK makes the current thread non-preemptible by other threads. * Unless XNTRAPLB is also set for the thread, the latter may still - * block, in which case, the lock will be reacquired automatically - * when it is scheduled back in. + * block, dropping the lock temporarily, in which case, the lock will + * be reacquired automatically when the thread resumes execution. * * - XNWARN enables debugging notifications for the current thread. A * SIGDEBUG (Linux-originated) signal is sent when the following @@ -718,13 +723,15 @@
[Xenomai-git] Philippe Gerum : cobalt/kernel: make most SIGDEBUG notifications depend on XNWARN
Module: xenomai-3 Branch: next Commit: 0cc5564c796480da5d3ae1515b0f97f0351ae9b7 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0cc5564c796480da5d3ae1515b0f97f0351ae9b7 Author: Philippe Gerum r...@xenomai.org Date: Sat Jul 11 17:25:15 2015 +0200 cobalt/kernel: make most SIGDEBUG notifications depend on XNWARN Only two situations are still unconditionally reported via SIGDEBUG, regardless of XNWARN being set or not: - lack of process memory locking when binding to the core - mayday trigger --- include/cobalt/kernel/thread.h |5 ++- include/cobalt/uapi/kernel/thread.h |5 +-- kernel/cobalt/rtdm/core.c |6 +-- kernel/cobalt/synch.c |4 +- kernel/cobalt/thread.c | 17 ++--- lib/cobalt/thread.c | 71 --- 6 files changed, 73 insertions(+), 35 deletions(-) diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h index ef7de04..8a9236a 100644 --- a/include/cobalt/kernel/thread.h +++ b/include/cobalt/kernel/thread.h @@ -502,9 +502,10 @@ static inline void xnthread_get_resource(struct xnthread *thread) static inline int xnthread_put_resource(struct xnthread *thread) { - if (xnthread_test_state(thread, XNWEAK|XNDEBUG)) { + if (xnthread_test_state(thread, XNWEAK) || + IS_ENABLED(CONFIG_XENO_OPT_DEBUG_USER)) { if (unlikely(thread-res_count == 0)) { - if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_USER)) + if (xnthread_test_state(thread, XNWARN)) xnthread_signal(thread, SIGDEBUG, SIGDEBUG_RESCNT_IMBALANCE); return -EPERM; diff --git a/include/cobalt/uapi/kernel/thread.h b/include/cobalt/uapi/kernel/thread.h index c053472..89853e8 100644 --- a/include/cobalt/uapi/kernel/thread.h +++ b/include/cobalt/uapi/kernel/thread.h @@ -94,11 +94,10 @@ * 'T' - Ptraced and stopped. * 'l' - Locks scheduler. * 'r' - Undergoes round-robin. - * 't' - Mode switches trapped. + * 't' - Runtime mode errors notified. * 'L' - Lock breaks trapped. - * 'd' - Debug mode turned on. */ -#define XNTHREAD_STATE_LABELS SWDRU..X.HbTlrt.Ld +#define XNTHREAD_STATE_LABELS SWDRU..X.HbTlrt.L. struct xnthread_user_window { __u32 state; diff --git a/kernel/cobalt/rtdm/core.c b/kernel/cobalt/rtdm/core.c index d00b0c4..fda3dab 100644 --- a/kernel/cobalt/rtdm/core.c +++ b/kernel/cobalt/rtdm/core.c @@ -104,12 +104,12 @@ open_devnode(struct rtdm_device *dev, const char *path, int oflag) struct file *filp; char *filename; -#ifdef CONFIG_XENO_OPT_DEBUG_USER - if (strncmp(path, /dev/rtdm/, 10)) + if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_USER) + strncmp(path, /dev/rtdm/, 10)) printk(XENO_WARNING %s[%d] opens obsolete device path: %s\n, current-comm, current-pid, path); -#endif + filename = kasprintf(GFP_KERNEL, /dev/rtdm/%s, dev-name); if (filename == NULL) return ERR_PTR(-ENOMEM); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 536e0a7..f3c9d31 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -171,7 +171,9 @@ int xnsynch_sleep_on(struct xnsynch *synch, xnticks_t timeout, thread = xnthread_current(); - if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_USER) thread-res_count 0) + if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_USER) + thread-res_count 0 + xnthread_test_state(thread, XNWARN)) xnthread_signal(thread, SIGDEBUG, SIGDEBUG_RESCNT_SLEEP); xnlock_get_irqsave(nklock, s); diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c index fa2fffd..acaf1a3 100644 --- a/kernel/cobalt/thread.c +++ b/kernel/cobalt/thread.c @@ -166,6 +166,11 @@ int __xnthread_init(struct xnthread *thread, ksformat(thread-name, sizeof(thread-name), @%p, thread); + /* +* We mirror the global user debug state into the per-thread +* state, to speed up branch taking in lib/cobalt wherever +* this needs to be tested. +*/ if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_USER)) flags |= XNDEBUG; @@ -706,8 +711,8 @@ EXPORT_SYMBOL_GPL(xnthread_start); * * - XNLOCK makes the current thread non-preemptible by other threads. * Unless XNTRAPLB is also set for the thread, the latter may still - * block, in which case, the lock will be reacquired automatically - * when it is scheduled back in. + * block, dropping the lock temporarily, in which case, the lock will + * be reacquired automatically when the thread resumes execution. * * - XNWARN enables debugging notifications for the current thread. A * SIGDEBUG (Linux-originated) signal is sent when the following @@ -718,13 +723,15 @@