All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Wolfgang Mauerer <wm@domain.hid>
Cc: Jan Kiszka <jan.kiszka@domain.hid>,
	"xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai-core] Realtime gettimeofday()
Date: Wed, 02 Dec 2009 23:20:03 +0100	[thread overview]
Message-ID: <4B16E813.6050906@domain.hid> (raw)
In-Reply-To: <4B16E417.3000400@domain.hid>

Wolfgang Mauerer wrote:
> Gilles Chanteperdrix wrote:
>> Gilles Chanteperdrix wrote:
>>> Jan Kiszka wrote:
>>>> I surely don't want to duplicate ntp code, just the results it spits out
>>>> (e.g. into the vdso page).
>>> Ok, good point, we can avoid duplicating ntp code, but the vdso page
>>> trick only works on two architectures. So, IMO, the nucleus should get
>>> the infos, and copies them to the shared area. The question is to know
>>> if the infos are portable/in usable units such as nanoseconds or clock
>>> source ticks.
>> Ok. Had a look, the info is pretty much generic. We can use it on all
>> architectures. The point which would generate the I-pipe event is
>> vsyscall_update.
> completely agreed. But this required arch-specific changes to the
> I-pipe patch and cannot be done in a generic fashion.

Well, it can be done in many ways. One of them is to create a function

static inline ipipe_vsyscall_update(whatever)
{
	vsyscall_update(whatever);
	ipipe_dispatch_event(whatever);
}

in linux/clocksource.h

and replace calls to vsyscall_update in generic code with a call to
ipipe_vsyscall_update.

So, no, this does not necessarily requires arch-specific changes.
However, changing it in the arch-specific way is probably the easier to
maintain on the long run (if we use the method just sketched, we will
have to check with every release if a new call to vsyscall_update
appears). Besides, for the architectures which do not implement
vsyscall_update (the majority, xenomai-wise, only x86 and ppc implement
vsyscall_update), the call to ipipe_dispatch_event may be put in the
empty implementation which may be found in linux/clocksource.h.

>>>> The kernel need to synchronize with user land, so the problem is
>>>> (almost) the same as with obtaining the original data from Linux
>>>> directly: user land can only use a retry or a smart fall-back mechanism
>>>> to obtain consistent data.
>>> Well, ok, I imagine something like a revision counter. But I do not see
>>> how it would work on an SMP system (kernel writing on one CPU,
>>> user-space reading on another cpu).
>> Ok, I had a look at seqlock.h, we can do it the same way, in an area of
>> the global heap. We will have to provide our own implementation since we
>> can not include linux/seqlock.h in user-space. update_vsyscall on x86_64
>> turns off the irqs, to protect against the same code or some reader
>> being called in an interrupt handler. We will have to do the same.
> 
> But then the code can loop potentially unbounded, can't it? It may be
> that I'm missing something, but this was the initial reasaon for the
> three-buffer idea I've presented initially.

Well, on a normally running system, the update takes place for every
Linux timer interrupt (or is it only for the periodic tick ?), anyway,
if real-time code is running, there is no chance that it can be
preempted by a Linux timer interrupt, and if the code is called from non
real-time context, we do not care much.

Note that we already use such code for tsc emulation on some platforms,
and well, it works. And this is normal, the chances to get preempted
several times in a row by a timer interrupt without being able to
complete the loop are pretty low. Otherwise it would mean that there are
plenty of timer interrupts.

-- 
					    Gilles.


  reply	other threads:[~2009-12-02 22:20 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-02 12:55 [Xenomai-core] Realtime gettimeofday() Wolfgang Mauerer
2009-12-02 13:23 ` Gilles Chanteperdrix
2009-12-02 13:43   ` Jan Kiszka
2009-12-02 14:15     ` Gilles Chanteperdrix
2009-12-02 14:31       ` Jan Kiszka
2009-12-02 14:35         ` Gilles Chanteperdrix
2009-12-02 14:55           ` Jan Kiszka
2009-12-02 15:03             ` Gilles Chanteperdrix
2009-12-02 15:16               ` Jan Kiszka
2009-12-02 16:08                 ` Gilles Chanteperdrix
2009-12-02 16:23                   ` Jan Kiszka
2009-12-02 16:59                     ` Gilles Chanteperdrix
2009-12-02 20:54                       ` Gilles Chanteperdrix
2009-12-02 22:03                         ` Wolfgang Mauerer
2009-12-02 22:20                           ` Gilles Chanteperdrix [this message]
2009-12-02 22:33                             ` Gilles Chanteperdrix
2009-12-03  9:36                             ` Wolfgang Mauerer
2009-12-03 10:50                               ` Gilles Chanteperdrix
2009-12-03 13:11                                 ` Wolfgang Mauerer
2009-12-03 13:14                                   ` Gilles Chanteperdrix
2009-12-03 13:32                                     ` Wolfgang Mauerer
2009-12-03 13:38                                       ` Gilles Chanteperdrix
2009-12-03 20:31                                         ` Wolfgang Mauerer
2009-12-03 21:42                                           ` Gilles Chanteperdrix
2009-12-05 16:11                                             ` Philippe Gerum
2009-12-07  9:14                                               ` Jan Kiszka
2009-12-07 13:43                                                 ` Gilles Chanteperdrix
2009-12-07 13:50                                                   ` Jan Kiszka
2009-12-07 14:07                                                   ` Philippe Gerum
2009-12-07 14:21                                                     ` Wolfgang Mauerer
2009-12-15 15:00   ` Richard Cochran
2009-12-15 15:07     ` 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=4B16E813.6050906@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=jan.kiszka@domain.hid \
    --cc=wm@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.