All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: "François Legal" <devel@thom.fr.eu.org>
Cc: Jan Kiszka <jan.kiszka@siemens.com>,
	Julien Blanc <julien.blanc@sprinte.eu>,
	"xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: Large gpio interrupt latency
Date: Fri, 23 Jul 2021 10:04:58 +0200	[thread overview]
Message-ID: <87v9515uc5.fsf@xenomai.org> (raw)
In-Reply-To: <10a7-60fa6980-b1-35a6e6c0@10117939>


François Legal <devel@thom.fr.eu.org> writes:

> Le Mardi, Juin 22, 2021 12:07 CEST, Philippe Gerum <rpm@xenomai.org> a écrit: 
>  
>> 
>> Jan Kiszka <jan.kiszka@siemens.com> writes:
>> 
>> > On 22.06.21 11:31, Philippe Gerum wrote:
>> >> 
>> >> Jan Kiszka <jan.kiszka@siemens.com> writes:
>> >> 
>> >>> On 22.06.21 10:37, Philippe Gerum wrote:
>> >>>>
>> >>>> Jan Kiszka <jan.kiszka@siemens.com> writes:
>> >>>>
>> >>>>> On 22.06.21 09:49, Julien Blanc via Xenomai wrote:
>> >>>>>> Le mardi 22 juin 2021 à 09:38 +0200, Philippe Gerum via Xenomai a
>> >>>>>> écrit :
>> >>>>>>>
>> >>>>>>> With this in mind, assuming that we have previously sanitized the
>> >>>>>>> clock
>> >>>>>>> identifier, doing this:
>> >>>>>>>
>> >>>>>>> #define get_timestamp(__clock) \
>> >>>>>>> ({ (__clock) == CLOCK_MONOTONIC ? rtdm_clock_read_monotonic() :
>> >>>>>>> rtdm_clock_read(); })
>> >>>>>>>
>> >>>>>>> may end up being faster than:
>> >>>>>>>
>> >>>>>>> xnticks_t (*__get_timestamp)(clockid_t clock);
>> >>>>>>> #define get_timestamp(__clock)	__get_timestamp(__clock)
>> >>>>>>
>> >>>>>> Is really a runtime switch necessary ? Since relying on the realtime
>> >>>>>> clock is inherently broken, my understanding is that it should be kept
>> >>>>>> as compatibility purpose only.
>> >>>>>
>> >>>>> Again: The real-time clock is not a broken clock per se. It is the basis
>> >>>>> of many services (POSIX...) and - if managed properly - it is as sound
>> >>>>> clock to build upon. If you need absolute timestamps to calculate
>> >>>>> absolute timeouts (like users of the existing code do), this is the
>> >>>>> clock to go, also in future versions.
>> >>>>
>> >>>> Definitely correct, for timeout specs.
>> >>>>
>> >>>>> Also if you want to use
>> >>>>> PTP-sync'ed clocks across systems (TSN...), it is THE way to go. At that
>> >>>>> point, monotonic timestamps will lose relevance in practice.
>> >>>>>
>> >>>>
>> >>>> We are not there yet. So, let's all agree than we need both clock bases,
>> >>>> and a flexible way to select the current one.
>> >>>>
>> >>>
>> >>> What's still missing with Dovetail and a Linux-operated PTP sync for the
>> >>> main clocksource? Hardending of software-based sync paths? Where it's
>> >>> hw-based, that should already be fine (latest Intel SOCs).
>> >>>
>> >> 
>> >> Again, we have two use cases: absolute timeouts based on a common epoch
>> >> which may change, and delays. We do know PTP with hw-based support is an
>> >> efficient way to maintain consistency among users of the former,
>> >> nevertheless we still need to express/measure strict delays in other
>> >> cases. So, we do need both clocks.
>> >> 
>> >
>> > If you need cross-system event stamping, the unsync'ed monotonic clock
>> > is the wrong choice as well.
>> >
>> 
>> As usual, it's a trade-off, a risk assessment between observing
>> non-coherent SMP readings and warp jumps. This is a call an application
>> should be allowed to make, I see no reason to impose a solution
>> arbitrarily without knowing what the app actually wants to do.
>> 
>> > Again: What is missing to use PTP-sync'ed clock-realtime under Dovetail
>> > today?
>> >
>> 
>> Nothing when it comes to reading timestamps, via the NMI-safe
>> ktime_get_real_fast_ns() service (updates will be non-preemptible while
>> holding the seqlock).
>> 
>
> Hi there,
>
> to move this topic forward, I propose to create a patch to replace the call to rtdm_clock_read_monotonic by rtdm_clock_read in gpio_core.c,
> plus another one that would introduce the possibility to switch between those 2 different clocks.
>

There is no timed wait calls in this driver which might benefit from a
general "clock switch" feature, is it?  So what about either of these
options instead:

- adding GPIO_RTIOC_TS_REAL only for the purpose of retrieving
  timestamps. That would leave the existing client code unaffected, and
  _might_ be backported to the stable tree since this is a mere
  extension of the ABI.

- renaming the current ioctl request to GPIO_RTIOC_GET_TS_MONO, and
  provide GPIO_RTIOC_GET_TS[_REAL] based on rtdm_clock_read() in the
  same move. That would force the existing client code to revisit their
  implementation wrt retrieving a timestamp, providing the desired
  alternative between mono/real too. That sort of change would have to
  wait for 3.2 though.

-- 
Philippe.


  reply	other threads:[~2021-07-23  8:04 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-16  7:15 Large gpio interrupt latency François Legal
2021-06-16  8:10 ` Chen, Hongzhan
2021-06-16  8:18   ` François Legal
2021-06-16  9:05     ` Chen, Hongzhan
2021-06-16  9:12       ` François Legal
2021-06-16  9:40         ` Jan Kiszka
2021-06-16 13:29           ` François Legal
2021-06-16 13:38             ` Jan Kiszka
2021-06-16 13:51               ` François Legal
2021-06-16 15:10                 ` Jan Kiszka
2021-06-17  7:15                   ` François Legal
2021-06-18 18:41                   ` François Legal
2021-06-21  6:56                     ` Jan Kiszka
2021-06-21  9:39                       ` Philippe Gerum
2021-06-21 13:38                         ` Jan Kiszka
2021-06-21 13:54                           ` Philippe Gerum
2021-06-21 14:02                             ` Jan Kiszka
2021-06-21 14:28                               ` Philippe Gerum
2021-06-21 14:46                                 ` Jan Kiszka
2021-06-21 14:57                                   ` Philippe Gerum
2021-06-21 15:35                                     ` François Legal
2021-06-21 16:38                                       ` Philippe Gerum
2021-06-21 16:45                                         ` Philippe Gerum
2021-06-21 18:06                                           ` François Legal
2021-06-22  7:38                                             ` Philippe Gerum
2021-06-22  7:49                                               ` Julien Blanc
2021-06-22  8:22                                                 ` Jan Kiszka
2021-06-22  8:37                                                   ` Philippe Gerum
2021-06-22  9:14                                                     ` Jan Kiszka
2021-06-22  9:31                                                       ` Philippe Gerum
2021-06-22  9:39                                                         ` Jan Kiszka
2021-06-22 10:07                                                           ` Philippe Gerum
2021-07-23  7:02                                                             ` François Legal
2021-07-23  8:04                                                               ` Philippe Gerum [this message]
2021-08-02 12:24                                                                 ` Jan Kiszka
2021-08-05 15:11                                                                   ` François Legal

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=87v9515uc5.fsf@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=devel@thom.fr.eu.org \
    --cc=jan.kiszka@siemens.com \
    --cc=julien.blanc@sprinte.eu \
    --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.