All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Jan Kiszka <jan.kiszka@domain.hid>
Cc: xenomai-core <xenomai@xenomai.org>
Subject: [Xenomai-core] Re: SVN checkin #2010
Date: Tue, 02 Jan 2007 15:32:29 +0100	[thread overview]
Message-ID: <459A6CFD.4030805@domain.hid> (raw)
In-Reply-To: <459A6A88.8000803@domain.hid>

[-- Attachment #1: Type: text/plain, Size: 2345 bytes --]

Jan Kiszka wrote:
> Philippe Gerum wrote:
> 
>>On Tue, 2007-01-02 at 14:56 +0100, Gilles Chanteperdrix wrote:
>>
>>>Philippe Gerum wrote:
>>>
>>>>On Tue, 2007-01-02 at 14:30 +0100, Gilles Chanteperdrix wrote:
>>>>
>>>>
>>>>>Philippe Gerum wrote:
>>>>>
>>>>>
>>>>>>On Tue, 2007-01-02 at 11:20 +0100, Jan Kiszka wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>>Hi all - and happy new year,
>>>>>>>
>>>>>>>I haven't looked at all the new code yet, only the commit messages. I
>>>>>>>found something similar to my fast-forward-on-timer-overrun patch in
>>>>>>>#2010 and wondered if Gilles' original concerns on side effects for the
>>>>>>>POSIX skin were addressed [1]. I recalled that my own final summary on
>>>>>>>this was "leave it as it is" [2].
>>>>>>>
>>>>>>
>>>>>>The best approach is to update the POSIX skin so that it does not rely
>>>>>>on the timer code to act in a sub-optimal way; that's why this patch
>>>>>>found its way in. Scheduling and processing timer shots uselessly is a
>>>>>>bug, not a feature in this case.
>>>>>
>>>>>There is some work to be done on the posix skin anyway, this will all be
>>>>>at once. By the way, I tested the trunk on ARM, and I still get a lockup
>>>>>when the latency period is too low. I wonder if we should not compare to
>>>>>"now + nkschedlat", or even use xnarch_get_cpu_tsc() instead of "now".
>>>>
>>>>You mean as below, in order to account for the time spent in the handler(s)?	
>>>>
>>>>-	while ((xntimerh_date(&timer->aplink) += timer->interval) < now)
>>>>+	while ((xntimerh_date(&timer->aplink) += timer->interval) < xnarch_get_cpu_tsc())
>>>>		    ;
>>>>
>>>
>>>I mean even:
>>>
>>>	while ((xntimerh_date(&timer->aplink) += timer->interval) <
>>>		xnarch_get_cpu_tsc() + nkschedlat)
>>>                 ;
>>>
>>>Because if the timer date is between now and now + nkschedlat, its
>>>handler will be called again.
>>>
>>
>>Ack.
>>
> 
> 
> Keep in mind that this code is now a performance regression for the
> non-overflow case, specifically when xnarch_get_cpu_tsc() costs more
> than just a simple CPU register access.
> 
> My previous "leave it as it is" was also due to the consideration that
> we shouldn't pay too much in hotpaths for things that go wrong on
> misdesigned systems.

What about a greedy version like this.

-- 
                                                 Gilles Chanteperdrix

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: xeno-greedy-timer-fast-forward.diff --]
[-- Type: text/x-patch; name="xeno-greedy-timer-fast-forward.diff", Size: 1237 bytes --]

Index: ksrc/nucleus/timer.c
===================================================================
--- ksrc/nucleus/timer.c	(révision 2037)
+++ ksrc/nucleus/timer.c	(copie de travail)
@@ -184,10 +184,10 @@
 	xntimer_t *timer;
 	xnticks_t now;
 
+	now = xnarch_get_cpu_tsc();
 	while ((holder = xntimerq_head(timerq)) != NULL) {
 		timer = aplink2timer(holder);
 
-		now = xnarch_get_cpu_tsc();
 		if (xntimerh_date(&timer->aplink) - nkschedlat > now)
 			/* No need to continue in aperiodic mode since timeout
 			   dates are ordered by increasing values. */
@@ -199,6 +199,7 @@
 			if (!testbits(nktbase.status, XNTBLCK)) {
 				timer->handler(timer);
 
+				now = xnarch_get_cpu_tsc();
 				if (timer->interval == XN_INFINITE ||
 				    !testbits(timer->status, XNTIMER_DEQUEUED)
 				    || testbits(timer->status, XNTIMER_KILLED))
@@ -221,8 +222,9 @@
 			   translates into precious microsecs on low-end hw. */
 			__setbits(sched->status, XNHTICK);
 
-		while ((xntimerh_date(&timer->aplink) += timer->interval) < now)
-		    ;
+		do {
+			xntimerh_date(&timer->aplink) += timer->interval;
+		} while (xntimerh_date(&timer->aplink) < now + nkschedlat);
 		xntimer_enqueue_aperiodic(timer);
 	}
 

  reply	other threads:[~2007-01-02 14:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-02 10:20 [Xenomai-core] SVN checkin #2010 Jan Kiszka
2007-01-02 13:22 ` [Xenomai-core] " Philippe Gerum
2007-01-02 13:30   ` Gilles Chanteperdrix
2007-01-02 13:49     ` Philippe Gerum
2007-01-02 13:56       ` Gilles Chanteperdrix
2007-01-02 14:13         ` Philippe Gerum
2007-01-02 14:22           ` Jan Kiszka
2007-01-02 14:32             ` Gilles Chanteperdrix [this message]
2007-01-02 15:07               ` Philippe Gerum
2007-01-02 15:07               ` Jan Kiszka
2007-01-03  9:09               ` Gilles Chanteperdrix
2007-01-03 17:47               ` Philippe Gerum
2007-01-02 14:53             ` Philippe Gerum
2007-01-02 15:28               ` [Xenomai-core] Timer patches evaluation (was: SVN checkin #2010) Jan Kiszka
2007-01-02 16:19                 ` [Xenomai-core] " Philippe Gerum
2007-01-03  9:31                   ` [Xenomai-core] Re: Timer patches evaluation Gilles Chanteperdrix

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=459A6CFD.4030805@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=jan.kiszka@domain.hid \
    --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.