Dennis Kellly
|
ClockCycles() use in interrupt handlers
|
Dennis Kellly
03/14/2008 11:44 AM
post5816
|
ClockCycles() use in interrupt handlers
ClockCycles() is listed in docs as "unsafe" to call from an interrupt handler. However, for interrupt latency tests,
there seems to be no "safe" call for a precise timestamp.
Also release notes for 6.2.1B list "Execution of ClockCycles() inside an interrupt causes kernel crash (Ref# 14369)" as
having been fixed, i.e. it must have been a valid use case.
Why is it listed as unsafe? Does it re-enable interrupts on exit?
Thanks.
|
|
|
Attilla Danko(deleted)
|
Re: ClockCycles() use in interrupt handlers
|
Attilla Danko(deleted)
03/14/2008 3:35 PM
post5833
|
Re: ClockCycles() use in interrupt handlers
I've been using ClockCycles() from the context of the clock interrupt
handler since 2004.
Dennis Kellly wrote:
> ClockCycles() is listed in docs as "unsafe" to call from an interrupt
> handler. However, for interrupt latency tests, there seems to be no
> "safe" call for a precise timestamp.
>
> Also release notes for 6.2.1B list "Execution of ClockCycles() inside an
> interrupt causes kernel crash (Ref# 14369)" as having been fixed, i.e.
> it must have been a valid use case.
>
> Why is it listed as unsafe? Does it re-enable interrupts on exit?
>
> Thanks.
>
>
>
> _______________________________________________
> OSTech
> http://community.qnx.com/sf/go/post5816
>
|
|
|
Mario Charest
|
Re: ClockCycles() use in interrupt handlers
|
Mario Charest
03/14/2008 3:42 PM
post5834
|
Re: ClockCycles() use in interrupt handlers
> ClockCycles() is listed in docs as "unsafe" to call from an interrupt handler.
> However, for interrupt latency tests, there seems to be no "safe" call for a
> precise timestamp.
>
> Also release notes for 6.2.1B list "Execution of ClockCycles() inside an
> interrupt causes kernel crash (Ref# 14369)" as having been fixed, i.e. it must
> have been a valid use case.
>
> Why is it listed as unsafe? Does it re-enable interrupts on exit?
>
> Thanks.
>
It's safe on x86 as for the other platform I don't know
|
|
|
Pavol Kycina
|
Re: ClockCycles() use in interrupt handlers
|
Pavol Kycina
03/17/2008 3:21 AM
post5849
|
Re: ClockCycles() use in interrupt handlers
It's probably safe only on HW which has rdtsc opcode.
When this opcode is missing, it crashes the kernel.
PKY
|
|
|
Thomas Haupt
|
AW: ClockCycles() use in interrupt handlers
|
Thomas Haupt
03/17/2008 5:43 AM
post5850
|
AW: ClockCycles() use in interrupt handlers
Looking at the implementations in
/usr/include/<platform>/neutrino.h
it looks like there are interrupt-safe implementations of ClockCycles()
for all platforms except for the ARM (i.e., mips, ppc, sh, and x86).
I guess a function is listed as "unsafe" as long as we cannot guarantee
that the implementation will be [interrupt]-safe on /all/ platforms...
Oh, and the bit about re-enabling interrupts would only be true for
kernel calls -- and those exactly you must avoid by all means in an
interrupt handler (the handler was itself invoked by the kernel; doing
a kernel-call would introduce a reentrancy we cannot handle at that
point). The inline-assembly-implementations of ClockCycles on non-arm-
platforms all just read some special CPU registers and maybe do a tiny
bit of calculation; so there's no need to call kernel there.
Hope this helps,
- Thomas
> -----Ursprüngliche Nachricht-----
> Von: Dennis Kelly
> Gesendet: 14 March 2008 16:44
> An: ostech-core_os
> Betreff: ClockCycles() use in interrupt handlers
>
>
> ClockCycles() is listed in docs as "unsafe" to call from an
> interrupt handler. However, for interrupt latency tests,
> there seems to be no "safe" call for a precise timestamp.
>
> Also release notes for 6.2.1B list "Execution of
> ClockCycles() inside an interrupt causes kernel crash (Ref#
> 14369)" as having been fixed, i.e. it must have been a valid use case.
>
> Why is it listed as unsafe? Does it re-enable interrupts on exit?
>
> Thanks.
>
>
>
> _______________________________________________
> OSTech
> http://community.qnx.com/sf/go/post5816
>
|
|
|
Brian Stecher
|
Re: ClockCycles() use in interrupt handlers
|
Brian Stecher
03/17/2008 8:01 AM
post5853
|
Re: ClockCycles() use in interrupt handlers
The documentation is wrong. ClockCyles() is safe to use in all environments
on all architectures. The kernel instrumentation wouldn't work if that
wasn't true.
On Mon, Mar 17, 2008 at 05:43:34AM -0400, Thomas Haupt wrote:
> Looking at the implementations in
> /usr/include/<platform>/neutrino.h
> it looks like there are interrupt-safe implementations of ClockCycles()
> for all platforms except for the ARM (i.e., mips, ppc, sh, and x86).
>
> I guess a function is listed as "unsafe" as long as we cannot guarantee
> that the implementation will be [interrupt]-safe on /all/ platforms...
>
> Oh, and the bit about re-enabling interrupts would only be true for
> kernel calls -- and those exactly you must avoid by all means in an
> interrupt handler (the handler was itself invoked by the kernel; doing
> a kernel-call would introduce a reentrancy we cannot handle at that
> point). The inline-assembly-implementations of ClockCycles on non-arm-
> platforms all just read some special CPU registers and maybe do a tiny
> bit of calculation; so there's no need to call kernel there.
>
> Hope this helps,
> - Thomas
>
> > -----Ursprüngliche Nachricht-----
> > Von: Dennis Kelly
> > Gesendet: 14 March 2008 16:44
> > An: ostech-core_os
> > Betreff: ClockCycles() use in interrupt handlers
> >
> >
> > ClockCycles() is listed in docs as "unsafe" to call from an
> > interrupt handler. However, for interrupt latency tests,
> > there seems to be no "safe" call for a precise timestamp.
> >
> > Also release notes for 6.2.1B list "Execution of
> > ClockCycles() inside an interrupt causes kernel crash (Ref#
> > 14369)" as having been fixed, i.e. it must have been a valid use case.
> >
> > Why is it listed as unsafe? Does it re-enable interrupts on exit?
> >
> > Thanks.
> >
> >
> >
> > _______________________________________________
> > OSTech
> > http://community.qnx.com/sf/go/post5816
> >
>
> _______________________________________________
> OSTech
> http://community.qnx.com/sf/go/post5850
--
Brian Stecher (bstecher@qnx.com) QNX Software Systems
phone: +1 (613) 591-0931 (voice) 175 Terence Matthews Cr.
+1 (613) 591-3579 (fax) Kanata, Ontario, Canada K2M 1W8
|
|
|
Dennis Kellly
|
Re: ClockCycles() use in interrupt handlers
|
Dennis Kellly
03/17/2008 8:52 AM
post5854
|
Re: ClockCycles() use in interrupt handlers
>>>The documentation is wrong.
Thanks. It would be good if we get the docs fixed for 6.4.
|
|
|
Brian K Hlady(deleted)
|
RE: ClockCycles() use in interrupt handlers
|
Brian K Hlady(deleted)
03/17/2008 9:20 AM
post5855
|
RE: ClockCycles() use in interrupt handlers
Dennis,
Can you please file a PR then? That's the best way to ensure it gets fixed.
Cheers,
-Brian
> -----Original Message-----
> From: Dennis Kellly [mailto:dkelly@qnx.com]
> Sent: Monday, March 17, 2008 08 53
> To: ostech-core_os
> Subject: Re: ClockCycles() use in interrupt handlers
>
> >>>The documentation is wrong.
> Thanks. It would be good if we get the docs fixed for 6.4.
>
> _______________________________________________
> OSTech
> http://community.qnx.com/sf/go/post5854
>
|
|
|
Steve Reid
|
Re: RE: ClockCycles() use in interrupt handlers
|
Steve Reid
03/19/2008 4:27 PM
post5982
|
Re: RE: ClockCycles() use in interrupt handlers
|
|
|
Michael Tasche
|
Re: ClockCycles() use in interrupt handlers
|
Michael Tasche
04/08/2008 2:29 AM
post6513
|
Re: ClockCycles() use in interrupt handlers
Hi,
> The documentation is wrong. ClockCyles() is safe to use in all environments
since when?
I remember, that "rdtsc" instructions were emulated on 386/486 cpu's by "wrong opcode exceptions" using the PIT. This
did "not" work in ISR's.
If this has been changed, can someone tell me the 1st QNX Version, which can use ClockCycles in ISR's on 386/486?
-Michael
> on all architectures. The kernel instrumentation wouldn't work if that
> wasn't true.
>
> On Mon, Mar 17, 2008 at 05:43:34AM -0400, Thomas Haupt wrote:
> > Looking at the implementations in
> > /usr/include/<platform>/neutrino.h
> > it looks like there are interrupt-safe implementations of ClockCycles()
> > for all platforms except for the ARM (i.e., mips, ppc, sh, and x86).
> >
> > I guess a function is listed as "unsafe" as long as we cannot guarantee
> > that the implementation will be [interrupt]-safe on /all/ platforms...
> >
> > Oh, and the bit about re-enabling interrupts would only be true for
> > kernel calls -- and those exactly you must avoid by all means in an
> > interrupt handler (the handler was itself invoked by the kernel; doing
> > a kernel-call would introduce a reentrancy we cannot handle at that
> > point). The inline-assembly-implementations of ClockCycles on non-arm-
> > platforms all just read some special CPU registers and maybe do a tiny
> > bit of calculation; so there's no need to call kernel there.
> >
> > Hope this helps,
> > - Thomas
> >
> > > -----Ursprüngliche Nachricht-----
> > > Von: Dennis Kelly
> > > Gesendet: 14 March 2008 16:44
> > > An: ostech-core_os
> > > Betreff: ClockCycles() use in interrupt handlers
> > >
> > >
> > > ClockCycles() is listed in docs as "unsafe" to call from an
> > > interrupt handler. However, for interrupt latency tests,
> > > there seems to be no "safe" call for a precise timestamp.
> > >
> > > Also release notes for 6.2.1B list "Execution of
> > > ClockCycles() inside an interrupt causes kernel crash (Ref#
> > > 14369)" as having been fixed, i.e. it must have been a valid use case.
> > >
> > > Why is it listed as unsafe? Does it re-enable interrupts on exit?
> > >
> > > Thanks.
> > >
> > >
> > >
> > > _______________________________________________
> > > OSTech
> > > http://community.qnx.com/sf/go/post5816
> > >
> >
> > _______________________________________________
> > OSTech
> > http://community.qnx.com/sf/go/post5850
>
> --
> Brian Stecher (bstecher@qnx.com) QNX Software Systems
> phone: +1 (613) 591-0931 (voice) 175 Terence Matthews Cr.
> +1 (613) 591-3579 (fax) Kanata, Ontario, Canada K2M 1W8
|
|
|
Brian Stecher
|
Re: ClockCycles() use in interrupt handlers
|
Brian Stecher
04/08/2008 8:55 AM
post6520
|
Re: ClockCycles() use in interrupt handlers
On Tue, Apr 08, 2008 at 02:29:54AM -0400, Michael Tasche wrote:
> > The documentation is wrong. ClockCyles() is safe to use in all
environments
>
> since when?
> I remember, that "rdtsc" instructions were emulated on 386/486 cpu's by
"wrong opcode exceptions" using the PIT. This did "not" work in ISR's.
>
> If this has been changed, can someone tell me the 1st QNX Version, which
can use ClockCycles in ISR's on 386/486?
I don't know what version it went out in, but the bug fix was implemented
in January of 2003.
Brian
--
Brian Stecher (bstecher@qnx.com) QNX Software Systems
phone: +1 (613) 591-0931 (voice) 175 Terence Matthews Cr.
+1 (613) 591-3579 (fax) Kanata, Ontario, Canada K2M 1W8
|
|
|
|