[Xenomai-git] Philippe Gerum : posix: introduce SIGSUSP/SIGRESM for pthread_kill()

2010-10-18 Thread GIT version control
Module: xenomai-head
Branch: master
Commit: 86abf6b12baa26679dc01c3713167970190eb7bf
URL:
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=86abf6b12baa26679dc01c3713167970190eb7bf

Author: Philippe Gerum 
Date:   Mon Oct 18 17:30:29 2010 +0200

posix: introduce SIGSUSP/SIGRESM for pthread_kill()

In order to support the red core layer, we need a way to
suspend/resume a thread synchronously, using the low-level nucleus
services.

To this end, this patch introduces two pseudo-signals, namely SIGSUSP
and SIGRESM, to respectively call xnpod_suspend_thread() or
xnpod_resume_thread() for the target thread.

CAVEAT: those are pseudo-signals above SIGRTMAX, so they can't be
blocked, or queued, or even set in a sigset. They are just meant for
internal usage. They are semantically very different from POSIX's
SIGSTOP/SIGCONT, since:

- they are thread-specific

- they are guaranteed to perform the action synchronously, i.e. the
  target thread shall be suspended or resumed before the call
  returns. If SIGSUSP is sent to the current thread, pthread_kill()
  only returns after SIGRESM is received conversely, sent from another
  thread.

---

 include/posix/signal.h |   13 +
 ksrc/skins/posix/signal.c  |   21 +
 ksrc/skins/posix/syscall.c |   22 --
 3 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/include/posix/signal.h b/include/posix/signal.h
index 50f6c60..78a6b93 100644
--- a/include/posix/signal.h
+++ b/include/posix/signal.h
@@ -114,4 +114,17 @@ int pthread_sigqueue_np (struct pse51_thread *thread, int 
sig, union sigval valu
 
 #endif /* !(__KERNEL__ || __XENO_SIM__) */
 
+/*
+ * Those are pseudo-signals only available with pthread_kill() to
+ * suspend/resume threads synchronously via the low-level nucleus
+ * interface. Can't block them, queue them, or even set them in a
+ * sigset. Those are nasty, strictly anti-POSIX things; we do provide
+ * them nevertheless only because we are mean people doing harmful
+ * code for no valid reason. Can't go against your nature, right?
+ * Nah... (this said, don't blame us for POSIX, we are not _that_
+ * mean).
+ */
+#define SIGSUSP (SIGRTMAX + 1)
+#define SIGRESM (SIGRTMAX + 2)
+
 #endif /* _XENO_POSIX_SIGNAL_H */
diff --git a/ksrc/skins/posix/signal.c b/ksrc/skins/posix/signal.c
index 94bc3e4..4ab27d6 100644
--- a/ksrc/skins/posix/signal.c
+++ b/ksrc/skins/posix/signal.c
@@ -529,6 +529,27 @@ int pthread_kill(pthread_t thread, int sig)
pse51_siginfo_t *si = NULL;
spl_t s;
 
+   /*
+* Undocumented pseudo-signals to suspend and resume threads
+* via the low-level nucleus services. Process them early,
+* before anyone can notice...
+*/
+   if (sig == SIGSUSP) {
+   /*
+* The self-suspension case for shadows was handled at
+* call site: we must be in primary mode already.
+*/
+   xnpod_suspend_thread(&thread->threadbase, XNSUSP,
+XN_INFINITE, XN_RELATIVE, NULL);
+   if (&thread->threadbase == xnpod_current_thread() &&
+   xnthread_test_info(&thread->threadbase, XNBREAK))
+   return -EINTR;
+   return 0;
+   } else if (sig == SIGRESM) {
+   xnpod_resume_thread(&thread->threadbase, XNSUSP);
+   return 0;
+   }
+
if ((unsigned)sig > SIGRTMAX)
return EINVAL;
 
diff --git a/ksrc/skins/posix/syscall.c b/ksrc/skins/posix/syscall.c
index 25831ab..be5bbb0 100644
--- a/ksrc/skins/posix/syscall.c
+++ b/ksrc/skins/posix/syscall.c
@@ -441,7 +441,8 @@ static int __pthread_set_name_np(struct pt_regs *regs)
 static int __pthread_kill(struct pt_regs *regs)
 {
struct pse51_hkey hkey;
-   pthread_t k_tid;
+   pthread_t k_tid, curr;
+   int sig, ret;
 
hkey.u_tid = __xn_reg_arg1(regs);
hkey.mm = current->mm;
@@ -449,8 +450,25 @@ static int __pthread_kill(struct pt_regs *regs)
 
if (!k_tid)
return -ESRCH;
+   /*
+* We have to take care of self-suspension, when the
+* underlying shadow thread is currently relaxed. In that
+* case, we must switch back to primary before issuing the
+* suspend call to the nucleus in pthread_kill(). Marking the
+* __pthread_kill syscall as __xn_exec_primary would be
+* overkill, since no other signal would require this, so we
+* handle that case locally here.
+*/
+   sig = __xn_reg_arg2(regs);
+   if (sig == SIGSUSP && xnpod_current_p(&k_tid->threadbase)) {
+   if (!xnpod_shadow_p()) {
+   ret = xnshadow_harden();
+   if (ret)
+   return ret;
+   }
+   }
 
-   return -pthread_kill(k_tid, __xn_reg_arg2(regs));
+   return -pthread_kill(k_tid, sig);
 }
 
 static int __sem_init(stru

[Xenomai-git] Philippe Gerum : Merge branch 'master' of ssh+git://xenomai.org/ xenomai-head

2010-10-18 Thread GIT version control
Module: xenomai-head
Branch: master
Commit: 95686362b3a32cd9e1828974bba52f7b0885e0bf
URL:
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=95686362b3a32cd9e1828974bba52f7b0885e0bf

Author: Philippe Gerum 
Date:   Mon Oct 18 17:32:00 2010 +0200

Merge branch 'master' of ssh+git://xenomai.org/xenomai-head

---




___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Jan Kiszka : posix: Cleanup CLOCK_HOST_REALTIME

2010-10-18 Thread GIT version control
Module: xenomai-jki
Branch: for-upstream
Commit: fc7fd75eb8477ee7522a72e7810de458700476f6
URL:
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=fc7fd75eb8477ee7522a72e7810de458700476f6

Author: Jan Kiszka 
Date:   Sat Oct  9 12:33:13 2010 +0200

posix: Cleanup CLOCK_HOST_REALTIME

__do_clock_host_realtime is now only called under
XNARCH_HAVE_NONPRIV_TSC.

Signed-off-by: Jan Kiszka 

---

 src/skins/posix/clock.c |   15 +++
 1 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/src/skins/posix/clock.c b/src/skins/posix/clock.c
index 7232c48..0ebcfed 100644
--- a/src/skins/posix/clock.c
+++ b/src/skins/posix/clock.c
@@ -59,9 +59,9 @@ int __wrap_clock_getres(clockid_t clock_id, struct timespec 
*tp)
return -1;
 }
 
-int __do_clock_host_realtime(struct timespec *ts, void *tzp)
-{
 #ifdef XNARCH_HAVE_NONPRIV_TSC
+static int __do_clock_host_realtime(struct timespec *ts, void *tzp)
+{
unsigned int seq;
cycle_t now, base, mask, cycle_delta;
unsigned long mult, shift, nsec, rem;
@@ -102,17 +102,8 @@ retry:
ts->tv_nsec = rem;
 
return 0;
-#else /* XNARCH_HAVE_NONPRIV_TSC */
-   int err = -XENOMAI_SKINCALL2(__pse51_muxid,
-__pse51_clock_gettime,
-CLOCK_HOST_REALTIME, ts);
-   if (!err)
-   return 0;
-
-   errno = err;
-   return -1;
-#endif /* XNARCH_HAVE_NONPRIV_TSC */
 }
+#endif /* XNARCH_HAVE_NONPRIV_TSC */
 
 int __wrap_clock_gettime(clockid_t clock_id, struct timespec *tp)
 {


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Jan Kiszka : Remove duplicate PCI ID

2010-10-18 Thread GIT version control
Module: xenomai-jki
Branch: for-upstream
Commit: 89bc5bb2903bfd2ed86ee087fd992aa0da3f78c7
URL:
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=89bc5bb2903bfd2ed86ee087fd992aa0da3f78c7

Author: Jan Kiszka 
Date:   Sat Oct  9 12:48:34 2010 +0200

Remove duplicate PCI ID

Signed-off-by: Jan Kiszka 

---

 include/asm-generic/pci_ids.h |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/include/asm-generic/pci_ids.h b/include/asm-generic/pci_ids.h
index 9279cfb..d298bf4 100644
--- a/include/asm-generic/pci_ids.h
+++ b/include/asm-generic/pci_ids.h
@@ -7,9 +7,6 @@
 #ifndef PCI_DEVICE_ID_INTEL_ESB2_0
 #define PCI_DEVICE_ID_INTEL_ESB2_0 0x2670
 #endif
-#ifndef PCI_DEVICE_ID_INTEL_ESB2_0
-#define PCI_DEVICE_ID_INTEL_ESB2_0 0x2670
-#endif
 #ifndef PCI_DEVICE_ID_INTEL_ICH7_0
 #define PCI_DEVICE_ID_INTEL_ICH7_0 0x27b8
 #endif


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Jan Kiszka : Re-enable marker support for latest LTTng

2010-10-18 Thread GIT version control
Module: xenomai-jki
Branch: for-upstream
Commit: b76800e4f6322f1262875e41d8c5d1ca63909803
URL:
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=b76800e4f6322f1262875e41d8c5d1ca63909803

Author: Jan Kiszka 
Date:   Sat Oct  9 12:26:56 2010 +0200

Re-enable marker support for latest LTTng

LTTng decided to out-source their tracing modules, thus CONFIG_LTT
disappeared from the kernel config. However, markers are only part of
the LTTng patch since 2.6.32, so use this dependency on recent kernels
instead.

Signed-off-by: Jan Kiszka 

---

 include/asm-generic/wrappers.h |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/include/asm-generic/wrappers.h b/include/asm-generic/wrappers.h
index 995ecf0..e5b8c89 100644
--- a/include/asm-generic/wrappers.h
+++ b/include/asm-generic/wrappers.h
@@ -480,7 +480,8 @@ static inline void *kzalloc(size_t size, int flags)
 #define IRQF_SHAREDSA_SHIRQ
 #endif /* < 2.6.18 */
 
-#ifdef CONFIG_LTT
+#if defined(CONFIG_LTT) || \
+(LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31) && defined(CONFIG_MARKERS))
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
 #define trace_mark(channel, ev, fmt, args...)  \
@@ -494,10 +495,12 @@ static inline void *kzalloc(size_t size, int flags)
 #endif /* < 2.6.27 */
 #endif /* >= 2.6.24 */
 
-#else /* !CONFIG_LTT */
+#else /* !LTTng markers */
+
 #undef trace_mark
 #define trace_mark(channel, ev, fmt, args...)  do { } while (0)
-#endif /* !CONFIG_LTT */
+
+#endif /* !LTTng markers */
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
 #define KMALLOC_MAX_SIZE 131072


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Jan Kiszka : Basic trace events conversion

2010-10-18 Thread GIT version control
Module: xenomai-jki
Branch: queues/ftrace
Commit: 9c2621cc0683e4f1d02c526b1559df53590d58fb
URL:
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=9c2621cc0683e4f1d02c526b1559df53590d58fb

Author: Jan Kiszka 
Date:   Mon Oct 18 12:54:33 2010 +0200

Basic trace events conversion

Convert a few nucleus tracepoints into TRACE_EVENT format, providing
both the oportunity to build them against LTTng markers and upstream
kernel event tracepoints.

Signed-off-by: Jan Kiszka 

---

 include/trace/xn_nucleus.h |  228 
 ksrc/nucleus/pod.c |   39 +++-
 2 files changed, 241 insertions(+), 26 deletions(-)

diff --git a/include/trace/xn_nucleus.h b/include/trace/xn_nucleus.h
new file mode 100644
index 000..f5a518b
--- /dev/null
+++ b/include/trace/xn_nucleus.h
@@ -0,0 +1,228 @@
+#ifndef CONFIG_MARKERS
+
+#if !defined(_TRACE_XN_NUCLEUS_MAIN_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_XN_NUCLEUS_H
+
+#include 
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM xn_nucleus
+
+TRACE_EVENT(xn_nucleus_sched,
+   TP_PROTO(struct xnsched *sched),
+   TP_ARGS(sched),
+
+   TP_STRUCT__entry(
+   __field(unsigned long,  status)
+   ),
+
+   TP_fast_assign(
+   __entry->status = sched->status;
+   ),
+
+   TP_printk("status=%lx", __entry->status)
+);
+
+TRACE_EVENT(xn_nucleus_sched_remote,
+   TP_PROTO(struct xnsched *sched),
+   TP_ARGS(sched),
+
+   TP_STRUCT__entry(
+   __field(unsigned long,  status)
+   ),
+
+   TP_fast_assign(
+   __entry->status = sched->status;
+   ),
+
+   TP_printk("status=%lx", __entry->status)
+);
+
+TRACE_EVENT(xn_nucleus_sched_switch,
+   TP_PROTO(struct xnthread *prev, struct xnthread *next),
+   TP_ARGS(prev, next),
+
+   TP_STRUCT__entry(
+   __field(struct xnthread *,  prev)
+   __field(struct xnthread *,  next)
+   __array(char,   prev_name, XNOBJECT_NAME_LEN)
+   __array(char,   next_name, XNOBJECT_NAME_LEN)
+   ),
+
+   TP_fast_assign(
+   __entry->prev   = prev;
+   __entry->next   = next;
+   memcpy(__entry->prev_name, xnthread_name(prev),
+  XNOBJECT_NAME_LEN);
+   memcpy(__entry->next_name, xnthread_name(next),
+  XNOBJECT_NAME_LEN);
+   ),
+
+   TP_printk("prev=%p prev_name=%s next=%p next_name=%s",
+ __entry->prev, __entry->prev_name,
+ __entry->next, __entry->next_name)
+);
+
+TRACE_EVENT(xn_nucleus_sched_sigdispatch,
+   TP_PROTO(struct xnthread *thread),
+   TP_ARGS(thread),
+
+   TP_STRUCT__entry(
+   __field(unsigned long,  signals)
+   ),
+
+   TP_fast_assign(
+   __entry->signals= thread->signals;
+   ),
+
+   TP_printk("signals=%lx", __entry->signals)
+);
+
+TRACE_EVENT(xn_nucleus_thread_init,
+   TP_PROTO(struct xnthread *thread,
+const struct xnthread_init_attr *attr,
+struct xnsched_class *sched_class),
+   TP_ARGS(thread, attr, sched_class),
+
+   TP_STRUCT__entry(
+   __field(struct xnthread *,  thread)
+   __array(char,   thread_name, XNOBJECT_NAME_LEN)
+   __field(xnflags_t,  flags)
+   __array(char,   class_name, XNOBJECT_NAME_LEN)
+   __field(int,cprio)
+   ),
+
+   TP_fast_assign(
+   __entry->thread = thread;
+   memcpy(__entry->thread_name, xnthread_name(thread),
+  XNOBJECT_NAME_LEN);
+   __entry->flags  = attr->flags;
+   memcpy(__entry->class_name, sched_class->name,
+  XNOBJECT_NAME_LEN-1);
+   __entry->class_name[XNOBJECT_NAME_LEN-1] = 0;
+   __entry->cprio  = thread->cprio;
+   ),
+
+   TP_printk("thread=%p thread_name=%s flags=%lx class=%s prio=%d",
+  __entry->thread, __entry->thread_name, __entry->flags,
+  __entry->class_name, __entry->cprio)
+);
+
+TRACE_EVENT(xn_nucleus_thread_suspend,
+   TP_PROTO(struct xnthread *thread, xnflags_t mask, xnticks_t timeout,
+xntmode_t timeout_mode, xnsynch_t *wchan),
+   TP_ARGS(thread, mask, timeout, timeout_mode, wchan),
+
+   TP_STRUCT__entry(
+   __field(struct xnthread *,  thread)
+   __array(char,   thread_name, XNOBJECT_NAME_LEN)
+   __field(xnflags_t,  mask)
+   __field(xnticks_t,  timeout)
+   __field(xntmode_t,  timeout_mode)
+   __field(xnsynch_t *,wchan)
+   ),
+
+   TP_fast_