All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: xenomai@xenomai.org
Subject: Re: [Xenomai] [Xenomai-git] Jan Kiszka : cobalt/timer: Make xntimer_get_overruns robust against stopped timers
Date: Wed, 24 Feb 2016 22:10:48 +0100	[thread overview]
Message-ID: <20160224211048.GA31084@hermes.click-hack.org> (raw)
In-Reply-To: <E1aYgex-0004LE-7y@sd-51317.xenomai.org>

On Wed, Feb 24, 2016 at 10:07:47PM +0100, git repository hosting wrote:
> Module: xenomai-jki
> Branch: for-forge
> Commit: 8e6d76e07af74056f6cb4d8cfb192485d07732f7
> URL:    http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=8e6d76e07af74056f6cb4d8cfb192485d07732f7
> 
> Author: Jan Kiszka <jan.kiszka@siemens.com>
> Date:   Wed Feb 24 21:44:41 2016 +0100
> 
> cobalt/timer: Make xntimer_get_overruns robust against stopped timers
> 
> xntimer_get_overruns might be called on meanwhile stopped timers,
> specifically by cobalt_timer_deliver. We crash if we try to dequeue a
> stopped timer, and we should not restart it as well.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> 
> ---
> 
>  kernel/cobalt/timer.c |   14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/kernel/cobalt/timer.c b/kernel/cobalt/timer.c
> index db6263d..3e85a53 100644
> --- a/kernel/cobalt/timer.c
> +++ b/kernel/cobalt/timer.c
> @@ -602,13 +602,15 @@ unsigned long long xntimer_get_overruns(struct xntimer *timer, xnticks_t now)
>  		overruns = xnarch_div64(delta, period);
>  		timer->pexpect_ticks += overruns;
>  
> -		q = xntimer_percpu_queue(timer);
> -		xntimer_dequeue(timer, q);
> -		while (xntimerh_date(&timer->aplink) < now) {
> -			timer->periodic_ticks++;
> -			xntimer_update_date(timer);
> +		if (xntimer_running_p(timer)) {
> +			q = xntimer_percpu_queue(timer);
> +			xntimer_dequeue(timer, q);
> +			while (xntimerh_date(&timer->aplink) < now) {
> +				timer->periodic_ticks++;
> +				xntimer_update_date(timer);
> +			}
> +			xntimer_enqueue_and_program(timer, q);
>  		}
> -		xntimer_enqueue_and_program(timer, q);

This looks wrong. xntimer_get_overruns should not be called on a
stopped timer. We want the caller to return an error if called on a
stopped timer, not the condition being silently ignored.

-- 
					    Gilles.
https://click-hack.org


       reply	other threads:[~2016-02-24 21:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1aYgex-0004LE-7y@sd-51317.xenomai.org>
2016-02-24 21:10 ` Gilles Chanteperdrix [this message]
2016-02-24 21:15   ` [Xenomai] [Xenomai-git] Jan Kiszka : cobalt/timer: Make xntimer_get_overruns robust against stopped timers Jan Kiszka
2016-02-24 21:20     ` Gilles Chanteperdrix
2016-02-24 21:21       ` Jan Kiszka
2016-02-25 15:11         ` Gilles Chanteperdrix
2016-02-25 15:17           ` Jan Kiszka
2016-02-26 11:30             ` Gilles Chanteperdrix
2016-02-26 11:34               ` Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160224211048.GA31084@hermes.click-hack.org \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.