Discussion:
[PATCH] Use tsc for implementation of clock_gettime.
Gilles Chanteperdrix
2007-05-17 11:29:56 UTC
Permalink
Hi,

here comes, for review, a patch which reduces the overhead of
clock_gettime by directly reading the tsc in user-space for
architectures that support it.
--
Gilles Chanteperdrix.
Jan Kiszka
2007-05-17 12:43:16 UTC
Permalink
Post by Gilles Chanteperdrix
Hi,
here comes, for review, a patch which reduces the overhead of
clock_gettime by directly reading the tsc in user-space for
architectures that support it.
Highly welcome. But I have one concern: How and when do you propagate
wallclock_offset changes to user space?

I think we need some vsyscall-alike approach for this, some read-only
page that is mapped into every RT process, containing things like a
regularly updated offset (seqlock fashioned) or other read-only
information (shadow mode? cpu id?).

Jan
Gilles Chanteperdrix
2007-05-17 12:54:02 UTC
Permalink
Post by Jan Kiszka
Post by Gilles Chanteperdrix
Hi,
here comes, for review, a patch which reduces the overhead of
clock_gettime by directly reading the tsc in user-space for
architectures that support it.
Highly welcome. But I have one concern: How and when do you propagate
wallclock_offset changes to user space?
Since clock_settime is not implemented, never, but if clock_settime was
implemented, clock_settime would re-issue the __xn_sys_info syscall.
Post by Jan Kiszka
I think we need some vsyscall-alike approach for this, some read-only
page that is mapped into every RT process, containing things like a
regularly updated offset (seqlock fashioned) or other read-only
information (shadow mode? cpu id?).
As I said yesterday, having a page mapped at a different address in
kernel-space and user-space is not an option on ARM, because each
mapping of this page would have a separated cache.
--
Gilles Chanteperdrix.
Jan Kiszka
2007-05-17 13:00:39 UTC
Permalink
Post by Gilles Chanteperdrix
Post by Jan Kiszka
Post by Gilles Chanteperdrix
Hi,
here comes, for review, a patch which reduces the overhead of
clock_gettime by directly reading the tsc in user-space for
architectures that support it.
Highly welcome. But I have one concern: How and when do you propagate
wallclock_offset changes to user space?
Since clock_settime is not implemented, never, but if clock_settime was
implemented, clock_settime would re-issue the __xn_sys_info syscall.
This excludes automatic clock adjustment, something I'm convinced we
will have to provide in the future.
Post by Gilles Chanteperdrix
Post by Jan Kiszka
I think we need some vsyscall-alike approach for this, some read-only
page that is mapped into every RT process, containing things like a
regularly updated offset (seqlock fashioned) or other read-only
information (shadow mode? cpu id?).
As I said yesterday, having a page mapped at a different address in
kernel-space and user-space is not an option on ARM, because each
mapping of this page would have a separated cache.
Hmm, what about the kernel writing directly to the (current) user
address? We then only need to keep track of the per-mm address and have
not fixed kernel equivalent. At least on arm, other archs may handle
this differently at compile time.

Jan
Gilles Chanteperdrix
2007-05-17 13:10:13 UTC
Permalink
Post by Jan Kiszka
Post by Gilles Chanteperdrix
Post by Jan Kiszka
Post by Gilles Chanteperdrix
Hi,
here comes, for review, a patch which reduces the overhead of
clock_gettime by directly reading the tsc in user-space for
architectures that support it.
Highly welcome. But I have one concern: How and when do you propagate
wallclock_offset changes to user space?
Since clock_settime is not implemented, never, but if clock_settime was
implemented, clock_settime would re-issue the __xn_sys_info syscall.
This excludes automatic clock adjustment, something I'm convinced we
will have to provide in the future.
When we provide automatic clock adjustment, we will have to devise
something more subtle than just an offset, so we will have to redesign
posix clocks support anyway. Maybe clock_gettime(CLOCK_REALTIME) will
then always be a syscall. After all, rt_timer_read is a syscall. If you
want the fast clock, use CLOCK_MONOTONIC or rt_timer_tsc.
--
Gilles Chanteperdrix.
Jan Kiszka
2007-05-17 13:31:44 UTC
Permalink
Post by Gilles Chanteperdrix
Post by Jan Kiszka
Post by Gilles Chanteperdrix
Post by Jan Kiszka
Post by Gilles Chanteperdrix
Hi,
here comes, for review, a patch which reduces the overhead of
clock_gettime by directly reading the tsc in user-space for
architectures that support it.
Highly welcome. But I have one concern: How and when do you propagate
wallclock_offset changes to user space?
Since clock_settime is not implemented, never, but if clock_settime was
implemented, clock_settime would re-issue the __xn_sys_info syscall.
This excludes automatic clock adjustment, something I'm convinced we
will have to provide in the future.
When we provide automatic clock adjustment, we will have to devise
something more subtle than just an offset, so we will have to redesign
I think offset + scaling factor.
Post by Gilles Chanteperdrix
posix clocks support anyway. Maybe clock_gettime(CLOCK_REALTIME) will
then always be a syscall. After all, rt_timer_read is a syscall. If you
want the fast clock, use CLOCK_MONOTONIC or rt_timer_tsc.
Actually, the issue of the intermediate approach starts earlier: as soon
as you have clock_settime. Then you need to sync the offset across
applications in different processes.

Having clock_monotonic (and maybe also rt_timer_tsc2ns) as a fast
variant already now is not bad. But beyond that, before introducing a
new interface between kernel and user space, I would like to consider
the effort to get it future-proof immediately. That doesn't mean that we
already have to implement clock adjustment, but we may already prepare
the prerequisites.

Jan
Gilles Chanteperdrix
2007-05-17 15:21:55 UTC
Permalink
Post by Jan Kiszka
Post by Gilles Chanteperdrix
Post by Jan Kiszka
Post by Gilles Chanteperdrix
Post by Jan Kiszka
Post by Gilles Chanteperdrix
Hi,
here comes, for review, a patch which reduces the overhead of
clock_gettime by directly reading the tsc in user-space for
architectures that support it.
Highly welcome. But I have one concern: How and when do you propagate
wallclock_offset changes to user space?
Since clock_settime is not implemented, never, but if clock_settime was
implemented, clock_settime would re-issue the __xn_sys_info syscall.
This excludes automatic clock adjustment, something I'm convinced we
will have to provide in the future.
When we provide automatic clock adjustment, we will have to devise
something more subtle than just an offset, so we will have to redesign
I think offset + scaling factor.
Post by Gilles Chanteperdrix
posix clocks support anyway. Maybe clock_gettime(CLOCK_REALTIME) will
then always be a syscall. After all, rt_timer_read is a syscall. If you
want the fast clock, use CLOCK_MONOTONIC or rt_timer_tsc.
Actually, the issue of the intermediate approach starts earlier: as soon
as you have clock_settime. Then you need to sync the offset across
applications in different processes.
Having clock_monotonic (and maybe also rt_timer_tsc2ns) as a fast
variant already now is not bad. But beyond that, before introducing a
new interface between kernel and user space, I would like to consider
the effort to get it future-proof immediately. That doesn't mean that we
already have to implement clock adjustment, but we may already prepare
the prerequisites.
Ok. Here is a new version that does not break the ABI, and where
clock_gettime(CLOCK_REALTIME) remains a syscall.

Note that it also adds user-space conversions between tsc and ns to the
native skin.
--
Gilles Chanteperdrix.
Gilles Chanteperdrix
2007-05-17 15:56:19 UTC
Permalink
Post by Gilles Chanteperdrix
Post by Jan Kiszka
Post by Gilles Chanteperdrix
Post by Jan Kiszka
Post by Gilles Chanteperdrix
Post by Jan Kiszka
Post by Gilles Chanteperdrix
Hi,
here comes, for review, a patch which reduces the overhead of
clock_gettime by directly reading the tsc in user-space for
architectures that support it.
Highly welcome. But I have one concern: How and when do you propagate
wallclock_offset changes to user space?
Since clock_settime is not implemented, never, but if clock_settime was
implemented, clock_settime would re-issue the __xn_sys_info syscall.
This excludes automatic clock adjustment, something I'm convinced we
will have to provide in the future.
When we provide automatic clock adjustment, we will have to devise
something more subtle than just an offset, so we will have to redesign
I think offset + scaling factor.
Post by Gilles Chanteperdrix
posix clocks support anyway. Maybe clock_gettime(CLOCK_REALTIME) will
then always be a syscall. After all, rt_timer_read is a syscall. If you
want the fast clock, use CLOCK_MONOTONIC or rt_timer_tsc.
Actually, the issue of the intermediate approach starts earlier: as soon
as you have clock_settime. Then you need to sync the offset across
applications in different processes.
Having clock_monotonic (and maybe also rt_timer_tsc2ns) as a fast
variant already now is not bad. But beyond that, before introducing a
new interface between kernel and user space, I would like to consider
the effort to get it future-proof immediately. That doesn't mean that we
already have to implement clock adjustment, but we may already prepare
the prerequisites.
Ok. Here is a new version that does not break the ABI, and where
clock_gettime(CLOCK_REALTIME) remains a syscall.
Note that it also adds user-space conversions between tsc and ns to the
native skin.
This one is actually tested.
--
Gilles Chanteperdrix.
Jan Kiszka
2007-05-18 05:52:12 UTC
Permalink
Post by Gilles Chanteperdrix
Post by Gilles Chanteperdrix
Post by Jan Kiszka
Post by Gilles Chanteperdrix
Post by Jan Kiszka
Post by Gilles Chanteperdrix
Post by Jan Kiszka
Post by Gilles Chanteperdrix
Hi,
here comes, for review, a patch which reduces the overhead of
clock_gettime by directly reading the tsc in user-space for
architectures that support it.
Highly welcome. But I have one concern: How and when do you propagate
wallclock_offset changes to user space?
Since clock_settime is not implemented, never, but if clock_settime was
implemented, clock_settime would re-issue the __xn_sys_info syscall.
This excludes automatic clock adjustment, something I'm convinced we
will have to provide in the future.
When we provide automatic clock adjustment, we will have to devise
something more subtle than just an offset, so we will have to redesign
I think offset + scaling factor.
Post by Gilles Chanteperdrix
posix clocks support anyway. Maybe clock_gettime(CLOCK_REALTIME) will
then always be a syscall. After all, rt_timer_read is a syscall. If you
want the fast clock, use CLOCK_MONOTONIC or rt_timer_tsc.
Actually, the issue of the intermediate approach starts earlier: as soon
as you have clock_settime. Then you need to sync the offset across
applications in different processes.
Having clock_monotonic (and maybe also rt_timer_tsc2ns) as a fast
variant already now is not bad. But beyond that, before introducing a
new interface between kernel and user space, I would like to consider
the effort to get it future-proof immediately. That doesn't mean that we
already have to implement clock adjustment, but we may already prepare
the prerequisites.
Ok. Here is a new version that does not break the ABI, and where
clock_gettime(CLOCK_REALTIME) remains a syscall.
Note that it also adds user-space conversions between tsc and ns to the
native skin.
This one is actually tested.
Looks good to me, builds and runs fine here.

Jan

Loading...