[Xenomai-git] Philippe Gerum : testsuite/smokey: fail if out of TP schedule
Module: xenomai-3 Branch: next Commit: 73151aa4dd5089ff8d937655b77cd22166043832 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=73151aa4dd5089ff8d937655b77cd22166043832 Author: Philippe Gerum r...@xenomai.org Date: Thu Jul 30 09:12:29 2015 +0200 testsuite/smokey: fail if out of TP schedule --- testsuite/smokey/sched-tp/sched-tp.c | 64 ++ 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/testsuite/smokey/sched-tp/sched-tp.c b/testsuite/smokey/sched-tp/sched-tp.c index 4f5f7bc..f28de54 100644 --- a/testsuite/smokey/sched-tp/sched-tp.c +++ b/testsuite/smokey/sched-tp/sched-tp.c @@ -11,6 +11,7 @@ #include memory.h #include malloc.h #include unistd.h +#include string.h #include signal.h #include pthread.h #include semaphore.h @@ -33,6 +34,18 @@ static pthread_t threadA, threadB, threadC; static sem_t barrier; +static const char ref_schedule[] = + CCBAACCBAACCBAACC + BAACCBAACCBAACCBAA + CCBAACCBAACCBAACC + BAACCBAACCBAA; + +static char schedule[sizeof(ref_schedule) + 8], *curr = schedule; + +static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; + +static int overflow; + static void *thread_body(void *arg) { pthread_t me = pthread_self(); @@ -58,10 +71,22 @@ static void *thread_body(void *arg) sem_post(barrier); for (;;) { - putchar('A' + part); - fflush(stdout); + /* +* The mutex is there in case the scheduler behaves in +* a really weird way so that we don't write out of +* bounds; otherwise no serialization should happen +* due to this lock. +*/ + pthread_mutex_lock(lock); + if (curr = schedule + sizeof(schedule)) { + pthread_mutex_unlock(lock); + overflow = 1; + break; + } + *curr++ = 'A' + part; + pthread_mutex_unlock(lock); ts.tv_sec = 0; - ts.tv_nsec = 1000; + ts.tv_nsec = 1050; clock_nanosleep(CLOCK_MONOTONIC, 0, ts, NULL); } @@ -106,6 +131,7 @@ static int run_sched_tp(struct smokey_test *t, int argc, char *const argv[]) union sched_config *p; int ret, n, policies; size_t len; + char *s; ret = cobalt_corectl(_CC_COBALT_GET_POLICIES, policies, sizeof(policies)); if (ret || (policies _CC_COBALT_SCHED_TP) == 0) @@ -136,6 +162,7 @@ static int run_sched_tp(struct smokey_test *t, int argc, char *const argv[]) if (p == NULL) error(1, ENOMEM, malloc); + p-tp.op = sched_tp_install; p-tp.nr_windows = NR_WINDOWS; p-tp.windows[0].offset.tv_sec = 0; p-tp.windows[0].offset.tv_nsec = 0; @@ -158,10 +185,10 @@ static int run_sched_tp(struct smokey_test *t, int argc, char *const argv[]) p-tp.windows[3].duration.tv_nsec = 23000; p-tp.windows[3].ptid = -1; - /* Assign the TP schedule to CPU #0 */ + /* Assign the TP schedule to CPU #0 */ ret = sched_setconfig_np(0, SCHED_TP, p, len); if (ret) - error(1, ret, sched_setconfig_np); + error(1, ret, sched_setconfig_np(install)); memset(p, 0xa5, len); @@ -183,11 +210,36 @@ static int run_sched_tp(struct smokey_test *t, int argc, char *const argv[]) create_thread(threadA, 0); create_thread(threadB, 1); create_thread(threadC, 2); - sem_post(barrier); + /* Start the TP schedule. */ + len = sched_tp_confsz(0); + p-tp.op = sched_tp_start; + ret = sched_setconfig_np(0, SCHED_TP, p, len); + if (ret) + error(1, ret, sched_setconfig_np(start)); + + sem_post(barrier); sleep(5); cleanup(); sem_destroy(barrier); + free(p); + + if (overflow) { + smokey_warning(schedule overflowed); + return -EPROTO; + } + + /* +* The first time window might be decreased for enough time to +* skip an iteration due to lingering inits, and a few more +* marks may be generated while we are busy stopping the +* threads, so we look for a valid sub-sequence. +*/ + s = strstr(ref_schedule, schedule); + if (s == NULL || s - ref_schedule 1) { + smokey_warning(unexpected schedule:\n%s, schedule); + return -EPROTO; + } return 0; } ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : testsuite/latency: disable -t1/2 over Mercury
Module: xenomai-3 Branch: next Commit: be70e0e1e3654933b2d8a4bcd60851acf9094855 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=be70e0e1e3654933b2d8a4bcd60851acf9094855 Author: Philippe Gerum r...@xenomai.org Date: Fri Jul 31 11:38:35 2015 +0200 testsuite/latency: disable -t1/2 over Mercury --- testsuite/latency/latency.c |5 + 1 file changed, 5 insertions(+) diff --git a/testsuite/latency/latency.c b/testsuite/latency/latency.c index bbc4317..9f358d7 100644 --- a/testsuite/latency/latency.c +++ b/testsuite/latency/latency.c @@ -732,6 +732,11 @@ int main(int argc, char *const *argv) if (test_mode USER_TASK || test_mode TIMER_HANDLER) error(1, EINVAL, invalid test mode); +#ifdef CONFIG_XENO_MERCURY + if (test_mode ! USER_TASK) + error(1, EINVAL, -t1, -t2 not allowed over Mercury); +#endif + time(test_start); histogram_avg = calloc(histogram_size, sizeof(int32_t)); ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : copperplate/regd: do timed wait for anon connection
Module: xenomai-3 Branch: next Commit: f6e8d20f45fab08dd87ffd38d9fb146e94e24571 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f6e8d20f45fab08dd87ffd38d9fb146e94e24571 Author: Philippe Gerum r...@xenomai.org Date: Fri Jul 31 15:00:48 2015 +0200 copperplate/regd: do timed wait for anon connection --- lib/copperplate/regd/regd.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/copperplate/regd/regd.c b/lib/copperplate/regd/regd.c index 4f48273..01ecc60 100644 --- a/lib/copperplate/regd/regd.c +++ b/lib/copperplate/regd/regd.c @@ -343,7 +343,7 @@ static void handle_requests(void) FD_ZERO(refset); FD_SET(sockfd, refset); - if (!(linger || anon)) { + if (!linger) { tmfd = __STD(timerfd_create(CLOCK_MONOTONIC, 0)); if (tmfd 0) error(1, errno, handle_requests/timerfd_create); @@ -371,8 +371,14 @@ static void handle_requests(void) continue; } FD_SET(s, refset); - if (tmfd != -1) - __STD(timerfd_settime(tmfd, 0, its, NULL)); + if (tmfd != -1) { + if (anon) { + FD_CLR(tmfd, refset); + __STD(close(tmfd)); + tmfd = -1; + } else + __STD(timerfd_settime(tmfd, 0, its, NULL)); + } } if (tmfd != -1 FD_ISSET(tmfd, set)) { ret = __STD(read(tmfd, exp, sizeof(exp))); ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/sched: add start, stop SCHED_TP config operations
Module: xenomai-3 Branch: next Commit: 08af0a3457514230180cce05b3e0eda751a377db URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=08af0a3457514230180cce05b3e0eda751a377db Author: Philippe Gerum r...@xenomai.org Date: Thu Jul 30 14:16:04 2015 +0200 cobalt/sched: add start, stop SCHED_TP config operations We may want to start/stop a TP schedule without removing it from the CPU entirely. To this end, this commit introduces the sched_tp_start/stop requests, processed by sched_config_np(). --- include/cobalt/kernel/compat.h |1 + include/cobalt/uapi/sched.h |8 + kernel/cobalt/posix/sched.c | 30 +--- kernel/cobalt/posix/syscall32.c |4 +++ kernel/cobalt/sched-tp.c|9 +++-- lib/cobalt/thread.c | 72 --- 6 files changed, 97 insertions(+), 27 deletions(-) diff --git a/include/cobalt/kernel/compat.h b/include/cobalt/kernel/compat.h index 7420804..b0ef81e 100644 --- a/include/cobalt/kernel/compat.h +++ b/include/cobalt/kernel/compat.h @@ -61,6 +61,7 @@ struct compat_sched_tp_window { }; struct __compat_sched_config_tp { + int op; int nr_windows; struct compat_sched_tp_window windows[0]; }; diff --git a/include/cobalt/uapi/sched.h b/include/cobalt/uapi/sched.h index fc04f49..b672095 100644 --- a/include/cobalt/uapi/sched.h +++ b/include/cobalt/uapi/sched.h @@ -57,7 +57,15 @@ struct sched_tp_window { int ptid; }; +enum { + sched_tp_install, + sched_tp_uninstall, + sched_tp_start, + sched_tp_stop, +}; + struct __sched_config_tp { + int op; int nr_windows; struct sched_tp_window windows[0]; }; diff --git a/kernel/cobalt/posix/sched.c b/kernel/cobalt/posix/sched.c index 0e7d405..be2e441 100644 --- a/kernel/cobalt/posix/sched.c +++ b/kernel/cobalt/posix/sched.c @@ -242,14 +242,35 @@ int set_tp_config(int cpu, union sched_config *config, size_t len) if (len sizeof(config-tp)) return -EINVAL; - if (config-tp.nr_windows == 0) { + sched = xnsched_struct(cpu); + + switch (config-tp.op) { + case sched_tp_install: + if (config-tp.nr_windows 0) + break; + /* Fallback wanted. */ + case sched_tp_uninstall: gps = NULL; goto set_schedule; + case sched_tp_start: + xnlock_get_irqsave(nklock, s); + xnsched_tp_start_schedule(sched); + xnlock_put_irqrestore(nklock, s); + return 0; + case sched_tp_stop: + xnlock_get_irqsave(nklock, s); + xnsched_tp_stop_schedule(sched); + xnlock_put_irqrestore(nklock, s); + return 0; + default: + return -EINVAL; } + /* Install a new TP schedule on CPU. */ + gps = xnmalloc(sizeof(*gps) + config-tp.nr_windows * sizeof(*w)); if (gps == NULL) - goto fail; + return -ENOMEM; for (n = 0, p = config-tp.windows, w = gps-pwins, next_offset = 0; n config-tp.nr_windows; n++, p++, w++) { @@ -279,10 +300,8 @@ int set_tp_config(int cpu, union sched_config *config, size_t len) gps-pwin_nr = n; gps-tf_duration = next_offset; set_schedule: - sched = xnsched_struct(cpu); xnlock_get_irqsave(nklock, s); ogps = xnsched_tp_set_schedule(sched, gps); - xnsched_tp_start_schedule(sched); xnlock_put_irqrestore(nklock, s); if (ogps) @@ -292,7 +311,7 @@ set_schedule: cleanup_and_fail: xnfree(gps); -fail: + return -EINVAL; } @@ -333,6 +352,7 @@ ssize_t get_tp_config(int cpu, void __user *u_config, size_t len, goto out; } + config-tp.op = sched_tp_install; config-tp.nr_windows = gps-pwin_nr; for (n = 0, pp = p = config-tp.windows, pw = w = gps-pwins; n gps-pwin_nr; pp = p, p++, pw = w, w++, n++) { diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c index 78d3c57..b3ce8a7 100644 --- a/kernel/cobalt/posix/syscall32.c +++ b/kernel/cobalt/posix/syscall32.c @@ -341,6 +341,7 @@ sys32_fetch_config(int policy, const void __user *u_config, size_t *len) if (policy == SCHED_QUOTA) memcpy(buf-quota, cbuf-quota, sizeof(cbuf-quota)); else { + buf-tp.op = cbuf-tp.op; buf-tp.nr_windows = cbuf-tp.nr_windows; for (n = 0; n buf-tp.nr_windows; n++) { buf-tp.windows[n].ptid = cbuf-tp.windows[n].ptid; @@ -387,9 +388,12 @@ static ssize_t sys32_put_config(int policy, sizeof(u_p-quota.info); } + /* SCHED_TP */ + if (u_len compat_sched_tp_confsz(config-tp.nr_windows)) return -ENOSPC; + __xn_put_user(config-tp.op, u_p-tp.op);
[Xenomai-git] Jan Kiszka : kernel/cobalt: Add reason to gorelax trace point
Module: xenomai-jki Branch: for-forge Commit: 30a6227e3c734a0bd3381a603edba383841b0ca6 URL: http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=30a6227e3c734a0bd3381a603edba383841b0ca6 Author: Jan Kiszka jan.kis...@siemens.com Date: Wed Jul 29 17:30:47 2015 +0200 kernel/cobalt: Add reason to gorelax trace point Trace and print the name of the relaxation reason whenever available. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- kernel/cobalt/thread.c|2 +- kernel/cobalt/trace/cobalt-core.h | 26 +++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c index 4cec6e7..2d1f840 100644 --- a/kernel/cobalt/thread.c +++ b/kernel/cobalt/thread.c @@ -1997,7 +1997,7 @@ void xnthread_relax(int notify, int reason) * domain to the Linux domain. This will cause the Linux task * to resume using the register state of the shadow thread. */ - trace_cobalt_shadow_gorelax(thread); + trace_cobalt_shadow_gorelax(thread, reason); /* * If you intend to change the following interrupt-free diff --git a/kernel/cobalt/trace/cobalt-core.h b/kernel/cobalt/trace/cobalt-core.h index ee20b7c..d2b1c7e 100644 --- a/kernel/cobalt/trace/cobalt-core.h +++ b/kernel/cobalt/trace/cobalt-core.h @@ -357,9 +357,29 @@ DEFINE_EVENT(thread_event, cobalt_shadow_hardened, TP_ARGS(thread) ); -DEFINE_EVENT(thread_event, cobalt_shadow_gorelax, - TP_PROTO(struct xnthread *thread), - TP_ARGS(thread) +#define cobalt_print_relax_reason(reason) \ + __print_symbolic(reason,\ +{ SIGDEBUG_UNDEFINED, undefined }, \ +{ SIGDEBUG_MIGRATE_SIGNAL, signal }, \ +{ SIGDEBUG_MIGRATE_SYSCALL,syscall },\ +{ SIGDEBUG_MIGRATE_FAULT, fault }) + +TRACE_EVENT(cobalt_shadow_gorelax, + TP_PROTO(struct xnthread *thread, int reason), + TP_ARGS(thread, reason), + + TP_STRUCT__entry( + __field(struct xnthread *, thread) + __field(int, reason) + ), + + TP_fast_assign( + __entry-thread = thread; + __entry-reason = reason; + ), + + TP_printk(thread=%p reason=%s, + __entry-thread, cobalt_print_relax_reason(__entry-reason)) ); DEFINE_EVENT(thread_event, cobalt_shadow_relaxed, ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://xenomai.org/mailman/listinfo/xenomai-git