Skip to contentSkip to conversation

cobalt/kernel: always use explicit preprocessor conditionals

PATCH In review Philippe Gerum 2 participants 14 messages Sep 4, 2018 – Sep 25, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cobalt/kernel: always use explicit preprocessor conditionals

Testing debug switches using '#if XENO_DEBUG(<feat>)' may confuse the build system's dependency tracker, breaking the build, or even producing a non-bootable kernel in extreme cases. Typically, turning on/off the lock debugging code - usually in absence of any other change - may cause the following error to pop up at the link stage:

---
MODPOST vmlinux.o
kernel/xenomai/lock.o: In function `____xnlock_get':
linux/include/xenomai/cobalt/kernel/lock.h:184: undefined reference to xnlock_dbg_prepare_acquire' linux/include/xenomai/cobalt/kernel/lock.h:189: undefined reference to xnlock_dbg_acquired' kernel/xenomai/lock.o: In function `____xnlock_put':
linux/include/xenomai/cobalt/kernel/lock.h:196: undefined reference to `xnlock_dbg_release'
---

Replace all occurrences of the confusing conditionals with the equivalent expression explicitly testing the debug symbol.

---
 include/cobalt/kernel/assert.h         |  2 +-
 include/cobalt/kernel/lock.h           |  6 +++---
 include/cobalt/kernel/sched-sporadic.h |  2 +-
 include/cobalt/kernel/synch.h          |  2 +-
 include/cobalt/kernel/tree.h           |  2 +-
 kernel/cobalt/bufd.c                   | 10 +++++-----
 kernel/cobalt/debug.c                  |  2 +-
 kernel/cobalt/intr.c                   |  2 +-
 kernel/cobalt/posix/process.c          |  2 +-
 kernel/cobalt/procfs.c                 |  2 +-
 kernel/cobalt/sched-sporadic.c         |  4 ++--
 kernel/cobalt/synch.c                  |  2 +-
 12 files changed, 19 insertions(+), 19 deletions(-)
include/cobalt/kernel/assert.h +1 -1
index 2d2d65396..86d0a480f 100644
@@ -63,7 +63,7 @@
 #define realtime_cpu_only()	XENO_BUG_ON(CONTEXT, !xnsched_supported_cpu(ipipe_processor_id()))
 #define thread_only()		XENO_BUG_ON(CONTEXT, xnsched_interrupt_p())
 #define irqoff_only()		XENO_BUG_ON(CONTEXT, hard_irqs_disabled() == 0)
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
 #define atomic_only()		XENO_BUG_ON(CONTEXT, (xnlock_is_owner(&nklock) && hard_irqs_disabled()) == 0)
 #define preemptible_only()	XENO_BUG_ON(CONTEXT, xnlock_is_owner(&nklock) || hard_irqs_disabled())
 #else
include/cobalt/kernel/lock.h +3 -3
index 36f81688a..99c7848e8 100644
@@ -63,7 +63,7 @@ typedef unsigned long spl_t;
  */
 #define spltest()   ipipe_test_head()
 
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
 
 struct xnlock {
 	unsigned owner;
@@ -152,7 +152,7 @@ static inline int xnlock_dbg_release(struct xnlock *lock)
 
 #endif /* !XENO_DEBUG(LOCKING) */
 
-#if defined(CONFIG_SMP) || XENO_DEBUG(LOCKING)
+#if defined(CONFIG_SMP) || defined(CONFIG_XENO_OPT_DEBUG_LOCKING)
 
 #define xnlock_get(lock)		__xnlock_get(lock  XNLOCK_DBG_CONTEXT)
 #define xnlock_put(lock)		__xnlock_put(lock  XNLOCK_DBG_CONTEXT)
@@ -209,7 +209,7 @@ int ___xnlock_get(struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS);
 void ___xnlock_put(struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS);
 #endif /* out of line xnlock */
 
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
 /* Disable UP-over-SMP kernel optimization in debug mode. */
 #define __locking_active__  1
 #else
include/cobalt/kernel/sched-sporadic.h +1 -1
index 0eade47b0..50ca406c4 100644
@@ -56,7 +56,7 @@ struct xnsched_sporadic_data {
 };
 
 struct xnsched_sporadic {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
 	unsigned long drop_retries;
 #endif
 };
include/cobalt/kernel/synch.h +1 -1
index f5ac217ed..08056055a 100644
@@ -101,7 +101,7 @@ static inline struct xnthread *xnsynch_owner(struct xnsynch *synch)
 #define xnsynch_owner_check(synch, thread) \
 	xnsynch_fast_owner_check((synch)->fastlock, thread->handle)
 
-#if XENO_DEBUG(MUTEX_RELAXED)
+#ifdef CONFIG_XENO_OPT_DEBUG_MUTEX_RELAXED
 
 void xnsynch_detect_relaxed_owner(struct xnsynch *synch,
 				  struct xnthread *sleeper);
include/cobalt/kernel/tree.h +1 -1
index 9c751cc02..c52ee3220 100644
@@ -83,7 +83,7 @@ struct xnid *xnid_fetch(struct rb_root *t, xnkey_t key)
 
 static inline int xnid_remove(struct rb_root *t, struct xnid *xnid)
 {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
 	if (xnid_fetch(t, xnid->key) != xnid)
 		return -ENOENT;
 #endif
kernel/cobalt/bufd.c +5 -5
index 9b41b6ad6..3b79505d5 100644
@@ -493,7 +493,7 @@ ssize_t xnbufd_unmap_uread(struct xnbufd *bufd)
 {
 	preemptible_only();
 
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
 	bufd->b_ptr = (caddr_t)-1;
 #endif
 	return bufd->b_off;
@@ -551,7 +551,7 @@ ssize_t xnbufd_unmap_uwrite(struct xnbufd *bufd)
 	if (bufd->b_len > sizeof(bufd->b_buf))
 		xnfree(bufd->b_carry);
 done:
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
 	bufd->b_ptr = (caddr_t)-1;
 #endif
 	return ret ?: (ssize_t)len;
@@ -592,7 +592,7 @@ EXPORT_SYMBOL_GPL(xnbufd_unmap_uwrite);
  */
 void xnbufd_invalidate(struct xnbufd *bufd)
 {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
 	bufd->b_ptr = (caddr_t)-1;
 #endif
 	if (bufd->b_carry) {
@@ -620,7 +620,7 @@ EXPORT_SYMBOL_GPL(xnbufd_invalidate);
  */
 ssize_t xnbufd_unmap_kread(struct xnbufd *bufd)
 {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
 	bufd->b_ptr = (caddr_t)-1;
 #endif
 	return bufd->b_off;
@@ -643,7 +643,7 @@ EXPORT_SYMBOL_GPL(xnbufd_unmap_kread);
  */
 ssize_t xnbufd_unmap_kwrite(struct xnbufd *bufd)
 {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
 	bufd->b_ptr = (caddr_t)-1;
 #endif
 	return bufd->b_off;
kernel/cobalt/debug.c +1 -1
index 74022c516..af9a95ab6 100644
@@ -549,7 +549,7 @@ static inline void init_thread_relax_trace(struct xnthread *thread)
 
 #endif /* !XENO_OPT_DEBUG_TRACE_RELAX */
 
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
 
 void xnlock_dbg_prepare_acquire(unsigned long long *start)
 {
kernel/cobalt/intr.c +1 -1
index fb27a3295..69faa23ba 100644
@@ -531,7 +531,7 @@ static inline void xnintr_irq_detach(struct xnintr *intr)
 #else /* !CONFIG_XENO_OPT_SHIRQ */
 
 struct xnintr_vector {
-#if defined(CONFIG_SMP) || XENO_DEBUG(LOCKING)
+#if defined(CONFIG_SMP) || defined(CONFIG_XENO_OPT_DEBUG_LOCKING)
 	DECLARE_XNLOCK(lock);
 #endif /* CONFIG_SMP || XENO_DEBUG(LOCKING) */
 } ____cacheline_aligned_in_smp;
kernel/cobalt/posix/process.c +1 -1
index dbcb81ef8..50f752f13 100644
@@ -751,7 +751,7 @@ static inline int handle_exception(struct ipipe_trap_data *d)
 	 * running in primary mode, move it to the Linux domain,
 	 * leaving the kernel process the exception.
 	 */
-#if XENO_DEBUG(COBALT) || XENO_DEBUG(USER)
+#if defined(CONFIG_XENO_OPT_DEBUG_COBALT) || defined(CONFIG_XENO_OPT_DEBUG_USER)
 	if (!user_mode(d->regs)) {
 		xntrace_panic_freeze();
 		printk(XENO_WARNING
kernel/cobalt/procfs.c +1 -1
index ade13cf1c..d1f01f038 100644
@@ -27,7 +27,7 @@
 #include <xenomai/version.h>
 #include "debug.h"
 
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
 
 static int lock_vfile_show(struct xnvfile_regular_iterator *it, void *data)
 {
kernel/cobalt/sched-sporadic.c +2 -2
index d2a1f76d0..9cbfa5be3 100644
@@ -24,7 +24,7 @@
 
 static void sporadic_post_recharge(struct xnthread *thread, xnticks_t budget);
 
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
 
 static inline void sporadic_note_late_drop(struct xnsched *sched)
 {
@@ -236,7 +236,7 @@ static void xnsched_sporadic_init(struct xnsched *sched)
 	 * share the same priority scale, with the addition of budget
 	 * management for the sporadic ones.
 	 */
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
 	sched->pss.drop_retries = 0;
 #endif
 }
kernel/cobalt/synch.c +1 -1
index 7773a08e5..32df635a8 100644
@@ -902,7 +902,7 @@ void xnsynch_release_all_ownerships(struct xnthread *thread)
 }
 EXPORT_SYMBOL_GPL(xnsynch_release_all_ownerships);
 
-#if XENO_DEBUG(MUTEX_RELAXED)
+#ifdef CONFIG_XENO_OPT_DEBUG_MUTEX_RELAXED
 
 /*
  * Detect when a thread is about to sleep on a synchronization
Signature · 1 line
2.14.4
#1 lore raw
Quoted 246 lines · Philippe Gerum

Testing debug switches using '#if XENO_DEBUG(<feat>)' may confuse the build system's dependency tracker, breaking the build, or even producing a non-bootable kernel in extreme cases. Typically, turning on/off the lock debugging code - usually in absence of any other change - may cause the following error to pop up at the link stage:

---
MODPOST vmlinux.o
kernel/xenomai/lock.o: In function `____xnlock_get':
linux/include/xenomai/cobalt/kernel/lock.h:184: undefined reference to xnlock_dbg_prepare_acquire' linux/include/xenomai/cobalt/kernel/lock.h:189: undefined reference to xnlock_dbg_acquired' kernel/xenomai/lock.o: In function `____xnlock_put':
linux/include/xenomai/cobalt/kernel/lock.h:196: undefined reference to `xnlock_dbg_release'
---

Replace all occurrences of the confusing conditionals with the equivalent expression explicitly testing the debug symbol.

---
  include/cobalt/kernel/assert.h         |  2 +-
  include/cobalt/kernel/lock.h           |  6 +++---
  include/cobalt/kernel/sched-sporadic.h |  2 +-
  include/cobalt/kernel/synch.h          |  2 +-
  include/cobalt/kernel/tree.h           |  2 +-
  kernel/cobalt/bufd.c                   | 10 +++++-----
  kernel/cobalt/debug.c                  |  2 +-
  kernel/cobalt/intr.c                   |  2 +-
  kernel/cobalt/posix/process.c          |  2 +-
  kernel/cobalt/procfs.c                 |  2 +-
  kernel/cobalt/sched-sporadic.c         |  4 ++--
  kernel/cobalt/synch.c                  |  2 +-
  12 files changed, 19 insertions(+), 19 deletions(-)
include/cobalt/kernel/assert.h +1 -1
index 2d2d65396..86d0a480f 100644
@@ -63,7 +63,7 @@
  #define realtime_cpu_only()	XENO_BUG_ON(CONTEXT, !xnsched_supported_cpu(ipipe_processor_id()))
  #define thread_only()		XENO_BUG_ON(CONTEXT, xnsched_interrupt_p())
  #define irqoff_only()		XENO_BUG_ON(CONTEXT, hard_irqs_disabled() == 0)
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
  #define atomic_only()		XENO_BUG_ON(CONTEXT, (xnlock_is_owner(&nklock) && hard_irqs_disabled()) == 0)
  #define preemptible_only()	XENO_BUG_ON(CONTEXT, xnlock_is_owner(&nklock) || hard_irqs_disabled())
  #else
include/cobalt/kernel/lock.h +3 -3
index 36f81688a..99c7848e8 100644
@@ -63,7 +63,7 @@ typedef unsigned long spl_t;
   */
  #define spltest()   ipipe_test_head()
 
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
 
  struct xnlock {
  	unsigned owner;
@@ -152,7 +152,7 @@ static inline int xnlock_dbg_release(struct xnlock *lock)
 
  #endif /* !XENO_DEBUG(LOCKING) */
 
-#if defined(CONFIG_SMP) || XENO_DEBUG(LOCKING)
+#if defined(CONFIG_SMP) || defined(CONFIG_XENO_OPT_DEBUG_LOCKING)
 
  #define xnlock_get(lock)		__xnlock_get(lock  XNLOCK_DBG_CONTEXT)
  #define xnlock_put(lock)		__xnlock_put(lock  XNLOCK_DBG_CONTEXT)
@@ -209,7 +209,7 @@ int ___xnlock_get(struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS);
  void ___xnlock_put(struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS);
  #endif /* out of line xnlock */
 
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
  /* Disable UP-over-SMP kernel optimization in debug mode. */
  #define __locking_active__  1
  #else
include/cobalt/kernel/sched-sporadic.h +1 -1
index 0eade47b0..50ca406c4 100644
@@ -56,7 +56,7 @@ struct xnsched_sporadic_data {
  };
 
  struct xnsched_sporadic {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
  	unsigned long drop_retries;
  #endif
  };
include/cobalt/kernel/synch.h +1 -1
index f5ac217ed..08056055a 100644
@@ -101,7 +101,7 @@ static inline struct xnthread *xnsynch_owner(struct xnsynch *synch)
  #define xnsynch_owner_check(synch, thread) \
  	xnsynch_fast_owner_check((synch)->fastlock, thread->handle)
 
-#if XENO_DEBUG(MUTEX_RELAXED)
+#ifdef CONFIG_XENO_OPT_DEBUG_MUTEX_RELAXED
 
  void xnsynch_detect_relaxed_owner(struct xnsynch *synch,
  				  struct xnthread *sleeper);
include/cobalt/kernel/tree.h +1 -1
index 9c751cc02..c52ee3220 100644
@@ -83,7 +83,7 @@ struct xnid *xnid_fetch(struct rb_root *t, xnkey_t key)
 
  static inline int xnid_remove(struct rb_root *t, struct xnid *xnid)
  {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
  	if (xnid_fetch(t, xnid->key) != xnid)
  		return -ENOENT;
  #endif
kernel/cobalt/bufd.c +5 -5
index 9b41b6ad6..3b79505d5 100644
@@ -493,7 +493,7 @@ ssize_t xnbufd_unmap_uread(struct xnbufd *bufd)
  {
  	preemptible_only();
 
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
  	bufd->b_ptr = (caddr_t)-1;
  #endif
  	return bufd->b_off;
@@ -551,7 +551,7 @@ ssize_t xnbufd_unmap_uwrite(struct xnbufd *bufd)
  	if (bufd->b_len > sizeof(bufd->b_buf))
  		xnfree(bufd->b_carry);
  done:
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
  	bufd->b_ptr = (caddr_t)-1;
  #endif
  	return ret ?: (ssize_t)len;
@@ -592,7 +592,7 @@ EXPORT_SYMBOL_GPL(xnbufd_unmap_uwrite);
   */
  void xnbufd_invalidate(struct xnbufd *bufd)
  {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
  	bufd->b_ptr = (caddr_t)-1;
  #endif
  	if (bufd->b_carry) {
@@ -620,7 +620,7 @@ EXPORT_SYMBOL_GPL(xnbufd_invalidate);
   */
  ssize_t xnbufd_unmap_kread(struct xnbufd *bufd)
  {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
  	bufd->b_ptr = (caddr_t)-1;
  #endif
  	return bufd->b_off;
@@ -643,7 +643,7 @@ EXPORT_SYMBOL_GPL(xnbufd_unmap_kread);
   */
  ssize_t xnbufd_unmap_kwrite(struct xnbufd *bufd)
  {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
  	bufd->b_ptr = (caddr_t)-1;
  #endif
  	return bufd->b_off;
kernel/cobalt/debug.c +1 -1
index 74022c516..af9a95ab6 100644
@@ -549,7 +549,7 @@ static inline void init_thread_relax_trace(struct xnthread *thread)
 
  #endif /* !XENO_OPT_DEBUG_TRACE_RELAX */
 
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
 
  void xnlock_dbg_prepare_acquire(unsigned long long *start)
  {
kernel/cobalt/intr.c +1 -1
index fb27a3295..69faa23ba 100644
@@ -531,7 +531,7 @@ static inline void xnintr_irq_detach(struct xnintr *intr)
  #else /* !CONFIG_XENO_OPT_SHIRQ */
 
  struct xnintr_vector {
-#if defined(CONFIG_SMP) || XENO_DEBUG(LOCKING)
+#if defined(CONFIG_SMP) || defined(CONFIG_XENO_OPT_DEBUG_LOCKING)
  	DECLARE_XNLOCK(lock);
  #endif /* CONFIG_SMP || XENO_DEBUG(LOCKING) */
  } ____cacheline_aligned_in_smp;
kernel/cobalt/posix/process.c +1 -1
index dbcb81ef8..50f752f13 100644
@@ -751,7 +751,7 @@ static inline int handle_exception(struct ipipe_trap_data *d)
  	 * running in primary mode, move it to the Linux domain,
  	 * leaving the kernel process the exception.
  	 */
-#if XENO_DEBUG(COBALT) || XENO_DEBUG(USER)
+#if defined(CONFIG_XENO_OPT_DEBUG_COBALT) || defined(CONFIG_XENO_OPT_DEBUG_USER)
  	if (!user_mode(d->regs)) {
  		xntrace_panic_freeze();
  		printk(XENO_WARNING
kernel/cobalt/procfs.c +1 -1
index ade13cf1c..d1f01f038 100644
@@ -27,7 +27,7 @@
  #include <xenomai/version.h>
  #include "debug.h"
 
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
 
  static int lock_vfile_show(struct xnvfile_regular_iterator *it, void *data)
  {
kernel/cobalt/sched-sporadic.c +2 -2
index d2a1f76d0..9cbfa5be3 100644
@@ -24,7 +24,7 @@
 
  static void sporadic_post_recharge(struct xnthread *thread, xnticks_t budget);
 
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
 
  static inline void sporadic_note_late_drop(struct xnsched *sched)
  {
@@ -236,7 +236,7 @@ static void xnsched_sporadic_init(struct xnsched *sched)
  	 * share the same priority scale, with the addition of budget
  	 * management for the sporadic ones.
  	 */
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
  	sched->pss.drop_retries = 0;
  #endif
  }
kernel/cobalt/synch.c +0 -0
index 7773a08e5..32df635a8 100644

kernel/cobalt/synch.c void xnsynch_release_all_ownerships(struct xnthread *thread) · line 908

Quoted 8 lines
kernel/cobalt/synch.c +1 -1
@@ -902,7 +902,7 @@ void xnsynch_release_all_ownerships(struct xnthread *thread)
  }
  EXPORT_SYMBOL_GPL(xnsynch_release_all_ownerships);
 
-#if XENO_DEBUG(MUTEX_RELAXED)
+#ifdef CONFIG_XENO_OPT_DEBUG_MUTEX_RELAXED
 
  /*
   * Detect when a thread is about to sleep on a synchronization

Confused: This is not for next, is it?

E.g. that hunk above does not apply there anymore, for about a year...

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
#2 lore raw
Quoted 261 lines · Jan Kiszka
Quoted 250 lines · Philippe Gerum

Testing debug switches using '#if XENO_DEBUG(<feat>)' may confuse the build system's dependency tracker, breaking the build, or even producing a non-bootable kernel in extreme cases. Typically, turning on/off the lock debugging code - usually in absence of any other change - may cause the following error to pop up at the link stage:

---
MODPOST vmlinux.o
kernel/xenomai/lock.o: In function `____xnlock_get':
linux/include/xenomai/cobalt/kernel/lock.h:184: undefined reference to xnlock_dbg_prepare_acquire' linux/include/xenomai/cobalt/kernel/lock.h:189: undefined reference to xnlock_dbg_acquired'
kernel/xenomai/lock.o: In function `____xnlock_put':
linux/include/xenomai/cobalt/kernel/lock.h:196: undefined reference to `xnlock_dbg_release'
---

Replace all occurrences of the confusing conditionals with the equivalent expression explicitly testing the debug symbol.

---
  include/cobalt/kernel/assert.h         |  2 +- include/cobalt/kernel/lock.h           |  6 +++--- include/cobalt/kernel/sched-sporadic.h |  2 +- include/cobalt/kernel/synch.h          |  2 +- include/cobalt/kernel/tree.h           |  2 +- kernel/cobalt/bufd.c                   | 10 +++++----- kernel/cobalt/debug.c                  |  2 +- kernel/cobalt/intr.c                   |  2 +- kernel/cobalt/posix/process.c          |  2 +- kernel/cobalt/procfs.c                 |  2 +- kernel/cobalt/sched-sporadic.c         |  4 ++-- kernel/cobalt/synch.c                  |  2 +-

  12 files changed, 19 insertions(+), 19 deletions(-)
include/cobalt/kernel/assert.h +1 -1
index 2d2d65396..86d0a480f 100644
@@ -63,7 +63,7 @@
   #define realtime_cpu_only()    XENO_BUG_ON(CONTEXT,
 !xnsched_supported_cpu(ipipe_processor_id()))
   #define thread_only()        XENO_BUG_ON(CONTEXT,
 xnsched_interrupt_p())
   #define irqoff_only()        XENO_BUG_ON(CONTEXT,
 hard_irqs_disabled() == 0)
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING

  #define atomic_only()        XENO_BUG_ON(CONTEXT, (xnlock_is_owner(&nklock) && hard_irqs_disabled()) == 0) #define preemptible_only()    XENO_BUG_ON(CONTEXT, xnlock_is_owner(&nklock) || hard_irqs_disabled()) #else

include/cobalt/kernel/lock.h +3 -0
index 36f81688a..99c7848e8 100644
@@ -63,7 +63,7 @@ typedef unsigned long spl_t;
    */
   #define spltest()   ipipe_test_head()
   -#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
     struct xnlock {
       unsigned owner;
@@ -152,7 +152,7 @@ static inline int xnlock_dbg_release(struct xnlock
 *lock)
     #endif /* !XENO_DEBUG(LOCKING) */
   -#if defined(CONFIG_SMP) || XENO_DEBUG(LOCKING)
+#if defined(CONFIG_SMP) || defined(CONFIG_XENO_OPT_DEBUG_LOCKING)
     #define xnlock_get(lock)        __xnlock_get(lock 
 XNLOCK_DBG_CONTEXT)
   #define xnlock_put(lock)        __xnlock_put(lock  XNLOCK_DBG_CONTEXT)
@@ -209,7 +209,7 @@ int ___xnlock_get(struct xnlock *lock /*, */
 XNLOCK_DBG_CONTEXT_ARGS);
   void ___xnlock_put(struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS);
   #endif /* out of line xnlock */
   -#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
   /* Disable UP-over-SMP kernel optimization in debug mode. */
   #define __locking_active__  1

  #else

include/cobalt/kernel/sched-sporadic.h +1 -1
index 0eade47b0..50ca406c4 100644
@@ -56,7 +56,7 @@ struct xnsched_sporadic_data {
   };
     struct xnsched_sporadic {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       unsigned long drop_retries;
   #endif
   };
include/cobalt/kernel/synch.h +1 -0
index f5ac217ed..08056055a 100644
@@ -101,7 +101,7 @@ static inline struct xnthread
 *xnsynch_owner(struct xnsynch *synch)
   #define xnsynch_owner_check(synch, thread) \
       xnsynch_fast_owner_check((synch)->fastlock, thread->handle)
   -#if XENO_DEBUG(MUTEX_RELAXED)
+#ifdef CONFIG_XENO_OPT_DEBUG_MUTEX_RELAXED
     void xnsynch_detect_relaxed_owner(struct xnsynch *synch,
                     struct xnthread *sleeper);
include/cobalt/kernel/tree.h +1 -1
index 9c751cc02..c52ee3220 100644
@@ -83,7 +83,7 @@ struct xnid *xnid_fetch(struct rb_root *t, xnkey_t key)
     static inline int xnid_remove(struct rb_root *t, struct xnid *xnid)
   {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       if (xnid_fetch(t, xnid->key) != xnid)
           return -ENOENT;
   #endif
kernel/cobalt/bufd.c +1 -0
index 9b41b6ad6..3b79505d5 100644
@@ -493,7 +493,7 @@ ssize_t xnbufd_unmap_uread(struct xnbufd *bufd)
   {
       preemptible_only();
   -#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       bufd->b_ptr = (caddr_t)-1;
   #endif
       return bufd->b_off;
@@ -551,7 +551,7 @@ ssize_t xnbufd_unmap_uwrite(struct xnbufd *bufd)
       if (bufd->b_len > sizeof(bufd->b_buf))
           xnfree(bufd->b_carry);

  done:

kernel/cobalt/bufd.c +1 -1
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT

      bufd->b_ptr = (caddr_t)-1;
  #endif
      return ret ?: (ssize_t)len;

kernel/cobalt/bufd.c +3 -3
@@ -592,7 +592,7 @@ EXPORT_SYMBOL_GPL(xnbufd_unmap_uwrite);
    */
   void xnbufd_invalidate(struct xnbufd *bufd)
   {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       bufd->b_ptr = (caddr_t)-1;
   #endif
       if (bufd->b_carry) {
@@ -620,7 +620,7 @@ EXPORT_SYMBOL_GPL(xnbufd_invalidate);
    */
   ssize_t xnbufd_unmap_kread(struct xnbufd *bufd)
   {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       bufd->b_ptr = (caddr_t)-1;
   #endif
       return bufd->b_off;
@@ -643,7 +643,7 @@ EXPORT_SYMBOL_GPL(xnbufd_unmap_kread);
    */
   ssize_t xnbufd_unmap_kwrite(struct xnbufd *bufd)
   {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       bufd->b_ptr = (caddr_t)-1;
   #endif
       return bufd->b_off;
kernel/cobalt/debug.c +1 -0
index 74022c516..af9a95ab6 100644
@@ -549,7 +549,7 @@ static inline void init_thread_relax_trace(struct
 xnthread *thread)
     #endif /* !XENO_OPT_DEBUG_TRACE_RELAX */
   -#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
     void xnlock_dbg_prepare_acquire(unsigned long long *start)
   {
kernel/cobalt/intr.c +1 -1
index fb27a3295..69faa23ba 100644
@@ -531,7 +531,7 @@ static inline void xnintr_irq_detach(struct xnintr
 *intr)
   #else /* !CONFIG_XENO_OPT_SHIRQ */
     struct xnintr_vector {
-#if defined(CONFIG_SMP) || XENO_DEBUG(LOCKING)
+#if defined(CONFIG_SMP) || defined(CONFIG_XENO_OPT_DEBUG_LOCKING)
       DECLARE_XNLOCK(lock);
   #endif /* CONFIG_SMP || XENO_DEBUG(LOCKING) */
   } ____cacheline_aligned_in_smp;
kernel/cobalt/posix/process.c +1 -1
index dbcb81ef8..50f752f13 100644
@@ -751,7 +751,7 @@ static inline int handle_exception(struct
 ipipe_trap_data *d)
        * running in primary mode, move it to the Linux domain,
        * leaving the kernel process the exception.
        */
-#if XENO_DEBUG(COBALT) || XENO_DEBUG(USER)
+#if defined(CONFIG_XENO_OPT_DEBUG_COBALT) ||
 defined(CONFIG_XENO_OPT_DEBUG_USER)
       if (!user_mode(d->regs)) {

          xntrace_panic_freeze();
          printk(XENO_WARNING

kernel/cobalt/procfs.c +1 -0
index ade13cf1c..d1f01f038 100644
@@ -27,7 +27,7 @@
   #include <xenomai/version.h>
   #include "debug.h"
   -#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
     static int lock_vfile_show(struct xnvfile_regular_iterator *it,
 void *data)
   {
kernel/cobalt/sched-sporadic.c +2 -1
index d2a1f76d0..9cbfa5be3 100644
@@ -24,7 +24,7 @@
     static void sporadic_post_recharge(struct xnthread *thread,
 xnticks_t budget);
   -#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
     static inline void sporadic_note_late_drop(struct xnsched *sched)
   {
@@ -236,7 +236,7 @@ static void xnsched_sporadic_init(struct xnsched
 *sched)
        * share the same priority scale, with the addition of budget
        * management for the sporadic ones.
        */
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       sched->pss.drop_retries = 0;
   #endif

  }

kernel/cobalt/synch.c +0 -0
index 7773a08e5..32df635a8 100644

kernel/cobalt/synch.c void xnsynch_release_all_ownerships(struct · line 908

Quoted 7 lines
kernel/cobalt/synch.c +1 -0
@@ -902,7 +902,7 @@ void xnsynch_release_all_ownerships(struct
 xnthread *thread)
   }
   EXPORT_SYMBOL_GPL(xnsynch_release_all_ownerships);
   -#if XENO_DEBUG(MUTEX_RELAXED)
+#ifdef CONFIG_XENO_OPT_DEBUG_MUTEX_RELAXED
     /*
    * Detect when a thread is about to sleep on a synchronization

Confused: This is not for next, is it?

Quoted 2 lines

E.g. that hunk above does not apply there anymore, for about a year...

This is preferably aimed at the upcoming master at the moment. This does not change any internal or external API, fixing an annoying limitation of the watchdog. I'll soon set up my private trees, rebasing on the new upstream branches as needed. The purpose of this patch is mainly to trigger a review.

Signature · 1 line
Philippe.
#3 lore raw
Quoted 262 lines · Philippe Gerum
Quoted 261 lines · Jan Kiszka
Quoted 250 lines · Philippe Gerum

Testing debug switches using '#if XENO_DEBUG(<feat>)' may confuse the build system's dependency tracker, breaking the build, or even producing a non-bootable kernel in extreme cases. Typically, turning on/off the lock debugging code - usually in absence of any other change - may cause the following error to pop up at the link stage:

---
MODPOST vmlinux.o
kernel/xenomai/lock.o: In function `____xnlock_get':
linux/include/xenomai/cobalt/kernel/lock.h:184: undefined reference to xnlock_dbg_prepare_acquire' linux/include/xenomai/cobalt/kernel/lock.h:189: undefined reference to xnlock_dbg_acquired'
kernel/xenomai/lock.o: In function `____xnlock_put':
linux/include/xenomai/cobalt/kernel/lock.h:196: undefined reference to `xnlock_dbg_release'
---

Replace all occurrences of the confusing conditionals with the equivalent expression explicitly testing the debug symbol.

---
  include/cobalt/kernel/assert.h         |  2 +- include/cobalt/kernel/lock.h           |  6 +++--- include/cobalt/kernel/sched-sporadic.h |  2 +- include/cobalt/kernel/synch.h          |  2 +- include/cobalt/kernel/tree.h           |  2 +- kernel/cobalt/bufd.c                   | 10 +++++----- kernel/cobalt/debug.c                  |  2 +- kernel/cobalt/intr.c                   |  2 +- kernel/cobalt/posix/process.c          |  2 +- kernel/cobalt/procfs.c                 |  2 +- kernel/cobalt/sched-sporadic.c         |  4 ++-- kernel/cobalt/synch.c                  |  2 +-

  12 files changed, 19 insertions(+), 19 deletions(-)
include/cobalt/kernel/assert.h +1 -1
index 2d2d65396..86d0a480f 100644
@@ -63,7 +63,7 @@
   #define realtime_cpu_only()    XENO_BUG_ON(CONTEXT,
 !xnsched_supported_cpu(ipipe_processor_id()))
   #define thread_only()        XENO_BUG_ON(CONTEXT,
 xnsched_interrupt_p())
   #define irqoff_only()        XENO_BUG_ON(CONTEXT,
 hard_irqs_disabled() == 0)
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING

  #define atomic_only()        XENO_BUG_ON(CONTEXT, (xnlock_is_owner(&nklock) && hard_irqs_disabled()) == 0) #define preemptible_only()    XENO_BUG_ON(CONTEXT, xnlock_is_owner(&nklock) || hard_irqs_disabled()) #else

include/cobalt/kernel/lock.h +3 -0
index 36f81688a..99c7848e8 100644
@@ -63,7 +63,7 @@ typedef unsigned long spl_t;
    */
   #define spltest()   ipipe_test_head()
   -#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
     struct xnlock {
       unsigned owner;
@@ -152,7 +152,7 @@ static inline int xnlock_dbg_release(struct xnlock
 *lock)
     #endif /* !XENO_DEBUG(LOCKING) */
   -#if defined(CONFIG_SMP) || XENO_DEBUG(LOCKING)
+#if defined(CONFIG_SMP) || defined(CONFIG_XENO_OPT_DEBUG_LOCKING)
     #define xnlock_get(lock)        __xnlock_get(lock 
 XNLOCK_DBG_CONTEXT)
   #define xnlock_put(lock)        __xnlock_put(lock  XNLOCK_DBG_CONTEXT)
@@ -209,7 +209,7 @@ int ___xnlock_get(struct xnlock *lock /*, */
 XNLOCK_DBG_CONTEXT_ARGS);
   void ___xnlock_put(struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS);
   #endif /* out of line xnlock */
   -#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
   /* Disable UP-over-SMP kernel optimization in debug mode. */
   #define __locking_active__  1

  #else

include/cobalt/kernel/sched-sporadic.h +1 -1
index 0eade47b0..50ca406c4 100644
@@ -56,7 +56,7 @@ struct xnsched_sporadic_data {
   };
     struct xnsched_sporadic {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       unsigned long drop_retries;
   #endif
   };
include/cobalt/kernel/synch.h +1 -0
index f5ac217ed..08056055a 100644
@@ -101,7 +101,7 @@ static inline struct xnthread
 *xnsynch_owner(struct xnsynch *synch)
   #define xnsynch_owner_check(synch, thread) \
       xnsynch_fast_owner_check((synch)->fastlock, thread->handle)
   -#if XENO_DEBUG(MUTEX_RELAXED)
+#ifdef CONFIG_XENO_OPT_DEBUG_MUTEX_RELAXED
     void xnsynch_detect_relaxed_owner(struct xnsynch *synch,
                     struct xnthread *sleeper);
include/cobalt/kernel/tree.h +1 -1
index 9c751cc02..c52ee3220 100644
@@ -83,7 +83,7 @@ struct xnid *xnid_fetch(struct rb_root *t, xnkey_t key)
     static inline int xnid_remove(struct rb_root *t, struct xnid *xnid)
   {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       if (xnid_fetch(t, xnid->key) != xnid)
           return -ENOENT;
   #endif
kernel/cobalt/bufd.c +1 -0
index 9b41b6ad6..3b79505d5 100644
@@ -493,7 +493,7 @@ ssize_t xnbufd_unmap_uread(struct xnbufd *bufd)
   {
       preemptible_only();
   -#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       bufd->b_ptr = (caddr_t)-1;
   #endif
       return bufd->b_off;
@@ -551,7 +551,7 @@ ssize_t xnbufd_unmap_uwrite(struct xnbufd *bufd)
       if (bufd->b_len > sizeof(bufd->b_buf))
           xnfree(bufd->b_carry);

  done:

kernel/cobalt/bufd.c +1 -1
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT

      bufd->b_ptr = (caddr_t)-1;
  #endif
      return ret ?: (ssize_t)len;

kernel/cobalt/bufd.c +3 -3
@@ -592,7 +592,7 @@ EXPORT_SYMBOL_GPL(xnbufd_unmap_uwrite);
    */
   void xnbufd_invalidate(struct xnbufd *bufd)
   {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       bufd->b_ptr = (caddr_t)-1;
   #endif
       if (bufd->b_carry) {
@@ -620,7 +620,7 @@ EXPORT_SYMBOL_GPL(xnbufd_invalidate);
    */
   ssize_t xnbufd_unmap_kread(struct xnbufd *bufd)
   {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       bufd->b_ptr = (caddr_t)-1;
   #endif
       return bufd->b_off;
@@ -643,7 +643,7 @@ EXPORT_SYMBOL_GPL(xnbufd_unmap_kread);
    */
   ssize_t xnbufd_unmap_kwrite(struct xnbufd *bufd)
   {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       bufd->b_ptr = (caddr_t)-1;
   #endif
       return bufd->b_off;
kernel/cobalt/debug.c +1 -0
index 74022c516..af9a95ab6 100644
@@ -549,7 +549,7 @@ static inline void init_thread_relax_trace(struct
 xnthread *thread)
     #endif /* !XENO_OPT_DEBUG_TRACE_RELAX */
   -#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
     void xnlock_dbg_prepare_acquire(unsigned long long *start)
   {
kernel/cobalt/intr.c +1 -1
index fb27a3295..69faa23ba 100644
@@ -531,7 +531,7 @@ static inline void xnintr_irq_detach(struct xnintr
 *intr)
   #else /* !CONFIG_XENO_OPT_SHIRQ */
     struct xnintr_vector {
-#if defined(CONFIG_SMP) || XENO_DEBUG(LOCKING)
+#if defined(CONFIG_SMP) || defined(CONFIG_XENO_OPT_DEBUG_LOCKING)
       DECLARE_XNLOCK(lock);
   #endif /* CONFIG_SMP || XENO_DEBUG(LOCKING) */
   } ____cacheline_aligned_in_smp;
kernel/cobalt/posix/process.c +1 -1
index dbcb81ef8..50f752f13 100644
@@ -751,7 +751,7 @@ static inline int handle_exception(struct
 ipipe_trap_data *d)
        * running in primary mode, move it to the Linux domain,
        * leaving the kernel process the exception.
        */
-#if XENO_DEBUG(COBALT) || XENO_DEBUG(USER)
+#if defined(CONFIG_XENO_OPT_DEBUG_COBALT) ||
 defined(CONFIG_XENO_OPT_DEBUG_USER)
       if (!user_mode(d->regs)) {

          xntrace_panic_freeze();
          printk(XENO_WARNING

kernel/cobalt/procfs.c +1 -0
index ade13cf1c..d1f01f038 100644
@@ -27,7 +27,7 @@
   #include <xenomai/version.h>
   #include "debug.h"
   -#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
     static int lock_vfile_show(struct xnvfile_regular_iterator *it,
 void *data)
   {
kernel/cobalt/sched-sporadic.c +2 -1
index d2a1f76d0..9cbfa5be3 100644
@@ -24,7 +24,7 @@
     static void sporadic_post_recharge(struct xnthread *thread,
 xnticks_t budget);
   -#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
     static inline void sporadic_note_late_drop(struct xnsched *sched)
   {
@@ -236,7 +236,7 @@ static void xnsched_sporadic_init(struct xnsched
 *sched)
        * share the same priority scale, with the addition of budget
        * management for the sporadic ones.
        */
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       sched->pss.drop_retries = 0;
   #endif

  }

kernel/cobalt/synch.c +0 -0
index 7773a08e5..32df635a8 100644

kernel/cobalt/synch.c void xnsynch_release_all_ownerships(struct · line 908

Quoted 7 lines
kernel/cobalt/synch.c +1 -0
@@ -902,7 +902,7 @@ void xnsynch_release_all_ownerships(struct
 xnthread *thread)
   }
   EXPORT_SYMBOL_GPL(xnsynch_release_all_ownerships);
   -#if XENO_DEBUG(MUTEX_RELAXED)
+#ifdef CONFIG_XENO_OPT_DEBUG_MUTEX_RELAXED
     /*
    * Detect when a thread is about to sleep on a synchronization

Confused: This is not for next, is it?

Quoted 6 lines
Quoted 2 lines

E.g. that hunk above does not apply there anymore, for about a year...

This is preferably aimed at the upcoming master at the moment. This does not change any internal or external API, fixing an annoying limitation of the watchdog.

The quite annoying issue is about generating bad kernels in this case, same reasoning with the watchdog issue.

Signature · 1 line
Philippe.
#4 lore raw
Quoted 266 lines · Philippe Gerum
Quoted 265 lines · Philippe Gerum
Quoted 263 lines · Jan Kiszka
Quoted 250 lines · Philippe Gerum

Testing debug switches using '#if XENO_DEBUG(<feat>)' may confuse the build system's dependency tracker, breaking the build, or even producing a non-bootable kernel in extreme cases. Typically, turning on/off the lock debugging code - usually in absence of any other change - may cause the following error to pop up at the link stage:

---
MODPOST vmlinux.o
kernel/xenomai/lock.o: In function `____xnlock_get':
linux/include/xenomai/cobalt/kernel/lock.h:184: undefined reference to xnlock_dbg_prepare_acquire' linux/include/xenomai/cobalt/kernel/lock.h:189: undefined reference to xnlock_dbg_acquired'
kernel/xenomai/lock.o: In function `____xnlock_put':
linux/include/xenomai/cobalt/kernel/lock.h:196: undefined reference to `xnlock_dbg_release'
---

Replace all occurrences of the confusing conditionals with the equivalent expression explicitly testing the debug symbol.

---
   include/cobalt/kernel/assert.h         |  2 +-
   include/cobalt/kernel/lock.h           |  6 +++---
   include/cobalt/kernel/sched-sporadic.h |  2 +-
   include/cobalt/kernel/synch.h          |  2 +-
   include/cobalt/kernel/tree.h           |  2 +-
   kernel/cobalt/bufd.c                   | 10 +++++-----
   kernel/cobalt/debug.c                  |  2 +-
   kernel/cobalt/intr.c                   |  2 +-
   kernel/cobalt/posix/process.c          |  2 +-
   kernel/cobalt/procfs.c                 |  2 +-
   kernel/cobalt/sched-sporadic.c         |  4 ++--
   kernel/cobalt/synch.c                  |  2 +-
   12 files changed, 19 insertions(+), 19 deletions(-)
include/cobalt/kernel/assert.h +1 -1
index 2d2d65396..86d0a480f 100644
@@ -63,7 +63,7 @@
   #define realtime_cpu_only()    XENO_BUG_ON(CONTEXT,
 !xnsched_supported_cpu(ipipe_processor_id()))
   #define thread_only()        XENO_BUG_ON(CONTEXT,
 xnsched_interrupt_p())
   #define irqoff_only()        XENO_BUG_ON(CONTEXT,
 hard_irqs_disabled() == 0)
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING

  #define atomic_only()        XENO_BUG_ON(CONTEXT,
(xnlock_is_owner(&nklock) && hard_irqs_disabled()) == 0)
  #define preemptible_only()    XENO_BUG_ON(CONTEXT,
xnlock_is_owner(&nklock) || hard_irqs_disabled())
  #else

include/cobalt/kernel/lock.h +3 -0
index 36f81688a..99c7848e8 100644
@@ -63,7 +63,7 @@ typedef unsigned long spl_t;
    */
   #define spltest()   ipipe_test_head()
   -#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
     struct xnlock {
       unsigned owner;
@@ -152,7 +152,7 @@ static inline int xnlock_dbg_release(struct xnlock
 *lock)
     #endif /* !XENO_DEBUG(LOCKING) */
   -#if defined(CONFIG_SMP) || XENO_DEBUG(LOCKING)
+#if defined(CONFIG_SMP) || defined(CONFIG_XENO_OPT_DEBUG_LOCKING)
     #define xnlock_get(lock)        __xnlock_get(lock
 XNLOCK_DBG_CONTEXT)
   #define xnlock_put(lock)        __xnlock_put(lock  XNLOCK_DBG_CONTEXT)
@@ -209,7 +209,7 @@ int ___xnlock_get(struct xnlock *lock /*, */
 XNLOCK_DBG_CONTEXT_ARGS);
   void ___xnlock_put(struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS);
   #endif /* out of line xnlock */
   -#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
   /* Disable UP-over-SMP kernel optimization in debug mode. */
   #define __locking_active__  1
   #else
include/cobalt/kernel/sched-sporadic.h +1 -1
index 0eade47b0..50ca406c4 100644
@@ -56,7 +56,7 @@ struct xnsched_sporadic_data {
   };
     struct xnsched_sporadic {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       unsigned long drop_retries;
   #endif
   };
include/cobalt/kernel/synch.h +1 -0
index f5ac217ed..08056055a 100644
@@ -101,7 +101,7 @@ static inline struct xnthread
 *xnsynch_owner(struct xnsynch *synch)
   #define xnsynch_owner_check(synch, thread) \
       xnsynch_fast_owner_check((synch)->fastlock, thread->handle)
   -#if XENO_DEBUG(MUTEX_RELAXED)
+#ifdef CONFIG_XENO_OPT_DEBUG_MUTEX_RELAXED
     void xnsynch_detect_relaxed_owner(struct xnsynch *synch,
                     struct xnthread *sleeper);
include/cobalt/kernel/tree.h +1 -1
index 9c751cc02..c52ee3220 100644
@@ -83,7 +83,7 @@ struct xnid *xnid_fetch(struct rb_root *t, xnkey_t key)
     static inline int xnid_remove(struct rb_root *t, struct xnid *xnid)
   {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       if (xnid_fetch(t, xnid->key) != xnid)
           return -ENOENT;
   #endif
kernel/cobalt/bufd.c +5 -4
index 9b41b6ad6..3b79505d5 100644
@@ -493,7 +493,7 @@ ssize_t xnbufd_unmap_uread(struct xnbufd *bufd)
   {
       preemptible_only();
   -#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       bufd->b_ptr = (caddr_t)-1;
   #endif
       return bufd->b_off;
@@ -551,7 +551,7 @@ ssize_t xnbufd_unmap_uwrite(struct xnbufd *bufd)
       if (bufd->b_len > sizeof(bufd->b_buf))
           xnfree(bufd->b_carry);
   done:
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       bufd->b_ptr = (caddr_t)-1;
   #endif
       return ret ?: (ssize_t)len;
@@ -592,7 +592,7 @@ EXPORT_SYMBOL_GPL(xnbufd_unmap_uwrite);
    */
   void xnbufd_invalidate(struct xnbufd *bufd)
   {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       bufd->b_ptr = (caddr_t)-1;
   #endif
       if (bufd->b_carry) {
@@ -620,7 +620,7 @@ EXPORT_SYMBOL_GPL(xnbufd_invalidate);
    */
   ssize_t xnbufd_unmap_kread(struct xnbufd *bufd)
   {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       bufd->b_ptr = (caddr_t)-1;
   #endif
       return bufd->b_off;
@@ -643,7 +643,7 @@ EXPORT_SYMBOL_GPL(xnbufd_unmap_kread);
    */
   ssize_t xnbufd_unmap_kwrite(struct xnbufd *bufd)
   {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       bufd->b_ptr = (caddr_t)-1;
   #endif
       return bufd->b_off;
kernel/cobalt/debug.c +1 -0
index 74022c516..af9a95ab6 100644
@@ -549,7 +549,7 @@ static inline void init_thread_relax_trace(struct
 xnthread *thread)
     #endif /* !XENO_OPT_DEBUG_TRACE_RELAX */
   -#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
     void xnlock_dbg_prepare_acquire(unsigned long long *start)
   {
kernel/cobalt/intr.c +1 -1
index fb27a3295..69faa23ba 100644
@@ -531,7 +531,7 @@ static inline void xnintr_irq_detach(struct xnintr
 *intr)
   #else /* !CONFIG_XENO_OPT_SHIRQ */
     struct xnintr_vector {
-#if defined(CONFIG_SMP) || XENO_DEBUG(LOCKING)
+#if defined(CONFIG_SMP) || defined(CONFIG_XENO_OPT_DEBUG_LOCKING)
       DECLARE_XNLOCK(lock);
   #endif /* CONFIG_SMP || XENO_DEBUG(LOCKING) */
   } ____cacheline_aligned_in_smp;
kernel/cobalt/posix/process.c +1 -1
index dbcb81ef8..50f752f13 100644
@@ -751,7 +751,7 @@ static inline int handle_exception(struct
 ipipe_trap_data *d)
        * running in primary mode, move it to the Linux domain,
        * leaving the kernel process the exception.
        */
-#if XENO_DEBUG(COBALT) || XENO_DEBUG(USER)
+#if defined(CONFIG_XENO_OPT_DEBUG_COBALT) ||
 defined(CONFIG_XENO_OPT_DEBUG_USER)
       if (!user_mode(d->regs)) {

          xntrace_panic_freeze();
          printk(XENO_WARNING

kernel/cobalt/procfs.c +1 -0
index ade13cf1c..d1f01f038 100644
@@ -27,7 +27,7 @@
   #include <xenomai/version.h>
   #include "debug.h"
   -#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
     static int lock_vfile_show(struct xnvfile_regular_iterator *it,
 void *data)
   {
kernel/cobalt/sched-sporadic.c +2 -1
index d2a1f76d0..9cbfa5be3 100644
@@ -24,7 +24,7 @@
     static void sporadic_post_recharge(struct xnthread *thread,
 xnticks_t budget);
   -#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
     static inline void sporadic_note_late_drop(struct xnsched *sched)
   {
@@ -236,7 +236,7 @@ static void xnsched_sporadic_init(struct xnsched
 *sched)
        * share the same priority scale, with the addition of budget
        * management for the sporadic ones.
        */
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
       sched->pss.drop_retries = 0;
   #endif

  }

kernel/cobalt/synch.c +0 -0
index 7773a08e5..32df635a8 100644

kernel/cobalt/synch.c void xnsynch_release_all_ownerships(struct · line 908

Quoted 7 lines
kernel/cobalt/synch.c +1 -0
@@ -902,7 +902,7 @@ void xnsynch_release_all_ownerships(struct
 xnthread *thread)
   }
   EXPORT_SYMBOL_GPL(xnsynch_release_all_ownerships);
   -#if XENO_DEBUG(MUTEX_RELAXED)
+#ifdef CONFIG_XENO_OPT_DEBUG_MUTEX_RELAXED
     /*
    * Detect when a thread is about to sleep on a synchronization

Confused: This is not for next, is it?

E.g. that hunk above does not apply there anymore, for about a year...

Quoted 7 lines
Quoted 3 lines

This is preferably aimed at the upcoming master at the moment. This does not change any internal or external API, fixing an annoying limitation of the watchdog.

The quite annoying issue is about generating bad kernels in this case, same reasoning with the watchdog issue.

As it's based on a seriously old code base, I can't really review this patch. Please rebase everything first.

Upcoming master will simply be current next + X as soon as we agree on the workflow I proposed. If that does not work via fast-forward merge, we may need a hard reset once. I'll look into that later today.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
#5 lore raw
In reply to Jan Kiszka
Quoted 16 lines · Jan Kiszka

kernel/cobalt/synch.c void xnsynch_release_all_ownerships(struct · line 908

Quoted 13 lines
kernel/cobalt/synch.c +1 -0
index 7773a08e5..32df635a8 100644
@@ -902,7 +902,7 @@ void xnsynch_release_all_ownerships(struct
 xnthread *thread)
   }
   EXPORT_SYMBOL_GPL(xnsynch_release_all_ownerships);
   -#if XENO_DEBUG(MUTEX_RELAXED)
+#ifdef CONFIG_XENO_OPT_DEBUG_MUTEX_RELAXED
     /*
    * Detect when a thread is about to sleep on a synchronization

Confused: This is not for next, is it?

Quoted 2 lines

E.g. that hunk above does not apply there anymore, for about a year...

Something looks wrong here. The three patches apply on commit #e23d58715
[1] at [2], which is on top of stable/v3.0.x, post-3.0.7 material. Which tree/branch are you looking at?

[1]
commit e23d587156f138a8f9bff648e310427127a98cfc (origin/stable/v3.0.x)

Author: Sebastian Smolorz <[email protected]>
Date:   Thu Aug 16 21:10:00 2018 +0200

net: Split internal rtnet.h and install rtdm/net.h and rtdm/uapi/net.h

For external projects wanting to use RTnet with its special features like RTnet IOCTLs it is necessary to provide the API headers in the Xenomai installation directory.

[2] https://gitlab.denx.de/Xenomai/xenomai/commits/stable/v3.0.x

Signature · 1 line
Philippe.
#6 lore raw
Quoted 17 lines · Philippe Gerum
Quoted 16 lines · Jan Kiszka

kernel/cobalt/synch.c void xnsynch_release_all_ownerships(struct · line 908

Quoted 13 lines
kernel/cobalt/synch.c +1 -0
index 7773a08e5..32df635a8 100644
@@ -902,7 +902,7 @@ void xnsynch_release_all_ownerships(struct
 xnthread *thread)
   }
   EXPORT_SYMBOL_GPL(xnsynch_release_all_ownerships);
   -#if XENO_DEBUG(MUTEX_RELAXED)
+#ifdef CONFIG_XENO_OPT_DEBUG_MUTEX_RELAXED
     /*
    * Detect when a thread is about to sleep on a synchronization

Confused: This is not for next, is it?

Quoted 6 lines
Quoted 2 lines

E.g. that hunk above does not apply there anymore, for about a year...

Something looks wrong here. The three patches apply on commit #e23d58715
[1] at [2], which is on top of stable/v3.0.x, post-3.0.7 material. Which tree/branch are you looking at?

next - stable is yours.

If you like review of stable backports, please tag those commits as [stable] or so. And maybe also explain any deviation.

My vision would be that only patches that are in next/master would make it to stable. Ideally, no or only minor tweaking should be needed to such commits for the backport.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
#7 lore raw
Quoted 18 lines · Jan Kiszka
Quoted 17 lines · Philippe Gerum
Quoted 16 lines · Jan Kiszka

kernel/cobalt/synch.c void xnsynch_release_all_ownerships(struct · line 908

Quoted 13 lines
kernel/cobalt/synch.c +1 -0
index 7773a08e5..32df635a8 100644
@@ -902,7 +902,7 @@ void xnsynch_release_all_ownerships(struct
 xnthread *thread)
    }
    EXPORT_SYMBOL_GPL(xnsynch_release_all_ownerships);
    -#if XENO_DEBUG(MUTEX_RELAXED)
+#ifdef CONFIG_XENO_OPT_DEBUG_MUTEX_RELAXED
      /*
     * Detect when a thread is about to sleep on a synchronization

Confused: This is not for next, is it?

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

E.g. that hunk above does not apply there anymore, for about a year...

Something looks wrong here. The three patches apply on commit #e23d58715
[1] at [2], which is on top of stable/v3.0.x, post-3.0.7 material. Which tree/branch are you looking at?

next - stable is yours.

Is it? Ok, for now, until a -stable maintainer is appointed eventually.

Quoted 3 lines

If you like review of stable backports, please tag those commits as [stable] or so. And maybe also explain any deviation.

The way -stable was used is obviously different in the new process, and the patches were consistent with the previous process, so let's drop those patches if you can't review them, I'll rebase over the upcoming -next branch to make it easier for everyone.

Quoted 2 lines

My vision would be that only patches that are in next/master would make it to stable.

I understand that you want to align with the basics of the mainline kernel workflow, I'm ok with this. Please set (or re-purpose) the (existing) git branches on gitlab the way you want to, to clarify the situation.

Ideally, no or only minor tweaking should be needed to

Quoted 2 lines

such commits for the backport.

This should be ok in most cases. Unfortunately, the XENO_DEBUG() fixes are going to be an exception because they have to spread all over the map - unless they don't go to stable, which could be an issue since the corresponding bug may produce bad kernels.

Signature · 1 line
Philippe.
#8 lore raw
Quoted 48 lines · Philippe Gerum
Quoted 18 lines · Jan Kiszka
Quoted 17 lines · Philippe Gerum
Quoted 16 lines · Jan Kiszka

kernel/cobalt/synch.c void xnsynch_release_all_ownerships(struct · line 908

Quoted 13 lines
kernel/cobalt/synch.c +1 -0
index 7773a08e5..32df635a8 100644
@@ -902,7 +902,7 @@ void xnsynch_release_all_ownerships(struct
 xnthread *thread)
    }
    EXPORT_SYMBOL_GPL(xnsynch_release_all_ownerships);
    -#if XENO_DEBUG(MUTEX_RELAXED)
+#ifdef CONFIG_XENO_OPT_DEBUG_MUTEX_RELAXED
      /*
     * Detect when a thread is about to sleep on a synchronization

Confused: This is not for next, is it?

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

E.g. that hunk above does not apply there anymore, for about a year...

Something looks wrong here. The three patches apply on commit #e23d58715
[1] at [2], which is on top of stable/v3.0.x, post-3.0.7 material. Which tree/branch are you looking at?

next - stable is yours.

Is it? Ok, for now, until a -stable maintainer is appointed eventually.

Quoted 3 lines

If you like review of stable backports, please tag those commits as [stable] or so. And maybe also explain any deviation.

The way -stable was used is obviously different in the new process, and the patches were consistent with the previous process, so let's drop those patches if you can't review them, I'll rebase over the upcoming -next branch to make it easier for everyone.

Quoted 2 lines

My vision would be that only patches that are in next/master would make it to stable.

I understand that you want to align with the basics of the mainline kernel workflow, I'm ok with this. Please set (or re-purpose) the (existing) git branches on gitlab the way you want to, to clarify the situation.

Quoted 9 lines

Ideally, no or only minor tweaking should be needed to

Quoted 2 lines

such commits for the backport.

This should be ok in most cases. Unfortunately, the XENO_DEBUG() fixes are going to be an exception because they have to spread all over the map - unless they don't go to stable, which could be an issue since the corresponding bug may produce bad kernels.

It seems we addressed most of the XENO_DEBUG cases in next. Are the related commits no stable candidates because they do more? If they are, I would start with backporting them, and then address what remains.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
#9 lore raw
Quoted 55 lines · Jan Kiszka
Quoted 54 lines · Philippe Gerum
Quoted 21 lines · Jan Kiszka
Quoted 20 lines · Philippe Gerum
Quoted 18 lines · Jan Kiszka

kernel/cobalt/synch.c void xnsynch_release_all_ownerships(struct · line 908

Quoted 13 lines
kernel/cobalt/synch.c +1 -0
index 7773a08e5..32df635a8 100644
@@ -902,7 +902,7 @@ void xnsynch_release_all_ownerships(struct
 xnthread *thread)
     }
     EXPORT_SYMBOL_GPL(xnsynch_release_all_ownerships);
     -#if XENO_DEBUG(MUTEX_RELAXED)
+#ifdef CONFIG_XENO_OPT_DEBUG_MUTEX_RELAXED
       /*
      * Detect when a thread is about to sleep on a synchronization

Confused: This is not for next, is it?

E.g. that hunk above does not apply there anymore, for about a year...

Quoted 8 lines
Quoted 5 lines

Something looks wrong here. The three patches apply on commit #e23d58715
[1] at [2], which is on top of stable/v3.0.x, post-3.0.7 material. Which
tree/branch are you looking at?

next - stable is yours.

Is it? Ok, for now, until a -stable maintainer is appointed eventually.

Quoted 3 lines

If you like review of stable backports, please tag those commits as [stable] or so. And maybe also explain any deviation.

The way -stable was used is obviously different in the new process, and the patches were consistent with the previous process, so let's drop those patches if you can't review them, I'll rebase over the upcoming -next branch to make it easier for everyone.

Quoted 2 lines

My vision would be that only patches that are in next/master would make it to stable.

I understand that you want to align with the basics of the mainline kernel workflow, I'm ok with this. Please set (or re-purpose) the (existing) git branches on gitlab the way you want to, to clarify the situation.

  Ideally, no or only minor tweaking should be needed to

Quoted 2 lines

such commits for the backport.

Quoted 7 lines
Quoted 5 lines

This should be ok in most cases. Unfortunately, the XENO_DEBUG() fixes are going to be an exception because they have to spread all over the map - unless they don't go to stable, which could be an issue since the corresponding bug may produce bad kernels.

It seems we addressed most of the XENO_DEBUG cases in next. Are the

Yes, there is only one missing:

kernel/cobalt/intr.c:#if defined(CONFIG_SMP) || XENO_DEBUG(LOCKING)

Quoted 3 lines

related commits no stable candidates because they do more? If they are, I would start with backporting them, and then address what remains.

The related commits are in essence -stable candidates, done at a time when -stable was actually the code base the -next branch would be rebased on periodically (we used to inherit bug fixes in next, not the other way around via backports).

The main issue with the conflicting patch stems from the fact that the XENO_DEBUG() changes were originally based on the -next branch, and I did not backport them to -stable. Now I'm kind of doing so, plugging the last hole in the process for -stable. That should be done for -next, ... next.

I'll submit the proper patches.

Signature · 1 line
Philippe.
#10 lore raw
In reply to Philippe Gerum
Quoted 246 lines · Philippe Gerum

Testing debug switches using '#if XENO_DEBUG(<feat>)' may confuse the build system's dependency tracker, breaking the build, or even producing a non-bootable kernel in extreme cases. Typically, turning on/off the lock debugging code - usually in absence of any other change - may cause the following error to pop up at the link stage:

---
MODPOST vmlinux.o
kernel/xenomai/lock.o: In function `____xnlock_get':
linux/include/xenomai/cobalt/kernel/lock.h:184: undefined reference to xnlock_dbg_prepare_acquire' linux/include/xenomai/cobalt/kernel/lock.h:189: undefined reference to xnlock_dbg_acquired' kernel/xenomai/lock.o: In function `____xnlock_put':
linux/include/xenomai/cobalt/kernel/lock.h:196: undefined reference to `xnlock_dbg_release'
---

Replace all occurrences of the confusing conditionals with the equivalent expression explicitly testing the debug symbol.

---
  include/cobalt/kernel/assert.h         |  2 +-
  include/cobalt/kernel/lock.h           |  6 +++---
  include/cobalt/kernel/sched-sporadic.h |  2 +-
  include/cobalt/kernel/synch.h          |  2 +-
  include/cobalt/kernel/tree.h           |  2 +-
  kernel/cobalt/bufd.c                   | 10 +++++-----
  kernel/cobalt/debug.c                  |  2 +-
  kernel/cobalt/intr.c                   |  2 +-
  kernel/cobalt/posix/process.c          |  2 +-
  kernel/cobalt/procfs.c                 |  2 +-
  kernel/cobalt/sched-sporadic.c         |  4 ++--
  kernel/cobalt/synch.c                  |  2 +-
  12 files changed, 19 insertions(+), 19 deletions(-)
include/cobalt/kernel/assert.h +1 -1
index 2d2d65396..86d0a480f 100644
@@ -63,7 +63,7 @@
  #define realtime_cpu_only()	XENO_BUG_ON(CONTEXT, !xnsched_supported_cpu(ipipe_processor_id()))
  #define thread_only()		XENO_BUG_ON(CONTEXT, xnsched_interrupt_p())
  #define irqoff_only()		XENO_BUG_ON(CONTEXT, hard_irqs_disabled() == 0)
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
  #define atomic_only()		XENO_BUG_ON(CONTEXT, (xnlock_is_owner(&nklock) && hard_irqs_disabled()) == 0)
  #define preemptible_only()	XENO_BUG_ON(CONTEXT, xnlock_is_owner(&nklock) || hard_irqs_disabled())
  #else
include/cobalt/kernel/lock.h +3 -3
index 36f81688a..99c7848e8 100644
@@ -63,7 +63,7 @@ typedef unsigned long spl_t;
   */
  #define spltest()   ipipe_test_head()
 
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
 
  struct xnlock {
  	unsigned owner;
@@ -152,7 +152,7 @@ static inline int xnlock_dbg_release(struct xnlock *lock)
 
  #endif /* !XENO_DEBUG(LOCKING) */
 
-#if defined(CONFIG_SMP) || XENO_DEBUG(LOCKING)
+#if defined(CONFIG_SMP) || defined(CONFIG_XENO_OPT_DEBUG_LOCKING)
 
  #define xnlock_get(lock)		__xnlock_get(lock  XNLOCK_DBG_CONTEXT)
  #define xnlock_put(lock)		__xnlock_put(lock  XNLOCK_DBG_CONTEXT)
@@ -209,7 +209,7 @@ int ___xnlock_get(struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS);
  void ___xnlock_put(struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS);
  #endif /* out of line xnlock */
 
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
  /* Disable UP-over-SMP kernel optimization in debug mode. */
  #define __locking_active__  1
  #else
include/cobalt/kernel/sched-sporadic.h +1 -1
index 0eade47b0..50ca406c4 100644
@@ -56,7 +56,7 @@ struct xnsched_sporadic_data {
  };
 
  struct xnsched_sporadic {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
  	unsigned long drop_retries;
  #endif
  };
include/cobalt/kernel/synch.h +1 -1
index f5ac217ed..08056055a 100644
@@ -101,7 +101,7 @@ static inline struct xnthread *xnsynch_owner(struct xnsynch *synch)
  #define xnsynch_owner_check(synch, thread) \
  	xnsynch_fast_owner_check((synch)->fastlock, thread->handle)
 
-#if XENO_DEBUG(MUTEX_RELAXED)
+#ifdef CONFIG_XENO_OPT_DEBUG_MUTEX_RELAXED
 
  void xnsynch_detect_relaxed_owner(struct xnsynch *synch,
  				  struct xnthread *sleeper);
include/cobalt/kernel/tree.h +1 -1
index 9c751cc02..c52ee3220 100644
@@ -83,7 +83,7 @@ struct xnid *xnid_fetch(struct rb_root *t, xnkey_t key)
 
  static inline int xnid_remove(struct rb_root *t, struct xnid *xnid)
  {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
  	if (xnid_fetch(t, xnid->key) != xnid)
  		return -ENOENT;
  #endif
kernel/cobalt/bufd.c +5 -5
index 9b41b6ad6..3b79505d5 100644
@@ -493,7 +493,7 @@ ssize_t xnbufd_unmap_uread(struct xnbufd *bufd)
  {
  	preemptible_only();
 
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
  	bufd->b_ptr = (caddr_t)-1;
  #endif
  	return bufd->b_off;
@@ -551,7 +551,7 @@ ssize_t xnbufd_unmap_uwrite(struct xnbufd *bufd)
  	if (bufd->b_len > sizeof(bufd->b_buf))
  		xnfree(bufd->b_carry);
  done:
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
  	bufd->b_ptr = (caddr_t)-1;
  #endif
  	return ret ?: (ssize_t)len;
@@ -592,7 +592,7 @@ EXPORT_SYMBOL_GPL(xnbufd_unmap_uwrite);
   */
  void xnbufd_invalidate(struct xnbufd *bufd)
  {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
  	bufd->b_ptr = (caddr_t)-1;
  #endif
  	if (bufd->b_carry) {
@@ -620,7 +620,7 @@ EXPORT_SYMBOL_GPL(xnbufd_invalidate);
   */
  ssize_t xnbufd_unmap_kread(struct xnbufd *bufd)
  {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
  	bufd->b_ptr = (caddr_t)-1;
  #endif
  	return bufd->b_off;
@@ -643,7 +643,7 @@ EXPORT_SYMBOL_GPL(xnbufd_unmap_kread);
   */
  ssize_t xnbufd_unmap_kwrite(struct xnbufd *bufd)
  {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
  	bufd->b_ptr = (caddr_t)-1;
  #endif
  	return bufd->b_off;
kernel/cobalt/debug.c +1 -1
index 74022c516..af9a95ab6 100644
@@ -549,7 +549,7 @@ static inline void init_thread_relax_trace(struct xnthread *thread)
 
  #endif /* !XENO_OPT_DEBUG_TRACE_RELAX */
 
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
 
  void xnlock_dbg_prepare_acquire(unsigned long long *start)
  {
kernel/cobalt/intr.c +1 -1
index fb27a3295..69faa23ba 100644
@@ -531,7 +531,7 @@ static inline void xnintr_irq_detach(struct xnintr *intr)
  #else /* !CONFIG_XENO_OPT_SHIRQ */
 
  struct xnintr_vector {
-#if defined(CONFIG_SMP) || XENO_DEBUG(LOCKING)
+#if defined(CONFIG_SMP) || defined(CONFIG_XENO_OPT_DEBUG_LOCKING)
  	DECLARE_XNLOCK(lock);
  #endif /* CONFIG_SMP || XENO_DEBUG(LOCKING) */
  } ____cacheline_aligned_in_smp;
kernel/cobalt/posix/process.c +1 -1
index dbcb81ef8..50f752f13 100644
@@ -751,7 +751,7 @@ static inline int handle_exception(struct ipipe_trap_data *d)
  	 * running in primary mode, move it to the Linux domain,
  	 * leaving the kernel process the exception.
  	 */
-#if XENO_DEBUG(COBALT) || XENO_DEBUG(USER)
+#if defined(CONFIG_XENO_OPT_DEBUG_COBALT) || defined(CONFIG_XENO_OPT_DEBUG_USER)
  	if (!user_mode(d->regs)) {
  		xntrace_panic_freeze();
  		printk(XENO_WARNING
kernel/cobalt/procfs.c +1 -1
index ade13cf1c..d1f01f038 100644
@@ -27,7 +27,7 @@
  #include <xenomai/version.h>
  #include "debug.h"
 
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
 
  static int lock_vfile_show(struct xnvfile_regular_iterator *it, void *data)
  {
kernel/cobalt/sched-sporadic.c +2 -2
index d2a1f76d0..9cbfa5be3 100644
@@ -24,7 +24,7 @@
 
  static void sporadic_post_recharge(struct xnthread *thread, xnticks_t budget);
 
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
 
  static inline void sporadic_note_late_drop(struct xnsched *sched)
  {
@@ -236,7 +236,7 @@ static void xnsched_sporadic_init(struct xnsched *sched)
  	 * share the same priority scale, with the addition of budget
  	 * management for the sporadic ones.
  	 */
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
  	sched->pss.drop_retries = 0;
  #endif
  }
kernel/cobalt/synch.c +0 -0
index 7773a08e5..32df635a8 100644

kernel/cobalt/synch.c void xnsynch_release_all_ownerships(struct xnthread *thread) · line 908

Quoted 8 lines
kernel/cobalt/synch.c +1 -1
@@ -902,7 +902,7 @@ void xnsynch_release_all_ownerships(struct xnthread *thread)
  }
  EXPORT_SYMBOL_GPL(xnsynch_release_all_ownerships);
 
-#if XENO_DEBUG(MUTEX_RELAXED)
+#ifdef CONFIG_XENO_OPT_DEBUG_MUTEX_RELAXED
 
  /*
   * Detect when a thread is about to sleep on a synchronization

I've picked this one now as stable backport to our 3.0.x branch. I'm not that sure we should put the other two ("cobalt/sched: improve watchdog accuracy", "cobalt/sched: group high-level init/cleanup code") there as well, though.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
#11 lore raw
Quoted 7 lines · Jan Kiszka
Quoted 6 lines · Philippe Gerum

Testing debug switches using '#if XENO_DEBUG(<feat>)' may confuse the build system's dependency tracker, breaking the build, or even producing a non-bootable kernel in extreme cases. Typically, turning on/off the lock debugging code - usually in absence of any other change - may cause the following error to pop up at the link stage:

[snip]

Quoted 6 lines

I've picked this one now as stable backport to our 3.0.x branch. I'm not that sure we should put the other two ("cobalt/sched: improve watchdog accuracy", "cobalt/sched: group high-level init/cleanup code") there as well, though.

We don't need the second one in stable for sure. Merging the first one there would be beneficial to people who want timeouts shorter than 4s. E.g. one just cannot use the watchdog feature with a 1s timeout, false positives would trigger almost immediately even with mildly busy rt systems.

This said, the only report I got (unfortunately privately) about such issue was only a few weeks ago, so this problem does not look like affecting many people.

Signature · 1 line
Philippe.
#12 lore raw
Quoted 18 lines · Philippe Gerum
Quoted 7 lines · Jan Kiszka
Quoted 6 lines · Philippe Gerum

Testing debug switches using '#if XENO_DEBUG(<feat>)' may confuse the build system's dependency tracker, breaking the build, or even producing a non-bootable kernel in extreme cases. Typically, turning on/off the lock debugging code - usually in absence of any other change - may cause the following error to pop up at the link stage:

[snip]

Quoted 6 lines

I've picked this one now as stable backport to our 3.0.x branch. I'm not that sure we should put the other two ("cobalt/sched: improve watchdog accuracy", "cobalt/sched: group high-level init/cleanup code") there as well, though.

Quoted 9 lines

We don't need the second one in stable for sure. Merging the first one there would be beneficial to people who want timeouts shorter than 4s. E.g. one just cannot use the watchdog feature with a 1s timeout, false positives would trigger almost immediately even with mildly busy rt systems.

This said, the only report I got (unfortunately privately) about such issue was only a few weeks ago, so this problem does not look like affecting many people.

Yeah, and we are getting closer to be able to release 3.1 with that improvement included. Therefore, I'm leaning towards declaring it a feature, not a stable fix.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
#13 lore raw
Quoted 25 lines · Jan Kiszka
Quoted 24 lines · Philippe Gerum
Quoted 7 lines · Jan Kiszka
Quoted 6 lines · Philippe Gerum

Testing debug switches using '#if XENO_DEBUG(<feat>)' may confuse the build system's dependency tracker, breaking the build, or even producing a non-bootable kernel in extreme cases. Typically, turning on/off the lock debugging code - usually in absence of any other change - may cause the following error to pop up at the link stage:

[snip]

Quoted 6 lines

I've picked this one now as stable backport to our 3.0.x branch. I'm not that sure we should put the other two ("cobalt/sched: improve watchdog accuracy", "cobalt/sched: group high-level init/cleanup code") there as well, though.

We don't need the second one in stable for sure. Merging the first one there would be beneficial to people who want timeouts shorter than 4s. E.g. one just cannot use the watchdog feature with a 1s timeout, false positives would trigger almost immediately even with mildly busy rt systems.

Quoted 9 lines
Quoted 4 lines

This said, the only report I got (unfortunately privately) about such issue was only a few weeks ago, so this problem does not look like affecting many people.

Yeah, and we are getting closer to be able to release 3.1 with that improvement included. Therefore, I'm leaning towards declaring it a feature, not a stable fix.

Ack.

Signature · 1 line
Philippe.