[Xenomai-git] Philippe Gerum : cobalt/registry, cobalt/thread: use wait context in binding operation
Module: xenomai-forge Branch: x32 Commit: faf103bde37e251f365eb64b885086d6e9b8a2b1 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=faf103bde37e251f365eb64b885086d6e9b8a2b1 Author: Philippe Gerum r...@xenomai.org Date: Tue Sep 9 12:19:25 2014 +0200 cobalt/registry, cobalt/thread: use wait context in binding operation --- include/cobalt/kernel/thread.h |2 -- kernel/cobalt/registry.c | 19 +-- kernel/cobalt/thread.c |1 - 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h index 0801cbc..03faf8f 100644 --- a/include/cobalt/kernel/thread.h +++ b/include/cobalt/kernel/thread.h @@ -169,8 +169,6 @@ struct xnthread { xnhandle_t handle; /* Handle in registry */ - const char *waitkey;/* Pended key */ - char name[XNOBJECT_NAME_LEN]; /* Symbolic name of thread */ void (*entry)(void *cookie); /* Thread entry routine */ diff --git a/kernel/cobalt/registry.c b/kernel/cobalt/registry.c index 561c8d9..6643865 100644 --- a/kernel/cobalt/registry.c +++ b/kernel/cobalt/registry.c @@ -559,15 +559,22 @@ static struct xnobject *registry_hash_find(const char *key) return NULL; } +struct registry_wait_context { + struct xnthread_wait_context wc; + const char *key; +}; + static inline int registry_wakeup_sleepers(const char *key) { + struct registry_wait_context *rwc; + struct xnthread_wait_context *wc; struct xnthread *sleeper, *tmp; int cnt = 0; xnsynch_for_each_sleeper_safe(sleeper, tmp, register_synch) { - if (*key == *sleeper-waitkey - strcmp(key, sleeper-waitkey) == 0) { - sleeper-waitkey = NULL; + wc = xnthread_get_wait_context(sleeper); + rwc = container_of(wc, struct registry_wait_context, wc); + if (*key == *rwc-key strcmp(key, rwc-key) == 0) { xnsynch_wakeup_this_sleeper(register_synch, sleeper); ++cnt; } @@ -731,8 +738,8 @@ EXPORT_SYMBOL_GPL(xnregistry_enter); int xnregistry_bind(const char *key, xnticks_t timeout, int timeout_mode, xnhandle_t *phandle) { + struct registry_wait_context rwc; struct xnobject *object; - struct xnthread *thread; int ret = 0, info; spl_t s; @@ -760,8 +767,8 @@ int xnregistry_bind(const char *key, xnticks_t timeout, int timeout_mode, goto unlock_and_exit; } - thread = xnthread_current(); - thread-waitkey = key; + rwc.key = key; + xnthread_prepare_wait(rwc.wc); info = xnsynch_sleep_on(register_synch, timeout, timeout_mode); if (info XNTIMEO) { ret = -ETIMEDOUT; diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c index 5fb2de1..7c2405a 100644 --- a/kernel/cobalt/thread.c +++ b/kernel/cobalt/thread.c @@ -180,7 +180,6 @@ int __xnthread_init(struct xnthread *thread, thread-wcontext = NULL; thread-res_count = 0; thread-handle = XN_NO_HANDLE; - thread-waitkey = NULL; memset(thread-stat, 0, sizeof(thread-stat)); thread-selector = NULL; INIT_LIST_HEAD(thread-claimq); ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : lib/cobalt: vdso - cobalt_vdso
Module: xenomai-forge Branch: next Commit: 0616798e213a6b9356fa81db39b106da472ba4b6 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=0616798e213a6b9356fa81db39b106da472ba4b6 Author: Philippe Gerum r...@xenomai.org Date: Tue Sep 9 08:53:08 2014 +0200 lib/cobalt: vdso - cobalt_vdso --- lib/cobalt/clock.c |6 +++--- lib/cobalt/umm.c |4 ++-- lib/cobalt/umm.h |2 +- testsuite/clocktest/clocktest.c| 28 ++-- testsuite/smokey/vdso-access/vdso-access.c |4 ++-- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c index 682c9cb..501cdec 100644 --- a/lib/cobalt/clock.c +++ b/lib/cobalt/clock.c @@ -116,10 +116,10 @@ static int __do_clock_host_realtime(struct timespec *ts) unsigned long rem; urwstate_t tmp; - if (!xnvdso_test_feature(vdso, XNVDSO_FEAT_HOST_REALTIME)) + if (!xnvdso_test_feature(cobalt_vdso, XNVDSO_FEAT_HOST_REALTIME)) return -1; - hostrt_data = vdso-hostrt_data; + hostrt_data = cobalt_vdso-hostrt_data; if (!hostrt_data-live) return -1; @@ -193,7 +193,7 @@ COBALT_IMPL(int, clock_gettime, (clockid_t clock_id, struct timespec *tp)) return 0; case CLOCK_REALTIME: ns = cobalt_ticks_to_ns(cobalt_read_tsc()); - ns += vdso-wallclock_offset; + ns += cobalt_vdso-wallclock_offset; tp-tv_sec = cobalt_divrem_billion(ns, rem); tp-tv_nsec = rem; return 0; diff --git a/lib/cobalt/umm.c b/lib/cobalt/umm.c index 2460e0c..7ae57f2 100644 --- a/lib/cobalt/umm.c +++ b/lib/cobalt/umm.c @@ -34,7 +34,7 @@ #include umm.h #include internal.h -struct xnvdso *vdso; +struct xnvdso *cobalt_vdso; void *cobalt_umm_private = NULL; @@ -110,7 +110,7 @@ static void init_vdso(void) exit(EXIT_FAILURE); } - vdso = (struct xnvdso *)(cobalt_umm_shared + sysinfo.vdso); + cobalt_vdso = (struct xnvdso *)(cobalt_umm_shared + sysinfo.vdso); } /* diff --git a/lib/cobalt/umm.h b/lib/cobalt/umm.h index 1b14106..e0e3cf8 100644 --- a/lib/cobalt/umm.h +++ b/lib/cobalt/umm.h @@ -22,6 +22,6 @@ void cobalt_init_umm(void); struct xnvdso; -extern struct xnvdso *vdso; +extern struct xnvdso *cobalt_vdso; #endif /* _LIB_COBALT_UMM_H */ diff --git a/testsuite/clocktest/clocktest.c b/testsuite/clocktest/clocktest.c index 56260c5..ef19c95 100644 --- a/testsuite/clocktest/clocktest.c +++ b/testsuite/clocktest/clocktest.c @@ -34,7 +34,7 @@ #include xeno_config.h -extern struct xnvdso *vdso; +extern struct xnvdso *cobalt_vdso; #ifndef HAVE_RECENT_SETAFFINITY #ifdef HAVE_OLD_SETAFFINITY @@ -82,12 +82,12 @@ struct per_cpu_data { static void show_hostrt_diagnostics(void) { - if (!xnvdso_test_feature(vdso, XNVDSO_FEAT_HOST_REALTIME)) { + if (!xnvdso_test_feature(cobalt_vdso, XNVDSO_FEAT_HOST_REALTIME)) { printf(XNVDSO_FEAT_HOST_REALTIME not available\n); return; } - if (vdso-hostrt_data.live) + if (cobalt_vdso-hostrt_data.live) printf(hostrt data area is live\n); else { printf(hostrt data area is not live\n); @@ -95,29 +95,29 @@ static void show_hostrt_diagnostics(void) } printf(Sequence counter : %u\n, - vdso-hostrt_data.lock.sequence); + cobalt_vdso-hostrt_data.lock.sequence); printf(wall_time_sec: %lld\n, - (unsigned long long)vdso-hostrt_data.wall_time_sec); - printf(wall_time_nsec : %u\n, vdso-hostrt_data.wall_time_nsec); + (unsigned long long)cobalt_vdso-hostrt_data.wall_time_sec); + printf(wall_time_nsec : %u\n, cobalt_vdso-hostrt_data.wall_time_nsec); printf(wall_to_monotonic\n); printf( tv_sec : %jd\n, - (intmax_t)vdso-hostrt_data.wall_to_monotonic.tv_sec); + (intmax_t)cobalt_vdso-hostrt_data.wall_to_monotonic.tv_sec); printf( tv_nsec : %ld\n, - vdso-hostrt_data.wall_to_monotonic.tv_nsec); - printf(cycle_last : %Lu\n, vdso-hostrt_data.cycle_last); - printf(mask : 0x%Lx\n, vdso-hostrt_data.mask); - printf(mult : %u\n, vdso-hostrt_data.mult); - printf(shift: %u\n\n, vdso-hostrt_data.shift); + cobalt_vdso-hostrt_data.wall_to_monotonic.tv_nsec); + printf(cycle_last : %Lu\n, cobalt_vdso-hostrt_data.cycle_last); + printf(mask : 0x%Lx\n, cobalt_vdso-hostrt_data.mask); + printf(mult : %u\n, cobalt_vdso-hostrt_data.mult); + printf(shift: %u\n\n, cobalt_vdso-hostrt_data.shift); } static void show_realtime_offset(void) { - if (!xnvdso_test_feature(vdso,
[Xenomai-git] Philippe Gerum : cobalt/thread: sanitize header, drop pedantic accessors
Module: xenomai-forge Branch: next Commit: 98e0378927e957ce89939a6bf945e0f22feac454 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=98e0378927e957ce89939a6bf945e0f22feac454 Author: Philippe Gerum r...@xenomai.org Date: Tue Sep 9 12:04:24 2014 +0200 cobalt/thread: sanitize header, drop pedantic accessors --- include/cobalt/kernel/synch.h |2 +- include/cobalt/kernel/thread.h | 74 kernel/cobalt/assert.c |4 +- kernel/cobalt/posix/monitor.c |4 +- kernel/cobalt/posix/mutex.c|7 ++-- kernel/cobalt/posix/process.c |8 ++-- kernel/cobalt/posix/syscall.c |6 +-- kernel/cobalt/posix/thread.c | 23 +-- kernel/cobalt/posix/timer.c|4 +- kernel/cobalt/posix/timerfd.c |2 +- kernel/cobalt/registry.c |8 ++-- kernel/cobalt/sched-sporadic.c |4 +- kernel/cobalt/sched.c | 36 ++ kernel/cobalt/synch.c | 14 +++ kernel/cobalt/thread.c | 28 ++ kernel/cobalt/trace/cobalt-core.h | 32 kernel/cobalt/trace/cobalt-posix.h |4 +- kernel/cobalt/trace/cobalt-rtdm.h | 16 18 files changed, 135 insertions(+), 141 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 7509909..d4df940 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -101,7 +101,7 @@ static inline struct xnthread *xnsynch_owner(struct xnsynch *synch) #define xnsynch_fastlock(synch)((synch)-fastlock) #define xnsynch_fastlock_p(synch) ((synch)-fastlock != NULL) #define xnsynch_owner_check(synch, thread) \ - xnsynch_fast_owner_check((synch)-fastlock, xnthread_handle(thread)) + xnsynch_fast_owner_check((synch)-fastlock, thread-handle) #define xnsynch_fast_is_claimed(fastlock) \ xnhandle_test_spare(fastlock, XNSYNCH_FLCLAIM) diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h index a455399..0801cbc 100644 --- a/include/cobalt/kernel/thread.h +++ b/include/cobalt/kernel/thread.h @@ -119,7 +119,7 @@ struct xnthread { */ int wprio; - unsigned long schedlck; /** Scheduler lock count. */ + int lock_count; /** Scheduler lock count. */ /** * Thread holder in xnsched runnable queue. Prioritized by @@ -146,7 +146,7 @@ struct xnthread { struct xnsynch *wwake; /* Wait channel the thread was resumed from */ - int hrescnt;/* Held resources count */ + int res_count; /* Held resources count */ struct xntimer rtimer; /* Resource timer */ @@ -167,16 +167,9 @@ struct xnthread { struct xnselector *selector;/* For select. */ - int imode; /* Initial mode */ + xnhandle_t handle; /* Handle in registry */ - struct xnsched_class *init_class; /* Initial scheduling class */ - - union xnsched_policy_param init_schedparam; /* Initial scheduling parameters */ - - struct { - xnhandle_t handle; /* Handle in registry */ - const char *waitkey;/* Pended key */ - } registry; + const char *waitkey;/* Pended key */ char name[XNOBJECT_NAME_LEN]; /* Symbolic name of thread */ @@ -195,11 +188,10 @@ struct xnthread { struct xnsynch join_synch; }; -#define xnthread_name(thread) ((thread)-name) -#define xnthread_clear_name(thread)do { *(thread)-name = 0; } while(0) -#define xnthread_sched(thread) ((thread)-sched) -#define xnthread_start_time(thread)((thread)-stime) -#define xnthread_state_flags(thread) ((thread)-state) +static inline int xnthread_get_state(const struct xnthread *thread) +{ + return thread-state; +} static inline int xnthread_test_state(struct xnthread *thread, int bits) { @@ -236,28 +228,28 @@ static inline struct xnarchtcb *xnthread_archtcb(struct xnthread *thread) return thread-tcb; } -#define xnthread_lock_count(thread)((thread)-schedlck) -#define xnthread_init_schedparam(thread) ((thread)-init_schedparam) -#define xnthread_base_priority(thread) ((thread)-bprio) -#define xnthread_current_priority(thread) ((thread)-cprio) -#define xnthread_init_class(thread)((thread)-init_class) -#define xnthread_base_class(thread)((thread)-base_class) -#define xnthread_sched_class(thread) ((thread)-sched_class) -#define xnthread_time_slice(thread)((thread)-rrperiod) -#define xnthread_timeout(thread) xntimer_get_timeout((thread)-rtimer) -#define xnthread_handle(thread)((thread)-registry.handle) -#define xnthread_host_task(thread) (xnthread_archtcb(thread)-core.host_task) -#define xnthread_host_pid(thread)
[Xenomai-git] Philippe Gerum : cobalt/registry, cobalt/thread: use wait context in binding operation
Module: xenomai-forge Branch: next Commit: 715a198aa593cf3e15d6da8ed9d13ca475acbdbb URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=715a198aa593cf3e15d6da8ed9d13ca475acbdbb Author: Philippe Gerum r...@xenomai.org Date: Tue Sep 9 12:19:25 2014 +0200 cobalt/registry, cobalt/thread: use wait context in binding operation --- include/cobalt/kernel/thread.h |2 -- kernel/cobalt/registry.c | 19 +-- kernel/cobalt/thread.c |1 - 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h index 0801cbc..03faf8f 100644 --- a/include/cobalt/kernel/thread.h +++ b/include/cobalt/kernel/thread.h @@ -169,8 +169,6 @@ struct xnthread { xnhandle_t handle; /* Handle in registry */ - const char *waitkey;/* Pended key */ - char name[XNOBJECT_NAME_LEN]; /* Symbolic name of thread */ void (*entry)(void *cookie); /* Thread entry routine */ diff --git a/kernel/cobalt/registry.c b/kernel/cobalt/registry.c index 561c8d9..6643865 100644 --- a/kernel/cobalt/registry.c +++ b/kernel/cobalt/registry.c @@ -559,15 +559,22 @@ static struct xnobject *registry_hash_find(const char *key) return NULL; } +struct registry_wait_context { + struct xnthread_wait_context wc; + const char *key; +}; + static inline int registry_wakeup_sleepers(const char *key) { + struct registry_wait_context *rwc; + struct xnthread_wait_context *wc; struct xnthread *sleeper, *tmp; int cnt = 0; xnsynch_for_each_sleeper_safe(sleeper, tmp, register_synch) { - if (*key == *sleeper-waitkey - strcmp(key, sleeper-waitkey) == 0) { - sleeper-waitkey = NULL; + wc = xnthread_get_wait_context(sleeper); + rwc = container_of(wc, struct registry_wait_context, wc); + if (*key == *rwc-key strcmp(key, rwc-key) == 0) { xnsynch_wakeup_this_sleeper(register_synch, sleeper); ++cnt; } @@ -731,8 +738,8 @@ EXPORT_SYMBOL_GPL(xnregistry_enter); int xnregistry_bind(const char *key, xnticks_t timeout, int timeout_mode, xnhandle_t *phandle) { + struct registry_wait_context rwc; struct xnobject *object; - struct xnthread *thread; int ret = 0, info; spl_t s; @@ -760,8 +767,8 @@ int xnregistry_bind(const char *key, xnticks_t timeout, int timeout_mode, goto unlock_and_exit; } - thread = xnthread_current(); - thread-waitkey = key; + rwc.key = key; + xnthread_prepare_wait(rwc.wc); info = xnsynch_sleep_on(register_synch, timeout, timeout_mode); if (info XNTIMEO) { ret = -ETIMEDOUT; diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c index 5fb2de1..7c2405a 100644 --- a/kernel/cobalt/thread.c +++ b/kernel/cobalt/thread.c @@ -180,7 +180,6 @@ int __xnthread_init(struct xnthread *thread, thread-wcontext = NULL; thread-res_count = 0; thread-handle = XN_NO_HANDLE; - thread-waitkey = NULL; memset(thread-stat, 0, sizeof(thread-stat)); thread-selector = NULL; INIT_LIST_HEAD(thread-claimq); ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/timerfd: force primary exec mode on timerfd_settime()
Module: xenomai-forge Branch: next Commit: b1c6abc5b9db26ba23d667dad5acf1dc55f330a3 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=b1c6abc5b9db26ba23d667dad5acf1dc55f330a3 Author: Philippe Gerum r...@xenomai.org Date: Tue Sep 9 10:18:35 2014 +0200 cobalt/timerfd: force primary exec mode on timerfd_settime() For consistency with timer_settime(), and also because the current thread is assumed to receive the notifications if TFD_WAKEUP is set. --- kernel/cobalt/posix/syscall.c |2 +- kernel/cobalt/posix/timerfd.c |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c index 48d0fc1..e3b594e 100644 --- a/kernel/cobalt/posix/syscall.c +++ b/kernel/cobalt/posix/syscall.c @@ -938,7 +938,7 @@ static const int cobalt_sysmodes[] = { __COBALT_MODE(timer_getoverrun, current), __COBALT_MODE(timerfd_create, lostage), __COBALT_MODE(timerfd_gettime, current), - __COBALT_MODE(timerfd_settime, current), + __COBALT_MODE(timerfd_settime, primary), __COBALT_MODE(select, nonrestartable), __COBALT_MODE(sched_minprio, current), __COBALT_MODE(sched_maxprio, current), diff --git a/kernel/cobalt/posix/timerfd.c b/kernel/cobalt/posix/timerfd.c index c9e54c0..cb33994 100644 --- a/kernel/cobalt/posix/timerfd.c +++ b/kernel/cobalt/posix/timerfd.c @@ -215,7 +215,7 @@ static inline void tfd_put(struct cobalt_tfd *tfd) rtdm_fd_put(tfd-fd); } -COBALT_SYSCALL(timerfd_settime, current, +COBALT_SYSCALL(timerfd_settime, primary, int, (int fd, int flags, const struct itimerspec __user *new_value, struct itimerspec __user *old_value)) ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/debug: use separate memory pool for tracing relax requests
Module: xenomai-forge Branch: next Commit: 32c7350488212db2ab98602ef6801d72922c8085 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=32c7350488212db2ab98602ef6801d72922c8085 Author: Philippe Gerum r...@xenomai.org Date: Tue Sep 9 09:40:31 2014 +0200 cobalt/debug: use separate memory pool for tracing relax requests Pulling memory from the system heap for logging such debug data has two adverse effects: - it might gradually deplete the core heap due to a constantly misbehaving application, - it may leave the user under the (wrong) impression that a memory leak is ongoing in the core heap, when a sane application is restarted multiple times, which invariably causes a few relax spots to be logged during the init phase. We fix this by assigning a private memory pool for this debug feature. Traces will simply stop being logged when the pool is full, until /proc/xenomai/debug/relax is written to for flushing it. --- kernel/cobalt/Kconfig | 12 kernel/cobalt/debug.c | 36 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/kernel/cobalt/Kconfig b/kernel/cobalt/Kconfig index c957ec2..6301437 100644 --- a/kernel/cobalt/Kconfig +++ b/kernel/cobalt/Kconfig @@ -350,6 +350,18 @@ config XENO_OPT_RTDM_FILDES descriptor is created by each successful call to the open() service of the Cobalt/POSIX API). +config XENO_OPT_DEBUG_TRACE_LOGSZ + int Trace log size + depends on XENO_OPT_DEBUG_TRACE_RELAX + default 16 + help + + The size (kilobytes) of the trace log of relax requests. Once + this limit is reached, subsequent traces will be silently + discarded. + + Writing to /proc/xenomai/debug/relax empties the trace log. + endmenu menuconfig XENO_OPT_DEBUG diff --git a/kernel/cobalt/debug.c b/kernel/cobalt/debug.c index b33ccb9..8a5a8b5 100644 --- a/kernel/cobalt/debug.c +++ b/kernel/cobalt/debug.c @@ -22,6 +22,7 @@ #include linux/jhash.h #include linux/mm.h #include linux/signal.h +#include linux/vmalloc.h #include cobalt/kernel/sched.h #include cobalt/kernel/heap.h #include cobalt/kernel/clock.h @@ -50,6 +51,8 @@ struct hashed_symbol { static struct hashed_symbol *symbol_jhash[SYMBOL_HSLOTS]; +static struct xnheap memory_pool; + /* * This is a permanent storage for ASCII strings which comes handy to * get a unique and constant reference to a symbol while preserving @@ -80,7 +83,7 @@ static const char *hash_symbol(const char *symbol) if (p) goto done; - p = xnmalloc(sizeof(*p) + len + 1); + p = xnheap_alloc(memory_pool, sizeof(*p) + len + 1); if (p == NULL) { s = NULL; goto out; @@ -328,7 +331,7 @@ void xndebug_trace_relax(int nr, unsigned long __user *u_backtrace, * allocation while probing and updating the hash table in a * single move. */ - p = xnmalloc(sizeof(*p)); + p = xnheap_alloc(memory_pool, sizeof(*p)); if (p == NULL) goto out; /* Something is about to go wrong... */ @@ -479,7 +482,7 @@ static ssize_t relax_vfile_store(struct xnvfile_input *input) while (p) { np = p-r_next; - xnfree(p); + xnheap_free(memory_pool, p); p = np; } @@ -501,12 +504,37 @@ static struct xnvfile_regular relax_vfile = { static inline int init_trace_relax(void) { - return xnvfile_init_regular(relax, relax_vfile, debug_vfroot); + u32 size = CONFIG_XENO_OPT_DEBUG_TRACE_LOGSZ * 1024; + void *p; + int ret; + + p = vmalloc(size); + if (p == NULL) + return -ENOMEM; + + ret = xnheap_init(memory_pool, p, size); + if (ret) + return ret; + + xnheap_set_name(memory_pool, debug log); + + ret = xnvfile_init_regular(relax, relax_vfile, debug_vfroot); + if (ret) { + xnheap_destroy(memory_pool); + vfree(p); + } + + return ret; } static inline void cleanup_trace_relax(void) { + void *p; + xnvfile_destroy_regular(relax_vfile); + p = xnheap_get_membase(memory_pool); + xnheap_destroy(memory_pool); + vfree(p); } #else /* !CONFIG_XENO_OPT_DEBUG_TRACE_RELAX */ ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/kernel: drop superfluous xntime_t
Module: xenomai-forge Branch: next Commit: 83ffe382fc97c8fa3c85b8bc53b6d4bc50b7fe6e URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=83ffe382fc97c8fa3c85b8bc53b6d4bc50b7fe6e Author: Philippe Gerum r...@xenomai.org Date: Tue Sep 9 10:44:33 2014 +0200 cobalt/kernel: drop superfluous xntime_t A Cobalt/POSIX time value is a count of ticks with each tick representing a nanosecond, so xnticks_t can and should be used. We don't deal with hardware time stamp counters at this level, so there is no ambiguity. --- include/cobalt/kernel/sched-sporadic.h |4 ++-- include/cobalt/kernel/schedparam.h |4 ++-- include/cobalt/uapi/kernel/types.h |4 kernel/cobalt/posix/clock.h|8 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/include/cobalt/kernel/sched-sporadic.h b/include/cobalt/kernel/sched-sporadic.h index a4b4434..0eade47 100644 --- a/include/cobalt/kernel/sched-sporadic.h +++ b/include/cobalt/kernel/sched-sporadic.h @@ -38,8 +38,8 @@ extern struct xnsched_class xnsched_class_sporadic; struct xnsched_sporadic_repl { - xntime_t date; - xntime_t amount; + xnticks_t date; + xnticks_t amount; }; struct xnsched_sporadic_data { diff --git a/include/cobalt/kernel/schedparam.h b/include/cobalt/kernel/schedparam.h index 1fe9c31..9da95aa 100644 --- a/include/cobalt/kernel/schedparam.h +++ b/include/cobalt/kernel/schedparam.h @@ -42,8 +42,8 @@ struct xnsched_tp_param { }; struct xnsched_sporadic_param { - xntime_t init_budget; - xntime_t repl_period; + xnticks_t init_budget; + xnticks_t repl_period; int max_repl; int low_prio; int normal_prio; diff --git a/include/cobalt/uapi/kernel/types.h b/include/cobalt/uapi/kernel/types.h index d2e5067..0c86a62 100644 --- a/include/cobalt/uapi/kernel/types.h +++ b/include/cobalt/uapi/kernel/types.h @@ -25,10 +25,6 @@ typedef __u64 xnticks_t; typedef __s64 xnsticks_t; -typedef __u64 xntime_t; /* ns */ - -typedef __s64 xnstime_t; - typedef __u32 xnhandle_t; #define XN_NO_HANDLE ((xnhandle_t)0) diff --git a/kernel/cobalt/posix/clock.h b/kernel/cobalt/posix/clock.h index 8a601f9..75ff9f4 100644 --- a/kernel/cobalt/posix/clock.h +++ b/kernel/cobalt/posix/clock.h @@ -32,20 +32,20 @@ static inline void ns2ts(struct timespec *ts, xnticks_t nsecs) static inline xnticks_t ts2ns(const struct timespec *ts) { - xntime_t nsecs = ts-tv_nsec; + xnticks_t nsecs = ts-tv_nsec; if (ts-tv_sec) - nsecs += (xntime_t)ts-tv_sec * ONE_BILLION; + nsecs += (xnticks_t)ts-tv_sec * ONE_BILLION; return nsecs; } static inline xnticks_t tv2ns(const struct timeval *tv) { - xntime_t nsecs = tv-tv_usec * 1000; + xnticks_t nsecs = tv-tv_usec * 1000; if (tv-tv_sec) - nsecs += (xntime_t)tv-tv_sec * ONE_BILLION; + nsecs += (xnticks_t)tv-tv_sec * ONE_BILLION; return nsecs; } ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/posix/timerfd, lib/cobalt: alloc file descriptors on the anon inode
Module: xenomai-forge Branch: next Commit: 291b25fc77c2a0b2ab0eb91498f57b35370b4453 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=291b25fc77c2a0b2ab0eb91498f57b35370b4453 Author: Philippe Gerum r...@xenomai.org Date: Tue Sep 9 16:11:38 2014 +0200 cobalt/posix/timerfd, lib/cobalt: alloc file descriptors on the anon inode --- kernel/cobalt/posix/timerfd.c | 36 kernel/cobalt/posix/timerfd.h |2 +- lib/cobalt/timerfd.c | 17 ++--- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/kernel/cobalt/posix/timerfd.c b/kernel/cobalt/posix/timerfd.c index 5502bf1..8b85de3 100644 --- a/kernel/cobalt/posix/timerfd.c +++ b/kernel/cobalt/posix/timerfd.c @@ -18,6 +18,8 @@ #include linux/timerfd.h #include linux/err.h +#include linux/fdtable.h +#include linux/anon_inodes.h #include cobalt/kernel/timer.h #include cobalt/kernel/select.h #include rtdm/fd.h @@ -162,15 +164,12 @@ static void timerfd_handler(struct xntimer *xntimer) } COBALT_SYSCALL(timerfd_create, lostage, - int, (int ufd, int clockid, int flags)) + int, (int clockid, int flags)) { struct cobalt_tfd *tfd; struct xnthread *curr; - struct xnsys_ppd *p; - - p = cobalt_ppd_get(0); - if (p == __xnsys_global_ppd) - return -EPERM; + struct xnsys_ppd *ppd; + int ret, ufd; if (clockid != CLOCK_REALTIME clockid != CLOCK_MONOTONIC) return -EINVAL; @@ -182,6 +181,14 @@ COBALT_SYSCALL(timerfd_create, lostage, if (tfd == NULL) return -ENOMEM; + ppd = cobalt_ppd_get(0); + ufd = anon_inode_getfd([cobalt-timerfd], rtdm_dumb_fops, ppd, + O_RDWR | (flags TFD_SHARED_FCNTL_FLAGS)); + if (ufd 0) { + ret = ufd; + goto fail_getfd; + } + tfd-flags = flags; tfd-clockid = clockid; curr = xnthread_current(); @@ -191,8 +198,21 @@ COBALT_SYSCALL(timerfd_create, lostage, xnselect_init(tfd-read_select); tfd-target = NULL; - return rtdm_fd_enter(p, tfd-fd, ufd, COBALT_TIMERFD_MAGIC, - timerfd_ops); + ret = rtdm_fd_enter(ppd, tfd-fd, ufd, COBALT_TIMERFD_MAGIC, + timerfd_ops); + if (ret 0) + goto fail; + + return ufd; +fail: + xnselect_destroy(tfd-read_select); + xnsynch_destroy(tfd-readers); + xntimer_destroy(tfd-timer); + __close_fd(current-files, ufd); +fail_getfd: + xnfree(tfd); + + return ret; } static inline struct cobalt_tfd *tfd_get(int ufd) diff --git a/kernel/cobalt/posix/timerfd.h b/kernel/cobalt/posix/timerfd.h index c833c83..ef1592c 100644 --- a/kernel/cobalt/posix/timerfd.h +++ b/kernel/cobalt/posix/timerfd.h @@ -5,7 +5,7 @@ #include xenomai/posix/syscall.h COBALT_SYSCALL_DECL(timerfd_create, - int, (int fd, int clockid, int flags)); + int, (int clockid, int flags)); COBALT_SYSCALL_DECL(timerfd_settime, int, (int fd, int flags, diff --git a/lib/cobalt/timerfd.c b/lib/cobalt/timerfd.c index 97e54eb..417e3aa 100644 --- a/lib/cobalt/timerfd.c +++ b/lib/cobalt/timerfd.c @@ -24,20 +24,15 @@ COBALT_IMPL(int, timerfd_create, (int clockid, int flags)) { - int ret; int fd; - fd = __STD(open(/dev/null, O_RDWR, 0)); - if (fd == -1) - return fd; - - ret = -XENOMAI_SYSCALL3(sc_cobalt_timerfd_create, fd, clockid, flags); - if (ret == 0) - return fd; + fd = XENOMAI_SYSCALL2(sc_cobalt_timerfd_create, clockid, flags); + if (fd 0) { + errno = -fd; + return -1; + } - __STD(close(fd)); - errno = ret; - return -1; + return fd; } COBALT_IMPL(int, timerfd_settime, (int fd, int flags, ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/rtdm: drop obsolete rtdm_user_info_t
Module: xenomai-forge Branch: next Commit: 50acfea1634149fe2a61163e7a2def486412cfe9 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=50acfea1634149fe2a61163e7a2def486412cfe9 Author: Philippe Gerum r...@xenomai.org Date: Tue Sep 9 09:00:37 2014 +0200 cobalt/rtdm: drop obsolete rtdm_user_info_t --- include/cobalt/kernel/rtdm/rtdm.h |1 - 1 file changed, 1 deletion(-) diff --git a/include/cobalt/kernel/rtdm/rtdm.h b/include/cobalt/kernel/rtdm/rtdm.h index 2a10f8c..645cb9a 100644 --- a/include/cobalt/kernel/rtdm/rtdm.h +++ b/include/cobalt/kernel/rtdm/rtdm.h @@ -31,7 +31,6 @@ #define RTDM_FD_MAGIC 0x5256 typedef u32 socklen_t; -typedef struct task_struct rtdm_user_info_t; int __rt_dev_open(struct xnsys_ppd *p, int ufd, const char *path, int oflag); ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/timerfd: force primary exec mode on timerfd_settime()
Module: xenomai-forge Branch: next Commit: 538f3c9cf5d1d64097c0c0e5ab21eae137de9720 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=538f3c9cf5d1d64097c0c0e5ab21eae137de9720 Author: Philippe Gerum r...@xenomai.org Date: Tue Sep 9 10:18:35 2014 +0200 cobalt/timerfd: force primary exec mode on timerfd_settime() For consistency with timer_settime(), and also because the current thread is assumed to receive the notifications if TFD_WAKEUP is set. --- kernel/cobalt/posix/syscall.c |2 +- kernel/cobalt/posix/timerfd.c |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c index 48d0fc1..e3b594e 100644 --- a/kernel/cobalt/posix/syscall.c +++ b/kernel/cobalt/posix/syscall.c @@ -938,7 +938,7 @@ static const int cobalt_sysmodes[] = { __COBALT_MODE(timer_getoverrun, current), __COBALT_MODE(timerfd_create, lostage), __COBALT_MODE(timerfd_gettime, current), - __COBALT_MODE(timerfd_settime, current), + __COBALT_MODE(timerfd_settime, primary), __COBALT_MODE(select, nonrestartable), __COBALT_MODE(sched_minprio, current), __COBALT_MODE(sched_maxprio, current), diff --git a/kernel/cobalt/posix/timerfd.c b/kernel/cobalt/posix/timerfd.c index c9e54c0..cb33994 100644 --- a/kernel/cobalt/posix/timerfd.c +++ b/kernel/cobalt/posix/timerfd.c @@ -215,7 +215,7 @@ static inline void tfd_put(struct cobalt_tfd *tfd) rtdm_fd_put(tfd-fd); } -COBALT_SYSCALL(timerfd_settime, current, +COBALT_SYSCALL(timerfd_settime, primary, int, (int fd, int flags, const struct itimerspec __user *new_value, struct itimerspec __user *old_value)) ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : lib/cobalt: vdso - cobalt_vdso
Module: xenomai-forge Branch: next Commit: b0cea96daeb80438c4d077e12b2baa617a79d07e URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=b0cea96daeb80438c4d077e12b2baa617a79d07e Author: Philippe Gerum r...@xenomai.org Date: Tue Sep 9 08:53:08 2014 +0200 lib/cobalt: vdso - cobalt_vdso --- lib/cobalt/clock.c |6 +++--- lib/cobalt/umm.c |4 ++-- lib/cobalt/umm.h |2 +- testsuite/clocktest/clocktest.c| 28 ++-- testsuite/smokey/vdso-access/vdso-access.c |4 ++-- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c index 682c9cb..501cdec 100644 --- a/lib/cobalt/clock.c +++ b/lib/cobalt/clock.c @@ -116,10 +116,10 @@ static int __do_clock_host_realtime(struct timespec *ts) unsigned long rem; urwstate_t tmp; - if (!xnvdso_test_feature(vdso, XNVDSO_FEAT_HOST_REALTIME)) + if (!xnvdso_test_feature(cobalt_vdso, XNVDSO_FEAT_HOST_REALTIME)) return -1; - hostrt_data = vdso-hostrt_data; + hostrt_data = cobalt_vdso-hostrt_data; if (!hostrt_data-live) return -1; @@ -193,7 +193,7 @@ COBALT_IMPL(int, clock_gettime, (clockid_t clock_id, struct timespec *tp)) return 0; case CLOCK_REALTIME: ns = cobalt_ticks_to_ns(cobalt_read_tsc()); - ns += vdso-wallclock_offset; + ns += cobalt_vdso-wallclock_offset; tp-tv_sec = cobalt_divrem_billion(ns, rem); tp-tv_nsec = rem; return 0; diff --git a/lib/cobalt/umm.c b/lib/cobalt/umm.c index 2460e0c..7ae57f2 100644 --- a/lib/cobalt/umm.c +++ b/lib/cobalt/umm.c @@ -34,7 +34,7 @@ #include umm.h #include internal.h -struct xnvdso *vdso; +struct xnvdso *cobalt_vdso; void *cobalt_umm_private = NULL; @@ -110,7 +110,7 @@ static void init_vdso(void) exit(EXIT_FAILURE); } - vdso = (struct xnvdso *)(cobalt_umm_shared + sysinfo.vdso); + cobalt_vdso = (struct xnvdso *)(cobalt_umm_shared + sysinfo.vdso); } /* diff --git a/lib/cobalt/umm.h b/lib/cobalt/umm.h index 1b14106..e0e3cf8 100644 --- a/lib/cobalt/umm.h +++ b/lib/cobalt/umm.h @@ -22,6 +22,6 @@ void cobalt_init_umm(void); struct xnvdso; -extern struct xnvdso *vdso; +extern struct xnvdso *cobalt_vdso; #endif /* _LIB_COBALT_UMM_H */ diff --git a/testsuite/clocktest/clocktest.c b/testsuite/clocktest/clocktest.c index 56260c5..ef19c95 100644 --- a/testsuite/clocktest/clocktest.c +++ b/testsuite/clocktest/clocktest.c @@ -34,7 +34,7 @@ #include xeno_config.h -extern struct xnvdso *vdso; +extern struct xnvdso *cobalt_vdso; #ifndef HAVE_RECENT_SETAFFINITY #ifdef HAVE_OLD_SETAFFINITY @@ -82,12 +82,12 @@ struct per_cpu_data { static void show_hostrt_diagnostics(void) { - if (!xnvdso_test_feature(vdso, XNVDSO_FEAT_HOST_REALTIME)) { + if (!xnvdso_test_feature(cobalt_vdso, XNVDSO_FEAT_HOST_REALTIME)) { printf(XNVDSO_FEAT_HOST_REALTIME not available\n); return; } - if (vdso-hostrt_data.live) + if (cobalt_vdso-hostrt_data.live) printf(hostrt data area is live\n); else { printf(hostrt data area is not live\n); @@ -95,29 +95,29 @@ static void show_hostrt_diagnostics(void) } printf(Sequence counter : %u\n, - vdso-hostrt_data.lock.sequence); + cobalt_vdso-hostrt_data.lock.sequence); printf(wall_time_sec: %lld\n, - (unsigned long long)vdso-hostrt_data.wall_time_sec); - printf(wall_time_nsec : %u\n, vdso-hostrt_data.wall_time_nsec); + (unsigned long long)cobalt_vdso-hostrt_data.wall_time_sec); + printf(wall_time_nsec : %u\n, cobalt_vdso-hostrt_data.wall_time_nsec); printf(wall_to_monotonic\n); printf( tv_sec : %jd\n, - (intmax_t)vdso-hostrt_data.wall_to_monotonic.tv_sec); + (intmax_t)cobalt_vdso-hostrt_data.wall_to_monotonic.tv_sec); printf( tv_nsec : %ld\n, - vdso-hostrt_data.wall_to_monotonic.tv_nsec); - printf(cycle_last : %Lu\n, vdso-hostrt_data.cycle_last); - printf(mask : 0x%Lx\n, vdso-hostrt_data.mask); - printf(mult : %u\n, vdso-hostrt_data.mult); - printf(shift: %u\n\n, vdso-hostrt_data.shift); + cobalt_vdso-hostrt_data.wall_to_monotonic.tv_nsec); + printf(cycle_last : %Lu\n, cobalt_vdso-hostrt_data.cycle_last); + printf(mask : 0x%Lx\n, cobalt_vdso-hostrt_data.mask); + printf(mult : %u\n, cobalt_vdso-hostrt_data.mult); + printf(shift: %u\n\n, cobalt_vdso-hostrt_data.shift); } static void show_realtime_offset(void) { - if (!xnvdso_test_feature(vdso,
[Xenomai-git] Philippe Gerum : config: bump ABI revision levels
Module: xenomai-forge Branch: next Commit: 9a8a6874203a3b037c42faabea3875c31d49f0ce URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=9a8a6874203a3b037c42faabea3875c31d49f0ce Author: Philippe Gerum r...@xenomai.org Date: Mon Sep 8 21:19:01 2014 +0200 config: bump ABI revision levels --- kernel/cobalt/arch/arm/include/asm/xenomai/uapi/features.h |2 +- kernel/cobalt/arch/blackfin/include/asm/xenomai/uapi/features.h |2 +- kernel/cobalt/arch/nios2/include/asm/xenomai/uapi/features.h|2 +- kernel/cobalt/arch/powerpc/include/asm/xenomai/uapi/features.h |2 +- kernel/cobalt/arch/sh/include/asm/xenomai/uapi/features.h |2 +- kernel/cobalt/arch/x86/include/asm/xenomai/uapi/features.h |2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/features.h b/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/features.h index acf10a9..1a3baca 100644 --- a/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/features.h +++ b/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/features.h @@ -22,7 +22,7 @@ #define _COBALT_ARM_ASM_UAPI_FEATURES_H /* The ABI revision level we use on this arch. */ -#define XENOMAI_ABI_REV 9UL +#define XENOMAI_ABI_REV 10UL #define XENOMAI_FEAT_DEP (__xn_feat_generic_mask) diff --git a/kernel/cobalt/arch/blackfin/include/asm/xenomai/uapi/features.h b/kernel/cobalt/arch/blackfin/include/asm/xenomai/uapi/features.h index 5300ca7..aaabe1b 100644 --- a/kernel/cobalt/arch/blackfin/include/asm/xenomai/uapi/features.h +++ b/kernel/cobalt/arch/blackfin/include/asm/xenomai/uapi/features.h @@ -19,7 +19,7 @@ #define _COBALT_BLACKFIN_ASM_UAPI_FEATURES_H /* The ABI revision level we use on this arch. */ -#define XENOMAI_ABI_REV 9UL +#define XENOMAI_ABI_REV 10UL #define XENOMAI_FEAT_DEP __xn_feat_generic_mask diff --git a/kernel/cobalt/arch/nios2/include/asm/xenomai/uapi/features.h b/kernel/cobalt/arch/nios2/include/asm/xenomai/uapi/features.h index 5f3985a..cfeb0c2 100644 --- a/kernel/cobalt/arch/nios2/include/asm/xenomai/uapi/features.h +++ b/kernel/cobalt/arch/nios2/include/asm/xenomai/uapi/features.h @@ -21,7 +21,7 @@ #include linux/types.h /* The ABI revision level we use on this arch. */ -#define XENOMAI_ABI_REV 8UL +#define XENOMAI_ABI_REV 9UL #define XENOMAI_FEAT_DEP __xn_feat_generic_mask diff --git a/kernel/cobalt/arch/powerpc/include/asm/xenomai/uapi/features.h b/kernel/cobalt/arch/powerpc/include/asm/xenomai/uapi/features.h index 2317ff2..8a2aee7 100644 --- a/kernel/cobalt/arch/powerpc/include/asm/xenomai/uapi/features.h +++ b/kernel/cobalt/arch/powerpc/include/asm/xenomai/uapi/features.h @@ -19,7 +19,7 @@ #define _COBALT_POWERPC_ASM_UAPI_FEATURES_H /* The ABI revision level we use on this arch. */ -#define XENOMAI_ABI_REV 9UL +#define XENOMAI_ABI_REV 10UL #define XENOMAI_FEAT_DEP __xn_feat_generic_mask diff --git a/kernel/cobalt/arch/sh/include/asm/xenomai/uapi/features.h b/kernel/cobalt/arch/sh/include/asm/xenomai/uapi/features.h index c38c403..5d1500f 100644 --- a/kernel/cobalt/arch/sh/include/asm/xenomai/uapi/features.h +++ b/kernel/cobalt/arch/sh/include/asm/xenomai/uapi/features.h @@ -21,7 +21,7 @@ #include linux/types.h /* The ABI revision level we use on this arch. */ -#define XENOMAI_ABI_REV 6UL +#define XENOMAI_ABI_REV 7UL #define XENOMAI_FEAT_DEP __xn_feat_generic_mask diff --git a/kernel/cobalt/arch/x86/include/asm/xenomai/uapi/features.h b/kernel/cobalt/arch/x86/include/asm/xenomai/uapi/features.h index 5e96f85..dba7921 100644 --- a/kernel/cobalt/arch/x86/include/asm/xenomai/uapi/features.h +++ b/kernel/cobalt/arch/x86/include/asm/xenomai/uapi/features.h @@ -19,7 +19,7 @@ #define _COBALT_X86_ASM_UAPI_FEATURES_H /* The ABI revision level we use on this arch. */ -#define XENOMAI_ABI_REV 9UL +#define XENOMAI_ABI_REV 10UL #define XENOMAI_FEAT_DEP __xn_feat_generic_mask ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/registry, cobalt/thread: use wait context in binding operation
Module: xenomai-forge Branch: next Commit: a2070d49f6a9d3c7a578e5075c4135325930ddbb URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=a2070d49f6a9d3c7a578e5075c4135325930ddbb Author: Philippe Gerum r...@xenomai.org Date: Tue Sep 9 12:19:25 2014 +0200 cobalt/registry, cobalt/thread: use wait context in binding operation --- include/cobalt/kernel/thread.h |2 -- kernel/cobalt/registry.c | 19 +-- kernel/cobalt/thread.c |1 - 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h index 0801cbc..03faf8f 100644 --- a/include/cobalt/kernel/thread.h +++ b/include/cobalt/kernel/thread.h @@ -169,8 +169,6 @@ struct xnthread { xnhandle_t handle; /* Handle in registry */ - const char *waitkey;/* Pended key */ - char name[XNOBJECT_NAME_LEN]; /* Symbolic name of thread */ void (*entry)(void *cookie); /* Thread entry routine */ diff --git a/kernel/cobalt/registry.c b/kernel/cobalt/registry.c index 561c8d9..6643865 100644 --- a/kernel/cobalt/registry.c +++ b/kernel/cobalt/registry.c @@ -559,15 +559,22 @@ static struct xnobject *registry_hash_find(const char *key) return NULL; } +struct registry_wait_context { + struct xnthread_wait_context wc; + const char *key; +}; + static inline int registry_wakeup_sleepers(const char *key) { + struct registry_wait_context *rwc; + struct xnthread_wait_context *wc; struct xnthread *sleeper, *tmp; int cnt = 0; xnsynch_for_each_sleeper_safe(sleeper, tmp, register_synch) { - if (*key == *sleeper-waitkey - strcmp(key, sleeper-waitkey) == 0) { - sleeper-waitkey = NULL; + wc = xnthread_get_wait_context(sleeper); + rwc = container_of(wc, struct registry_wait_context, wc); + if (*key == *rwc-key strcmp(key, rwc-key) == 0) { xnsynch_wakeup_this_sleeper(register_synch, sleeper); ++cnt; } @@ -731,8 +738,8 @@ EXPORT_SYMBOL_GPL(xnregistry_enter); int xnregistry_bind(const char *key, xnticks_t timeout, int timeout_mode, xnhandle_t *phandle) { + struct registry_wait_context rwc; struct xnobject *object; - struct xnthread *thread; int ret = 0, info; spl_t s; @@ -760,8 +767,8 @@ int xnregistry_bind(const char *key, xnticks_t timeout, int timeout_mode, goto unlock_and_exit; } - thread = xnthread_current(); - thread-waitkey = key; + rwc.key = key; + xnthread_prepare_wait(rwc.wc); info = xnsynch_sleep_on(register_synch, timeout, timeout_mode); if (info XNTIMEO) { ret = -ETIMEDOUT; diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c index 5fb2de1..7c2405a 100644 --- a/kernel/cobalt/thread.c +++ b/kernel/cobalt/thread.c @@ -180,7 +180,6 @@ int __xnthread_init(struct xnthread *thread, thread-wcontext = NULL; thread-res_count = 0; thread-handle = XN_NO_HANDLE; - thread-waitkey = NULL; memset(thread-stat, 0, sizeof(thread-stat)); thread-selector = NULL; INIT_LIST_HEAD(thread-claimq); ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/debug: use separate memory pool for tracing relax requests
Module: xenomai-forge Branch: next Commit: 9e0dce83f29bfb1540ffee9fb38ac3d16445ef1e URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=9e0dce83f29bfb1540ffee9fb38ac3d16445ef1e Author: Philippe Gerum r...@xenomai.org Date: Tue Sep 9 09:40:31 2014 +0200 cobalt/debug: use separate memory pool for tracing relax requests Pulling memory from the system heap for logging such debug data has two adverse effects: - it might gradually deplete the core heap due to a constantly misbehaving application, - it may leave the user under the (wrong) impression that a memory leak is ongoing in the core heap, when a sane application is restarted multiple times, which invariably causes a few relax spots to be logged during the init phase. We fix this by assigning a private memory pool for this debug feature. Traces will simply stop being logged when the pool is full, until /proc/xenomai/debug/relax is written to for flushing it. --- kernel/cobalt/Kconfig | 12 kernel/cobalt/debug.c | 36 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/kernel/cobalt/Kconfig b/kernel/cobalt/Kconfig index c957ec2..6301437 100644 --- a/kernel/cobalt/Kconfig +++ b/kernel/cobalt/Kconfig @@ -350,6 +350,18 @@ config XENO_OPT_RTDM_FILDES descriptor is created by each successful call to the open() service of the Cobalt/POSIX API). +config XENO_OPT_DEBUG_TRACE_LOGSZ + int Trace log size + depends on XENO_OPT_DEBUG_TRACE_RELAX + default 16 + help + + The size (kilobytes) of the trace log of relax requests. Once + this limit is reached, subsequent traces will be silently + discarded. + + Writing to /proc/xenomai/debug/relax empties the trace log. + endmenu menuconfig XENO_OPT_DEBUG diff --git a/kernel/cobalt/debug.c b/kernel/cobalt/debug.c index b33ccb9..8a5a8b5 100644 --- a/kernel/cobalt/debug.c +++ b/kernel/cobalt/debug.c @@ -22,6 +22,7 @@ #include linux/jhash.h #include linux/mm.h #include linux/signal.h +#include linux/vmalloc.h #include cobalt/kernel/sched.h #include cobalt/kernel/heap.h #include cobalt/kernel/clock.h @@ -50,6 +51,8 @@ struct hashed_symbol { static struct hashed_symbol *symbol_jhash[SYMBOL_HSLOTS]; +static struct xnheap memory_pool; + /* * This is a permanent storage for ASCII strings which comes handy to * get a unique and constant reference to a symbol while preserving @@ -80,7 +83,7 @@ static const char *hash_symbol(const char *symbol) if (p) goto done; - p = xnmalloc(sizeof(*p) + len + 1); + p = xnheap_alloc(memory_pool, sizeof(*p) + len + 1); if (p == NULL) { s = NULL; goto out; @@ -328,7 +331,7 @@ void xndebug_trace_relax(int nr, unsigned long __user *u_backtrace, * allocation while probing and updating the hash table in a * single move. */ - p = xnmalloc(sizeof(*p)); + p = xnheap_alloc(memory_pool, sizeof(*p)); if (p == NULL) goto out; /* Something is about to go wrong... */ @@ -479,7 +482,7 @@ static ssize_t relax_vfile_store(struct xnvfile_input *input) while (p) { np = p-r_next; - xnfree(p); + xnheap_free(memory_pool, p); p = np; } @@ -501,12 +504,37 @@ static struct xnvfile_regular relax_vfile = { static inline int init_trace_relax(void) { - return xnvfile_init_regular(relax, relax_vfile, debug_vfroot); + u32 size = CONFIG_XENO_OPT_DEBUG_TRACE_LOGSZ * 1024; + void *p; + int ret; + + p = vmalloc(size); + if (p == NULL) + return -ENOMEM; + + ret = xnheap_init(memory_pool, p, size); + if (ret) + return ret; + + xnheap_set_name(memory_pool, debug log); + + ret = xnvfile_init_regular(relax, relax_vfile, debug_vfroot); + if (ret) { + xnheap_destroy(memory_pool); + vfree(p); + } + + return ret; } static inline void cleanup_trace_relax(void) { + void *p; + xnvfile_destroy_regular(relax_vfile); + p = xnheap_get_membase(memory_pool); + xnheap_destroy(memory_pool); + vfree(p); } #else /* !CONFIG_XENO_OPT_DEBUG_TRACE_RELAX */ ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/rtdm: allow omitting open/socket/close handlers
Module: xenomai-forge Branch: next Commit: 2550a70929c16b1b7905a5fc221ca5868320a664 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=2550a70929c16b1b7905a5fc221ca5868320a664 Author: Philippe Gerum r...@xenomai.org Date: Tue Sep 9 17:38:34 2014 +0200 cobalt/rtdm: allow omitting open/socket/close handlers Although unusual, omitting open/socket/close handlers in drivers is perfectly legitimate, and nothing justifies to keep them required. --- kernel/cobalt/rtdm/core.c | 37 ++--- kernel/cobalt/rtdm/device.c | 16 2 files changed, 18 insertions(+), 35 deletions(-) diff --git a/kernel/cobalt/rtdm/core.c b/kernel/cobalt/rtdm/core.c index 18cf0c6..f84d8b0 100644 --- a/kernel/cobalt/rtdm/core.c +++ b/kernel/cobalt/rtdm/core.c @@ -56,7 +56,8 @@ static void cleanup_instance(struct rtdm_device *device, void __rt_dev_close(struct rtdm_fd *fd) { struct rtdm_dev_context *context = rtdm_fd_to_context(fd); - context-reserved.close(fd); + if (context-reserved.close) + context-reserved.close(fd); cleanup_instance(context-device, context); } @@ -168,13 +169,13 @@ int __rt_dev_open(struct xnsys_ppd *p, int ufd, const char *path, int oflag) trace_cobalt_fd_open(current, context-fd, ufd, oflag); - ret = device-ops.open(context-fd, oflag); - - if (!XENO_ASSERT(COBALT, !spltest())) - splnone(); - - if (ret 0) - goto cleanup_out; + if (device-ops.open) { + ret = device-ops.open(context-fd, oflag); + if (!XENO_ASSERT(COBALT, !spltest())) + splnone(); + if (ret 0) + goto cleanup_out; + } trace_cobalt_fd_created(context-fd, ufd); @@ -195,9 +196,8 @@ int __rt_dev_socket(struct xnsys_ppd *p, int ufd, int protocol_family, int ret; device = __rtdm_get_protocol_device(protocol_family, socket_type); - ret = -EAFNOSUPPORT; - if (!device) - goto err_out; + if (device == NULL) + return -EAFNOSUPPORT; ret = create_instance(p, ufd, device, context); if (ret 0) @@ -206,13 +206,13 @@ int __rt_dev_socket(struct xnsys_ppd *p, int ufd, int protocol_family, trace_cobalt_fd_socket(current, context-fd, ufd, protocol_family); - ret = device-ops.socket(context-fd, protocol); - - if (!XENO_ASSERT(COBALT, !spltest())) - splnone(); - - if (unlikely(ret 0)) - goto cleanup_out; + if (device-ops.socket) { + ret = device-ops.socket(context-fd, protocol); + if (!XENO_ASSERT(COBALT, !spltest())) + splnone(); + if (ret 0) + goto cleanup_out; + } trace_cobalt_fd_created(context-fd, ufd); @@ -221,7 +221,6 @@ int __rt_dev_socket(struct xnsys_ppd *p, int ufd, int protocol_family, cleanup_out: cleanup_instance(device, context); -err_out: return ret; } EXPORT_SYMBOL_GPL(__rt_dev_socket); diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c index 14e4492..d513685 100644 --- a/kernel/cobalt/rtdm/device.c +++ b/kernel/cobalt/rtdm/device.c @@ -195,20 +195,10 @@ int rtdm_dev_register(struct rtdm_device *device) switch (device-device_flags RTDM_DEVICE_TYPE_MASK) { case RTDM_NAMED_DEVICE: - /* Sanity check: any open handler? */ - if (device-ops.open == NULL) { - printk(XENO_ERR missing open handler for RTDM device\n); - return -EINVAL; - } device-ops.socket = (typeof(device-ops.socket))enosys; break; case RTDM_PROTOCOL_DEVICE: - /* Sanity check: any socket handler? */ - if (device-ops.socket == NULL) { - printk(XENO_ERR missing socket handler for RTDM device\n); - return -EINVAL; - } device-ops.open = (typeof(device-ops.open))enosys; break; @@ -216,12 +206,6 @@ int rtdm_dev_register(struct rtdm_device *device) return -EINVAL; } - /* Sanity check: driver-defined close handler? -* (Always required for forced cleanup) */ - if (device-ops.close == NULL) { - printk(XENO_ERR missing close handler for RTDM device\n); - return -EINVAL; - } device-reserved.close = device-ops.close; device-ops.close = __rt_dev_close; atomic_set(device-reserved.refcount, 0); ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/posix/memory: omit empty .open/ .close handlers in memdev
Module: xenomai-forge Branch: next Commit: 969a6a172cbca19b06f804aae07641571a0f4b40 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=969a6a172cbca19b06f804aae07641571a0f4b40 Author: Philippe Gerum r...@xenomai.org Date: Tue Sep 9 17:49:06 2014 +0200 cobalt/posix/memory: omit empty .open/.close handlers in memdev --- kernel/cobalt/posix/memory.c | 14 -- 1 file changed, 14 deletions(-) diff --git a/kernel/cobalt/posix/memory.c b/kernel/cobalt/posix/memory.c index 06422ef..126b8c7 100644 --- a/kernel/cobalt/posix/memory.c +++ b/kernel/cobalt/posix/memory.c @@ -38,13 +38,6 @@ static struct rtdm_device private_umm_device; static struct rtdm_device shared_umm_device; -static int umm_open(struct rtdm_fd *fd, int oflags) -{ - return 0; -} - -static void umm_close(struct rtdm_fd *fd) { } - static void umm_vmopen(struct vm_area_struct *vma) { struct cobalt_umm *umm = vma-vm_private_data; @@ -161,8 +154,6 @@ static int sysmem_open(struct rtdm_fd *fd, int oflags) return 0; } -static void sysmem_close(struct rtdm_fd *fd) { } - static int do_sysmem_ioctls(struct rtdm_fd *fd, unsigned int request, void __user *arg) { @@ -202,11 +193,9 @@ static struct rtdm_device private_umm_device = { .device_flags = RTDM_NAMED_DEVICE, .context_size = 0, .ops = { - .open = umm_open, .ioctl_rt = umm_ioctl_rt, .ioctl_nrt = umm_ioctl_nrt, .mmap = umm_mmap, - .close = umm_close, }, .device_class = RTDM_CLASS_MEMORY, .device_sub_class = UMM_PRIVATE, @@ -223,11 +212,9 @@ static struct rtdm_device shared_umm_device = { .device_flags = RTDM_NAMED_DEVICE, .context_size = 0, .ops = { - .open = umm_open, .ioctl_rt = umm_ioctl_rt, .ioctl_nrt = umm_ioctl_nrt, .mmap = umm_mmap, - .close = umm_close, }, .device_class = RTDM_CLASS_MEMORY, .device_sub_class = UMM_SHARED, @@ -247,7 +234,6 @@ static struct rtdm_device sysmem_device = { .open = sysmem_open, .ioctl_rt = sysmem_ioctl_rt, .ioctl_nrt = sysmem_ioctl_nrt, - .close = sysmem_close, }, .device_class = RTDM_CLASS_MEMORY, .device_sub_class = SYS_GLOBAL, ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : scripts/prepare-kernel: remove support for legacy patches
Module: xenomai-forge Branch: next Commit: 99256a25bad97b2f8de547171c7b70f8fb15836f URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=99256a25bad97b2f8de547171c7b70f8fb15836f Author: Philippe Gerum r...@xenomai.org Date: Tue Sep 9 16:59:57 2014 +0200 scripts/prepare-kernel: remove support for legacy patches --- scripts/prepare-kernel.sh |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh index 7111d3f..f1791ca 100755 --- a/scripts/prepare-kernel.sh +++ b/scripts/prepare-kernel.sh @@ -321,9 +321,9 @@ if test -r $linux_tree/include/linux/ipipe.h; then fi else if test x$ipipe_patch = x; then - # We pick ipipe-core-* patches first over adeos-ipipe-* ones, - # then the highest numbered sequence/release number. - default_ipipe_patch=`( ls $xenomai_root/kernel/cobalt/arch/$linux_arch/patches/ipipe-core-$linux_version*-$linux_arch-* $xenomai_root/kernel/cobalt/arch/$linux_arch/patches/adeos-ipipe-$linux_version*-$linux_arch-*|sort -r ) 2/dev/null | head -n1` + # Pick ipipe-core-* patches based on the highest numbered + # sequence/release number. + default_ipipe_patch=`( ls $xenomai_root/kernel/cobalt/arch/$linux_arch/patches/ipipe-core-$linux_version*-$linux_arch-*|sort -r ) 2/dev/null | head -n1` fi if test x$default_ipipe_patch = x; then if test x$verbose = x1; then ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : configure: require shm_open() with --enable-pshared
Module: xenomai-forge Branch: next Commit: 3ab0f27e006d2f968d4ff5c2ee5d67258faeaa2d URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=3ab0f27e006d2f968d4ff5c2ee5d67258faeaa2d Author: Philippe Gerum r...@xenomai.org Date: Tue Sep 9 18:51:05 2014 +0200 configure: require shm_open() with --enable-pshared --- configure| 10 ++ configure.ac |7 +++ 2 files changed, 17 insertions(+) diff --git a/configure b/configure index e1c1871..248ac6c 100755 --- a/configure +++ b/configure @@ -13784,6 +13784,16 @@ $as_echo #define CONFIG_XENO_COPPERPLATE_CLOCK_RESTRICTED 1 confdefs.h fi +if test x$use_pshared = xy; then + ac_fn_c_check_func $LINENO shm_open ac_cv_func_shm_open +if test x$ac_cv_func_shm_open = xyes; then : + +else + as_fn_error $? shm_open() is missing, --disable-pshared is required $LINENO 5 +fi + +fi + cat confdefs.h _ACEOF diff --git a/configure.ac b/configure.ac index 023d270..e50d875 100644 --- a/configure.ac +++ b/configure.ac @@ -531,6 +531,13 @@ dnl won't vary for a given Xenomai installation. AC_CHECK_FUNC(pthread_condattr_setclock,, [AC_DEFINE(CONFIG_XENO_COPPERPLATE_CLOCK_RESTRICTED, 1,[config])]) +dnl Check that Copperplate can implement a shared heap if +dnl --enable-pshared was given. +if test x$use_pshared = xy; then + AC_CHECK_FUNC(shm_open,, + [AC_MSG_ERROR([shm_open() is missing, --disable-pshared is required])]) +fi + dnl dnl Produce the info needed to build xeno_config.h dnl ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/rtdm: fix mmap helper for MMU-less
Module: xenomai-forge Branch: next Commit: 933e00fbb097b49bc62da88cc6bfa195f6a54e68 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=933e00fbb097b49bc62da88cc6bfa195f6a54e68 Author: Philippe Gerum r...@xenomai.org Date: Tue Sep 9 19:17:18 2014 +0200 cobalt/rtdm: fix mmap helper for MMU-less --- kernel/cobalt/rtdm/drvlib.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index aab8725..e147b6e 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1606,7 +1606,7 @@ unsigned long unmapped_area_helper(struct file *filp, if (pa) return (unsigned long)__va(pa); - return (unsigned long)mmap_data-src_vaddr; + return (unsigned long)helper_data-src_vaddr; } static unsigned long ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git