netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: netdev@vger.kernel.org,
	"Richard Cochran" <richardcochran@gmail.com>,
	"Christopher Hall" <christopher.s.hall@intel.com>,
	"John Stultz" <jstultz@google.com>,
	"Frederic Weisbecker" <frederic@kernel.org>,
	"Anna-Maria Behnsen" <anna-maria@linutronix.de>,
	"Miroslav Lichvar" <mlichvar@redhat.com>,
	"Werner Abt" <werner.abt@meinberg-usa.com>,
	"David Woodhouse" <dwmw2@infradead.org>,
	"Stephen Boyd" <sboyd@kernel.org>,
	"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
	"Kurt Kanzenbach" <kurt@linutronix.de>,
	"Nam Cao" <namcao@linutronix.de>,
	"Antoine Tenart" <atenart@kernel.org>
Subject: [patch V2 05/26] time: Introduce auxiliary POSIX clocks
Date: Mon, 19 May 2025 10:33:20 +0200 (CEST)	[thread overview]
Message-ID: <20250519083025.905800695@linutronix.de> (raw)
In-Reply-To: 20250519082042.742926976@linutronix.de

From: Anna-Maria Behnsen <anna-maria@linutronix.de>

To support auxiliary timekeeping and the related user space interfaces,
it's required to define a clock ID range for them.

Reserve 8 auxiliary clock IDs after the regular timekeeping clock ID space.

This is the maximum number of auxiliary clocks the kernel can support. The actual
number of supported clocks depends obviously on the presence of related devices
and might be constraint by the available VDSO space.

Add the corresponding timekeeper IDs as well.

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 include/linux/timekeeper_internal.h |    6 ++++++
 include/uapi/linux/time.h           |   11 +++++++++++
 kernel/time/Kconfig                 |   15 +++++++++++++--
 3 files changed, 30 insertions(+), 2 deletions(-)
---
--- a/include/linux/timekeeper_internal.h
+++ b/include/linux/timekeeper_internal.h
@@ -14,10 +14,16 @@
 /**
  * timekeeper_ids - IDs for various time keepers in the kernel
  * @TIMEKEEPER_CORE:	The central core timekeeper managing system time
+ * @TIMEKEEPER_AUX:	The first AUX timekeeper
+ * @TIMEKEEPER_AUX_LAST:The last AUX timekeeper
  * @TIMEKEEPERS_MAX:	The maximum number of timekeepers managed
  */
 enum timekeeper_ids {
 	TIMEKEEPER_CORE,
+#ifdef CONFIG_POSIX_AUX_CLOCKS
+	TIMEKEEPER_AUX,
+	TIMEKEEPER_AUX_LAST = TIMEKEEPER_AUX + MAX_AUX_CLOCKS - 1,
+#endif
 	TIMEKEEPERS_MAX,
 };
 
--- a/include/uapi/linux/time.h
+++ b/include/uapi/linux/time.h
@@ -64,6 +64,17 @@ struct timezone {
 #define CLOCK_TAI			11
 
 #define MAX_CLOCKS			16
+
+/*
+ * AUX clock support. AUXiliary clocks are dynamically configured by
+ * enabling a clock ID. These clock can be steered independently of the
+ * core timekeeper. The kernel can support up to 8 auxiliary clocks, but
+ * the actual limit depends on eventual architecture constraints vs. VDSO.
+ */
+#define	CLOCK_AUX			MAX_CLOCKS
+#define	MAX_AUX_CLOCKS			8
+#define CLOCK_AUX_LAST			(CLOCK_AUX + MAX_AUX_CLOCKS - 1)
+
 #define CLOCKS_MASK			(CLOCK_REALTIME | CLOCK_MONOTONIC)
 #define CLOCKS_MONO			CLOCK_MONOTONIC
 
--- a/kernel/time/Kconfig
+++ b/kernel/time/Kconfig
@@ -82,9 +82,9 @@ config CONTEXT_TRACKING_IDLE
 	help
 	  Tracks idle state on behalf of RCU.
 
-if GENERIC_CLOCKEVENTS
 menu "Timers subsystem"
 
+if GENERIC_CLOCKEVENTS
 # Core internal switch. Selected by NO_HZ_COMMON / HIGH_RES_TIMERS. This is
 # only related to the tick functionality. Oneshot clockevent devices
 # are supported independent of this.
@@ -208,6 +208,17 @@ config CLOCKSOURCE_WATCHDOG_MAX_SKEW_US
 	  interval and NTP's maximum frequency drift of 500 parts
 	  per million.	If the clocksource is good enough for NTP,
 	  it is good enough for the clocksource watchdog!
+endif
+
+config POSIX_AUX_CLOCKS
+	bool "Enable auxiliary POSIX clocks"
+	depends on POSIX_TIMERS
+	help
+	  Auxiliary POSIX clocks are clocks which can be steered
+	  independently of the core timekeeper, which controls the
+	  MONOTONIC, REALTIME, BOOTTIME and TAI clocks.  They are useful to
+	  provide e.g. lockless time accessors to independent PTP clocks
+	  and other clock domains, which are not correlated to the TAI/NTP
+	  notion of time.
 
 endmenu
-endif


  parent reply	other threads:[~2025-05-19  8:33 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-19  8:33 [patch V2 00/26] timekeeping: Provide support for auxiliary timekeepers Thomas Gleixner
2025-05-19  8:33 ` [patch V2 01/26] timekeeping: Remove hardcoded access to tk_core Thomas Gleixner
2025-06-12 22:34   ` John Stultz
2025-05-19  8:33 ` [patch V2 02/26] timekeeping: Cleanup kernel doc of __ktime_get_real_seconds() Thomas Gleixner
2025-06-12 22:36   ` John Stultz
2025-05-19  8:33 ` [patch V2 03/26] timekeeping: Avoid double notification in do_adjtimex() Thomas Gleixner
2025-05-19  8:33 ` [patch V2 04/26] timekeeping: Introduce timekeeper ID Thomas Gleixner
2025-06-13  0:03   ` John Stultz
2025-05-19  8:33 ` Thomas Gleixner [this message]
2025-06-13  0:06   ` [patch V2 05/26] time: Introduce auxiliary POSIX clocks John Stultz
2025-05-19  8:33 ` [patch V2 06/26] ntp: Add support for auxiliary timekeepers Thomas Gleixner
2025-06-13  0:14   ` John Stultz
2025-06-13  6:32   ` Thomas Weißschuh
2025-05-19  8:33 ` [patch V2 07/26] ntp: Add timekeeper ID arguments to public functions Thomas Gleixner
2025-06-13  0:20   ` John Stultz
2025-05-19  8:33 ` [patch V2 08/26] ntp: Rename __do_adjtimex() to ntp_adjtimex() Thomas Gleixner
2025-06-13  0:20   ` John Stultz
2025-05-19  8:33 ` [patch V2 09/26] timekeeping: Make __timekeeping_advance() reusable Thomas Gleixner
2025-06-13  0:23   ` John Stultz
2025-05-19  8:33 ` [patch V2 10/26] timekeeping: Prepare timekeeping_update_from_shadow() Thomas Gleixner
2025-05-19  8:33 ` [patch V2 11/26] timekeeping: Add clock_valid flag to timekeeper Thomas Gleixner
2025-06-13  4:05   ` John Stultz
2025-05-19  8:33 ` [patch V2 12/26] timekeeping: Introduce auxiliary timekeepers Thomas Gleixner
2025-06-14  2:41   ` John Stultz
2025-05-19  8:33 ` [patch V2 13/26] timekeeping: Provide ktime_get_ntp_seconds() Thomas Gleixner
2025-05-19  8:33 ` [patch V2 14/26] ntp: Use ktime_get_ntp_seconds() Thomas Gleixner
2025-05-19  8:33 ` [patch V2 15/26] timekeeping: Add AUX offset to struct timekeeper Thomas Gleixner
2025-06-14  2:44   ` John Stultz
2025-05-19  8:33 ` [patch V2 16/26] timekeeping: Update auxiliary timekeepers on clocksource change Thomas Gleixner
2025-05-19  8:33 ` [patch V2 17/26] timekeeping: Provide time getters for auxiliary clocks Thomas Gleixner
2025-06-14  2:51   ` John Stultz
2025-06-14  7:18     ` Thomas Gleixner
2025-05-19  8:33 ` [patch V2 18/26] timekeeping: Add minimal posix-timers support " Thomas Gleixner
2025-05-19  8:33 ` [patch V2 19/26] timekeeping: Provide time setter " Thomas Gleixner
2025-05-19  8:33 ` [patch V2 20/26] timekeeping: Make timekeeping_inject_offset() reusable Thomas Gleixner
2025-05-19  8:33 ` [patch V2 21/26] timekeeping: Add auxiliary clock support to __timekeeping_inject_offset() Thomas Gleixner
2025-05-19  8:33 ` [patch V2 22/26] timekeeping: Make do_adjtimex() reusable Thomas Gleixner
2025-05-19  8:33 ` [patch V2 23/26] timekeeping: Prepare do_adtimex() for auxiliary clocks Thomas Gleixner
2025-05-19  8:33 ` [patch V2 24/26] timekeeping: Provide adjtimex() " Thomas Gleixner
2025-05-19  8:33 ` [patch V2 25/26] timekeeping: Provide update for auxiliary timekeepers Thomas Gleixner
2025-05-19  8:33 ` [patch V2 26/26] timekeeping: Provide interface to control auxiliary clocks Thomas Gleixner
2025-06-13  7:18   ` Thomas Weißschuh

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=20250519083025.905800695@linutronix.de \
    --to=tglx@linutronix.de \
    --cc=anna-maria@linutronix.de \
    --cc=atenart@kernel.org \
    --cc=christopher.s.hall@intel.com \
    --cc=dwmw2@infradead.org \
    --cc=frederic@kernel.org \
    --cc=jstultz@google.com \
    --cc=kurt@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mlichvar@redhat.com \
    --cc=namcao@linutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=sboyd@kernel.org \
    --cc=thomas.weissschuh@linutronix.de \
    --cc=werner.abt@meinberg-usa.com \
    /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 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).