linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Safonov <dima@arista.com>
To: linux-kernel@vger.kernel.org
Cc: Dmitry Safonov <0x7f454c46@gmail.com>,
	Andrei Vagin <avagin@gmail.com>, Dmitry Safonov <dima@arista.com>,
	Adrian Reber <adrian@lisas.de>, Andrei Vagin <avagin@openvz.org>,
	Andy Lutomirski <luto@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	Christian Brauner <christian.brauner@ubuntu.com>,
	Cyrill Gorcunov <gorcunov@openvz.org>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>,
	Jann Horn <jannh@google.com>, Jeff Dike <jdike@addtoit.com>,
	Oleg Nesterov <oleg@redhat.com>,
	Pavel Emelyanov <xemul@virtuozzo.com>,
	Shuah Khan <shuah@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Vincenzo Frascino <vincenzo.frascino@arm.com>,
	containers@lists.linux-foundation.org, criu@openvz.org,
	linux-api@vger.kernel.org, x86@kernel.org
Subject: [PATCHv5 03/37] posix-clocks: Rename the clock_get() into clock_get_timespec()
Date: Mon, 29 Jul 2019 22:56:45 +0100	[thread overview]
Message-ID: <20190729215758.28405-4-dima@arista.com> (raw)
In-Reply-To: <20190729215758.28405-1-dima@arista.com>

From: Andrei Vagin <avagin@gmail.com>

The upcoming support for time namespaces requires to have access to:
 - The time in a task's time namespace for sys_clock_gettime()
 - The time in the root name space for common_timer_get()

That adds a valid reason to finally implement a separate callback which
returns the time in ktime_t format, rather than in (struct timespec).

Rename clock_get() callback into clock_get_timespec() as a preparation
for introducing clock_get_ktime().

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
Co-developed-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 kernel/time/alarmtimer.c       |  4 ++--
 kernel/time/posix-clock.c      |  8 ++++----
 kernel/time/posix-cpu-timers.c | 32 ++++++++++++++++----------------
 kernel/time/posix-timers.c     | 22 +++++++++++-----------
 kernel/time/posix-timers.h     |  4 ++--
 5 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 57518efc3810..cada96fdc615 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -644,7 +644,7 @@ static int alarm_clock_getres(const clockid_t which_clock, struct timespec64 *tp
 }
 
 /**
- * alarm_clock_get - posix clock_get interface
+ * alarm_clock_get - posix clock_get_timespec interface
  * @which_clock: clockid
  * @tp: timespec to fill.
  *
@@ -824,7 +824,7 @@ static int alarm_timer_nsleep(const clockid_t which_clock, int flags,
 
 const struct k_clock alarm_clock = {
 	.clock_getres		= alarm_clock_getres,
-	.clock_get		= alarm_clock_get,
+	.clock_get_timespec	= alarm_clock_get,
 	.timer_create		= alarm_timer_create,
 	.timer_set		= common_timer_set,
 	.timer_del		= common_timer_del,
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index ec960bb939fd..c8f9c9b1cd82 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -315,8 +315,8 @@ static int pc_clock_settime(clockid_t id, const struct timespec64 *ts)
 }
 
 const struct k_clock clock_posix_dynamic = {
-	.clock_getres	= pc_clock_getres,
-	.clock_set	= pc_clock_settime,
-	.clock_get	= pc_clock_gettime,
-	.clock_adj	= pc_clock_adjtime,
+	.clock_getres		= pc_clock_getres,
+	.clock_set		= pc_clock_settime,
+	.clock_get_timespec	= pc_clock_gettime,
+	.clock_adj		= pc_clock_adjtime,
 };
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 0a426f4e3125..dccf7dfcd36a 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -1417,26 +1417,26 @@ static int thread_cpu_timer_create(struct k_itimer *timer)
 }
 
 const struct k_clock clock_posix_cpu = {
-	.clock_getres	= posix_cpu_clock_getres,
-	.clock_set	= posix_cpu_clock_set,
-	.clock_get	= posix_cpu_clock_get,
-	.timer_create	= posix_cpu_timer_create,
-	.nsleep		= posix_cpu_nsleep,
-	.timer_set	= posix_cpu_timer_set,
-	.timer_del	= posix_cpu_timer_del,
-	.timer_get	= posix_cpu_timer_get,
-	.timer_rearm	= posix_cpu_timer_rearm,
+	.clock_getres		= posix_cpu_clock_getres,
+	.clock_set		= posix_cpu_clock_set,
+	.clock_get_timespec	= posix_cpu_clock_get,
+	.timer_create		= posix_cpu_timer_create,
+	.nsleep			= posix_cpu_nsleep,
+	.timer_set		= posix_cpu_timer_set,
+	.timer_del		= posix_cpu_timer_del,
+	.timer_get		= posix_cpu_timer_get,
+	.timer_rearm		= posix_cpu_timer_rearm,
 };
 
 const struct k_clock clock_process = {
-	.clock_getres	= process_cpu_clock_getres,
-	.clock_get	= process_cpu_clock_get,
-	.timer_create	= process_cpu_timer_create,
-	.nsleep		= process_cpu_nsleep,
+	.clock_getres		= process_cpu_clock_getres,
+	.clock_get_timespec	= process_cpu_clock_get,
+	.timer_create		= process_cpu_timer_create,
+	.nsleep			= process_cpu_nsleep,
 };
 
 const struct k_clock clock_thread = {
-	.clock_getres	= thread_cpu_clock_getres,
-	.clock_get	= thread_cpu_clock_get,
-	.timer_create	= thread_cpu_timer_create,
+	.clock_getres		= thread_cpu_clock_getres,
+	.clock_get_timespec	= thread_cpu_clock_get,
+	.timer_create		= thread_cpu_timer_create,
 };
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index d7f2d91acdac..6c9c0f2d2f1e 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -667,7 +667,7 @@ void common_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting)
 	 * The timespec64 based conversion is suboptimal, but it's not
 	 * worth to implement yet another callback.
 	 */
-	kc->clock_get(timr->it_clock, &ts64);
+	kc->clock_get_timespec(timr->it_clock, &ts64);
 	now = timespec64_to_ktime(ts64);
 
 	/*
@@ -781,7 +781,7 @@ static void common_hrtimer_arm(struct k_itimer *timr, ktime_t expires,
 	 * Posix magic: Relative CLOCK_REALTIME timers are not affected by
 	 * clock modifications, so they become CLOCK_MONOTONIC based under the
 	 * hood. See hrtimer_init(). Update timr->kclock, so the generic
-	 * functions which use timr->kclock->clock_get() work.
+	 * functions which use timr->kclock->clock_get_timespec() work.
 	 *
 	 * Note: it_clock stays unmodified, because the next timer_set() might
 	 * use ABSTIME, so it needs to switch back.
@@ -1032,7 +1032,7 @@ SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
 	if (!kc)
 		return -EINVAL;
 
-	error = kc->clock_get(which_clock, &kernel_tp);
+	error = kc->clock_get_timespec(which_clock, &kernel_tp);
 
 	if (!error && put_timespec64(&kernel_tp, tp))
 		error = -EFAULT;
@@ -1114,7 +1114,7 @@ SYSCALL_DEFINE2(clock_gettime32, clockid_t, which_clock,
 	if (!kc)
 		return -EINVAL;
 
-	err = kc->clock_get(which_clock, &ts);
+	err = kc->clock_get_timespec(which_clock, &ts);
 
 	if (!err && put_old_timespec32(&ts, tp))
 		err = -EFAULT;
@@ -1226,7 +1226,7 @@ SYSCALL_DEFINE4(clock_nanosleep_time32, clockid_t, which_clock, int, flags,
 
 static const struct k_clock clock_realtime = {
 	.clock_getres		= posix_get_hrtimer_res,
-	.clock_get		= posix_clock_realtime_get,
+	.clock_get_timespec	= posix_clock_realtime_get,
 	.clock_set		= posix_clock_realtime_set,
 	.clock_adj		= posix_clock_realtime_adj,
 	.nsleep			= common_nsleep,
@@ -1243,7 +1243,7 @@ static const struct k_clock clock_realtime = {
 
 static const struct k_clock clock_monotonic = {
 	.clock_getres		= posix_get_hrtimer_res,
-	.clock_get		= posix_ktime_get_ts,
+	.clock_get_timespec	= posix_ktime_get_ts,
 	.nsleep			= common_nsleep,
 	.timer_create		= common_timer_create,
 	.timer_set		= common_timer_set,
@@ -1258,22 +1258,22 @@ static const struct k_clock clock_monotonic = {
 
 static const struct k_clock clock_monotonic_raw = {
 	.clock_getres		= posix_get_hrtimer_res,
-	.clock_get		= posix_get_monotonic_raw,
+	.clock_get_timespec	= posix_get_monotonic_raw,
 };
 
 static const struct k_clock clock_realtime_coarse = {
 	.clock_getres		= posix_get_coarse_res,
-	.clock_get		= posix_get_realtime_coarse,
+	.clock_get_timespec	= posix_get_realtime_coarse,
 };
 
 static const struct k_clock clock_monotonic_coarse = {
 	.clock_getres		= posix_get_coarse_res,
-	.clock_get		= posix_get_monotonic_coarse,
+	.clock_get_timespec	= posix_get_monotonic_coarse,
 };
 
 static const struct k_clock clock_tai = {
 	.clock_getres		= posix_get_hrtimer_res,
-	.clock_get		= posix_get_tai,
+	.clock_get_timespec	= posix_get_tai,
 	.nsleep			= common_nsleep,
 	.timer_create		= common_timer_create,
 	.timer_set		= common_timer_set,
@@ -1288,7 +1288,7 @@ static const struct k_clock clock_tai = {
 
 static const struct k_clock clock_boottime = {
 	.clock_getres		= posix_get_hrtimer_res,
-	.clock_get		= posix_get_boottime,
+	.clock_get_timespec	= posix_get_boottime,
 	.nsleep			= common_nsleep,
 	.timer_create		= common_timer_create,
 	.timer_set		= common_timer_set,
diff --git a/kernel/time/posix-timers.h b/kernel/time/posix-timers.h
index de5daa6d975a..b3cc9ee36a6b 100644
--- a/kernel/time/posix-timers.h
+++ b/kernel/time/posix-timers.h
@@ -6,8 +6,8 @@ struct k_clock {
 				struct timespec64 *tp);
 	int	(*clock_set)(const clockid_t which_clock,
 			     const struct timespec64 *tp);
-	int	(*clock_get)(const clockid_t which_clock,
-			     struct timespec64 *tp);
+	int	(*clock_get_timespec)(const clockid_t which_clock,
+				      struct timespec64 *tp);
 	int	(*clock_adj)(const clockid_t which_clock, struct __kernel_timex *tx);
 	int	(*timer_create)(struct k_itimer *timer);
 	int	(*nsleep)(const clockid_t which_clock, int flags,
-- 
2.22.0


  parent reply	other threads:[~2019-07-29 21:58 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-29 21:56 [PATCHv5 00/37] kernel: Introduce Time Namespace Dmitry Safonov
2019-07-29 21:56 ` [PATCHv5 01/37] ns: " Dmitry Safonov
2019-08-01  5:29   ` Andy Lutomirski
2019-08-01 23:46     ` Dmitry Safonov
2019-08-07  0:24   ` [PATCHv6 " Dmitry Safonov
2019-07-29 21:56 ` [PATCHv5 02/37] timens: Add timens_offsets Dmitry Safonov
2019-07-29 21:56 ` Dmitry Safonov [this message]
2019-07-29 21:56 ` [PATCHv5 04/37] posix-clocks: Rename *_clock_get() functions into *_clock_get_timespec() Dmitry Safonov
2019-08-07  6:01   ` Thomas Gleixner
2019-07-29 21:56 ` [PATCHv5 05/37] alarmtimer: Rename gettime() callback to get_ktime() Dmitry Safonov
2019-07-29 21:56 ` [PATCHv5 06/37] alarmtimer: Provide get_timespec() callback Dmitry Safonov
2019-08-07  6:04   ` Thomas Gleixner
2019-08-08  6:18     ` Andrei Vagin
2019-07-29 21:56 ` [PATCHv5 07/37] posix-clocks: Introduce clock_get_ktime() callback Dmitry Safonov
2019-07-29 21:56 ` [PATCHv5 08/37] posix-timers: Use clock_get_ktime() in common_timer_get() Dmitry Safonov
2019-07-29 21:56 ` [PATCHv5 09/37] posix-clocks: Introduce CLOCK_MONOTONIC time namespace offsets Dmitry Safonov
2019-08-07  6:07   ` Thomas Gleixner
2019-07-29 21:56 ` [PATCHv5 10/37] posix-clocks: Introduce CLOCK_BOOTTIME time namespace offset Dmitry Safonov
2019-07-29 21:56 ` [PATCHv5 11/37] kernel: Add do_timens_ktime_to_host() helper Dmitry Safonov
2019-07-29 21:56 ` [PATCHv5 12/37] timerfd: Make timerfd_settime() time namespace aware Dmitry Safonov
2019-07-29 21:56 ` [PATCHv5 13/37] posix-timers: Make timer_settime() " Dmitry Safonov
2019-07-29 21:56 ` [PATCHv5 14/37] alarmtimer: Make nanosleep " Dmitry Safonov
2019-07-29 21:56 ` [PATCHv5 15/37] hrtimers: Prepare hrtimer_nanosleep() for time namespaces Dmitry Safonov
2019-07-29 21:56 ` [PATCHv5 16/37] posix-timers: Make clock_nanosleep() time namespace aware Dmitry Safonov
2019-07-29 21:56 ` [PATCHv5 17/37] fd/proc: Respect boottime inside time namespace for /proc/uptime Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 18/37] x86/vdso2c: Correct err messages on file opening Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 19/37] x86/vdso2c: Convert iterator to unsigned Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 20/37] x86/vdso/Makefile: Add vobjs32 Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 21/37] x86/vdso: Restrict splitting VVAR VMA Dmitry Safonov
2019-08-01  5:23   ` Andy Lutomirski
2019-07-29 21:57 ` [PATCHv5 22/37] x86/vdso: Rename vdso_image {.data=>.text} Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 23/37] x86/vdso: Add offsets page in vvar Dmitry Safonov
2019-08-01  5:22   ` Andy Lutomirski
2019-07-29 21:57 ` [PATCHv5 24/37] x86/vdso: Allocate timens vdso Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 25/37] x86/vdso: Switch image on setns()/clone() Dmitry Safonov
2019-08-01  5:34   ` Andy Lutomirski
2019-08-01  6:09     ` hpa
2019-08-01 21:39       ` Andy Lutomirski
2019-08-07  0:27   ` [PATCHv6 " Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 26/37] vdso: Introduce vdso_static_branch_unlikely() Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 27/37] x86/vdso2c: Process jump tables Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 28/37] x86/vdso: Enable static branches for the timens vdso Dmitry Safonov
2019-08-01  5:21   ` Andy Lutomirski
2019-08-01  6:48     ` Thomas Gleixner
2019-07-29 21:57 ` [PATCHv5 29/37] posix-clocks: Add align for timens_offsets Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 30/37] fs/proc: Introduce /proc/pid/timens_offsets Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 31/37] selftest/timens: Add Time Namespace test for supported clocks Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 32/37] selftest/timens: Add a test for timerfd Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 33/37] selftest/timens: Add a test for clock_nanosleep() Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 34/37] selftest/timens: Add procfs selftest Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 35/37] selftest/timens: Add timer offsets test Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 36/37] selftests/timens: Add a simple perf test for clock_gettime() Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 37/37] selftest/timens: Check that a right vdso is mapped after fork and exec Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 00/37] kernel: Introduce Time Namespace Dmitry Safonov
2019-07-29 22:07   ` Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 01/37] ns: " Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 02/37] timens: Add timens_offsets Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 03/37] posix-clocks: Rename the clock_get() into clock_get_timespec() Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 04/37] posix-clocks: Rename *_clock_get() functions into *_clock_get_timespec() Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 05/37] alarmtimer: Rename gettime() callback to get_ktime() Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 06/37] alarmtimer: Provide get_timespec() callback Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 07/37] posix-clocks: Introduce clock_get_ktime() callback Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 08/37] posix-timers: Use clock_get_ktime() in common_timer_get() Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 09/37] posix-clocks: Introduce CLOCK_MONOTONIC time namespace offsets Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 10/37] posix-clocks: Introduce CLOCK_BOOTTIME time namespace offset Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 11/37] kernel: Add do_timens_ktime_to_host() helper Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 12/37] timerfd: Make timerfd_settime() time namespace aware Dmitry Safonov
2019-07-29 21:57 ` [PATCHv5 13/37] posix-timers: Make timer_settime() " Dmitry Safonov

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=20190729215758.28405-4-dima@arista.com \
    --to=dima@arista.com \
    --cc=0x7f454c46@gmail.com \
    --cc=adrian@lisas.de \
    --cc=arnd@arndb.de \
    --cc=avagin@gmail.com \
    --cc=avagin@openvz.org \
    --cc=christian.brauner@ubuntu.com \
    --cc=containers@lists.linux-foundation.org \
    --cc=criu@openvz.org \
    --cc=ebiederm@xmission.com \
    --cc=gorcunov@openvz.org \
    --cc=hpa@zytor.com \
    --cc=jannh@google.com \
    --cc=jdike@addtoit.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=oleg@redhat.com \
    --cc=shuah@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=vincenzo.frascino@arm.com \
    --cc=x86@kernel.org \
    --cc=xemul@virtuozzo.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).