public inbox for linux-rt-users@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexander Gerasiov <gq@cs.msu.su>
To: linux-rt-users@vger.kernel.org
Cc: zlobin_d@redlab-i.ru
Subject: Problem with hrtimer_cancel() does not cancel timer
Date: Sat, 18 Feb 2017 01:15:22 +0300	[thread overview]
Message-ID: <20170218011522.09d42119@brick.gerasiov.net> (raw)

Hello folks,

I met some problem with preempt version of kernel 4.4.

I have hrtimer which runs callback, it forwards time and returns
HRTIMER_RESTART. Very common scheme. When I stop the routine I call
hrtimer_cancel(). It should wait for callback completion if any and
unqueue any future timers.

But suddenly I noticed, that sometimes hrtimer's routine continue to
work and work after hrtimer_cancel(). It could be reproduced with simple
test:

Start hrtimer.
In callback increase counter and restart.
In the other thread cancel timer, save counter, sleep, check that
counter is not changed, restart timer, repeat.
Here is sample module:
https://gist.github.com/gerasiov/010e6c2cb96fd891c1802facf816fe84

It works OK on v3.10.74-rt79 with PREEMPL FULL.
It works OK on v4.4.47-rt59 with preempt patch but PREEMPT NONE.
But on 4.4 (tested on v4.4.47-rt59 and v4.4.32-rt43) with PREEMPT FULL
it fails: counter continue to increase (BUG_ON() line 45 hits), that
means that hrtimer continue to work after cancel(). And I must say,
that this is not single iteration, it continues to work in cycle.

It was reproduced on i386 SMP box.
kernel config:
https://github.com/redlab-i/linux/blob/v4.4.47-rt59-stand2/.config

Do anyone have any ideas where could be the problem? Or may be I missed
something in my research?

-- 
Best regards,
 Alexander Gerasiov

 Contacts:
 e-mail: gq@cs.msu.su  Homepage: http://gerasiov.net  Skype: gerasiov
 PGP fingerprint: 04B5 9D90 DF7C C2AB CD49  BAEA CA87 E9E8 2AAC 33F1

             reply	other threads:[~2017-02-17 22:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-17 22:15 Alexander Gerasiov [this message]
2017-02-21 14:15 ` Problem with hrtimer_cancel() does not cancel timer Dmitry
2017-02-28 13:02 ` Alexander Gerasiov
2017-03-01 15:01 ` Sebastian Andrzej Siewior
2017-03-01 23:48   ` Alexander Gerasiov
2017-03-02  8:19     ` Sebastian Andrzej Siewior

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=20170218011522.09d42119@brick.gerasiov.net \
    --to=gq@cs.msu.su \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=zlobin_d@redlab-i.ru \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox