[Xenomai-git] Philippe Gerum : cobalt/sched: return overall quota reservation in SCHED_QUOTA ops
Module: xenomai-forge Branch: next Commit: f16dca16d635a5283b446accb9ef5c4632922051 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=f16dca16d635a5283b446accb9ef5c4632922051 Author: Philippe Gerum r...@xenomai.org Date: Wed May 28 11:49:06 2014 +0200 cobalt/sched: return overall quota reservation in SCHED_QUOTA ops --- include/cobalt/kernel/sched-quota.h | 11 +-- include/cobalt/uapi/sched.h |1 + kernel/cobalt/posix/thread.c| 40 +++--- kernel/cobalt/sched-quota.c | 62 ++- testsuite/unit/sched-quota.c|7 ++-- 5 files changed, 88 insertions(+), 33 deletions(-) diff --git a/include/cobalt/kernel/sched-quota.h b/include/cobalt/kernel/sched-quota.h index 381f8cb..97d2387 100644 --- a/include/cobalt/kernel/sched-quota.h +++ b/include/cobalt/kernel/sched-quota.h @@ -66,16 +66,21 @@ static inline int xnsched_quota_init_thread(struct xnthread *thread) } int xnsched_quota_create_group(struct xnsched_quota_group *tg, - struct xnsched *sched); + struct xnsched *sched, + int *quota_sum_r); -int xnsched_quota_destroy_group(struct xnsched_quota_group *tg); +int xnsched_quota_destroy_group(struct xnsched_quota_group *tg, + int *quota_sum_r); void xnsched_quota_set_limit(struct xnsched_quota_group *tg, -int quota_percent, int quota_peak_percent); +int quota_percent, int quota_peak_percent, +int *quota_sum_r); struct xnsched_quota_group * xnsched_quota_find_group(struct xnsched *sched, int tgid); +int xnsched_quota_sum_all(struct xnsched *sched); + #endif /* !CONFIG_XENO_OPT_SCHED_QUOTA */ #endif /* !_COBALT_KERNEL_SCHED_QUOTA_H */ diff --git a/include/cobalt/uapi/sched.h b/include/cobalt/uapi/sched.h index 11bbc1a..99f0f98 100644 --- a/include/cobalt/uapi/sched.h +++ b/include/cobalt/uapi/sched.h @@ -83,6 +83,7 @@ enum { struct __sched_config_quota { int op; + int *sum_r; struct { int *tgid_r; } add; diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c index 41fcd5d..b791d59 100644 --- a/kernel/cobalt/posix/thread.c +++ b/kernel/cobalt/posix/thread.c @@ -1453,10 +1453,10 @@ get_tp_config(int cpu, union sched_config __user *u_config, #ifdef CONFIG_XENO_OPT_SCHED_QUOTA static inline -int set_quota_config(int cpu, const union sched_config *config, size_t len) +int do_quota_config(int cpu, const union sched_config *config, size_t len) { + int ret = -ESRCH, quota_percent, quota_peak_percent, quota_sum; const struct __sched_config_quota *p = config-quota; - int ret = -ESRCH, quota_percent, quota_peak_percent; struct xnsched_quota_group *tg; struct xnsched *sched; spl_t s; @@ -1470,13 +1470,17 @@ int set_quota_config(int cpu, const union sched_config *config, size_t len) return -ENOMEM; xnlock_get_irqsave(nklock, s); sched = xnsched_struct(cpu); - ret = xnsched_quota_create_group(tg, sched); + ret = xnsched_quota_create_group(tg, sched, quota_sum); xnlock_put_irqrestore(nklock, s); - if (ret == 0) - ret = __xn_safe_copy_to_user(p-add.tgid_r, tg-tgid, -sizeof(tg-tgid)); if (ret) xnfree(tg); + else { + ret = __xn_safe_copy_to_user(p-add.tgid_r, tg-tgid, +sizeof(tg-tgid)); + if (ret == 0 p-sum_r) + ret = __xn_safe_copy_to_user(p-sum_r, quota_sum, +sizeof(quota_sum)); + } return ret; } @@ -1485,10 +1489,14 @@ int set_quota_config(int cpu, const union sched_config *config, size_t len) sched = xnsched_struct(cpu); tg = xnsched_quota_find_group(sched, p-remove.tgid); if (tg) { - ret = xnsched_quota_destroy_group(tg); + ret = xnsched_quota_destroy_group(tg, quota_sum); xnlock_put_irqrestore(nklock, s); - if (ret == 0) + if (ret == 0) { xnfree(tg); + if (p-sum_r) + ret = __xn_safe_copy_to_user(p-sum_r, quota_sum, + sizeof(quota_sum)); + } return ret; } xnlock_put_irqrestore(nklock, s); @@ -1502,10 +1510,14 @@ int
[Xenomai-git] Philippe Gerum : cobalt/sched: fix error path in xnsched_quota_find_group( )
Module: xenomai-forge Branch: next Commit: 5a5b08817bacbd1920c6561fac5a199bc51a19cc URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=5a5b08817bacbd1920c6561fac5a199bc51a19cc Author: Philippe Gerum r...@xenomai.org Date: Wed May 28 17:06:14 2014 +0200 cobalt/sched: fix error path in xnsched_quota_find_group() --- kernel/cobalt/sched-quota.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/cobalt/sched-quota.c b/kernel/cobalt/sched-quota.c index 5dd9db8..a932ac4 100644 --- a/kernel/cobalt/sched-quota.c +++ b/kernel/cobalt/sched-quota.c @@ -596,7 +596,7 @@ xnsched_quota_find_group(struct xnsched *sched, int tgid) return tg; } - return tg; + return NULL; } EXPORT_SYMBOL_GPL(xnsched_quota_find_group); ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/kernel: drop 'any domain' exec mode bit for syscalls
Module: xenomai-forge Branch: next Commit: b43e8facdb34fa3f9509b02bb8c5e8ca13c50e64 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=b43e8facdb34fa3f9509b02bb8c5e8ca13c50e64 Author: Philippe Gerum r...@xenomai.org Date: Wed May 28 15:09:57 2014 +0200 cobalt/kernel: drop 'any domain' exec mode bit for syscalls This mode is wrong by design for callers issuing syscalls from secondary mode: thread[relaxed] syscall[harden] handle_head_syscall() syscall-handler !access-fault! kernel-page-fault-handler handle_exception() ...root caller, won't migrate... !secondary-only code traversed in primary mode! The access fault could be triggered by any copy_to/from_user() present in the syscall handler, which means from most of them. The only sane and safe exec mode bit for such case is 'current', which won't cause any overhead to Xenomai threads already running in primary mode when issuing the syscall. Other contexts will have to roll back from primary to secondary mode via pipeline propagation (i.e. EVENT_PROPAGATE) before the syscall handler may run. --- .../cobalt/include/asm-generic/xenomai/syscall.h |6 +- kernel/cobalt/posix/syscall.c | 106 ++-- kernel/cobalt/shadow.c | 35 +++ 3 files changed, 70 insertions(+), 77 deletions(-) diff --git a/kernel/cobalt/include/asm-generic/xenomai/syscall.h b/kernel/cobalt/include/asm-generic/xenomai/syscall.h index dcf6df7..2865778 100644 --- a/kernel/cobalt/include/asm-generic/xenomai/syscall.h +++ b/kernel/cobalt/include/asm-generic/xenomai/syscall.h @@ -42,7 +42,7 @@ struct xnsyscall { #define __xn_exec_lostage0x1 /* Syscall must run into the Xenomai domain. */ #define __xn_exec_histage0x2 -/* Shadow syscall; caller must be mapped. */ +/* Shadow syscall: caller must be mapped. */ #define __xn_exec_shadow 0x4 /* Switch back toggle; caller must return to its original mode. */ #define __xn_exec_switchback 0x8 @@ -54,8 +54,6 @@ struct xnsyscall { #define __xn_exec_adaptive 0x40 /* Do not restart syscall upon signal receipt. */ #define __xn_exec_norestart 0x80 -/* Context-agnostic syscall. Will actually run in Xenomai domain. */ -#define __xn_exec_any0x0 /* Shorthand for shadow init syscall. */ #define __xn_exec_init __xn_exec_lostage /* Shorthand for shadow syscall in Xenomai space. */ @@ -69,7 +67,7 @@ struct xnsyscall { /* Shorthand for domain probing syscall */ #define __xn_exec_probing (__xn_exec_current|__xn_exec_adaptive) /* Shorthand for oneway trap - does not return to call site. */ -#define __xn_exec_oneway(__xn_exec_any|__xn_exec_norestart) +#define __xn_exec_oneway__xn_exec_norestart unsigned long flags; }; diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c index 52e9f8c..4c79f01 100644 --- a/kernel/cobalt/posix/syscall.c +++ b/kernel/cobalt/posix/syscall.c @@ -89,49 +89,49 @@ static struct xnsyscall cobalt_syscalls[] = { [0 ... __NR_COBALT_SYSCALLS-1] = SKINCALL_NI, SKINCALL_DEF(sc_cobalt_thread_create, cobalt_thread_create, init), SKINCALL_DEF(sc_cobalt_thread_setschedparam_ex, cobalt_thread_setschedparam_ex, conforming), - SKINCALL_DEF(sc_cobalt_thread_getschedparam_ex, cobalt_thread_getschedparam_ex, any), - SKINCALL_DEF(sc_cobalt_sched_weightprio, cobalt_sched_weighted_prio, any), + SKINCALL_DEF(sc_cobalt_thread_getschedparam_ex, cobalt_thread_getschedparam_ex, current), + SKINCALL_DEF(sc_cobalt_sched_weightprio, cobalt_sched_weighted_prio, current), SKINCALL_DEF(sc_cobalt_sched_yield, cobalt_sched_yield, primary), SKINCALL_DEF(sc_cobalt_thread_make_periodic, cobalt_thread_make_periodic_np, conforming), SKINCALL_DEF(sc_cobalt_thread_wait, cobalt_thread_wait_np, primary), SKINCALL_DEF(sc_cobalt_thread_set_mode, cobalt_thread_set_mode_np, primary), - SKINCALL_DEF(sc_cobalt_thread_set_name, cobalt_thread_set_name_np, any), + SKINCALL_DEF(sc_cobalt_thread_set_name, cobalt_thread_set_name_np, current), SKINCALL_DEF(sc_cobalt_thread_kill, cobalt_thread_kill, conforming), - SKINCALL_DEF(sc_cobalt_thread_getstat, cobalt_thread_stat, any), + SKINCALL_DEF(sc_cobalt_thread_getstat, cobalt_thread_stat, current), SKINCALL_DEF(sc_cobalt_thread_join, cobalt_thread_join, primary), - SKINCALL_DEF(sc_cobalt_sem_init, cobalt_sem_init, any), - SKINCALL_DEF(sc_cobalt_sem_destroy, cobalt_sem_destroy, any), - SKINCALL_DEF(sc_cobalt_sem_post, cobalt_sem_post, any), + SKINCALL_DEF(sc_cobalt_sem_init, cobalt_sem_init, current), + SKINCALL_DEF(sc_cobalt_sem_destroy, cobalt_sem_destroy, current), + SKINCALL_DEF(sc_cobalt_sem_post, cobalt_sem_post, current),
[Xenomai-git] Jorge Ramirez-Ortiz : utils/analogy: add extra debug info to errors
Module: xenomai-forge Branch: next Commit: ae896db38b17bc9e29166b65794380ffb4f46a1f URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=ae896db38b17bc9e29166b65794380ffb4f46a1f Author: Jorge Ramirez-Ortiz j...@xenomai.org Date: Wed May 28 11:40:39 2014 -0400 utils/analogy: add extra debug info to errors --- utils/analogy/analogy_config.c | 35 +-- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/utils/analogy/analogy_config.c b/utils/analogy/analogy_config.c index 3642d50..88c1752 100644 --- a/utils/analogy/analogy_config.c +++ b/utils/analogy/analogy_config.c @@ -29,6 +29,10 @@ #include xeno_config.h #include rtdm/analogy.h +#define RTDM_DEVICES_PROC /proc/xenomai/rtdm/named_devices +#define ANALOGY_DRIVERS_PROC /proc/analogy/drivers +#define ANALOGY_DEVICES_PROC /proc/analogy/devices + #define __OPTS_DELIMITER , enum actions { @@ -207,8 +211,9 @@ int main(int argc, char *argv[]) !(actions DO_BUFCONFIG) argc - optind 2) { do_print_usage(); goto out_a4l_config; - } else if (!(actions DO_DETACH) argc - optind = 2) + } else if (!(actions DO_DETACH) argc - optind = 2) { actions |= DO_ATTACH; + } /* Whatever the action, we need to retrieve the device path */ devfile = argv[optind]; @@ -219,23 +224,23 @@ int main(int argc, char *argv[]) if (fd 0) { err = fd; fprintf(stderr, - analogy_config: a4l_open failed err=%d\n, err); + analogy_config: a4l_open(%s) failed err=%d\n, devfile, + err); goto out_a4l_config; } if (actions DO_DETACH) { - err = a4l_sys_detach(fd); if (err 0) fprintf(stderr, - analogy_config: detach failed err=%d\n, err); + analogy_config: a4l_detach(%s) failed err=%d\n, + devfile, err); goto out_a4l_config; } if (actions DO_ATTACH) { a4l_lnkdesc_t lnkdsc; - memset(lnkdsc, 0, sizeof(a4l_lnkdesc_t)); /* Fill the descriptor with the driver name */ @@ -244,17 +249,17 @@ int main(int argc, char *argv[]) /* Process driver-specific options */ if (argc - optind == 3) { - err = process_extra_arg(lnkdsc, argv[optind + 2]); if (err 0) goto out_a4l_config; } - /* Go... */ + /* Go...*/ err = a4l_sys_attach(fd, lnkdsc); if (err 0) { fprintf(stderr, - analogy_config: attach failed err=%d\n, err); + analogy_config: a4l_attach(%s) failed err=%d\n, + lnkdsc.bname, err); goto out_a4l_config; } @@ -267,13 +272,23 @@ int main(int argc, char *argv[]) err = a4l_sys_bufcfg(fd, A4L_BUF_DEFMAGIC, bufsize); if (err 0) { fprintf(stderr, - analogy_config: bufffer configuraiton failed - (err=%d)\n, err); + analogy_config: a4l_bufcfg(%s) configuration failed + err=%d\n, devfile, err); goto out_a4l_config; } } out_a4l_config: +if (err 0) { + fprintf(stderr, + analogy_config: please chek the rtdm and analogy procs \n +- rtdm devices:%s \n +- analogy devices: %s \n +- analogy drivers: %s \n, + RTDM_DEVICES_PROC, + ANALOGY_DEVICES_PROC, + ANALOGY_DRIVERS_PROC); + } if (fd = 0) a4l_sys_close(fd); ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git