Linux-rt-users archive on lore.kernel.org
 help / color / Atom feed
* wait_event_interruptible_timeout() not sleeping accurately
@ 2019-11-22 19:39 Dick Hollenbeck
  2019-11-25 17:31 ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 2+ messages in thread
From: Dick Hollenbeck @ 2019-11-22 19:39 UTC (permalink / raw)
  To: linux-rt-users


In a user thread I block on wait_event_interruptible_timeout() for about 3300 usecs or
until my threaded interrupt handler calls wake_up_interruptible() when the hardware event
happens.

This seems to work fine for the case when the event actually happens.  But for the timeout
case, the function wait_event_interruptible_timeout() is sleeping 9000 usecs or so rather
than 3300 usecs as requested.  I confirmed this by toggling a GPIO pin before and after
the call and feeding that signal to a logic analyzer.

The user thread is RT round robin at about a priority 5.

Am I doing something disallowed under PREEMPT_RT?
What could be the reason for the inaccurate wait_event_interruptible_timeout() timeout?


			ret = wait_event_interruptible_timeout(bh->rx_waitq,
				bh->rx_intr_flag,
				usecs_to_jiffies(aTimeoutUSecs) );


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: wait_event_interruptible_timeout() not sleeping accurately
  2019-11-22 19:39 wait_event_interruptible_timeout() not sleeping accurately Dick Hollenbeck
@ 2019-11-25 17:31 ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Andrzej Siewior @ 2019-11-25 17:31 UTC (permalink / raw)
  To: Dick Hollenbeck; +Cc: linux-rt-users

On 2019-11-22 13:39:38 [-0600], Dick Hollenbeck wrote:
> 
> In a user thread I block on wait_event_interruptible_timeout() for about 3300 usecs or
> until my threaded interrupt handler calls wake_up_interruptible() when the hardware event
> happens.
> 
> This seems to work fine for the case when the event actually happens.  But for the timeout
> case, the function wait_event_interruptible_timeout() is sleeping 9000 usecs or so rather
> than 3300 usecs as requested.  I confirmed this by toggling a GPIO pin before and after
> the call and feeding that signal to a logic analyzer.
> 
> The user thread is RT round robin at about a priority 5.
> 
> Am I doing something disallowed under PREEMPT_RT?
> What could be the reason for the inaccurate wait_event_interruptible_timeout() timeout?
> 
> 
> 			ret = wait_event_interruptible_timeout(bh->rx_waitq,
> 				bh->rx_intr_flag,
> 				usecs_to_jiffies(aTimeoutUSecs) );

Could you enable some tracing and check what delays the wakeup? There
should be some delay between time timer callback and the wakeup. Maybe
the timer itself is delayed if enough RT tasks are busy.

Sebastian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-22 19:39 wait_event_interruptible_timeout() not sleeping accurately Dick Hollenbeck
2019-11-25 17:31 ` Sebastian Andrzej Siewior

Linux-rt-users archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rt-users/0 linux-rt-users/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rt-users linux-rt-users/ https://lore.kernel.org/linux-rt-users \
		linux-rt-users@vger.kernel.org
	public-inbox-index linux-rt-users

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rt-users


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git