[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 47529713f5a67529533fd4032ed97ebf07d71877
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=47529713f5a67529533fd4032ed97ebf07d71877

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, 74 insertions(+)

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 37637f6..6f30fcd 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 2582949..0aeff28 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -731,6 +731,15 @@ restart:
goto ret_handled;
}
switched = 1;
+   } else {
+   /*
+* 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));
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 9f2261e..b8304e2 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1969,6 +1970,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;
 }
 
@@ -2090,6 +2096,40 @@ static void post_wakeup(struct task_struct *p)
ipipe_post_work_root(, work);
 }
 
+void __xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret;
+   struct task_struct *p = current;
+   struct sched_param param;
+   spl_t s;
+
+   /*
+* Test-set race for XNSCHEDP is ok, the propagation is meant
+* to be done asap but not guaranteed to be 

[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation

2017-06-03 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 0afa49a1e4ba8e09db98aecc36236d7e9a2f393a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0afa49a1e4ba8e09db98aecc36236d7e9a2f393a

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, 74 insertions(+)

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 37637f6..6f30fcd 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 2582949..0aeff28 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -731,6 +731,15 @@ restart:
goto ret_handled;
}
switched = 1;
+   } else {
+   /*
+* 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));
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index ad70664..71b4058 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1964,6 +1965,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;
 }
 
@@ -2085,6 +2091,40 @@ static void post_wakeup(struct task_struct *p)
ipipe_post_work_root(, work);
 }
 
+void __xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret;
+   struct task_struct *p = current;
+   struct sched_param param;
+   spl_t s;
+
+   /*
+* Test-set race for XNSCHEDP is ok, the propagation is meant
+* to be done asap but not guaranteed to be 

[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation

2017-05-15 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: faa026b047a302e0ecb37de6ed655dfecfba6a72
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=faa026b047a302e0ecb37de6ed655dfecfba6a72

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, 74 insertions(+)

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 37637f6..6f30fcd 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 2582949..0aeff28 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -731,6 +731,15 @@ restart:
goto ret_handled;
}
switched = 1;
+   } else {
+   /*
+* 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));
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index ad70664..71b4058 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1964,6 +1965,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;
 }
 
@@ -2085,6 +2091,40 @@ static void post_wakeup(struct task_struct *p)
ipipe_post_work_root(, work);
 }
 
+void __xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret;
+   struct task_struct *p = current;
+   struct sched_param param;
+   spl_t s;
+
+   /*
+* Test-set race for XNSCHEDP is ok, the propagation is meant
+* to be done asap but not guaranteed to be 

[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation

2017-05-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 4da9145b96ad8a267d174c99e2b5fba0e83e523e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4da9145b96ad8a267d174c99e2b5fba0e83e523e

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, 74 insertions(+)

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 37637f6..6f30fcd 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 2582949..0aeff28 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -731,6 +731,15 @@ restart:
goto ret_handled;
}
switched = 1;
+   } else {
+   /*
+* 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));
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index ad70664..71b4058 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1964,6 +1965,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;
 }
 
@@ -2085,6 +2091,40 @@ static void post_wakeup(struct task_struct *p)
ipipe_post_work_root(, work);
 }
 
+void __xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret;
+   struct task_struct *p = current;
+   struct sched_param param;
+   spl_t s;
+
+   /*
+* Test-set race for XNSCHEDP is ok, the propagation is meant
+* to be done asap but not guaranteed to be 

[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation

2017-04-17 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: e22e36062ea23d483ef3e3fff9463971e9587ad6
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e22e36062ea23d483ef3e3fff9463971e9587ad6

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, 74 insertions(+)

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 37637f6..6f30fcd 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 2582949..0aeff28 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -731,6 +731,15 @@ restart:
goto ret_handled;
}
switched = 1;
+   } else {
+   /*
+* 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));
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index ad70664..71b4058 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1964,6 +1965,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;
 }
 
@@ -2085,6 +2091,40 @@ static void post_wakeup(struct task_struct *p)
ipipe_post_work_root(, work);
 }
 
+void __xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret;
+   struct task_struct *p = current;
+   struct sched_param param;
+   spl_t s;
+
+   /*
+* Test-set race for XNSCHEDP is ok, the propagation is meant
+* to be done asap but not guaranteed to be 

[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation

2017-03-15 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 3e89073bbb5705aaa9dad89d7f620a3951d06cb1
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3e89073bbb5705aaa9dad89d7f620a3951d06cb1

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, 74 insertions(+)

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 37637f6..6f30fcd 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 2582949..0aeff28 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -731,6 +731,15 @@ restart:
goto ret_handled;
}
switched = 1;
+   } else {
+   /*
+* 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));
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index d00714c..7db3c1b 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1961,6 +1962,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;
 }
 
@@ -2082,6 +2088,40 @@ static void post_wakeup(struct task_struct *p)
ipipe_post_work_root(, work);
 }
 
+void __xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret;
+   struct task_struct *p = current;
+   struct sched_param param;
+   spl_t s;
+
+   /*
+* Test-set race for XNSCHEDP is ok, the propagation is meant
+* to be done asap but not guaranteed to be 

[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: fc0164bc20716ec32251c3ea2029597b203a7727
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=fc0164bc20716ec32251c3ea2029597b203a7727

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, 74 insertions(+)

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 37637f6..6f30fcd 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 2582949..0aeff28 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -731,6 +731,15 @@ restart:
goto ret_handled;
}
switched = 1;
+   } else {
+   /*
+* 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));
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index d00714c..7db3c1b 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1961,6 +1962,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;
 }
 
@@ -2082,6 +2088,40 @@ static void post_wakeup(struct task_struct *p)
ipipe_post_work_root(, work);
 }
 
+void __xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret;
+   struct task_struct *p = current;
+   struct sched_param param;
+   spl_t s;
+
+   /*
+* Test-set race for XNSCHEDP is ok, the propagation is meant
+* to be done asap but not guaranteed to be 

[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation

2017-03-05 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: d820d695170e9340f88f73f0d87464af81390162
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d820d695170e9340f88f73f0d87464af81390162

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, 74 insertions(+)

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 37637f6..6f30fcd 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 2582949..0aeff28 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -731,6 +731,15 @@ restart:
goto ret_handled;
}
switched = 1;
+   } else {
+   /*
+* 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));
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index d00714c..7db3c1b 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1961,6 +1962,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;
 }
 
@@ -2082,6 +2088,40 @@ static void post_wakeup(struct task_struct *p)
ipipe_post_work_root(, work);
 }
 
+void __xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret;
+   struct task_struct *p = current;
+   struct sched_param param;
+   spl_t s;
+
+   /*
+* Test-set race for XNSCHEDP is ok, the propagation is meant
+* to be done asap but not guaranteed to be 

[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation

2017-02-15 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 9c657a9bf662a4bc3a706b516ffafff98dd99ac6
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=9c657a9bf662a4bc3a706b516ffafff98dd99ac6

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, 74 insertions(+)

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 37637f6..6f30fcd 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 2582949..0aeff28 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -731,6 +731,15 @@ restart:
goto ret_handled;
}
switched = 1;
+   } else {
+   /*
+* 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));
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index d00714c..7db3c1b 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1961,6 +1962,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;
 }
 
@@ -2082,6 +2088,40 @@ static void post_wakeup(struct task_struct *p)
ipipe_post_work_root(, work);
 }
 
+void __xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret;
+   struct task_struct *p = current;
+   struct sched_param param;
+   spl_t s;
+
+   /*
+* Test-set race for XNSCHEDP is ok, the propagation is meant
+* to be done asap but not guaranteed to be 

[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation

2017-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: a1fdc7f90ecb3832079ae50b6093aabe92ca5179
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a1fdc7f90ecb3832079ae50b6093aabe92ca5179

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, 74 insertions(+)

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 37637f6..6f30fcd 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 2582949..0aeff28 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -731,6 +731,15 @@ restart:
goto ret_handled;
}
switched = 1;
+   } else {
+   /*
+* 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));
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index d00714c..7db3c1b 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1961,6 +1962,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;
 }
 
@@ -2082,6 +2088,40 @@ static void post_wakeup(struct task_struct *p)
ipipe_post_work_root(, work);
 }
 
+void __xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret;
+   struct task_struct *p = current;
+   struct sched_param param;
+   spl_t s;
+
+   /*
+* Test-set race for XNSCHEDP is ok, the propagation is meant
+* to be done asap but not guaranteed to be 

[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation

2016-12-09 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 789ea1f3acf0c6cbab325c68fe306654313d049c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=789ea1f3acf0c6cbab325c68fe306654313d049c

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, 74 insertions(+)

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 bd5e34a..e534471 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 3addd62..b9efa05 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -731,6 +731,15 @@ restart:
goto ret_handled;
}
switched = 1;
+   } else {
+   /*
+* 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));
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index d00714c..7db3c1b 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1961,6 +1962,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;
 }
 
@@ -2082,6 +2088,40 @@ static void post_wakeup(struct task_struct *p)
ipipe_post_work_root(, work);
 }
 
+void __xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret;
+   struct task_struct *p = current;
+   struct sched_param param;
+   spl_t s;
+
+   /*
+* Test-set race for XNSCHEDP is ok, the propagation is meant
+* to be done asap but not guaranteed to be 

[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation

2016-11-28 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: c9b0c028d3f72dd0049d27c33e7d196cdc9d5e1e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c9b0c028d3f72dd0049d27c33e7d196cdc9d5e1e

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, 74 insertions(+)

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 bd5e34a..e534471 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 3addd62..b9efa05 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -731,6 +731,15 @@ restart:
goto ret_handled;
}
switched = 1;
+   } else {
+   /*
+* 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));
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index d00714c..7db3c1b 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1961,6 +1962,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;
 }
 
@@ -2082,6 +2088,40 @@ static void post_wakeup(struct task_struct *p)
ipipe_post_work_root(, work);
 }
 
+void __xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret;
+   struct task_struct *p = current;
+   struct sched_param param;
+   spl_t s;
+
+   /*
+* Test-set race for XNSCHEDP is ok, the propagation is meant
+* to be done asap but not guaranteed to be 

[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation

2016-11-21 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: db18b68aea1dad7f9bb03ee831116c04f701b760
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=db18b68aea1dad7f9bb03ee831116c04f701b760

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, 74 insertions(+)

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 bd5e34a..e534471 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 3addd62..b9efa05 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -731,6 +731,15 @@ restart:
goto ret_handled;
}
switched = 1;
+   } else {
+   /*
+* 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));
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index d00714c..7db3c1b 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1961,6 +1962,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;
 }
 
@@ -2082,6 +2088,40 @@ static void post_wakeup(struct task_struct *p)
ipipe_post_work_root(, work);
 }
 
+void __xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret;
+   struct task_struct *p = current;
+   struct sched_param param;
+   spl_t s;
+
+   /*
+* Test-set race for XNSCHEDP is ok, the propagation is meant
+* to be done asap but not guaranteed to be 

[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation

2016-11-15 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: baf2df4a3235bb3aaae4bd1ab0f6ab8fdc20a0b3
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=baf2df4a3235bb3aaae4bd1ab0f6ab8fdc20a0b3

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, 74 insertions(+)

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 bd5e34a..e534471 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 3addd62..b9efa05 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -731,6 +731,15 @@ restart:
goto ret_handled;
}
switched = 1;
+   } else {
+   /*
+* 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));
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index d00714c..7db3c1b 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1961,6 +1962,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;
 }
 
@@ -2082,6 +2088,40 @@ static void post_wakeup(struct task_struct *p)
ipipe_post_work_root(, work);
 }
 
+void __xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret;
+   struct task_struct *p = current;
+   struct sched_param param;
+   spl_t s;
+
+   /*
+* Test-set race for XNSCHEDP is ok, the propagation is meant
+* to be done asap but not guaranteed to be 

[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation

2016-10-17 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: b8c63ccca4f65ca5f2552e1959200da40596801f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b8c63ccca4f65ca5f2552e1959200da40596801f

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, 74 insertions(+)

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 bd5e34a..e534471 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 3addd62..b9efa05 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -731,6 +731,15 @@ restart:
goto ret_handled;
}
switched = 1;
+   } else {
+   /*
+* 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));
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 96f2d03..3b57cba 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1963,6 +1964,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;
 }
 
@@ -2084,6 +2090,40 @@ static void post_wakeup(struct task_struct *p)
ipipe_post_work_root(, work);
 }
 
+void __xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret;
+   struct task_struct *p = current;
+   struct sched_param param;
+   spl_t s;
+
+   /*
+* Test-set race for XNSCHEDP is ok, the propagation is meant
+* to be done asap but not guaranteed to be 

[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation

2016-09-22 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: c02b617d58a1bb8002cd3235dbc7b78b42dc9ffd
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c02b617d58a1bb8002cd3235dbc7b78b42dc9ffd

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, 74 insertions(+)

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 bd5e34a..e534471 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 3addd62..b9efa05 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -731,6 +731,15 @@ restart:
goto ret_handled;
}
switched = 1;
+   } else {
+   /*
+* 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));
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 96f2d03..3b57cba 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1963,6 +1964,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;
 }
 
@@ -2084,6 +2090,40 @@ static void post_wakeup(struct task_struct *p)
ipipe_post_work_root(, work);
 }
 
+void __xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret;
+   struct task_struct *p = current;
+   struct sched_param param;
+   spl_t s;
+
+   /*
+* Test-set race for XNSCHEDP is ok, the propagation is meant
+* to be done asap but not guaranteed to be 

[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation

2016-03-20 Thread git repository hosting
Module: xenomai-3
Branch: wip/setsched-norelax
Commit: 20c1b3146818a6a8ca9eb8c3ea23124fce3b72f2
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=20c1b3146818a6a8ca9eb8c3ea23124fce3b72f2

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 4325e12..a2ed397 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1978,6 +1979,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;
 }
 
@@ -2099,6 +2105,40 @@ static void post_wakeup(struct task_struct *p)
ipipe_post_work_root(, work);
 }
 
+void __xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret;
+   struct task_struct *p = current;
+

[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation

2016-03-19 Thread git repository hosting
Module: xenomai-3
Branch: next
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(, work);
 }
 
+void __xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret;
+   struct task_struct *p = current;
+   struct