mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: gengdongjiu <gengdongjiu@huawei.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	<linux-rt-users@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<anna-maria@linutronix.de>, <john.stultz@linaro.org>
Cc: Hangaohuai <hangaohuai@huawei.com>,
	"zhangjianwei (D)" <zhangjianwei8@huawei.com>,
	<yangchuanlong@huawei.com>,
	"Zhangbin (EulerOS)" <zhangbin46@huawei.com>,
	<liupeifeng3@huawei.com>
Subject: hrtimer become inaccurate with RT patch
Date: Mon, 2 Jul 2018 17:34:34 +0800	[thread overview]
Message-ID: <43d78927-3955-acde-a2d1-d2b82932a7a6@huawei.com> (raw)
In-Reply-To: <12e6da4e-7681-771f-38d3-3c1abf943c24@huawei.com>

Hi Thomas/Anna/John,

  Recently I found that the hrtimer become inaccurate when there is a RT
process runs on the same cpu core, and the kernel has applied preempt_rt
patch.
  The Linux kernel version is v4.1.46, and the preempt_rt patch is
patch-4.1.46-rt52.patch.
  I know that in the preempt_rt environment the interrupt handlers no
longer run in interrupt context but in process context, so that RT
process will not be interrupt. But if the hrtimer is also runs in
process context the timer is useless when it's inaccurate. so I want to
consult you whether this is expected behavior? whether is reasonable to move the timer IRQ
handling to a thread?

  Check the patch-4.1.46-rt52.patch will found in function
'hrtimer_interrupt' the modify below:

@@ -1296,7 +1539,10 @@ retry:
 			if (basenow.tv64 < hrtimer_get_softexpires_tv64(timer))
 				break;

-			__run_hrtimer(timer, &basenow);
+			if (!hrtimer_rt_defer(timer))
+				__run_hrtimer(timer, &basenow);
+			else
+				raise = 1;
 		}
 	}
 	/* Reevaluate the clock bases for the next expiry */

@@ -1357,6 +1603,9 @@ retry:
 	tick_program_event(expires_next, 1);
 	printk_once(KERN_WARNING "hrtimer: interrupt took %llu ns\n",
 		    ktime_to_ns(delta));
+out:
+	if (raise)
+		raise_softirq_irqoff(HRTIMER_SOFTIRQ);
 }

I think this is why hrtimer is run as a thread, I tried to set
hrtimer.irqsafe to 1, but the timer still seemed not right. Could anyone
give some advise? Thanks.


       reply	other threads:[~2018-07-02  9:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <12e6da4e-7681-771f-38d3-3c1abf943c24@huawei.com>
2018-07-02  9:34 ` gengdongjiu [this message]
2018-07-02 10:14   ` Sebastian Andrzej Siewior
2018-07-02 11:19     ` gengdongjiu
2018-07-02 19:38       ` Sebastian Andrzej Siewior
2018-07-06 14:22     ` Daniel Wagner
2018-07-06 14:30       ` Sebastian Andrzej Siewior
2018-07-02 19:25   ` John Stultz
2018-07-02 20:13     ` Thomas Gleixner

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=43d78927-3955-acde-a2d1-d2b82932a7a6@huawei.com \
    --to=gengdongjiu@huawei.com \
    --cc=anna-maria@linutronix.de \
    --cc=hangaohuai@huawei.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=liupeifeng3@huawei.com \
    --cc=tglx@linutronix.de \
    --cc=yangchuanlong@huawei.com \
    --cc=zhangbin46@huawei.com \
    --cc=zhangjianwei8@huawei.com \
    /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

all inboxes | Powered by JetHome®