[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release
Module: xenomai-3 Branch: next Commit: 2d94d984e9c4109c6b6252f123e30e53f97199a6 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2d94d984e9c4109c6b6252f123e30e53f97199a6 Author: Jan KiszkaDate: Mon May 9 21:19:04 2016 +0200 cobalt/kernel: Return need_resched flag from xnsynch_release We currently return the next owner, but no caller of xnsynch_release evaluates this beyond != NULL and calls xnsched_run in that case. Simplify the API by returning a need_resched flag directly. This will also help with fixing the missing reschedule after PP deboost. Signed-off-by: Jan Kiszka --- include/cobalt/kernel/synch.h |3 +-- kernel/cobalt/posix/mutex.c |2 +- kernel/cobalt/rtdm/drvlib.c |2 +- kernel/cobalt/synch.c | 23 +++ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 246d2b9..b3a8004 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -164,8 +164,7 @@ int __must_check xnsynch_acquire(struct xnsynch *synch, int __must_check xnsynch_try_acquire(struct xnsynch *synch); -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *thread); +bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread); struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch); diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c index c6020ff..f99874b 100644 --- a/kernel/cobalt/posix/mutex.c +++ b/kernel/cobalt/posix/mutex.c @@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr, cobalt_cond_deferred_signals(cond); } } - need_resched |= xnsynch_release(>synchbase, curr) != NULL; + need_resched |= xnsynch_release(>synchbase, curr); return need_resched; } diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index 248a9a8..6f4f51e 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex) trace_cobalt_driver_mutex_release(mutex); if (unlikely(xnsynch_release(>synch_base, -xnsched_current_thread()) != NULL)) +xnsched_current_thread( xnsched_run(); } EXPORT_SYMBOL_GPL(rtdm_mutex_unlock); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 976261d..d8b83d9 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch, drop_booster(synch, owner); } -static struct xnthread *transfer_ownership(struct xnsynch *synch, - struct xnthread *lastowner) +static bool transfer_ownership(struct xnsynch *synch, + struct xnthread *lastowner) { /* nklock held, irqs off */ struct xnthread *nextowner; xnhandle_t nextownerh; @@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, if (list_empty(>pendq)) { synch->owner = NULL; atomic_set(lockp, XN_NO_HANDLE); - return NULL; + return false; } nextowner = list_first_entry(>pendq, struct xnthread, plink); @@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, atomic_set(lockp, nextownerh); - return nextowner; + return true; } /** - * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread *curr) + * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) * @brief Release a resource and pass it to the next waiting thread. * * This service releases the ownership of the given synchronization @@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * @param curr The descriptor address of the current thread, which * must own the object at the time of calling. * - * @return The descriptor address of the unblocked thread. + * @return True if a reschedule is required. * * @sideeffect * @@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * * @coretags{primary-only, might-switch} */ -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *curr) +bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) { - struct xnthread *nextowner = NULL; + bool need_resched = false; xnhandle_t currh, h; atomic_t *lockp; spl_t s; @@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, trace_cobalt_synch_release(synch); if (xnthread_put_resource(curr)) - return NULL; +
[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release
Module: xenomai-3 Branch: next Commit: 76e56e4744a957a3acd54ad5428b6ce55871c06a URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=76e56e4744a957a3acd54ad5428b6ce55871c06a Author: Jan KiszkaDate: Mon May 9 21:19:04 2016 +0200 cobalt/kernel: Return need_resched flag from xnsynch_release We currently return the next owner, but no caller of xnsynch_release evaluates this beyond != NULL and calls xnsched_run in that case. Simplify the API by returning a need_resched flag directly. This will also help with fixing the missing reschedule after PP deboost. Signed-off-by: Jan Kiszka --- include/cobalt/kernel/synch.h |3 +-- kernel/cobalt/posix/mutex.c |2 +- kernel/cobalt/rtdm/drvlib.c |2 +- kernel/cobalt/synch.c | 23 +++ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 246d2b9..b3a8004 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -164,8 +164,7 @@ int __must_check xnsynch_acquire(struct xnsynch *synch, int __must_check xnsynch_try_acquire(struct xnsynch *synch); -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *thread); +bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread); struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch); diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c index c6020ff..f99874b 100644 --- a/kernel/cobalt/posix/mutex.c +++ b/kernel/cobalt/posix/mutex.c @@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr, cobalt_cond_deferred_signals(cond); } } - need_resched |= xnsynch_release(>synchbase, curr) != NULL; + need_resched |= xnsynch_release(>synchbase, curr); return need_resched; } diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index 248a9a8..6f4f51e 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex) trace_cobalt_driver_mutex_release(mutex); if (unlikely(xnsynch_release(>synch_base, -xnsched_current_thread()) != NULL)) +xnsched_current_thread( xnsched_run(); } EXPORT_SYMBOL_GPL(rtdm_mutex_unlock); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 976261d..d8b83d9 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch, drop_booster(synch, owner); } -static struct xnthread *transfer_ownership(struct xnsynch *synch, - struct xnthread *lastowner) +static bool transfer_ownership(struct xnsynch *synch, + struct xnthread *lastowner) { /* nklock held, irqs off */ struct xnthread *nextowner; xnhandle_t nextownerh; @@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, if (list_empty(>pendq)) { synch->owner = NULL; atomic_set(lockp, XN_NO_HANDLE); - return NULL; + return false; } nextowner = list_first_entry(>pendq, struct xnthread, plink); @@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, atomic_set(lockp, nextownerh); - return nextowner; + return true; } /** - * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread *curr) + * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) * @brief Release a resource and pass it to the next waiting thread. * * This service releases the ownership of the given synchronization @@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * @param curr The descriptor address of the current thread, which * must own the object at the time of calling. * - * @return The descriptor address of the unblocked thread. + * @return True if a reschedule is required. * * @sideeffect * @@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * * @coretags{primary-only, might-switch} */ -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *curr) +bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) { - struct xnthread *nextowner = NULL; + bool need_resched = false; xnhandle_t currh, h; atomic_t *lockp; spl_t s; @@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, trace_cobalt_synch_release(synch); if (xnthread_put_resource(curr)) - return NULL; +
[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release
Module: xenomai-3 Branch: next Commit: 177f2e0f854627e252f32ee37be9f3441c1c4d11 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=177f2e0f854627e252f32ee37be9f3441c1c4d11 Author: Jan KiszkaDate: Mon May 9 21:19:04 2016 +0200 cobalt/kernel: Return need_resched flag from xnsynch_release We currently return the next owner, but no caller of xnsynch_release evaluates this beyond != NULL and calls xnsched_run in that case. Simplify the API by returning a need_resched flag directly. This will also help with fixing the missing reschedule after PP deboost. Signed-off-by: Jan Kiszka --- include/cobalt/kernel/synch.h |3 +-- kernel/cobalt/posix/mutex.c |2 +- kernel/cobalt/rtdm/drvlib.c |2 +- kernel/cobalt/synch.c | 23 +++ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 246d2b9..b3a8004 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -164,8 +164,7 @@ int __must_check xnsynch_acquire(struct xnsynch *synch, int __must_check xnsynch_try_acquire(struct xnsynch *synch); -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *thread); +bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread); struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch); diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c index c6020ff..f99874b 100644 --- a/kernel/cobalt/posix/mutex.c +++ b/kernel/cobalt/posix/mutex.c @@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr, cobalt_cond_deferred_signals(cond); } } - need_resched |= xnsynch_release(>synchbase, curr) != NULL; + need_resched |= xnsynch_release(>synchbase, curr); return need_resched; } diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index 248a9a8..6f4f51e 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex) trace_cobalt_driver_mutex_release(mutex); if (unlikely(xnsynch_release(>synch_base, -xnsched_current_thread()) != NULL)) +xnsched_current_thread( xnsched_run(); } EXPORT_SYMBOL_GPL(rtdm_mutex_unlock); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 976261d..d8b83d9 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch, drop_booster(synch, owner); } -static struct xnthread *transfer_ownership(struct xnsynch *synch, - struct xnthread *lastowner) +static bool transfer_ownership(struct xnsynch *synch, + struct xnthread *lastowner) { /* nklock held, irqs off */ struct xnthread *nextowner; xnhandle_t nextownerh; @@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, if (list_empty(>pendq)) { synch->owner = NULL; atomic_set(lockp, XN_NO_HANDLE); - return NULL; + return false; } nextowner = list_first_entry(>pendq, struct xnthread, plink); @@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, atomic_set(lockp, nextownerh); - return nextowner; + return true; } /** - * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread *curr) + * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) * @brief Release a resource and pass it to the next waiting thread. * * This service releases the ownership of the given synchronization @@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * @param curr The descriptor address of the current thread, which * must own the object at the time of calling. * - * @return The descriptor address of the unblocked thread. + * @return True if a reschedule is required. * * @sideeffect * @@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * * @coretags{primary-only, might-switch} */ -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *curr) +bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) { - struct xnthread *nextowner = NULL; + bool need_resched = false; xnhandle_t currh, h; atomic_t *lockp; spl_t s; @@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, trace_cobalt_synch_release(synch); if (xnthread_put_resource(curr)) - return NULL; +
[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release
Module: xenomai-3 Branch: next Commit: 4ad97c36455a66fc2916547918fee54ea17dc079 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4ad97c36455a66fc2916547918fee54ea17dc079 Author: Jan KiszkaDate: Mon May 9 21:19:04 2016 +0200 cobalt/kernel: Return need_resched flag from xnsynch_release We currently return the next owner, but no caller of xnsynch_release evaluates this beyond != NULL and calls xnsched_run in that case. Simplify the API by returning a need_resched flag directly. This will also help with fixing the missing reschedule after PP deboost. Signed-off-by: Jan Kiszka --- include/cobalt/kernel/synch.h |3 +-- kernel/cobalt/posix/mutex.c |2 +- kernel/cobalt/rtdm/drvlib.c |2 +- kernel/cobalt/synch.c | 23 +++ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 246d2b9..b3a8004 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -164,8 +164,7 @@ int __must_check xnsynch_acquire(struct xnsynch *synch, int __must_check xnsynch_try_acquire(struct xnsynch *synch); -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *thread); +bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread); struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch); diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c index c6020ff..f99874b 100644 --- a/kernel/cobalt/posix/mutex.c +++ b/kernel/cobalt/posix/mutex.c @@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr, cobalt_cond_deferred_signals(cond); } } - need_resched |= xnsynch_release(>synchbase, curr) != NULL; + need_resched |= xnsynch_release(>synchbase, curr); return need_resched; } diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index 7abdb1e..4808b93 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex) trace_cobalt_driver_mutex_release(mutex); if (unlikely(xnsynch_release(>synch_base, -xnsched_current_thread()) != NULL)) +xnsched_current_thread( xnsched_run(); } EXPORT_SYMBOL_GPL(rtdm_mutex_unlock); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 976261d..d8b83d9 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch, drop_booster(synch, owner); } -static struct xnthread *transfer_ownership(struct xnsynch *synch, - struct xnthread *lastowner) +static bool transfer_ownership(struct xnsynch *synch, + struct xnthread *lastowner) { /* nklock held, irqs off */ struct xnthread *nextowner; xnhandle_t nextownerh; @@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, if (list_empty(>pendq)) { synch->owner = NULL; atomic_set(lockp, XN_NO_HANDLE); - return NULL; + return false; } nextowner = list_first_entry(>pendq, struct xnthread, plink); @@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, atomic_set(lockp, nextownerh); - return nextowner; + return true; } /** - * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread *curr) + * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) * @brief Release a resource and pass it to the next waiting thread. * * This service releases the ownership of the given synchronization @@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * @param curr The descriptor address of the current thread, which * must own the object at the time of calling. * - * @return The descriptor address of the unblocked thread. + * @return True if a reschedule is required. * * @sideeffect * @@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * * @coretags{primary-only, might-switch} */ -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *curr) +bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) { - struct xnthread *nextowner = NULL; + bool need_resched = false; xnhandle_t currh, h; atomic_t *lockp; spl_t s; @@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, trace_cobalt_synch_release(synch); if (xnthread_put_resource(curr)) - return NULL; +
[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release
Module: xenomai-3 Branch: next Commit: a5a2d7174dd40553d68bf4ebe276285e6606fe45 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a5a2d7174dd40553d68bf4ebe276285e6606fe45 Author: Jan KiszkaDate: Mon May 9 21:19:04 2016 +0200 cobalt/kernel: Return need_resched flag from xnsynch_release We currently return the next owner, but no caller of xnsynch_release evaluates this beyond != NULL and calls xnsched_run in that case. Simplify the API by returning a need_resched flag directly. This will also help with fixing the missing reschedule after PP deboost. Signed-off-by: Jan Kiszka --- include/cobalt/kernel/synch.h |3 +-- kernel/cobalt/posix/mutex.c |2 +- kernel/cobalt/rtdm/drvlib.c |2 +- kernel/cobalt/synch.c | 23 +++ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 246d2b9..b3a8004 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -164,8 +164,7 @@ int __must_check xnsynch_acquire(struct xnsynch *synch, int __must_check xnsynch_try_acquire(struct xnsynch *synch); -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *thread); +bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread); struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch); diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c index c6020ff..f99874b 100644 --- a/kernel/cobalt/posix/mutex.c +++ b/kernel/cobalt/posix/mutex.c @@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr, cobalt_cond_deferred_signals(cond); } } - need_resched |= xnsynch_release(>synchbase, curr) != NULL; + need_resched |= xnsynch_release(>synchbase, curr); return need_resched; } diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index 7abdb1e..4808b93 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex) trace_cobalt_driver_mutex_release(mutex); if (unlikely(xnsynch_release(>synch_base, -xnsched_current_thread()) != NULL)) +xnsched_current_thread( xnsched_run(); } EXPORT_SYMBOL_GPL(rtdm_mutex_unlock); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 976261d..d8b83d9 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch, drop_booster(synch, owner); } -static struct xnthread *transfer_ownership(struct xnsynch *synch, - struct xnthread *lastowner) +static bool transfer_ownership(struct xnsynch *synch, + struct xnthread *lastowner) { /* nklock held, irqs off */ struct xnthread *nextowner; xnhandle_t nextownerh; @@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, if (list_empty(>pendq)) { synch->owner = NULL; atomic_set(lockp, XN_NO_HANDLE); - return NULL; + return false; } nextowner = list_first_entry(>pendq, struct xnthread, plink); @@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, atomic_set(lockp, nextownerh); - return nextowner; + return true; } /** - * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread *curr) + * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) * @brief Release a resource and pass it to the next waiting thread. * * This service releases the ownership of the given synchronization @@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * @param curr The descriptor address of the current thread, which * must own the object at the time of calling. * - * @return The descriptor address of the unblocked thread. + * @return True if a reschedule is required. * * @sideeffect * @@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * * @coretags{primary-only, might-switch} */ -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *curr) +bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) { - struct xnthread *nextowner = NULL; + bool need_resched = false; xnhandle_t currh, h; atomic_t *lockp; spl_t s; @@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, trace_cobalt_synch_release(synch); if (xnthread_put_resource(curr)) - return NULL; +
[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release
Module: xenomai-3 Branch: next Commit: d5dcfdcd72a77d8c88bd2825450565c4f07cb7c9 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d5dcfdcd72a77d8c88bd2825450565c4f07cb7c9 Author: Jan KiszkaDate: Mon May 9 21:19:04 2016 +0200 cobalt/kernel: Return need_resched flag from xnsynch_release We currently return the next owner, but no caller of xnsynch_release evaluates this beyond != NULL and calls xnsched_run in that case. Simplify the API by returning a need_resched flag directly. This will also help with fixing the missing reschedule after PP deboost. Signed-off-by: Jan Kiszka --- include/cobalt/kernel/synch.h |3 +-- kernel/cobalt/posix/mutex.c |2 +- kernel/cobalt/rtdm/drvlib.c |2 +- kernel/cobalt/synch.c | 23 +++ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 246d2b9..b3a8004 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -164,8 +164,7 @@ int __must_check xnsynch_acquire(struct xnsynch *synch, int __must_check xnsynch_try_acquire(struct xnsynch *synch); -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *thread); +bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread); struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch); diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c index c6020ff..f99874b 100644 --- a/kernel/cobalt/posix/mutex.c +++ b/kernel/cobalt/posix/mutex.c @@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr, cobalt_cond_deferred_signals(cond); } } - need_resched |= xnsynch_release(>synchbase, curr) != NULL; + need_resched |= xnsynch_release(>synchbase, curr); return need_resched; } diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index 7abdb1e..4808b93 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex) trace_cobalt_driver_mutex_release(mutex); if (unlikely(xnsynch_release(>synch_base, -xnsched_current_thread()) != NULL)) +xnsched_current_thread( xnsched_run(); } EXPORT_SYMBOL_GPL(rtdm_mutex_unlock); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 976261d..d8b83d9 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch, drop_booster(synch, owner); } -static struct xnthread *transfer_ownership(struct xnsynch *synch, - struct xnthread *lastowner) +static bool transfer_ownership(struct xnsynch *synch, + struct xnthread *lastowner) { /* nklock held, irqs off */ struct xnthread *nextowner; xnhandle_t nextownerh; @@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, if (list_empty(>pendq)) { synch->owner = NULL; atomic_set(lockp, XN_NO_HANDLE); - return NULL; + return false; } nextowner = list_first_entry(>pendq, struct xnthread, plink); @@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, atomic_set(lockp, nextownerh); - return nextowner; + return true; } /** - * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread *curr) + * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) * @brief Release a resource and pass it to the next waiting thread. * * This service releases the ownership of the given synchronization @@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * @param curr The descriptor address of the current thread, which * must own the object at the time of calling. * - * @return The descriptor address of the unblocked thread. + * @return True if a reschedule is required. * * @sideeffect * @@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * * @coretags{primary-only, might-switch} */ -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *curr) +bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) { - struct xnthread *nextowner = NULL; + bool need_resched = false; xnhandle_t currh, h; atomic_t *lockp; spl_t s; @@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, trace_cobalt_synch_release(synch); if (xnthread_put_resource(curr)) - return NULL; +
[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release
Module: xenomai-3 Branch: next Commit: a8a02df98d9a217c5b383202f8d38f1867c5a956 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a8a02df98d9a217c5b383202f8d38f1867c5a956 Author: Jan KiszkaDate: Mon May 9 21:19:04 2016 +0200 cobalt/kernel: Return need_resched flag from xnsynch_release We currently return the next owner, but no caller of xnsynch_release evaluates this beyond != NULL and calls xnsched_run in that case. Simplify the API by returning a need_resched flag directly. This will also help with fixing the missing reschedule after PP deboost. Signed-off-by: Jan Kiszka --- include/cobalt/kernel/synch.h |3 +-- kernel/cobalt/posix/mutex.c |2 +- kernel/cobalt/rtdm/drvlib.c |2 +- kernel/cobalt/synch.c | 23 +++ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 04d7f10..1e99c18 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -164,8 +164,7 @@ int xnsynch_acquire(struct xnsynch *synch, int xnsynch_try_acquire(struct xnsynch *synch); -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *thread); +bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread); struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch); diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c index c6020ff..f99874b 100644 --- a/kernel/cobalt/posix/mutex.c +++ b/kernel/cobalt/posix/mutex.c @@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr, cobalt_cond_deferred_signals(cond); } } - need_resched |= xnsynch_release(>synchbase, curr) != NULL; + need_resched |= xnsynch_release(>synchbase, curr); return need_resched; } diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index 7abdb1e..4808b93 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex) trace_cobalt_driver_mutex_release(mutex); if (unlikely(xnsynch_release(>synch_base, -xnsched_current_thread()) != NULL)) +xnsched_current_thread( xnsched_run(); } EXPORT_SYMBOL_GPL(rtdm_mutex_unlock); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 976261d..d8b83d9 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch, drop_booster(synch, owner); } -static struct xnthread *transfer_ownership(struct xnsynch *synch, - struct xnthread *lastowner) +static bool transfer_ownership(struct xnsynch *synch, + struct xnthread *lastowner) { /* nklock held, irqs off */ struct xnthread *nextowner; xnhandle_t nextownerh; @@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, if (list_empty(>pendq)) { synch->owner = NULL; atomic_set(lockp, XN_NO_HANDLE); - return NULL; + return false; } nextowner = list_first_entry(>pendq, struct xnthread, plink); @@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, atomic_set(lockp, nextownerh); - return nextowner; + return true; } /** - * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread *curr) + * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) * @brief Release a resource and pass it to the next waiting thread. * * This service releases the ownership of the given synchronization @@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * @param curr The descriptor address of the current thread, which * must own the object at the time of calling. * - * @return The descriptor address of the unblocked thread. + * @return True if a reschedule is required. * * @sideeffect * @@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * * @coretags{primary-only, might-switch} */ -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *curr) +bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) { - struct xnthread *nextowner = NULL; + bool need_resched = false; xnhandle_t currh, h; atomic_t *lockp; spl_t s; @@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, trace_cobalt_synch_release(synch); if (xnthread_put_resource(curr)) - return NULL; + return false;
[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release
Module: xenomai-3 Branch: next Commit: 6fcfb39faf2e7c28b2f26a0ef86122a9d6d22eba URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6fcfb39faf2e7c28b2f26a0ef86122a9d6d22eba Author: Jan KiszkaDate: Mon May 9 21:19:04 2016 +0200 cobalt/kernel: Return need_resched flag from xnsynch_release We currently return the next owner, but no caller of xnsynch_release evaluates this beyond != NULL and calls xnsched_run in that case. Simplify the API by returning a need_resched flag directly. This will also help with fixing the missing reschedule after PP deboost. Signed-off-by: Jan Kiszka --- include/cobalt/kernel/synch.h |3 +-- kernel/cobalt/posix/mutex.c |2 +- kernel/cobalt/rtdm/drvlib.c |2 +- kernel/cobalt/synch.c | 23 +++ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 04d7f10..1e99c18 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -164,8 +164,7 @@ int xnsynch_acquire(struct xnsynch *synch, int xnsynch_try_acquire(struct xnsynch *synch); -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *thread); +bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread); struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch); diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c index c6020ff..f99874b 100644 --- a/kernel/cobalt/posix/mutex.c +++ b/kernel/cobalt/posix/mutex.c @@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr, cobalt_cond_deferred_signals(cond); } } - need_resched |= xnsynch_release(>synchbase, curr) != NULL; + need_resched |= xnsynch_release(>synchbase, curr); return need_resched; } diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index 7abdb1e..4808b93 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex) trace_cobalt_driver_mutex_release(mutex); if (unlikely(xnsynch_release(>synch_base, -xnsched_current_thread()) != NULL)) +xnsched_current_thread( xnsched_run(); } EXPORT_SYMBOL_GPL(rtdm_mutex_unlock); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 976261d..d8b83d9 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch, drop_booster(synch, owner); } -static struct xnthread *transfer_ownership(struct xnsynch *synch, - struct xnthread *lastowner) +static bool transfer_ownership(struct xnsynch *synch, + struct xnthread *lastowner) { /* nklock held, irqs off */ struct xnthread *nextowner; xnhandle_t nextownerh; @@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, if (list_empty(>pendq)) { synch->owner = NULL; atomic_set(lockp, XN_NO_HANDLE); - return NULL; + return false; } nextowner = list_first_entry(>pendq, struct xnthread, plink); @@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, atomic_set(lockp, nextownerh); - return nextowner; + return true; } /** - * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread *curr) + * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) * @brief Release a resource and pass it to the next waiting thread. * * This service releases the ownership of the given synchronization @@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * @param curr The descriptor address of the current thread, which * must own the object at the time of calling. * - * @return The descriptor address of the unblocked thread. + * @return True if a reschedule is required. * * @sideeffect * @@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * * @coretags{primary-only, might-switch} */ -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *curr) +bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) { - struct xnthread *nextowner = NULL; + bool need_resched = false; xnhandle_t currh, h; atomic_t *lockp; spl_t s; @@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, trace_cobalt_synch_release(synch); if (xnthread_put_resource(curr)) - return NULL; + return false;
[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release
Module: xenomai-3 Branch: next Commit: 6067be34b827633ef19f1091754b19350963db65 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6067be34b827633ef19f1091754b19350963db65 Author: Jan KiszkaDate: Mon May 9 21:19:04 2016 +0200 cobalt/kernel: Return need_resched flag from xnsynch_release We currently return the next owner, but no caller of xnsynch_release evaluates this beyond != NULL and calls xnsched_run in that case. Simplify the API by returning a need_resched flag directly. This will also help with fixing the missing reschedule after PP deboost. Signed-off-by: Jan Kiszka --- include/cobalt/kernel/synch.h |3 +-- kernel/cobalt/posix/mutex.c |2 +- kernel/cobalt/rtdm/drvlib.c |2 +- kernel/cobalt/synch.c | 23 +++ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 04d7f10..1e99c18 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -164,8 +164,7 @@ int xnsynch_acquire(struct xnsynch *synch, int xnsynch_try_acquire(struct xnsynch *synch); -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *thread); +bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread); struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch); diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c index c6020ff..f99874b 100644 --- a/kernel/cobalt/posix/mutex.c +++ b/kernel/cobalt/posix/mutex.c @@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr, cobalt_cond_deferred_signals(cond); } } - need_resched |= xnsynch_release(>synchbase, curr) != NULL; + need_resched |= xnsynch_release(>synchbase, curr); return need_resched; } diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index 7abdb1e..4808b93 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex) trace_cobalt_driver_mutex_release(mutex); if (unlikely(xnsynch_release(>synch_base, -xnsched_current_thread()) != NULL)) +xnsched_current_thread( xnsched_run(); } EXPORT_SYMBOL_GPL(rtdm_mutex_unlock); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 976261d..d8b83d9 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch, drop_booster(synch, owner); } -static struct xnthread *transfer_ownership(struct xnsynch *synch, - struct xnthread *lastowner) +static bool transfer_ownership(struct xnsynch *synch, + struct xnthread *lastowner) { /* nklock held, irqs off */ struct xnthread *nextowner; xnhandle_t nextownerh; @@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, if (list_empty(>pendq)) { synch->owner = NULL; atomic_set(lockp, XN_NO_HANDLE); - return NULL; + return false; } nextowner = list_first_entry(>pendq, struct xnthread, plink); @@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, atomic_set(lockp, nextownerh); - return nextowner; + return true; } /** - * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread *curr) + * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) * @brief Release a resource and pass it to the next waiting thread. * * This service releases the ownership of the given synchronization @@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * @param curr The descriptor address of the current thread, which * must own the object at the time of calling. * - * @return The descriptor address of the unblocked thread. + * @return True if a reschedule is required. * * @sideeffect * @@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * * @coretags{primary-only, might-switch} */ -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *curr) +bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) { - struct xnthread *nextowner = NULL; + bool need_resched = false; xnhandle_t currh, h; atomic_t *lockp; spl_t s; @@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, trace_cobalt_synch_release(synch); if (xnthread_put_resource(curr)) - return NULL; + return false;
[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release
Module: xenomai-3 Branch: next Commit: 9ec0b1291662fa337d45658e58b72b3c35fad502 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=9ec0b1291662fa337d45658e58b72b3c35fad502 Author: Jan KiszkaDate: Mon May 9 21:19:04 2016 +0200 cobalt/kernel: Return need_resched flag from xnsynch_release We currently return the next owner, but no caller of xnsynch_release evaluates this beyond != NULL and calls xnsched_run in that case. Simplify the API by returning a need_resched flag directly. This will also help with fixing the missing reschedule after PP deboost. Signed-off-by: Jan Kiszka --- include/cobalt/kernel/synch.h |3 +-- kernel/cobalt/posix/mutex.c |2 +- kernel/cobalt/rtdm/drvlib.c |2 +- kernel/cobalt/synch.c | 23 +++ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 04d7f10..1e99c18 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -164,8 +164,7 @@ int xnsynch_acquire(struct xnsynch *synch, int xnsynch_try_acquire(struct xnsynch *synch); -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *thread); +bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread); struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch); diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c index c6020ff..f99874b 100644 --- a/kernel/cobalt/posix/mutex.c +++ b/kernel/cobalt/posix/mutex.c @@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr, cobalt_cond_deferred_signals(cond); } } - need_resched |= xnsynch_release(>synchbase, curr) != NULL; + need_resched |= xnsynch_release(>synchbase, curr); return need_resched; } diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index ae55a4b..1973c37 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex) trace_cobalt_driver_mutex_release(mutex); if (unlikely(xnsynch_release(>synch_base, -xnsched_current_thread()) != NULL)) +xnsched_current_thread( xnsched_run(); } EXPORT_SYMBOL_GPL(rtdm_mutex_unlock); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 976261d..d8b83d9 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch, drop_booster(synch, owner); } -static struct xnthread *transfer_ownership(struct xnsynch *synch, - struct xnthread *lastowner) +static bool transfer_ownership(struct xnsynch *synch, + struct xnthread *lastowner) { /* nklock held, irqs off */ struct xnthread *nextowner; xnhandle_t nextownerh; @@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, if (list_empty(>pendq)) { synch->owner = NULL; atomic_set(lockp, XN_NO_HANDLE); - return NULL; + return false; } nextowner = list_first_entry(>pendq, struct xnthread, plink); @@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, atomic_set(lockp, nextownerh); - return nextowner; + return true; } /** - * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread *curr) + * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) * @brief Release a resource and pass it to the next waiting thread. * * This service releases the ownership of the given synchronization @@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * @param curr The descriptor address of the current thread, which * must own the object at the time of calling. * - * @return The descriptor address of the unblocked thread. + * @return True if a reschedule is required. * * @sideeffect * @@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * * @coretags{primary-only, might-switch} */ -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *curr) +bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) { - struct xnthread *nextowner = NULL; + bool need_resched = false; xnhandle_t currh, h; atomic_t *lockp; spl_t s; @@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, trace_cobalt_synch_release(synch); if (xnthread_put_resource(curr)) - return NULL; + return false;
[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release
Module: xenomai-3 Branch: next Commit: 4f6b74e6b3917e747b6039a927e3b389e3d0dcfc URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4f6b74e6b3917e747b6039a927e3b389e3d0dcfc Author: Jan KiszkaDate: Mon May 9 21:19:04 2016 +0200 cobalt/kernel: Return need_resched flag from xnsynch_release We currently return the next owner, but no caller of xnsynch_release evaluates this beyond != NULL and calls xnsched_run in that case. Simplify the API by returning a need_resched flag directly. This will also help with fixing the missing reschedule after PP deboost. Signed-off-by: Jan Kiszka --- include/cobalt/kernel/synch.h |3 +-- kernel/cobalt/posix/mutex.c |2 +- kernel/cobalt/rtdm/drvlib.c |2 +- kernel/cobalt/synch.c | 23 +++ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 04d7f10..1e99c18 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -164,8 +164,7 @@ int xnsynch_acquire(struct xnsynch *synch, int xnsynch_try_acquire(struct xnsynch *synch); -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *thread); +bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread); struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch); diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c index c6020ff..f99874b 100644 --- a/kernel/cobalt/posix/mutex.c +++ b/kernel/cobalt/posix/mutex.c @@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr, cobalt_cond_deferred_signals(cond); } } - need_resched |= xnsynch_release(>synchbase, curr) != NULL; + need_resched |= xnsynch_release(>synchbase, curr); return need_resched; } diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index ae55a4b..1973c37 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex) trace_cobalt_driver_mutex_release(mutex); if (unlikely(xnsynch_release(>synch_base, -xnsched_current_thread()) != NULL)) +xnsched_current_thread( xnsched_run(); } EXPORT_SYMBOL_GPL(rtdm_mutex_unlock); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 976261d..d8b83d9 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch, drop_booster(synch, owner); } -static struct xnthread *transfer_ownership(struct xnsynch *synch, - struct xnthread *lastowner) +static bool transfer_ownership(struct xnsynch *synch, + struct xnthread *lastowner) { /* nklock held, irqs off */ struct xnthread *nextowner; xnhandle_t nextownerh; @@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, if (list_empty(>pendq)) { synch->owner = NULL; atomic_set(lockp, XN_NO_HANDLE); - return NULL; + return false; } nextowner = list_first_entry(>pendq, struct xnthread, plink); @@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, atomic_set(lockp, nextownerh); - return nextowner; + return true; } /** - * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread *curr) + * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) * @brief Release a resource and pass it to the next waiting thread. * * This service releases the ownership of the given synchronization @@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * @param curr The descriptor address of the current thread, which * must own the object at the time of calling. * - * @return The descriptor address of the unblocked thread. + * @return True if a reschedule is required. * * @sideeffect * @@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * * @coretags{primary-only, might-switch} */ -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *curr) +bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) { - struct xnthread *nextowner = NULL; + bool need_resched = false; xnhandle_t currh, h; atomic_t *lockp; spl_t s; @@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, trace_cobalt_synch_release(synch); if (xnthread_put_resource(curr)) - return NULL; + return false;
[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release
Module: xenomai-3 Branch: next Commit: efaef202d14f9df3c12697ddbd169997597621c9 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=efaef202d14f9df3c12697ddbd169997597621c9 Author: Jan KiszkaDate: Mon May 9 21:19:04 2016 +0200 cobalt/kernel: Return need_resched flag from xnsynch_release We currently return the next owner, but no caller of xnsynch_release evaluates this beyond != NULL and calls xnsched_run in that case. Simplify the API by returning a need_resched flag directly. This will also help with fixing the missing reschedule after PP deboost. Signed-off-by: Jan Kiszka --- include/cobalt/kernel/synch.h |3 +-- kernel/cobalt/posix/mutex.c |2 +- kernel/cobalt/rtdm/drvlib.c |2 +- kernel/cobalt/synch.c | 23 +++ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 04d7f10..1e99c18 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -164,8 +164,7 @@ int xnsynch_acquire(struct xnsynch *synch, int xnsynch_try_acquire(struct xnsynch *synch); -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *thread); +bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread); struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch); diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c index c6020ff..f99874b 100644 --- a/kernel/cobalt/posix/mutex.c +++ b/kernel/cobalt/posix/mutex.c @@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr, cobalt_cond_deferred_signals(cond); } } - need_resched |= xnsynch_release(>synchbase, curr) != NULL; + need_resched |= xnsynch_release(>synchbase, curr); return need_resched; } diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index ae55a4b..1973c37 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex) trace_cobalt_driver_mutex_release(mutex); if (unlikely(xnsynch_release(>synch_base, -xnsched_current_thread()) != NULL)) +xnsched_current_thread( xnsched_run(); } EXPORT_SYMBOL_GPL(rtdm_mutex_unlock); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 976261d..d8b83d9 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch, drop_booster(synch, owner); } -static struct xnthread *transfer_ownership(struct xnsynch *synch, - struct xnthread *lastowner) +static bool transfer_ownership(struct xnsynch *synch, + struct xnthread *lastowner) { /* nklock held, irqs off */ struct xnthread *nextowner; xnhandle_t nextownerh; @@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, if (list_empty(>pendq)) { synch->owner = NULL; atomic_set(lockp, XN_NO_HANDLE); - return NULL; + return false; } nextowner = list_first_entry(>pendq, struct xnthread, plink); @@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, atomic_set(lockp, nextownerh); - return nextowner; + return true; } /** - * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread *curr) + * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) * @brief Release a resource and pass it to the next waiting thread. * * This service releases the ownership of the given synchronization @@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * @param curr The descriptor address of the current thread, which * must own the object at the time of calling. * - * @return The descriptor address of the unblocked thread. + * @return True if a reschedule is required. * * @sideeffect * @@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * * @coretags{primary-only, might-switch} */ -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *curr) +bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) { - struct xnthread *nextowner = NULL; + bool need_resched = false; xnhandle_t currh, h; atomic_t *lockp; spl_t s; @@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, trace_cobalt_synch_release(synch); if (xnthread_put_resource(curr)) - return NULL; + return false;
[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release
Module: xenomai-3 Branch: next Commit: b02bc057e71d8fee45d9f2b162605bbc57084584 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b02bc057e71d8fee45d9f2b162605bbc57084584 Author: Jan KiszkaDate: Mon May 9 21:19:04 2016 +0200 cobalt/kernel: Return need_resched flag from xnsynch_release We currently return the next owner, but no caller of xnsynch_release evaluates this beyond != NULL and calls xnsched_run in that case. Simplify the API by returning a need_resched flag directly. This will also help with fixing the missing reschedule after PP deboost. Signed-off-by: Jan Kiszka --- include/cobalt/kernel/synch.h |3 +-- kernel/cobalt/posix/mutex.c |2 +- kernel/cobalt/rtdm/drvlib.c |2 +- kernel/cobalt/synch.c | 23 +++ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 04d7f10..1e99c18 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -164,8 +164,7 @@ int xnsynch_acquire(struct xnsynch *synch, int xnsynch_try_acquire(struct xnsynch *synch); -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *thread); +bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread); struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch); diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c index c6020ff..f99874b 100644 --- a/kernel/cobalt/posix/mutex.c +++ b/kernel/cobalt/posix/mutex.c @@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr, cobalt_cond_deferred_signals(cond); } } - need_resched |= xnsynch_release(>synchbase, curr) != NULL; + need_resched |= xnsynch_release(>synchbase, curr); return need_resched; } diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index ae55a4b..1973c37 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex) trace_cobalt_driver_mutex_release(mutex); if (unlikely(xnsynch_release(>synch_base, -xnsched_current_thread()) != NULL)) +xnsched_current_thread( xnsched_run(); } EXPORT_SYMBOL_GPL(rtdm_mutex_unlock); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 976261d..d8b83d9 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch, drop_booster(synch, owner); } -static struct xnthread *transfer_ownership(struct xnsynch *synch, - struct xnthread *lastowner) +static bool transfer_ownership(struct xnsynch *synch, + struct xnthread *lastowner) { /* nklock held, irqs off */ struct xnthread *nextowner; xnhandle_t nextownerh; @@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, if (list_empty(>pendq)) { synch->owner = NULL; atomic_set(lockp, XN_NO_HANDLE); - return NULL; + return false; } nextowner = list_first_entry(>pendq, struct xnthread, plink); @@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, atomic_set(lockp, nextownerh); - return nextowner; + return true; } /** - * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread *curr) + * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) * @brief Release a resource and pass it to the next waiting thread. * * This service releases the ownership of the given synchronization @@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * @param curr The descriptor address of the current thread, which * must own the object at the time of calling. * - * @return The descriptor address of the unblocked thread. + * @return True if a reschedule is required. * * @sideeffect * @@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * * @coretags{primary-only, might-switch} */ -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *curr) +bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) { - struct xnthread *nextowner = NULL; + bool need_resched = false; xnhandle_t currh, h; atomic_t *lockp; spl_t s; @@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, trace_cobalt_synch_release(synch); if (xnthread_put_resource(curr)) - return NULL; + return false;
[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release
Module: xenomai-3 Branch: next Commit: 90b5f282f84ef7c60cb21e08c4545db07bc46899 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=90b5f282f84ef7c60cb21e08c4545db07bc46899 Author: Jan KiszkaDate: Mon May 9 21:19:04 2016 +0200 cobalt/kernel: Return need_resched flag from xnsynch_release We currently return the next owner, but no caller of xnsynch_release evaluates this beyond != NULL and calls xnsched_run in that case. Simplify the API by returning a need_resched flag directly. This will also help with fixing the missing reschedule after PP deboost. Signed-off-by: Jan Kiszka --- include/cobalt/kernel/synch.h |3 +-- kernel/cobalt/posix/mutex.c |2 +- kernel/cobalt/rtdm/drvlib.c |2 +- kernel/cobalt/synch.c | 23 +++ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 04d7f10..1e99c18 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -164,8 +164,7 @@ int xnsynch_acquire(struct xnsynch *synch, int xnsynch_try_acquire(struct xnsynch *synch); -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *thread); +bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread); struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch); diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c index c6020ff..f99874b 100644 --- a/kernel/cobalt/posix/mutex.c +++ b/kernel/cobalt/posix/mutex.c @@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr, cobalt_cond_deferred_signals(cond); } } - need_resched |= xnsynch_release(>synchbase, curr) != NULL; + need_resched |= xnsynch_release(>synchbase, curr); return need_resched; } diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index ae55a4b..1973c37 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex) trace_cobalt_driver_mutex_release(mutex); if (unlikely(xnsynch_release(>synch_base, -xnsched_current_thread()) != NULL)) +xnsched_current_thread( xnsched_run(); } EXPORT_SYMBOL_GPL(rtdm_mutex_unlock); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 976261d..d8b83d9 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch, drop_booster(synch, owner); } -static struct xnthread *transfer_ownership(struct xnsynch *synch, - struct xnthread *lastowner) +static bool transfer_ownership(struct xnsynch *synch, + struct xnthread *lastowner) { /* nklock held, irqs off */ struct xnthread *nextowner; xnhandle_t nextownerh; @@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, if (list_empty(>pendq)) { synch->owner = NULL; atomic_set(lockp, XN_NO_HANDLE); - return NULL; + return false; } nextowner = list_first_entry(>pendq, struct xnthread, plink); @@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, atomic_set(lockp, nextownerh); - return nextowner; + return true; } /** - * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread *curr) + * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) * @brief Release a resource and pass it to the next waiting thread. * * This service releases the ownership of the given synchronization @@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * @param curr The descriptor address of the current thread, which * must own the object at the time of calling. * - * @return The descriptor address of the unblocked thread. + * @return True if a reschedule is required. * * @sideeffect * @@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * * @coretags{primary-only, might-switch} */ -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *curr) +bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) { - struct xnthread *nextowner = NULL; + bool need_resched = false; xnhandle_t currh, h; atomic_t *lockp; spl_t s; @@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, trace_cobalt_synch_release(synch); if (xnthread_put_resource(curr)) - return NULL; + return false;
[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release
Module: xenomai-3 Branch: wip/dovetail Commit: 3223ffec97a360ceb967d487a57e9a0a4ae31500 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3223ffec97a360ceb967d487a57e9a0a4ae31500 Author: Jan KiszkaDate: Mon May 9 21:19:04 2016 +0200 cobalt/kernel: Return need_resched flag from xnsynch_release We currently return the next owner, but no caller of xnsynch_release evaluates this beyond != NULL and calls xnsched_run in that case. Simplify the API by returning a need_resched flag directly. This will also help with fixing the missing reschedule after PP deboost. Signed-off-by: Jan Kiszka --- include/cobalt/kernel/synch.h |3 +-- kernel/cobalt/posix/mutex.c |2 +- kernel/cobalt/rtdm/drvlib.c |2 +- kernel/cobalt/synch.c | 23 +++ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 04d7f10..1e99c18 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -164,8 +164,7 @@ int xnsynch_acquire(struct xnsynch *synch, int xnsynch_try_acquire(struct xnsynch *synch); -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *thread); +bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread); struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch); diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c index c6020ff..f99874b 100644 --- a/kernel/cobalt/posix/mutex.c +++ b/kernel/cobalt/posix/mutex.c @@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr, cobalt_cond_deferred_signals(cond); } } - need_resched |= xnsynch_release(>synchbase, curr) != NULL; + need_resched |= xnsynch_release(>synchbase, curr); return need_resched; } diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index ae55a4b..1973c37 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex) trace_cobalt_driver_mutex_release(mutex); if (unlikely(xnsynch_release(>synch_base, -xnsched_current_thread()) != NULL)) +xnsched_current_thread( xnsched_run(); } EXPORT_SYMBOL_GPL(rtdm_mutex_unlock); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 976261d..d8b83d9 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch, drop_booster(synch, owner); } -static struct xnthread *transfer_ownership(struct xnsynch *synch, - struct xnthread *lastowner) +static bool transfer_ownership(struct xnsynch *synch, + struct xnthread *lastowner) { /* nklock held, irqs off */ struct xnthread *nextowner; xnhandle_t nextownerh; @@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, if (list_empty(>pendq)) { synch->owner = NULL; atomic_set(lockp, XN_NO_HANDLE); - return NULL; + return false; } nextowner = list_first_entry(>pendq, struct xnthread, plink); @@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, atomic_set(lockp, nextownerh); - return nextowner; + return true; } /** - * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread *curr) + * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) * @brief Release a resource and pass it to the next waiting thread. * * This service releases the ownership of the given synchronization @@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * @param curr The descriptor address of the current thread, which * must own the object at the time of calling. * - * @return The descriptor address of the unblocked thread. + * @return True if a reschedule is required. * * @sideeffect * @@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * * @coretags{primary-only, might-switch} */ -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *curr) +bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) { - struct xnthread *nextowner = NULL; + bool need_resched = false; xnhandle_t currh, h; atomic_t *lockp; spl_t s; @@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, trace_cobalt_synch_release(synch); if (xnthread_put_resource(curr)) - return NULL; + return
[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release
Module: xenomai-3 Branch: next Commit: 3223ffec97a360ceb967d487a57e9a0a4ae31500 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3223ffec97a360ceb967d487a57e9a0a4ae31500 Author: Jan KiszkaDate: Mon May 9 21:19:04 2016 +0200 cobalt/kernel: Return need_resched flag from xnsynch_release We currently return the next owner, but no caller of xnsynch_release evaluates this beyond != NULL and calls xnsched_run in that case. Simplify the API by returning a need_resched flag directly. This will also help with fixing the missing reschedule after PP deboost. Signed-off-by: Jan Kiszka --- include/cobalt/kernel/synch.h |3 +-- kernel/cobalt/posix/mutex.c |2 +- kernel/cobalt/rtdm/drvlib.c |2 +- kernel/cobalt/synch.c | 23 +++ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 04d7f10..1e99c18 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -164,8 +164,7 @@ int xnsynch_acquire(struct xnsynch *synch, int xnsynch_try_acquire(struct xnsynch *synch); -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *thread); +bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread); struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch); diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c index c6020ff..f99874b 100644 --- a/kernel/cobalt/posix/mutex.c +++ b/kernel/cobalt/posix/mutex.c @@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr, cobalt_cond_deferred_signals(cond); } } - need_resched |= xnsynch_release(>synchbase, curr) != NULL; + need_resched |= xnsynch_release(>synchbase, curr); return need_resched; } diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index ae55a4b..1973c37 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex) trace_cobalt_driver_mutex_release(mutex); if (unlikely(xnsynch_release(>synch_base, -xnsched_current_thread()) != NULL)) +xnsched_current_thread( xnsched_run(); } EXPORT_SYMBOL_GPL(rtdm_mutex_unlock); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 976261d..d8b83d9 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch, drop_booster(synch, owner); } -static struct xnthread *transfer_ownership(struct xnsynch *synch, - struct xnthread *lastowner) +static bool transfer_ownership(struct xnsynch *synch, + struct xnthread *lastowner) { /* nklock held, irqs off */ struct xnthread *nextowner; xnhandle_t nextownerh; @@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, if (list_empty(>pendq)) { synch->owner = NULL; atomic_set(lockp, XN_NO_HANDLE); - return NULL; + return false; } nextowner = list_first_entry(>pendq, struct xnthread, plink); @@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, atomic_set(lockp, nextownerh); - return nextowner; + return true; } /** - * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread *curr) + * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) * @brief Release a resource and pass it to the next waiting thread. * * This service releases the ownership of the given synchronization @@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * @param curr The descriptor address of the current thread, which * must own the object at the time of calling. * - * @return The descriptor address of the unblocked thread. + * @return True if a reschedule is required. * * @sideeffect * @@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * * @coretags{primary-only, might-switch} */ -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *curr) +bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) { - struct xnthread *nextowner = NULL; + bool need_resched = false; xnhandle_t currh, h; atomic_t *lockp; spl_t s; @@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, trace_cobalt_synch_release(synch); if (xnthread_put_resource(curr)) - return NULL; + return false;
[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release
Module: xenomai-jki Branch: for-forge Commit: 5cb254e542e9bb076a24fa0475a2fb17e2cac478 URL: http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=5cb254e542e9bb076a24fa0475a2fb17e2cac478 Author: Jan KiszkaDate: Mon May 9 21:19:04 2016 +0200 cobalt/kernel: Return need_resched flag from xnsynch_release We currently return the next owner, but no caller of xnsynch_release evaluates this beyond != NULL and calls xnsched_run in that case. Simplify the API by returning a need_resched flag directly. This will also help with fixing the missing reschedule after PP deboost. Signed-off-by: Jan Kiszka --- include/cobalt/kernel/synch.h |3 +-- kernel/cobalt/posix/mutex.c |2 +- kernel/cobalt/rtdm/drvlib.c |2 +- kernel/cobalt/synch.c | 23 +++ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 04d7f10..1e99c18 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -164,8 +164,7 @@ int xnsynch_acquire(struct xnsynch *synch, int xnsynch_try_acquire(struct xnsynch *synch); -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *thread); +bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread); struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch); diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c index c6020ff..f99874b 100644 --- a/kernel/cobalt/posix/mutex.c +++ b/kernel/cobalt/posix/mutex.c @@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr, cobalt_cond_deferred_signals(cond); } } - need_resched |= xnsynch_release(>synchbase, curr) != NULL; + need_resched |= xnsynch_release(>synchbase, curr); return need_resched; } diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index ae55a4b..1973c37 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex) trace_cobalt_driver_mutex_release(mutex); if (unlikely(xnsynch_release(>synch_base, -xnsched_current_thread()) != NULL)) +xnsched_current_thread( xnsched_run(); } EXPORT_SYMBOL_GPL(rtdm_mutex_unlock); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 976261d..d8b83d9 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch, drop_booster(synch, owner); } -static struct xnthread *transfer_ownership(struct xnsynch *synch, - struct xnthread *lastowner) +static bool transfer_ownership(struct xnsynch *synch, + struct xnthread *lastowner) { /* nklock held, irqs off */ struct xnthread *nextowner; xnhandle_t nextownerh; @@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, if (list_empty(>pendq)) { synch->owner = NULL; atomic_set(lockp, XN_NO_HANDLE); - return NULL; + return false; } nextowner = list_first_entry(>pendq, struct xnthread, plink); @@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, atomic_set(lockp, nextownerh); - return nextowner; + return true; } /** - * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread *curr) + * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) * @brief Release a resource and pass it to the next waiting thread. * * This service releases the ownership of the given synchronization @@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * @param curr The descriptor address of the current thread, which * must own the object at the time of calling. * - * @return The descriptor address of the unblocked thread. + * @return True if a reschedule is required. * * @sideeffect * @@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * * @coretags{primary-only, might-switch} */ -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *curr) +bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) { - struct xnthread *nextowner = NULL; + bool need_resched = false; xnhandle_t currh, h; atomic_t *lockp; spl_t s; @@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, trace_cobalt_synch_release(synch); if (xnthread_put_resource(curr)) - return NULL; + return
[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release
Module: xenomai-jki Branch: for-forge Commit: 3c6a48e0eae6a1b656d18dcbe1dd96f3563bcf7a URL: http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=3c6a48e0eae6a1b656d18dcbe1dd96f3563bcf7a Author: Jan KiszkaDate: Mon May 9 21:19:04 2016 +0200 cobalt/kernel: Return need_resched flag from xnsynch_release We currently return the next owner, but no caller of xnsynch_release evaluates this beyond != NULL and calls xnsched_run in that case. Simplify the API by returning a need_resched flag directly. This will also help with fixing the missing reschedule after PP deboost. Signed-off-by: Jan Kiszka --- include/cobalt/kernel/synch.h |3 +-- kernel/cobalt/posix/mutex.c |2 +- kernel/cobalt/rtdm/drvlib.c |2 +- kernel/cobalt/synch.c | 23 +++ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 04d7f10..1e99c18 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -164,8 +164,7 @@ int xnsynch_acquire(struct xnsynch *synch, int xnsynch_try_acquire(struct xnsynch *synch); -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *thread); +bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread); struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch); diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c index c6020ff..f99874b 100644 --- a/kernel/cobalt/posix/mutex.c +++ b/kernel/cobalt/posix/mutex.c @@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr, cobalt_cond_deferred_signals(cond); } } - need_resched |= xnsynch_release(>synchbase, curr) != NULL; + need_resched |= xnsynch_release(>synchbase, curr); return need_resched; } diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index ae55a4b..1973c37 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex) trace_cobalt_driver_mutex_release(mutex); if (unlikely(xnsynch_release(>synch_base, -xnsched_current_thread()) != NULL)) +xnsched_current_thread( xnsched_run(); } EXPORT_SYMBOL_GPL(rtdm_mutex_unlock); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 976261d..0130844 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch, drop_booster(synch, owner); } -static struct xnthread *transfer_ownership(struct xnsynch *synch, - struct xnthread *lastowner) +static bool transfer_ownership(struct xnsynch *synch, + struct xnthread *lastowner) { /* nklock held, irqs off */ struct xnthread *nextowner; xnhandle_t nextownerh; @@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, if (list_empty(>pendq)) { synch->owner = NULL; atomic_set(lockp, XN_NO_HANDLE); - return NULL; + return false; } nextowner = list_first_entry(>pendq, struct xnthread, plink); @@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, atomic_set(lockp, nextownerh); - return nextowner; + return true; } /** - * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread *curr) + * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) * @brief Release a resource and pass it to the next waiting thread. * * This service releases the ownership of the given synchronization @@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * @param curr The descriptor address of the current thread, which * must own the object at the time of calling. * - * @return The descriptor address of the unblocked thread. + * @return True if a reschedule is required. * * @sideeffect * @@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * * @coretags{primary-only, might-switch} */ -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *curr) +bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) { - struct xnthread *nextowner = NULL; + bool need_resched = false; xnhandle_t currh, h; atomic_t *lockp; spl_t s; @@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, trace_cobalt_synch_release(synch); if (xnthread_put_resource(curr)) - return NULL; + return 0;
[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release
Module: xenomai-jki Branch: for-forge Commit: dd2df9a8bfbb7e45e1c262b52050cc1c3f75b3bd URL: http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=dd2df9a8bfbb7e45e1c262b52050cc1c3f75b3bd Author: Jan KiszkaDate: Mon May 9 21:19:04 2016 +0200 cobalt/kernel: Return need_resched flag from xnsynch_release We currently return the next owner, but no caller of xnsynch_release evaluates this beyond != NULL and calls xnsched_run in that case. Simplify the API by returning a need_resched flag directly. This will also help with fixing the missing reschedule after PP deboost. Signed-off-by: Jan Kiszka --- include/cobalt/kernel/synch.h |3 +-- kernel/cobalt/posix/mutex.c |2 +- kernel/cobalt/rtdm/drvlib.c |2 +- kernel/cobalt/synch.c | 22 ++ 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 04d7f10..83b82c4 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -164,8 +164,7 @@ int xnsynch_acquire(struct xnsynch *synch, int xnsynch_try_acquire(struct xnsynch *synch); -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *thread); +int xnsynch_release(struct xnsynch *synch, struct xnthread *thread); struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch); diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c index c6020ff..f99874b 100644 --- a/kernel/cobalt/posix/mutex.c +++ b/kernel/cobalt/posix/mutex.c @@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr, cobalt_cond_deferred_signals(cond); } } - need_resched |= xnsynch_release(>synchbase, curr) != NULL; + need_resched |= xnsynch_release(>synchbase, curr); return need_resched; } diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index ae55a4b..1973c37 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex) trace_cobalt_driver_mutex_release(mutex); if (unlikely(xnsynch_release(>synch_base, -xnsched_current_thread()) != NULL)) +xnsched_current_thread( xnsched_run(); } EXPORT_SYMBOL_GPL(rtdm_mutex_unlock); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 976261d..d9fb5a2 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -843,8 +843,7 @@ static inline void clear_pp_boost(struct xnsynch *synch, drop_booster(synch, owner); } -static struct xnthread *transfer_ownership(struct xnsynch *synch, - struct xnthread *lastowner) +static int transfer_ownership(struct xnsynch *synch, struct xnthread *lastowner) { /* nklock held, irqs off */ struct xnthread *nextowner; xnhandle_t nextownerh; @@ -859,7 +858,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, if (list_empty(>pendq)) { synch->owner = NULL; atomic_set(lockp, XN_NO_HANDLE); - return NULL; + return 0; } nextowner = list_first_entry(>pendq, struct xnthread, plink); @@ -879,11 +878,11 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, atomic_set(lockp, nextownerh); - return nextowner; + return 1; } /** - * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread *curr) + * @fn int xnsynch_release(struct xnsynch *synch, struct xnthread *curr) * @brief Release a resource and pass it to the next waiting thread. * * This service releases the ownership of the given synchronization @@ -900,7 +899,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * @param curr The descriptor address of the current thread, which * must own the object at the time of calling. * - * @return The descriptor address of the unblocked thread. + * @return Non-zero if a reschedule is required. * * @sideeffect * @@ -913,10 +912,9 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * * @coretags{primary-only, might-switch} */ -struct xnthread *xnsynch_release(struct xnsynch *synch, -struct xnthread *curr) +int xnsynch_release(struct xnsynch *synch, struct xnthread *curr) { - struct xnthread *nextowner = NULL; + int need_resched = 0; xnhandle_t currh, h; atomic_t *lockp; spl_t s; @@ -926,7 +924,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, trace_cobalt_synch_release(synch); if (xnthread_put_resource(curr)) - return NULL; + return 0; lockp = xnsynch_fastlock(synch);