Module: xenomai-3 Branch: wip/drivers Commit: b9642fc43473d91d11a16baee1ce0b1aaa1ec1f1 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b9642fc43473d91d11a16baee1ce0b1aaa1ec1f1
Author: Philippe Gerum <r...@xenomai.org> Date: Mon Nov 14 11:49:09 2016 +0100 cobalt/timer: consider clock event affinity when pinning timers Pinning a timer to the same CPU than the caller is affine to must take into account the affinity of the clock device backing the timer. When an affinity mismatch is detected by xntimer_set_sched(), the timer affinity is left unchanged, which will certainly cause additional overhead due to the requirement of waking up a thread on a remote CPU from the timer's handler, but will also keep the situation sane. --- include/cobalt/kernel/timer.h | 7 ++----- kernel/cobalt/timer.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/cobalt/kernel/timer.h b/include/cobalt/kernel/timer.h index 6cb2bb3..700392e 100644 --- a/include/cobalt/kernel/timer.h +++ b/include/cobalt/kernel/timer.h @@ -546,11 +546,8 @@ static inline void xntimer_release_ipi(void) { } #endif /* CONFIG_SMP */ -static inline void xntimer_set_sched(struct xntimer *timer, - struct xnsched *sched) -{ - xntimer_migrate(timer, sched); -} +bool xntimer_set_sched(struct xntimer *timer, + struct xnsched *sched); char *xntimer_format_time(xnticks_t ns, char *buf, size_t bufsz); diff --git a/kernel/cobalt/timer.c b/kernel/cobalt/timer.c index dd78c38..6263f5b 100644 --- a/kernel/cobalt/timer.c +++ b/kernel/cobalt/timer.c @@ -541,6 +541,23 @@ void __xntimer_migrate(struct xntimer *timer, struct xnsched *sched) } EXPORT_SYMBOL_GPL(__xntimer_migrate); +bool xntimer_set_sched(struct xntimer *timer, + struct xnsched *sched) +{ + /* + * We may deny the request if the target CPU does not receive + * any event from the clock device backing the timer. + */ + if (cpumask_test_cpu(xnsched_cpu(sched), + &xntimer_clock(timer)->affinity)) { + xntimer_migrate(timer, sched); + return true; + } + + return false; +} +EXPORT_SYMBOL_GPL(xntimer_set_sched); + int xntimer_setup_ipi(void) { return ipipe_request_irq(&xnsched_realtime_domain, _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git