netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/25] timekeeping: Rework to prepare support of indenpendent PTP clocks
@ 2024-10-09  8:28 Anna-Maria Behnsen
  2024-10-09  8:28 ` [PATCH v2 01/25] timekeeping: Read NTP tick length only once Anna-Maria Behnsen
                   ` (24 more replies)
  0 siblings, 25 replies; 53+ messages in thread
From: Anna-Maria Behnsen @ 2024-10-09  8:28 UTC (permalink / raw)
  To: John Stultz, Frederic Weisbecker, Thomas Gleixner
  Cc: linux-kernel, netdev, Miroslav Lichvar, Richard Cochran,
	Christopher S Hall, Anna-Maria Behnsen

The generic clock and timekeeping infrastructure supports only the already
defined clocks and as they are not independent there is no need of
generalization of data structures. But PTP clocks can be independent from
CLOCK_TAI.

PTP clocks already have clock_gettime() support via the file descriptor
based posix clocks. These interfaces access the PTP hardware and are
therefore slow and cannot be used from within the kernel, e.g. TSN
networking.

This problem can be solved by emulating clock_gettime() via the system
clock source e.g. TSC on x86. Such emulation requires:

1. timekeeping mechanism similar to the existing system timekeeping
2. clock steering equivalent to NTP/adjtimex()

In the already existing system timekeeping implementation the lock and
shadow timekeeper are separate from the timekeeper and sequence
counter. Move this information into a new struct type "tk_data" to be able
to recycle it for the above explained approach.

NTP/adjtimex() related information is all stored in static variables. Move
all of them into the new struct type ntp_data to make it reusable. (See
https://lore.kernel.org/r/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-0-2d52f4e13476@linutronix.de)

Even without the future support for independent PTP clocks, the
generalization of timekeeping and NTP/adjtimex() improves the structure and
readability of the already existing code.

Once this is implemented clock_gettime() support for these clocks via vdso
can be implement as well but this is an orthogonal task.

This queue covers only the generalization of timekeeping:

- Patch 1-5:   Basic cleanups
- Patch 6-11:  Generalization of tk_data
- Patch 12-25: Use always shadow timekeeper for updates

The queue is available here:

  git://git.kernel.org/pub/scm/linux/kernel/git/anna-maria/linux-devel.git timers/ptp/timekeeping

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
---
Changes in v2:
- Fix build problem reported by Simon Horman
- Link to v1: https://lore.kernel.org/r/20240911-devel-anna-maria-b4-timers-ptp-timekeeping-v1-0-f7cae09e25d6@linutronix.de

Thanks,

        Anna-Maria

---
Anna-Maria Behnsen (17):
      timekeeping: Avoid duplicate leap state update
      timekeeping: Move timekeeper_lock into tk_core
      timekeeping: Define a struct type for tk_core to make it reusable
      timekeeping: Introduce tkd_basic_setup() to make lock and seqcount init reusable
      timekeeping: Add struct tk_data as argument to timekeeping_update()
      timekeeping: Split out timekeeper update of timekeeping_advanced()
      timekeeping: Introduce combined timekeeping action flag
      timekeeping: Rework do_settimeofday64() to use shadow_timekeeper
      timekeeping: Rework timekeeping_inject_offset() to use shadow_timekeeper
      timekeeping: Rework change_clocksource() to use shadow_timekeeper
      timekeeping: Rework timekeeping_init() to use shadow_timekeeper
      timekeeping: Rework timekeeping_inject_sleeptime64() to use shadow_timekeeper
      timekeeping: Rework timekeeping_resume() to use shadow_timekeeper
      timekeeping: Rework timekeeping_suspend() to use shadow_timekeeper
      timekeeping: Rework do_adjtimex() to use shadow_timekeeper
      timekeeping: Remove TK_MIRROR timekeeping_update() action
      timekeeping: Merge timekeeping_update_staged() and timekeeping_update()

Thomas Gleixner (8):
      timekeeping: Read NTP tick length only once
      timekeeping: Don't stop time readers across hard_pps() update
      timekeeping: Abort clocksource change in case of failure
      timekeeping: Simplify code in timekeeping_advance()
      timekeeping: Reorder struct timekeeper
      timekeeping: Move shadow_timekeeper into tk_core
      timekeeping: Encapsulate locking/unlocking of timekeeper_lock
      timekeeping: Provide timekeeping_restore_shadow()

 include/linux/timekeeper_internal.h | 102 ++++++----
 kernel/time/timekeeping.c           | 369 +++++++++++++++++-------------------
 kernel/time/timekeeping_internal.h  |   3 +-
 kernel/time/vsyscall.c              |   5 +-
 4 files changed, 238 insertions(+), 241 deletions(-)


^ permalink raw reply	[flat|nested] 53+ messages in thread

end of thread, other threads:[~2024-10-24 22:41 UTC | newest]

Thread overview: 53+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-09  8:28 [PATCH v2 00/25] timekeeping: Rework to prepare support of indenpendent PTP clocks Anna-Maria Behnsen
2024-10-09  8:28 ` [PATCH v2 01/25] timekeeping: Read NTP tick length only once Anna-Maria Behnsen
2024-10-09 17:18   ` John Stultz
2024-10-09  8:28 ` [PATCH v2 02/25] timekeeping: Don't stop time readers across hard_pps() update Anna-Maria Behnsen
2024-10-09  8:28 ` [PATCH v2 03/25] timekeeping: Avoid duplicate leap state update Anna-Maria Behnsen
2024-10-09 17:31   ` John Stultz
2024-10-09  8:28 ` [PATCH v2 04/25] timekeeping: Abort clocksource change in case of failure Anna-Maria Behnsen
2024-10-09 19:58   ` John Stultz
2024-10-09  8:28 ` [PATCH v2 05/25] timekeeping: Simplify code in timekeeping_advance() Anna-Maria Behnsen
2024-10-09 21:00   ` John Stultz
2024-10-09  8:28 ` [PATCH v2 06/25] timekeeping: Reorder struct timekeeper Anna-Maria Behnsen
2024-10-11  3:22   ` John Stultz
2024-10-14  9:30     ` Anna-Maria Behnsen
2024-10-15 10:08   ` [PATCH v2a] " Anna-Maria Behnsen
2024-10-09  8:29 ` [PATCH v2 07/25] timekeeping: Move shadow_timekeeper into tk_core Anna-Maria Behnsen
2024-10-24 21:11   ` John Stultz
2024-10-09  8:29 ` [PATCH v2 08/25] timekeeping: Encapsulate locking/unlocking of timekeeper_lock Anna-Maria Behnsen
2024-10-24 21:19   ` John Stultz
2024-10-09  8:29 ` [PATCH v2 09/25] timekeeping: Move timekeeper_lock into tk_core Anna-Maria Behnsen
2024-10-24 21:20   ` John Stultz
2024-10-09  8:29 ` [PATCH v2 10/25] timekeeping: Define a struct type for tk_core to make it reusable Anna-Maria Behnsen
2024-10-24 21:21   ` John Stultz
2024-10-09  8:29 ` [PATCH v2 11/25] timekeeping: Introduce tkd_basic_setup() to make lock and seqcount init reusable Anna-Maria Behnsen
2024-10-24 21:25   ` John Stultz
2024-10-09  8:29 ` [PATCH v2 12/25] timekeeping: Add struct tk_data as argument to timekeeping_update() Anna-Maria Behnsen
2024-10-24 21:29   ` John Stultz
2024-10-09  8:29 ` [PATCH v2 13/25] timekeeping: Split out timekeeper update of timekeeping_advanced() Anna-Maria Behnsen
2024-10-24 21:43   ` John Stultz
2024-10-24 21:53   ` John Stultz
2024-10-09  8:29 ` [PATCH v2 14/25] timekeeping: Introduce combined timekeeping action flag Anna-Maria Behnsen
2024-10-24 22:12   ` John Stultz
2024-10-09  8:29 ` [PATCH v2 15/25] timekeeping: Provide timekeeping_restore_shadow() Anna-Maria Behnsen
2024-10-24 21:45   ` John Stultz
2024-10-09  8:29 ` [PATCH v2 16/25] timekeeping: Rework do_settimeofday64() to use shadow_timekeeper Anna-Maria Behnsen
2024-10-24 21:54   ` John Stultz
2024-10-09  8:29 ` [PATCH v2 17/25] timekeeping: Rework timekeeping_inject_offset() " Anna-Maria Behnsen
2024-10-24 21:57   ` John Stultz
2024-10-09  8:29 ` [PATCH v2 18/25] timekeeping: Rework change_clocksource() " Anna-Maria Behnsen
2024-10-24 21:58   ` John Stultz
2024-10-09  8:29 ` [PATCH v2 19/25] timekeeping: Rework timekeeping_init() " Anna-Maria Behnsen
2024-10-24 22:16   ` John Stultz
2024-10-09  8:29 ` [PATCH v2 20/25] timekeeping: Rework timekeeping_inject_sleeptime64() " Anna-Maria Behnsen
2024-10-24 22:16   ` John Stultz
2024-10-09  8:29 ` [PATCH v2 21/25] timekeeping: Rework timekeeping_resume() " Anna-Maria Behnsen
2024-10-24 22:18   ` John Stultz
2024-10-09  8:29 ` [PATCH v2 22/25] timekeeping: Rework timekeeping_suspend() " Anna-Maria Behnsen
2024-10-24 22:21   ` John Stultz
2024-10-09  8:29 ` [PATCH v2 23/25] timekeeping: Rework do_adjtimex() " Anna-Maria Behnsen
2024-10-24 22:26   ` John Stultz
2024-10-09  8:29 ` [PATCH v2 24/25] timekeeping: Remove TK_MIRROR timekeeping_update() action Anna-Maria Behnsen
2024-10-24 22:29   ` John Stultz
2024-10-09  8:29 ` [PATCH v2 25/25] timekeeping: Merge timekeeping_update_staged() and timekeeping_update() Anna-Maria Behnsen
2024-10-24 22:41   ` John Stultz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).