All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: John Stultz <john.stultz@linaro.org>,
	Richard Cochran <richard.cochran@omicron.at>,
	Ingo Molnar <mingo@elte.hu>,
	Peter Zijlstra <peterz@infradead.org>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Arnd Bergmann <arnd@arndb.de>, Christoph Lameter <cl@linux.com>,
	David Miller <davem@davemloft.net>,
	Krzysztof Halasa <khc@pm.waw.pl>,
	Rodolfo Giometti <giometti@linux.it>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Mike Frysinger <vapier@gentoo.org>,
	Paul Mackerras <paulus@samba.org>,
	Russell King <linux@arm.linux.org.uk>
Subject: [patch 25/28] posix clocks: Introduce a syscall for clock tuning.
Date: Tue, 01 Feb 2011 13:52:26 -0000	[thread overview]
Message-ID: <20110201134419.869804645@linutronix.de> (raw)
In-Reply-To: 20110201134320.688829863@linutronix.de

[-- Attachment #1: posix-clocks-introduce-a-syscall-for-clock-tuning.patch --]
[-- Type: text/plain, Size: 5079 bytes --]

From: Richard Cochran <richardcochran@gmail.com>

A new syscall is introduced that allows tuning of a POSIX clock. The
new call, clock_adjtime, takes two parameters, the clock ID and a
pointer to a struct timex. Any ADJTIMEX(2) operation may be requested
via this system call, but various POSIX clocks may or may not support
tuning.

[ tglx: Adapted to the posix-timer cleanup series. Avoid copy_to_user
  	in the error case ]

Signed-off-by: Richard Cochran <richard.cochran@omicron.at>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Christoph Lameter <cl@linux.com>
Cc: David Miller <davem@davemloft.net>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Krzysztof Halasa <khc@pm.waw.pl>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rodolfo Giometti <giometti@linux.it>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Russell King <linux@arm.linux.org.uk>
LKML-Reference: <2d5e2f3e6f388aa1848d40406646aab2e26a906f.1296124770.git.richard.cochran@omicron.at>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/posix-timers.h |    2 ++
 include/linux/syscalls.h     |    2 ++
 kernel/compat.c              |   23 +++++++++++++++++++++++
 kernel/posix-timers.c        |   30 ++++++++++++++++++++++++++++++
 4 files changed, 57 insertions(+)

Index: linux-2.6-tip/include/linux/posix-timers.h
===================================================================
--- linux-2.6-tip.orig/include/linux/posix-timers.h
+++ linux-2.6-tip/include/linux/posix-timers.h
@@ -4,6 +4,7 @@
 #include <linux/spinlock.h>
 #include <linux/list.h>
 #include <linux/sched.h>
+#include <linux/timex.h>
 
 union cpu_time_count {
 	cputime_t cpu;
@@ -71,6 +72,7 @@ struct k_clock {
 	int (*clock_set) (const clockid_t which_clock,
 			  const struct timespec *tp);
 	int (*clock_get) (const clockid_t which_clock, struct timespec * tp);
+	int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
 	int (*timer_create) (struct k_itimer *timer);
 	int (*nsleep) (const clockid_t which_clock, int flags,
 		       struct timespec *, struct timespec __user *);
Index: linux-2.6-tip/include/linux/syscalls.h
===================================================================
--- linux-2.6-tip.orig/include/linux/syscalls.h
+++ linux-2.6-tip/include/linux/syscalls.h
@@ -311,6 +311,8 @@ asmlinkage long sys_clock_settime(clocki
 				const struct timespec __user *tp);
 asmlinkage long sys_clock_gettime(clockid_t which_clock,
 				struct timespec __user *tp);
+asmlinkage long sys_clock_adjtime(clockid_t which_clock,
+				struct timex __user *tx);
 asmlinkage long sys_clock_getres(clockid_t which_clock,
 				struct timespec __user *tp);
 asmlinkage long sys_clock_nanosleep(clockid_t which_clock, int flags,
Index: linux-2.6-tip/kernel/compat.c
===================================================================
--- linux-2.6-tip.orig/kernel/compat.c
+++ linux-2.6-tip/kernel/compat.c
@@ -675,6 +675,29 @@ long compat_sys_clock_gettime(clockid_t 
 	return err;
 }
 
+long compat_sys_clock_adjtime(clockid_t which_clock,
+		struct compat_timex __user *utp)
+{
+	struct timex txc;
+	mm_segment_t oldfs;
+	int err, ret;
+
+	err = compat_get_timex(&txc, utp);
+	if (err)
+		return err;
+
+	oldfs = get_fs();
+	set_fs(KERNEL_DS);
+	ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
+	set_fs(oldfs);
+
+	err = compat_put_timex(utp, &txc);
+	if (err)
+		return err;
+
+	return ret;
+}
+
 long compat_sys_clock_getres(clockid_t which_clock,
 		struct compat_timespec __user *tp)
 {
Index: linux-2.6-tip/kernel/posix-timers.c
===================================================================
--- linux-2.6-tip.orig/kernel/posix-timers.c
+++ linux-2.6-tip/kernel/posix-timers.c
@@ -170,6 +170,12 @@ static inline int posix_clock_realtime_s
 	return do_sys_settimeofday(tp, NULL);
 }
 
+static inline int posix_clock_realtime_adj(const clockid_t which_clock,
+					   struct timex *t)
+{
+	return do_adjtimex(t);
+}
+
 /*
  * Get monotonic time for posix timers
  */
@@ -216,6 +222,7 @@ static __init int init_posix_timers(void
 		.clock_getres	= hrtimer_get_res,
 		.clock_get	= posix_clock_realtime_get,
 		.clock_set	= posix_clock_realtime_set,
+		.clock_adj	= posix_clock_realtime_adj,
 		.nsleep		= common_nsleep,
 		.nsleep_restart	= hrtimer_nanosleep_restart,
 		.timer_create	= common_timer_create,
@@ -930,6 +937,29 @@ SYSCALL_DEFINE2(clock_gettime, const clo
 	return error;
 }
 
+SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock,
+		struct timex __user *, utx)
+{
+	struct k_clock *kc = clockid_to_kclock(which_clock);
+	struct timex ktx;
+	int err;
+
+	if (!kc)
+		return -EINVAL;
+	if (!kc->clock_adj)
+		return -EOPNOTSUPP;
+
+	if (copy_from_user(&ktx, utx, sizeof(ktx)))
+		return -EFAULT;
+
+	err = kc->clock_adj(which_clock, &ktx);
+
+	if (!err && copy_to_user(utx, &ktx, sizeof(ktx)))
+		return -EFAULT;
+
+	return err;
+}
+
 SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock,
 		struct timespec __user *, tp)
 {



  parent reply	other threads:[~2011-02-01 13:53 UTC|newest]

Thread overview: 111+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-01 13:50 [patch 00/28] Rework of the PTP support series core code Thomas Gleixner
2011-02-01 13:50 ` [patch 01/28] time: Correct the *settime* parameters Thomas Gleixner
2011-02-01 14:22   ` Thomas Gleixner
2011-02-01 20:32   ` john stultz
2011-02-02 21:54   ` [tip:timers/core] " tip-bot for Richard Cochran
2011-02-01 13:51 ` [patch 02/28] posix-timers: Define nanosleep not supported error separate Thomas Gleixner
2011-02-01 20:32   ` John Stultz
2011-02-02 21:55   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2011-02-01 13:51 ` [patch 03/28] posix-timers: Cleanup struct initializers Thomas Gleixner
2011-02-01 20:33   ` john stultz
2011-02-02 21:55   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2011-02-01 13:51 ` [patch 04/28] posix-timers: Introduce clock_posix_cpu Thomas Gleixner
2011-02-01 20:34   ` john stultz
2011-02-02 21:56   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2011-02-01 13:51 ` [patch 05/28] posix-timers: Introduce clockid_to_kclock() Thomas Gleixner
2011-02-01 20:37   ` john stultz
2011-02-02 21:56   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2011-02-01 13:51 ` [patch 06/28] posix-timers: Convert clock_nanosleep to clockid_to_kclock() Thomas Gleixner
2011-02-01 20:41   ` john stultz
2011-02-02 21:57   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2011-02-01 13:51 ` [patch 07/28] posix-timers: Convert clock_nanosleep_restart " Thomas Gleixner
2011-02-01 20:42   ` John Stultz
2011-02-01 20:46     ` Thomas Gleixner
2011-02-01 21:08       ` Thomas Gleixner
2011-02-02 21:57   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2011-02-01 13:51 ` [patch 08/28] posix-timers: Cleanup restart_block usage Thomas Gleixner
2011-02-01 21:11   ` john stultz
2011-02-01 21:14     ` Thomas Gleixner
2011-02-02 21:57   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2011-02-01 13:51 ` [patch 09/28] thread_info: Remove legacy arg0-3 from restart_block Thomas Gleixner
2011-02-01 21:11   ` john stultz
2011-02-02 21:58   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2011-02-01 13:51 ` [patch 10/28] posix-cpu-timers: Remove the stub nanosleep functions Thomas Gleixner
2011-02-01 21:14   ` John Stultz
2011-02-02 21:58   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2011-02-01 13:51 ` [patch 11/28] posix-timers: Convert clock_settime to clockid_to_kclock() Thomas Gleixner
2011-02-01 21:15   ` john stultz
2011-02-02 21:59   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2011-02-01 13:51 ` [patch 12/28] posix-timers: Convert clock_gettime() " Thomas Gleixner
2011-02-01 21:16   ` john stultz
2011-02-02  9:09   ` Richard Cochran
2011-02-02  9:55     ` Thomas Gleixner
2011-02-02 21:59   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2011-02-01 13:51 ` [patch 13/28] posix-timers: Convert clock_getres() " Thomas Gleixner
2011-02-01 21:17   ` john stultz
2011-02-02 22:00   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2011-02-01 13:51 ` [patch 14/28] posix-timers: Remove useless res field from k_clock Thomas Gleixner
2011-02-01 21:18   ` john stultz
2011-02-02 22:00   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2011-02-01 13:51 ` [patch 15/28] posix-timers: Convert timer_create() to clockid_to_kclock() Thomas Gleixner
2011-02-01 21:20   ` john stultz
2011-02-02 22:00   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2011-02-01 13:52 ` [patch 16/28] posix-timers: Convert timer_settime() " Thomas Gleixner
2011-02-01 21:22   ` John Stultz
2011-02-02 22:01   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2011-02-01 13:52 ` [patch 17/28] posix-timers: Convert timer_gettime() " Thomas Gleixner
2011-02-01 21:23   ` john stultz
2011-02-02 22:01   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2011-02-01 13:52 ` [patch 18/28] posix-timers: Convert timer_delete() " Thomas Gleixner
2011-02-01 21:24   ` john stultz
2011-02-02  8:29   ` Richard Cochran
2011-02-02  9:53     ` Thomas Gleixner
2011-02-02 22:02   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2011-02-01 13:52 ` [patch 19/28] posix-timers: Remove CLOCK_DISPATCH leftovers Thomas Gleixner
2011-02-01 21:25   ` john stultz
2011-02-02 22:02   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2011-02-01 13:52 ` [patch 20/28] posix-timers: Make posix-cpu-timers functions static Thomas Gleixner
2011-02-01 21:28   ` John Stultz
2011-02-01 21:33     ` Thomas Gleixner
2011-02-02 22:03   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2011-02-01 13:52 ` [patch 21/28] posix-timer: Update comment Thomas Gleixner
2011-02-01 21:28   ` john stultz
2011-02-02 22:03   ` [tip:timers/core] " tip-bot for Richard Cochran
2011-02-01 13:52 ` [patch 22/28] time: Introduce timekeeping_inject_offset Thomas Gleixner
2011-02-02 22:03   ` [tip:timers/core] " tip-bot for John Stultz
2011-02-01 13:52 ` [patch 23/28] ntp: Add ADJ_SETOFFSET mode bit Thomas Gleixner
2011-02-01 21:30   ` john stultz
2011-02-01 13:52 ` [patch 24/28] posix-clocks: Splitout compat timex accessors Thomas Gleixner
2011-02-01 21:31   ` john stultz
2011-02-02 22:04   ` [tip:timers/core] time: " tip-bot for Richard Cochran
2011-02-01 13:52 ` Thomas Gleixner [this message]
2011-02-01 21:35   ` [patch 25/28] posix clocks: Introduce a syscall for clock tuning john stultz
2011-02-02 22:04   ` [tip:timers/core] posix-timers: " tip-bot for Richard Cochran
2011-02-01 13:52 ` [patch 26/28] posix_clocks: Add clock_adjtime for x86 Thomas Gleixner
2011-02-01 21:36   ` john stultz
2011-02-02 22:05   ` [tip:timers/core] x86: " tip-bot for Richard Cochran
2011-02-01 13:52 ` [patch 27/28] posix-timers: Add support for fd based clocks Thomas Gleixner
2011-02-01 21:38   ` john stultz
2011-02-02  9:19   ` Richard Cochran
2011-02-02 10:33     ` Thomas Gleixner
2011-02-02 22:05   ` [tip:timers/core] " tip-bot for Richard Cochran
2011-02-01 13:52 ` [patch 28/28] posix clocks: Introduce dynamic clocks Thomas Gleixner
2011-02-01 21:49   ` john stultz
2011-02-01 22:04     ` Thomas Gleixner
2011-02-02  7:50     ` Richard Cochran
2011-02-02 10:37       ` Thomas Gleixner
2011-02-02 11:25         ` Thomas Gleixner
2011-02-02 22:06           ` [tip:timers/core] posix-timers: Cleanup namespace tip-bot for Thomas Gleixner
2011-02-02 22:06   ` [tip:timers/core] posix clocks: Introduce dynamic clocks tip-bot for Richard Cochran
2011-03-03 14:50   ` [patch 28/28] " torbenh
2011-03-03 16:01     ` Richard Cochran
2011-03-03 17:07       ` torbenh
2011-03-04  6:05         ` Richard Cochran
2011-02-02  8:17 ` [patch 00/28] Rework of the PTP support series core code Richard Cochran
2011-02-02 13:53 ` Richard Cochran
2011-02-02 22:04 ` [tip:timers/core] ntp: Add ADJ_SETOFFSET mode bit tip-bot for Richard Cochran
2011-02-18  9:07   ` Richard Cochran
2011-02-18 16:07     ` [tip:timers/core] ntp: Remove redundant and incorrect parameter check tip-bot for Richard Cochran
2011-03-01 15:38 ` [patch 00/28] Rework of the PTP support series core code torbenh
2011-03-01 18:50   ` Richard Cochran
2011-03-02  9:41     ` torbenh

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=20110201134419.869804645@linutronix.de \
    --to=tglx@linutronix.de \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=arnd@arndb.de \
    --cc=benh@kernel.crashing.org \
    --cc=cl@linux.com \
    --cc=davem@davemloft.net \
    --cc=giometti@linux.it \
    --cc=john.stultz@linaro.org \
    --cc=khc@pm.waw.pl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=richard.cochran@omicron.at \
    --cc=vapier@gentoo.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.