Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1653571 > unrolled thread

[patch 00/26] alarmtimers/posixtimers: Bug fixes and spec conformity changes

Started byThomas Gleixner <tglx@linutronix.de>
First post2017-05-30 23:50 +0200
Last post2017-06-05 10:30 +0200
Articles 20 on this page of 57 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [patch 00/26] alarmtimers/posixtimers: Bug fixes and spec conformity  changes Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
    [patch 09/26] posix-timers: Unify overrun/requeue_pending handling Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] posix-timers: Unify overrun/requeue_pending  handling tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:30 +0200
    [patch 19/26] posix-timers: Add cancel/arm callbacks Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] posix-timers: Add cancel/arm callbacks tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:30 +0200
    [patch 11/26] posix-timers: Store k_clock pointer in k_itimer Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] posix-timers: Store k_clock pointer in k_itimer tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:30 +0200
    [patch 24/26] alarmtimer: Implement try_to_cancel callback Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] alarmtimer: Implement try_to_cancel callback tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:30 +0200
    [patch 08/26] posix-timers: Move posix-timer internals to core Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      Re: [patch 08/26] posix-timers: Move posix-timer internals to core Christoph Hellwig <hch@infradead.org> - 2017-05-31 17:40 +0200
      [tip:timers/core] posix-timers: Move posix-timer internals to core tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:20 +0200
    [patch 17/26] posix-timers: Make use of forward/remaining callbacks Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] posix-timers: Make use of forward/remaining  callbacks tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:30 +0200
    [patch 07/26] posix-timers: Cleanup struct k_itimer Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] posix-timers: Cleanup struct k_itimer tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:20 +0200
    [patch 02/26] alarmtimer: Rate limit periodic intervals Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/urgent] alarmtimer: Rate limit periodic intervals tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-04 15:30 +0200
      [tip:timers/urgent] alarmtimer: Rate limit periodic intervals tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-04 15:40 +0200
    [patch 14/26] posix-timers: Use timer_rearm() callback in  posixtimer_rearm() Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] posix-timers: Use timer_rearm() callback in  posixtimer_rearm() tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:30 +0200
    [patch 04/26] posix-timers: Remove unused export of  posix_timer_event() Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] posix-timers: Remove unused export of  posix_timer_event() tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:20 +0200
    [patch 23/26] alarmtimer: Implement remaining callback Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] alarmtimer: Implement remaining callback tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:30 +0200
    [patch 13/26] posix-timers: Rename do_schedule_next_timer Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      Re: [patch 13/26] posix-timers: Rename do_schedule_next_timer Christoph Hellwig <hch@infradead.org> - 2017-05-31 17:40 +0200
        Re: [patch 13/26] posix-timers: Rename do_schedule_next_timer Thomas Gleixner <tglx@linutronix.de> - 2017-06-01 23:00 +0200
          Re: [patch 13/26] posix-timers: Rename do_schedule_next_timer Christoph Hellwig <hch@infradead.org> - 2017-06-02 09:10 +0200
      [tip:timers/core] posix-timers: Rename do_schedule_next_timer tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:30 +0200
    [patch 22/26] alarmtimer: Implement forward callback Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] alarmtimer: Implement forward callback tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:30 +0200
    [patch 03/26] alarmtimer: Remove pointless config conditional Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] alarmtimer: Remove pointless config conditional tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:20 +0200
    [patch 26/26] alarmtimer: Switch over to generic set/get/rearm routine Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] alarmtimer: Switch over to generic set/get/rearm  routine tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:30 +0200
    [patch 06/26] posix-timers: Avoid gazillions of forward declarations Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] posix-timers: Avoid gazillions of forward  declarations tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:20 +0200
    [patch 12/26] posix-timers: Add timer_rearm() callback Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] posix-timers: Add timer_rearm() callback tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:30 +0200
    [patch 01/26] alarmtimer: Prevent overflow of relative timers Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/urgent] alarmtimer: Prevent overflow of relative timers tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-04 15:30 +0200
      [tip:timers/urgent] alarmtimer: Prevent overflow of relative timers tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-04 15:40 +0200
    [patch 15/26] posix-timers: Add active flag to k_itimer Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] posix-timers: Add active flag to k_itimer tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:30 +0200
    [patch 16/26] posix-timers: Add forward/remaining callbacks Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] posix-timers: Add forward/remaining callbacks tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:30 +0200
    [patch 25/26] alarmtimer: Implement arm callback Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] alarmtimer: Implement arm callback tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:30 +0200
    [patch 21/26] alarmtimer: Implement timer_rearm() callback Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] alarmtimer: Implement timer_rearm() callback tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:30 +0200
    [patch 10/26] posix-timers: Move interval out of the union Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] posix-timers: Move interval out of the union tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:30 +0200
    [patch 20/26] posix-timers: Make use of cancel/arm callbacks Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] posix-timers: Make use of cancel/arm callbacks tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:30 +0200
    [patch 18/26] posix-timers: Zero settings value in common code Thomas Gleixner <tglx@linutronix.de> - 2017-05-30 23:50 +0200
      [tip:timers/core] posix-timers: Zero settings value in common code tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-06-05 10:30 +0200

Page 2 of 3 — ← Prev page 1 [2] 3  Next page →


#1657364 — [tip:timers/core] posix-timers: Use timer_rearm() callback in posixtimer_rearm()

Fromtip-bot for Thomas Gleixner <tipbot@zytor.com>
Date2017-06-05 10:30 +0200
Subject[tip:timers/core] posix-timers: Use timer_rearm() callback in posixtimer_rearm()
Message-ID<tOVyF-rf-3@gated-at.bofh.it>
In reply to#1653582
Commit-ID:  f37fb0aa4f453c7c785bbcecc4991ac48c5c0e51
Gitweb:     http://git.kernel.org/tip/f37fb0aa4f453c7c785bbcecc4991ac48c5c0e51
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Tue, 30 May 2017 23:15:47 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 4 Jun 2017 15:40:26 +0200

posix-timers: Use timer_rearm() callback in posixtimer_rearm()

Use the new timer_rearm() callback to replace the conditional hardcoded
calls into the hrtimer and cpu timer code.

This allows later to bring the same logic to alarmtimers.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/20170530211656.889661919@linutronix.de

---
 kernel/time/posix-cpu-timers.c |  7 +++++--
 kernel/time/posix-timers.c     | 12 ++++++------
 kernel/time/posix-timers.h     |  2 --
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 1ba576d..96c833a 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -15,6 +15,8 @@
 
 #include "posix-timers.h"
 
+static void posix_cpu_timer_rearm(struct k_itimer *timer);
+
 /*
  * Called after updating RLIMIT_CPU to run cpu timer and update
  * tsk->signal->cputime_expires expiration cache if necessary. Needs
@@ -528,7 +530,7 @@ static void cpu_timer_fire(struct k_itimer *timer)
 		 * reload the timer.  But we need to keep it
 		 * ticking in case the signal is deliverable next time.
 		 */
-		posix_cpu_timer_schedule(timer);
+		posix_cpu_timer_rearm(timer);
 		++timer->it_requeue_pending;
 	}
 }
@@ -984,7 +986,7 @@ static void check_process_timers(struct task_struct *tsk,
  * This is called from the signal code (via posixtimer_rearm)
  * when the last timer signal was delivered and we have to reload the timer.
  */
-void posix_cpu_timer_schedule(struct k_itimer *timer)
+static void posix_cpu_timer_rearm(struct k_itimer *timer)
 {
 	struct sighand_struct *sighand;
 	unsigned long flags;
@@ -1431,6 +1433,7 @@ const struct k_clock clock_posix_cpu = {
 	.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 = {
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 036b7e7..b12582a 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -278,10 +278,9 @@ static __init int init_posix_timers(void)
 					NULL);
 	return 0;
 }
-
 __initcall(init_posix_timers);
 
-static void schedule_next_timer(struct k_itimer *timr)
+static void common_hrtimer_rearm(struct k_itimer *timr)
 {
 	struct hrtimer *timer = &timr->it.real.timer;
 
@@ -315,10 +314,7 @@ void posixtimer_rearm(struct siginfo *info)
 		return;
 
 	if (timr->it_requeue_pending == info->si_sys_private) {
-		if (timr->it_clock < 0)
-			posix_cpu_timer_schedule(timr);
-		else
-			schedule_next_timer(timr);
+		timr->kclock->timer_rearm(timr);
 
 		timr->it_overrun_last = timr->it_overrun;
 		timr->it_overrun = -1;
@@ -1046,6 +1042,7 @@ static const struct k_clock clock_realtime = {
 	.timer_set	= common_timer_set,
 	.timer_get	= common_timer_get,
 	.timer_del	= common_timer_del,
+	.timer_rearm	= common_hrtimer_rearm,
 };
 
 static const struct k_clock clock_monotonic = {
@@ -1057,6 +1054,7 @@ static const struct k_clock clock_monotonic = {
 	.timer_set	= common_timer_set,
 	.timer_get	= common_timer_get,
 	.timer_del	= common_timer_del,
+	.timer_rearm	= common_hrtimer_rearm,
 };
 
 static const struct k_clock clock_monotonic_raw = {
@@ -1083,6 +1081,7 @@ static const struct k_clock clock_tai = {
 	.timer_set	= common_timer_set,
 	.timer_get	= common_timer_get,
 	.timer_del	= common_timer_del,
+	.timer_rearm	= common_hrtimer_rearm,
 };
 
 static const struct k_clock clock_boottime = {
@@ -1094,6 +1093,7 @@ static const struct k_clock clock_boottime = {
 	.timer_set	= common_timer_set,
 	.timer_get	= common_timer_get,
 	.timer_del	= common_timer_del,
+	.timer_rearm	= common_hrtimer_rearm,
 };
 
 static const struct k_clock * const posix_clocks[] = {
diff --git a/kernel/time/posix-timers.h b/kernel/time/posix-timers.h
index 02ffd1b..1f6f6f9 100644
--- a/kernel/time/posix-timers.h
+++ b/kernel/time/posix-timers.h
@@ -28,5 +28,3 @@ extern const struct k_clock clock_thread;
 extern const struct k_clock alarm_clock;
 
 int posix_timer_event(struct k_itimer *timr, int si_private);
-
-void posix_cpu_timer_schedule(struct k_itimer *timer);

[toc] | [prev] | [next] | [standalone]


#1653583 — [patch 04/26] posix-timers: Remove unused export of posix_timer_event()

FromThomas Gleixner <tglx@linutronix.de>
Date2017-05-30 23:50 +0200
Subject[patch 04/26] posix-timers: Remove unused export of posix_timer_event()
Message-ID<tMXbA-4e6-31@gated-at.bofh.it>
In reply to#1653571
Since the removal of the mmtimer driver the export is not longer needed.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/time/posix-timers.c |    1 -
 1 file changed, 1 deletion(-)

--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -442,7 +442,6 @@ int posix_timer_event(struct k_itimer *t
 	/* If we failed to send the signal the timer stops. */
 	return ret > 0;
 }
-EXPORT_SYMBOL_GPL(posix_timer_event);
 
 /*
  * This function gets called when a POSIX.1b interval timer expires.  It

[toc] | [prev] | [next] | [standalone]


#1657357 — [tip:timers/core] posix-timers: Remove unused export of posix_timer_event()

Fromtip-bot for Thomas Gleixner <tipbot@zytor.com>
Date2017-06-05 10:20 +0200
Subject[tip:timers/core] posix-timers: Remove unused export of posix_timer_event()
Message-ID<tOVp1-nU-35@gated-at.bofh.it>
In reply to#1653583
Commit-ID:  a81129e5a189973abd661704b261f8aad9325407
Gitweb:     http://git.kernel.org/tip/a81129e5a189973abd661704b261f8aad9325407
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Tue, 30 May 2017 23:15:37 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 4 Jun 2017 15:40:22 +0200

posix-timers: Remove unused export of posix_timer_event()

Since the removal of the mmtimer driver the export is not longer needed.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/20170530211656.052744418@linutronix.de

---
 kernel/time/posix-timers.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 0c0cccf..44d4865 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -442,7 +442,6 @@ int posix_timer_event(struct k_itimer *timr, int si_private)
 	/* If we failed to send the signal the timer stops. */
 	return ret > 0;
 }
-EXPORT_SYMBOL_GPL(posix_timer_event);
 
 /*
  * This function gets called when a POSIX.1b interval timer expires.  It

[toc] | [prev] | [next] | [standalone]


#1653585 — [patch 23/26] alarmtimer: Implement remaining callback

FromThomas Gleixner <tglx@linutronix.de>
Date2017-05-30 23:50 +0200
Subject[patch 23/26] alarmtimer: Implement remaining callback
Message-ID<tMXbA-4e6-35@gated-at.bofh.it>
In reply to#1653571
Preparatory change to utilize the common posix timer mechanisms.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/time/alarmtimer.c |   31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -561,6 +561,18 @@ static int alarm_timer_forward(struct k_
 }
 
 /**
+ * alarm_timer_remaining - Posix timer callback to retrieve remaining time
+ * @timr:	Pointer to the posixtimer data struct
+ * @now:	Current time to calculate against
+ */
+static ktime_t alarm_timer_remaining(struct k_itimer *timr, ktime_t now)
+{
+	struct alarm *alarm = &timr->it.alarm.alarmtimer;
+
+	return ktime_sub(now, alarm->node.expires);
+}
+
+/**
  * alarm_clock_getres - posix getres interface
  * @which_clock: clockid
  * @tp: timespec to fill
@@ -881,15 +893,16 @@ static int alarm_timer_nsleep(const cloc
 }
 
 const struct k_clock alarm_clock = {
-	.clock_getres	= alarm_clock_getres,
-	.clock_get	= alarm_clock_get,
-	.timer_create	= alarm_timer_create,
-	.timer_set	= alarm_timer_set,
-	.timer_del	= alarm_timer_del,
-	.timer_get	= alarm_timer_get,
-	.timer_rearm	= alarm_timer_rearm,
-	.timer_forward	= alarm_timer_forward,
-	.nsleep		= alarm_timer_nsleep,
+	.clock_getres		= alarm_clock_getres,
+	.clock_get		= alarm_clock_get,
+	.timer_create		= alarm_timer_create,
+	.timer_set		= alarm_timer_set,
+	.timer_del		= alarm_timer_del,
+	.timer_get		= alarm_timer_get,
+	.timer_rearm		= alarm_timer_rearm,
+	.timer_forward		= alarm_timer_forward,
+	.timer_remaining	= alarm_timer_remaining,
+	.nsleep			= alarm_timer_nsleep,
 };
 #endif /* CONFIG_POSIX_TIMERS */
 

[toc] | [prev] | [next] | [standalone]


#1657376 — [tip:timers/core] alarmtimer: Implement remaining callback

Fromtip-bot for Thomas Gleixner <tipbot@zytor.com>
Date2017-06-05 10:30 +0200
Subject[tip:timers/core] alarmtimer: Implement remaining callback
Message-ID<tOVyH-rf-37@gated-at.bofh.it>
In reply to#1653585
Commit-ID:  d653d8457c76da11f047af1f66256ac9b8421b69
Gitweb:     http://git.kernel.org/tip/d653d8457c76da11f047af1f66256ac9b8421b69
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Tue, 30 May 2017 23:15:56 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 4 Jun 2017 15:40:31 +0200

alarmtimer: Implement remaining callback

Preparatory change to utilize the common posix timer mechanisms.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/20170530211657.592676753@linutronix.de

---
 kernel/time/alarmtimer.c | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 6082cf1..02ddc40 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -561,6 +561,18 @@ static int alarm_timer_forward(struct k_itimer *timr, ktime_t now)
 }
 
 /**
+ * alarm_timer_remaining - Posix timer callback to retrieve remaining time
+ * @timr:	Pointer to the posixtimer data struct
+ * @now:	Current time to calculate against
+ */
+static ktime_t alarm_timer_remaining(struct k_itimer *timr, ktime_t now)
+{
+	struct alarm *alarm = &timr->it.alarm.alarmtimer;
+
+	return ktime_sub(now, alarm->node.expires);
+}
+
+/**
  * alarm_clock_getres - posix getres interface
  * @which_clock: clockid
  * @tp: timespec to fill
@@ -881,15 +893,16 @@ out:
 }
 
 const struct k_clock alarm_clock = {
-	.clock_getres	= alarm_clock_getres,
-	.clock_get	= alarm_clock_get,
-	.timer_create	= alarm_timer_create,
-	.timer_set	= alarm_timer_set,
-	.timer_del	= alarm_timer_del,
-	.timer_get	= alarm_timer_get,
-	.timer_rearm	= alarm_timer_rearm,
-	.timer_forward	= alarm_timer_forward,
-	.nsleep		= alarm_timer_nsleep,
+	.clock_getres		= alarm_clock_getres,
+	.clock_get		= alarm_clock_get,
+	.timer_create		= alarm_timer_create,
+	.timer_set		= alarm_timer_set,
+	.timer_del		= alarm_timer_del,
+	.timer_get		= alarm_timer_get,
+	.timer_rearm		= alarm_timer_rearm,
+	.timer_forward		= alarm_timer_forward,
+	.timer_remaining	= alarm_timer_remaining,
+	.nsleep			= alarm_timer_nsleep,
 };
 #endif /* CONFIG_POSIX_TIMERS */
 

[toc] | [prev] | [next] | [standalone]


#1653586 — [patch 13/26] posix-timers: Rename do_schedule_next_timer

FromThomas Gleixner <tglx@linutronix.de>
Date2017-05-30 23:50 +0200
Subject[patch 13/26] posix-timers: Rename do_schedule_next_timer
Message-ID<tMXbA-4e6-39@gated-at.bofh.it>
In reply to#1653571
That function is a misnomer. Rename it with a proper prefix to
posixtimer_rearm().

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/asm-generic/siginfo.h  |    2 +-
 kernel/signal.c                |    2 +-
 kernel/time/posix-cpu-timers.c |    2 +-
 kernel/time/posix-timers.c     |   10 +++++-----
 4 files changed, 8 insertions(+), 8 deletions(-)

--- a/include/asm-generic/siginfo.h
+++ b/include/asm-generic/siginfo.h
@@ -15,7 +15,7 @@
 #define __SI_CODE(T,N)	((T) | ((N) & 0xffff))
 
 struct siginfo;
-void do_schedule_next_timer(struct siginfo *info);
+void posixtimer_rearm(struct siginfo *info);
 
 extern int copy_siginfo_to_user(struct siginfo __user *to, const struct siginfo *from);
 
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -629,7 +629,7 @@ int dequeue_signal(struct task_struct *t
 		 * about to disable them again anyway.
 		 */
 		spin_unlock(&tsk->sighand->siglock);
-		do_schedule_next_timer(info);
+		posixtimer_rearm(info);
 		spin_lock(&tsk->sighand->siglock);
 	}
 #endif
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -973,7 +973,7 @@ static void check_process_timers(struct
 }
 
 /*
- * This is called from the signal code (via do_schedule_next_timer)
+ * This is called from the signal code (via posixtimer_rearm)
  * when the last timer signal was delivered and we have to reload the timer.
  */
 void posix_cpu_timer_schedule(struct k_itimer *timer)
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -305,7 +305,7 @@ static void schedule_next_timer(struct k
  * To protect against the timer going away while the interrupt is queued,
  * we require that the it_requeue_pending flag be set.
  */
-void do_schedule_next_timer(struct siginfo *info)
+void posixtimer_rearm(struct siginfo *info)
 {
 	struct k_itimer *timr;
 	unsigned long flags;
@@ -336,12 +336,12 @@ int posix_timer_event(struct k_itimer *t
 	int shared, ret = -1;
 	/*
 	 * FIXME: if ->sigq is queued we can race with
-	 * dequeue_signal()->do_schedule_next_timer().
+	 * dequeue_signal()->posixtimer_rearm().
 	 *
 	 * If dequeue_signal() sees the "right" value of
-	 * si_sys_private it calls do_schedule_next_timer().
+	 * si_sys_private it calls posixtimer_rearm().
 	 * We re-queue ->sigq and drop ->it_lock().
-	 * do_schedule_next_timer() locks the timer
+	 * posixtimer_rearm() locks the timer
 	 * and re-schedules it while ->sigq is pending.
 	 * Not really bad, but not that we want.
 	 */
@@ -701,7 +701,7 @@ SYSCALL_DEFINE2(timer_gettime, timer_t,
  * accumulating overruns on the next timer.  The overrun is frozen when
  * the signal is delivered, either at the notify time (if the info block
  * is not queued) or at the actual delivery time (as we are informed by
- * the call back to do_schedule_next_timer().  So all we need to do is
+ * the call back to posixtimer_rearm().  So all we need to do is
  * to pick up the frozen overrun.
  */
 SYSCALL_DEFINE1(timer_getoverrun, timer_t, timer_id)

[toc] | [prev] | [next] | [standalone]


#1654363 — Re: [patch 13/26] posix-timers: Rename do_schedule_next_timer

FromChristoph Hellwig <hch@infradead.org>
Date2017-05-31 17:40 +0200
SubjectRe: [patch 13/26] posix-timers: Rename do_schedule_next_timer
Message-ID<tNdT4-6EZ-19@gated-at.bofh.it>
In reply to#1653586
On Tue, May 30, 2017 at 11:15:46PM +0200, Thomas Gleixner wrote:
> That function is a misnomer. Rename it with a proper prefix to
> posixtimer_rearm().

Please also move it out of asm-generic/siginfo.h as it's implemented
and used in generic code only, and there is no arch override at all.

In fact it seems like asm-generic/siginfo.h should probably just move
to include/linux/signinfo.h.

[toc] | [prev] | [next] | [standalone]


#1655755 — Re: [patch 13/26] posix-timers: Rename do_schedule_next_timer

FromThomas Gleixner <tglx@linutronix.de>
Date2017-06-01 23:00 +0200
SubjectRe: [patch 13/26] posix-timers: Rename do_schedule_next_timer
Message-ID<tNFmi-7IJ-5@gated-at.bofh.it>
In reply to#1654363
On Wed, 31 May 2017, Christoph Hellwig wrote:

> On Tue, May 30, 2017 at 11:15:46PM +0200, Thomas Gleixner wrote:
> > That function is a misnomer. Rename it with a proper prefix to
> > posixtimer_rearm().
> 
> Please also move it out of asm-generic/siginfo.h as it's implemented
> and used in generic code only, and there is no arch override at all.
> 
> In fact it seems like asm-generic/siginfo.h should probably just move
> to include/linux/signinfo.h.

That's one convoluted mess.

# find -name siginfo.h | xargs grep 'include.*siginfo.h'

./arch/score/include/uapi/asm/siginfo.h:#include <asm-generic/siginfo.h>
./arch/powerpc/include/uapi/asm/siginfo.h:#include <asm-generic/siginfo.h>
./arch/sparc/include/asm/siginfo.h:#include <uapi/asm/siginfo.h>
./arch/sparc/include/uapi/asm/siginfo.h:#include <asm-generic/siginfo.h>
./arch/metag/include/uapi/asm/siginfo.h:#include <asm-generic/siginfo.h>
./arch/frv/include/uapi/asm/siginfo.h:#include <asm-generic/siginfo.h>
./arch/x86/include/uapi/asm/siginfo.h:#include <asm-generic/siginfo.h>
./arch/alpha/include/uapi/asm/siginfo.h:#include <asm-generic/siginfo.h>
./arch/tile/include/uapi/asm/siginfo.h:#include <asm-generic/siginfo.h>
./arch/mn10300/include/uapi/asm/siginfo.h:#include <asm-generic/siginfo.h>
./arch/m32r/include/uapi/asm/siginfo.h:#include <asm-generic/siginfo.h>
./arch/blackfin/include/uapi/asm/siginfo.h:#include <asm-generic/siginfo.h>
./arch/ia64/include/asm/siginfo.h:#include <uapi/asm/siginfo.h>
./arch/ia64/include/uapi/asm/siginfo.h:#include <asm-generic/siginfo.h>
./arch/arm64/include/uapi/asm/siginfo.h:#include <asm-generic/siginfo.h>
./arch/parisc/include/uapi/asm/siginfo.h:#include <asm-generic/siginfo.h>
./arch/mips/include/uapi/asm/siginfo.h:#include <asm-generic/siginfo.h>
./arch/s390/include/uapi/asm/siginfo.h: *  Derived from "include/asm-i386/siginfo.h"
./arch/s390/include/uapi/asm/siginfo.h:#include <asm-generic/siginfo.h>
./arch/microblaze/include/uapi/asm/siginfo.h:#include <asm-generic/siginfo.h>
./include/asm-generic/siginfo.h:#include <uapi/asm-generic/siginfo.h>

Why the heck include uapi headers asm-generic/siginfo.h ???

Thanks,

	tglx

[toc] | [prev] | [next] | [standalone]


#1655936 — Re: [patch 13/26] posix-timers: Rename do_schedule_next_timer

FromChristoph Hellwig <hch@infradead.org>
Date2017-06-02 09:10 +0200
SubjectRe: [patch 13/26] posix-timers: Rename do_schedule_next_timer
Message-ID<tNOSB-698-1@gated-at.bofh.it>
In reply to#1655755
On Thu, Jun 01, 2017 at 10:50:42PM +0200, Thomas Gleixner wrote:
> On Wed, 31 May 2017, Christoph Hellwig wrote:
> 
> > On Tue, May 30, 2017 at 11:15:46PM +0200, Thomas Gleixner wrote:
> > > That function is a misnomer. Rename it with a proper prefix to
> > > posixtimer_rearm().
> > 
> > Please also move it out of asm-generic/siginfo.h as it's implemented
> > and used in generic code only, and there is no arch override at all.
> > 
> > In fact it seems like asm-generic/siginfo.h should probably just move
> > to include/linux/signinfo.h.
> 
> That's one convoluted mess.

Yes.  I tried to give it some love 2 days ago but my first attempt
failed badly.  Here is what I'm at now, but it's not quite ready for
prime time:

   http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/siginfo

[toc] | [prev] | [next] | [standalone]


#1657370 — [tip:timers/core] posix-timers: Rename do_schedule_next_timer

Fromtip-bot for Thomas Gleixner <tipbot@zytor.com>
Date2017-06-05 10:30 +0200
Subject[tip:timers/core] posix-timers: Rename do_schedule_next_timer
Message-ID<tOVyG-rf-21@gated-at.bofh.it>
In reply to#1653586
Commit-ID:  96fe3b072f134e4993f829d599eaa1e0eb5a10e5
Gitweb:     http://git.kernel.org/tip/96fe3b072f134e4993f829d599eaa1e0eb5a10e5
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Tue, 30 May 2017 23:15:46 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 4 Jun 2017 15:40:25 +0200

posix-timers: Rename do_schedule_next_timer

That function is a misnomer. Rename it with a proper prefix to
posixtimer_rearm().

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/20170530211656.811362578@linutronix.de

---
 include/linux/posix-timers.h   |  2 +-
 kernel/signal.c                |  2 +-
 kernel/time/posix-cpu-timers.c |  2 +-
 kernel/time/posix-timers.c     | 10 +++++-----
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 8f9cca3..771e5f7 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -112,6 +112,6 @@ long clock_nanosleep_restart(struct restart_block *restart_block);
 
 void update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new);
 
-void do_schedule_next_timer(struct siginfo *info);
+void posixtimer_rearm(struct siginfo *info);
 
 #endif
diff --git a/kernel/signal.c b/kernel/signal.c
index 1f85c84..d031cd2 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -630,7 +630,7 @@ int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
 		 * about to disable them again anyway.
 		 */
 		spin_unlock(&tsk->sighand->siglock);
-		do_schedule_next_timer(info);
+		posixtimer_rearm(info);
 		spin_lock(&tsk->sighand->siglock);
 	}
 #endif
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 0123ece..1ba576d 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -981,7 +981,7 @@ static void check_process_timers(struct task_struct *tsk,
 }
 
 /*
- * This is called from the signal code (via do_schedule_next_timer)
+ * This is called from the signal code (via posixtimer_rearm)
  * when the last timer signal was delivered and we have to reload the timer.
  */
 void posix_cpu_timer_schedule(struct k_itimer *timer)
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index eb007e1..036b7e7 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -305,7 +305,7 @@ static void schedule_next_timer(struct k_itimer *timr)
  * To protect against the timer going away while the interrupt is queued,
  * we require that the it_requeue_pending flag be set.
  */
-void do_schedule_next_timer(struct siginfo *info)
+void posixtimer_rearm(struct siginfo *info)
 {
 	struct k_itimer *timr;
 	unsigned long flags;
@@ -336,12 +336,12 @@ int posix_timer_event(struct k_itimer *timr, int si_private)
 	int shared, ret = -1;
 	/*
 	 * FIXME: if ->sigq is queued we can race with
-	 * dequeue_signal()->do_schedule_next_timer().
+	 * dequeue_signal()->posixtimer_rearm().
 	 *
 	 * If dequeue_signal() sees the "right" value of
-	 * si_sys_private it calls do_schedule_next_timer().
+	 * si_sys_private it calls posixtimer_rearm().
 	 * We re-queue ->sigq and drop ->it_lock().
-	 * do_schedule_next_timer() locks the timer
+	 * posixtimer_rearm() locks the timer
 	 * and re-schedules it while ->sigq is pending.
 	 * Not really bad, but not that we want.
 	 */
@@ -701,7 +701,7 @@ SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
  * accumulating overruns on the next timer.  The overrun is frozen when
  * the signal is delivered, either at the notify time (if the info block
  * is not queued) or at the actual delivery time (as we are informed by
- * the call back to do_schedule_next_timer().  So all we need to do is
+ * the call back to posixtimer_rearm().  So all we need to do is
  * to pick up the frozen overrun.
  */
 SYSCALL_DEFINE1(timer_getoverrun, timer_t, timer_id)

[toc] | [prev] | [next] | [standalone]


#1653588 — [patch 22/26] alarmtimer: Implement forward callback

FromThomas Gleixner <tglx@linutronix.de>
Date2017-05-30 23:50 +0200
Subject[patch 22/26] alarmtimer: Implement forward callback
Message-ID<tMXbA-4e6-37@gated-at.bofh.it>
In reply to#1653571
Preparatory change to utilize the common posix timer mechanisms.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/time/alarmtimer.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -549,6 +549,18 @@ static void alarm_timer_rearm(struct k_i
 }
 
 /**
+ * alarm_timer_forward - Posix timer callback for forwarding timer
+ * @timr:	Pointer to the posixtimer data struct
+ * @now:	Current time to forward the timer against
+ */
+static int alarm_timer_forward(struct k_itimer *timr, ktime_t now)
+{
+	struct alarm *alarm = &timr->it.alarm.alarmtimer;
+
+	return (int) alarm_forward(alarm, timr->it_interval, now);
+}
+
+/**
  * alarm_clock_getres - posix getres interface
  * @which_clock: clockid
  * @tp: timespec to fill
@@ -876,6 +888,7 @@ const struct k_clock alarm_clock = {
 	.timer_del	= alarm_timer_del,
 	.timer_get	= alarm_timer_get,
 	.timer_rearm	= alarm_timer_rearm,
+	.timer_forward	= alarm_timer_forward,
 	.nsleep		= alarm_timer_nsleep,
 };
 #endif /* CONFIG_POSIX_TIMERS */

[toc] | [prev] | [next] | [standalone]


#1657381 — [tip:timers/core] alarmtimer: Implement forward callback

Fromtip-bot for Thomas Gleixner <tipbot@zytor.com>
Date2017-06-05 10:30 +0200
Subject[tip:timers/core] alarmtimer: Implement forward callback
Message-ID<tOVyH-rf-43@gated-at.bofh.it>
In reply to#1653588
Commit-ID:  e7561f1633ac735df48c55ad09a2530e9ab9fab1
Gitweb:     http://git.kernel.org/tip/e7561f1633ac735df48c55ad09a2530e9ab9fab1
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Tue, 30 May 2017 23:15:55 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 4 Jun 2017 15:40:30 +0200

alarmtimer: Implement forward callback

Preparatory change to utilize the common posix timer mechanisms.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/20170530211657.513694229@linutronix.de

---
 kernel/time/alarmtimer.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index be85e3c..6082cf1 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -549,6 +549,18 @@ static void alarm_timer_rearm(struct k_itimer *timr)
 }
 
 /**
+ * alarm_timer_forward - Posix timer callback for forwarding timer
+ * @timr:	Pointer to the posixtimer data struct
+ * @now:	Current time to forward the timer against
+ */
+static int alarm_timer_forward(struct k_itimer *timr, ktime_t now)
+{
+	struct alarm *alarm = &timr->it.alarm.alarmtimer;
+
+	return (int) alarm_forward(alarm, timr->it_interval, now);
+}
+
+/**
  * alarm_clock_getres - posix getres interface
  * @which_clock: clockid
  * @tp: timespec to fill
@@ -876,6 +888,7 @@ const struct k_clock alarm_clock = {
 	.timer_del	= alarm_timer_del,
 	.timer_get	= alarm_timer_get,
 	.timer_rearm	= alarm_timer_rearm,
+	.timer_forward	= alarm_timer_forward,
 	.nsleep		= alarm_timer_nsleep,
 };
 #endif /* CONFIG_POSIX_TIMERS */

[toc] | [prev] | [next] | [standalone]


#1653589 — [patch 03/26] alarmtimer: Remove pointless config conditional

FromThomas Gleixner <tglx@linutronix.de>
Date2017-05-30 23:50 +0200
Subject[patch 03/26] alarmtimer: Remove pointless config conditional
Message-ID<tMXbA-4e6-41@gated-at.bofh.it>
In reply to#1653571
Having a IF_ENABLED(CONFIG_POSIX_TIMERS) inside of a
#ifdef CONFIG_POSIX_TIMERS section is pointless.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/time/alarmtimer.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -520,8 +520,7 @@ static enum alarmtimer_restart alarm_han
 
 	spin_lock_irqsave(&ptr->it_lock, flags);
 	if ((ptr->it_sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE) {
-		if (IS_ENABLED(CONFIG_POSIX_TIMERS) &&
-		    posix_timer_event(ptr, 0) != 0)
+		if (posix_timer_event(ptr, 0))
 			ptr->it_overrun++;
 	}
 

[toc] | [prev] | [next] | [standalone]


#1657356 — [tip:timers/core] alarmtimer: Remove pointless config conditional

Fromtip-bot for Thomas Gleixner <tipbot@zytor.com>
Date2017-06-05 10:20 +0200
Subject[tip:timers/core] alarmtimer: Remove pointless config conditional
Message-ID<tOVp1-nU-33@gated-at.bofh.it>
In reply to#1653589
Commit-ID:  18c700c4e3d0a37c43a2df8b8f740121d4dac645
Gitweb:     http://git.kernel.org/tip/18c700c4e3d0a37c43a2df8b8f740121d4dac645
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Tue, 30 May 2017 23:15:36 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 4 Jun 2017 15:40:22 +0200

alarmtimer: Remove pointless config conditional

Having a IF_ENABLED(CONFIG_POSIX_TIMERS) inside of a
#ifdef CONFIG_POSIX_TIMERS section is pointless.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/20170530211655.975218056@linutronix.de

---
 kernel/time/alarmtimer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index e645dcc..2a8675f 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -520,8 +520,7 @@ static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm,
 
 	spin_lock_irqsave(&ptr->it_lock, flags);
 	if ((ptr->it_sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE) {
-		if (IS_ENABLED(CONFIG_POSIX_TIMERS) &&
-		    posix_timer_event(ptr, 0) != 0)
+		if (posix_timer_event(ptr, 0))
 			ptr->it_overrun++;
 	}
 

[toc] | [prev] | [next] | [standalone]


#1653591 — [patch 26/26] alarmtimer: Switch over to generic set/get/rearm routine

FromThomas Gleixner <tglx@linutronix.de>
Date2017-05-30 23:50 +0200
Subject[patch 26/26] alarmtimer: Switch over to generic set/get/rearm routine
Message-ID<tMXbB-4e6-45@gated-at.bofh.it>
In reply to#1653571
All required callbacks are in place. Switch the alarm timer based posix
interval timer callbacks to the common implementation and remove the
incorrect private implementation.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/time/alarmtimer.c   |  121 ++++++---------------------------------------
 kernel/time/posix-timers.c |   12 +---
 kernel/time/posix-timers.h |    6 ++
 3 files changed, 29 insertions(+), 110 deletions(-)

--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -515,20 +515,26 @@ static enum alarmtimer_type clock2alarm(
 static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm,
 							ktime_t now)
 {
-	unsigned long flags;
 	struct k_itimer *ptr = container_of(alarm, struct k_itimer,
-						it.alarm.alarmtimer);
+					    it.alarm.alarmtimer);
 	enum alarmtimer_restart result = ALARMTIMER_NORESTART;
+	unsigned long flags;
+	int si_private = 0;
 
 	spin_lock_irqsave(&ptr->it_lock, flags);
-	if ((ptr->it_sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE) {
-		if (posix_timer_event(ptr, 0))
-			ptr->it_overrun++;
-	}
 
-	/* Re-add periodic timers */
-	if (ptr->it_interval) {
-		ptr->it_overrun += alarm_forward(alarm, now, ptr->it_interval);
+	ptr->it_active = 0;
+	if (ptr->it_interval)
+		si_private = ++ptr->it_requeue_pending;
+
+	if (posix_timer_event(ptr, si_private) && ptr->it_interval) {
+		/*
+		 * Handle ignored signals and rearm the timer. This will go
+		 * away once we handle ignored signals proper.
+		 */
+		ptr->it_overrun += alarm_forward_now(alarm, ptr->it_interval);
+		++ptr->it_requeue_pending;
+		ptr->it_active = 1;
 		result = ALARMTIMER_RESTART;
 	}
 	spin_unlock_irqrestore(&ptr->it_lock, flags);
@@ -659,97 +665,6 @@ static int alarm_timer_create(struct k_i
 }
 
 /**
- * alarm_timer_get - posix timer_get interface
- * @timr: k_itimer pointer
- * @cur_setting: itimerspec data to fill
- *
- * Copies out the current itimerspec data
- */
-static void alarm_timer_get(struct k_itimer *timr,
-			    struct itimerspec64 *cur_setting)
-{
-	ktime_t relative_expiry_time =
-		alarm_expires_remaining(&(timr->it.alarm.alarmtimer));
-
-	if (ktime_to_ns(relative_expiry_time) > 0) {
-		cur_setting->it_value = ktime_to_timespec64(relative_expiry_time);
-	} else {
-		cur_setting->it_value.tv_sec = 0;
-		cur_setting->it_value.tv_nsec = 0;
-	}
-
-	cur_setting->it_interval = ktime_to_timespec64(timr->it_interval);
-}
-
-/**
- * alarm_timer_del - posix timer_del interface
- * @timr: k_itimer pointer to be deleted
- *
- * Cancels any programmed alarms for the given timer.
- */
-static int alarm_timer_del(struct k_itimer *timr)
-{
-	if (!rtcdev)
-		return -ENOTSUPP;
-
-	if (alarm_try_to_cancel(&timr->it.alarm.alarmtimer) < 0)
-		return TIMER_RETRY;
-
-	return 0;
-}
-
-/**
- * alarm_timer_set - posix timer_set interface
- * @timr: k_itimer pointer to be deleted
- * @flags: timer flags
- * @new_setting: itimerspec to be used
- * @old_setting: itimerspec being replaced
- *
- * Sets the timer to new_setting, and starts the timer.
- */
-static int alarm_timer_set(struct k_itimer *timr, int flags,
-			   struct itimerspec64 *new_setting,
-			   struct itimerspec64 *old_setting)
-{
-	ktime_t exp;
-
-	if (!rtcdev)
-		return -ENOTSUPP;
-
-	if (flags & ~TIMER_ABSTIME)
-		return -EINVAL;
-
-	if (old_setting)
-		alarm_timer_get(timr, old_setting);
-
-	/* If the timer was already set, cancel it */
-	if (alarm_try_to_cancel(&timr->it.alarm.alarmtimer) < 0)
-		return TIMER_RETRY;
-
-	/* start the timer */
-	timr->it_interval = timespec64_to_ktime(new_setting->it_interval);
-
-	/*
-	 * Rate limit to the tick as a hot fix to prevent DOS. Will be
-	 * mopped up later.
-	 */
-	if (timr->it_interval < TICK_NSEC)
-		timr->it_interval = TICK_NSEC;
-
-	exp = timespec64_to_ktime(new_setting->it_value);
-	/* Convert (if necessary) to absolute time */
-	if (flags != TIMER_ABSTIME) {
-		ktime_t now;
-
-		now = alarm_bases[timr->it.alarm.alarmtimer.type].gettime();
-		exp = ktime_add_safe(now, exp);
-	}
-
-	alarm_start(&timr->it.alarm.alarmtimer, exp);
-	return 0;
-}
-
-/**
  * alarmtimer_nsleep_wakeup - Wakeup function for alarm_timer_nsleep
  * @alarm: ptr to alarm that fired
  *
@@ -926,9 +841,9 @@ const struct k_clock alarm_clock = {
 	.clock_getres		= alarm_clock_getres,
 	.clock_get		= alarm_clock_get,
 	.timer_create		= alarm_timer_create,
-	.timer_set		= alarm_timer_set,
-	.timer_del		= alarm_timer_del,
-	.timer_get		= alarm_timer_get,
+	.timer_set		= common_timer_set,
+	.timer_del		= common_timer_del,
+	.timer_get		= common_timer_get,
 	.timer_arm		= alarm_timer_arm,
 	.timer_rearm		= alarm_timer_rearm,
 	.timer_forward		= alarm_timer_forward,
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -637,8 +637,7 @@ static int common_hrtimer_forward(struct
  * it is the same as a requeue pending timer WRT to what we should
  * report.
  */
-static void
-common_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting)
+void common_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting)
 {
 	const struct k_clock *kc = timr->kclock;
 	ktime_t now, remaining, iv;
@@ -768,10 +767,9 @@ static int common_hrtimer_try_to_cancel(
 }
 
 /* Set a POSIX.1b interval timer. */
-static int
-common_timer_set(struct k_itimer *timr, int flags,
-		 struct itimerspec64 *new_setting,
-		 struct itimerspec64 *old_setting)
+int common_timer_set(struct k_itimer *timr, int flags,
+		     struct itimerspec64 *new_setting,
+		     struct itimerspec64 *old_setting)
 {
 	const struct k_clock *kc = timr->kclock;
 	bool sigev_none;
@@ -855,7 +853,7 @@ SYSCALL_DEFINE4(timer_settime, timer_t,
 	return error;
 }
 
-static int common_timer_del(struct k_itimer *timer)
+int common_timer_del(struct k_itimer *timer)
 {
 	const struct k_clock *kc = timer->kclock;
 
--- a/kernel/time/posix-timers.h
+++ b/kernel/time/posix-timers.h
@@ -5,3 +5,9 @@ extern const struct k_clock clock_thread
 extern const struct k_clock alarm_clock;
 
 int posix_timer_event(struct k_itimer *timr, int si_private);
+
+void common_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting);
+int common_timer_set(struct k_itimer *timr, int flags,
+		     struct itimerspec64 *new_setting,
+		     struct itimerspec64 *old_setting);
+int common_timer_del(struct k_itimer *timer);

[toc] | [prev] | [next] | [standalone]


#1657386 — [tip:timers/core] alarmtimer: Switch over to generic set/get/rearm routine

Fromtip-bot for Thomas Gleixner <tipbot@zytor.com>
Date2017-06-05 10:30 +0200
Subject[tip:timers/core] alarmtimer: Switch over to generic set/get/rearm routine
Message-ID<tOVyI-rf-55@gated-at.bofh.it>
In reply to#1653591
Commit-ID:  f2c45807d3992fe0f173f34af9c347d907c31686
Gitweb:     http://git.kernel.org/tip/f2c45807d3992fe0f173f34af9c347d907c31686
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Tue, 30 May 2017 23:15:59 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 4 Jun 2017 15:40:32 +0200

alarmtimer: Switch over to generic set/get/rearm routine

All required callbacks are in place. Switch the alarm timer based posix
interval timer callbacks to the common implementation and remove the
incorrect private implementation.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/20170530211657.825471962@linutronix.de

---
 kernel/time/alarmtimer.c   | 121 +++++++--------------------------------------
 kernel/time/posix-timers.c |  12 ++---
 kernel/time/posix-timers.h |   6 +++
 3 files changed, 29 insertions(+), 110 deletions(-)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index c618a44..d8a7a7e 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -515,20 +515,26 @@ static enum alarmtimer_type clock2alarm(clockid_t clockid)
 static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm,
 							ktime_t now)
 {
-	unsigned long flags;
 	struct k_itimer *ptr = container_of(alarm, struct k_itimer,
-						it.alarm.alarmtimer);
+					    it.alarm.alarmtimer);
 	enum alarmtimer_restart result = ALARMTIMER_NORESTART;
+	unsigned long flags;
+	int si_private = 0;
 
 	spin_lock_irqsave(&ptr->it_lock, flags);
-	if ((ptr->it_sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE) {
-		if (posix_timer_event(ptr, 0))
-			ptr->it_overrun++;
-	}
 
-	/* Re-add periodic timers */
-	if (ptr->it_interval) {
-		ptr->it_overrun += alarm_forward(alarm, now, ptr->it_interval);
+	ptr->it_active = 0;
+	if (ptr->it_interval)
+		si_private = ++ptr->it_requeue_pending;
+
+	if (posix_timer_event(ptr, si_private) && ptr->it_interval) {
+		/*
+		 * Handle ignored signals and rearm the timer. This will go
+		 * away once we handle ignored signals proper.
+		 */
+		ptr->it_overrun += alarm_forward_now(alarm, ptr->it_interval);
+		++ptr->it_requeue_pending;
+		ptr->it_active = 1;
 		result = ALARMTIMER_RESTART;
 	}
 	spin_unlock_irqrestore(&ptr->it_lock, flags);
@@ -659,97 +665,6 @@ static int alarm_timer_create(struct k_itimer *new_timer)
 }
 
 /**
- * alarm_timer_get - posix timer_get interface
- * @timr: k_itimer pointer
- * @cur_setting: itimerspec data to fill
- *
- * Copies out the current itimerspec data
- */
-static void alarm_timer_get(struct k_itimer *timr,
-			    struct itimerspec64 *cur_setting)
-{
-	ktime_t relative_expiry_time =
-		alarm_expires_remaining(&(timr->it.alarm.alarmtimer));
-
-	if (ktime_to_ns(relative_expiry_time) > 0) {
-		cur_setting->it_value = ktime_to_timespec64(relative_expiry_time);
-	} else {
-		cur_setting->it_value.tv_sec = 0;
-		cur_setting->it_value.tv_nsec = 0;
-	}
-
-	cur_setting->it_interval = ktime_to_timespec64(timr->it_interval);
-}
-
-/**
- * alarm_timer_del - posix timer_del interface
- * @timr: k_itimer pointer to be deleted
- *
- * Cancels any programmed alarms for the given timer.
- */
-static int alarm_timer_del(struct k_itimer *timr)
-{
-	if (!rtcdev)
-		return -ENOTSUPP;
-
-	if (alarm_try_to_cancel(&timr->it.alarm.alarmtimer) < 0)
-		return TIMER_RETRY;
-
-	return 0;
-}
-
-/**
- * alarm_timer_set - posix timer_set interface
- * @timr: k_itimer pointer to be deleted
- * @flags: timer flags
- * @new_setting: itimerspec to be used
- * @old_setting: itimerspec being replaced
- *
- * Sets the timer to new_setting, and starts the timer.
- */
-static int alarm_timer_set(struct k_itimer *timr, int flags,
-			   struct itimerspec64 *new_setting,
-			   struct itimerspec64 *old_setting)
-{
-	ktime_t exp;
-
-	if (!rtcdev)
-		return -ENOTSUPP;
-
-	if (flags & ~TIMER_ABSTIME)
-		return -EINVAL;
-
-	if (old_setting)
-		alarm_timer_get(timr, old_setting);
-
-	/* If the timer was already set, cancel it */
-	if (alarm_try_to_cancel(&timr->it.alarm.alarmtimer) < 0)
-		return TIMER_RETRY;
-
-	/* start the timer */
-	timr->it_interval = timespec64_to_ktime(new_setting->it_interval);
-
-	/*
-	 * Rate limit to the tick as a hot fix to prevent DOS. Will be
-	 * mopped up later.
-	 */
-	if (timr->it_interval < TICK_NSEC)
-		timr->it_interval = TICK_NSEC;
-
-	exp = timespec64_to_ktime(new_setting->it_value);
-	/* Convert (if necessary) to absolute time */
-	if (flags != TIMER_ABSTIME) {
-		ktime_t now;
-
-		now = alarm_bases[timr->it.alarm.alarmtimer.type].gettime();
-		exp = ktime_add_safe(now, exp);
-	}
-
-	alarm_start(&timr->it.alarm.alarmtimer, exp);
-	return 0;
-}
-
-/**
  * alarmtimer_nsleep_wakeup - Wakeup function for alarm_timer_nsleep
  * @alarm: ptr to alarm that fired
  *
@@ -926,9 +841,9 @@ const struct k_clock alarm_clock = {
 	.clock_getres		= alarm_clock_getres,
 	.clock_get		= alarm_clock_get,
 	.timer_create		= alarm_timer_create,
-	.timer_set		= alarm_timer_set,
-	.timer_del		= alarm_timer_del,
-	.timer_get		= alarm_timer_get,
+	.timer_set		= common_timer_set,
+	.timer_del		= common_timer_del,
+	.timer_get		= common_timer_get,
 	.timer_arm		= alarm_timer_arm,
 	.timer_rearm		= alarm_timer_rearm,
 	.timer_forward		= alarm_timer_forward,
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 8acc9ee..6e7a70b1 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -637,8 +637,7 @@ static int common_hrtimer_forward(struct k_itimer *timr, ktime_t now)
  * it is the same as a requeue pending timer WRT to what we should
  * report.
  */
-static void
-common_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting)
+void common_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting)
 {
 	const struct k_clock *kc = timr->kclock;
 	ktime_t now, remaining, iv;
@@ -768,10 +767,9 @@ static int common_hrtimer_try_to_cancel(struct k_itimer *timr)
 }
 
 /* Set a POSIX.1b interval timer. */
-static int
-common_timer_set(struct k_itimer *timr, int flags,
-		 struct itimerspec64 *new_setting,
-		 struct itimerspec64 *old_setting)
+int common_timer_set(struct k_itimer *timr, int flags,
+		     struct itimerspec64 *new_setting,
+		     struct itimerspec64 *old_setting)
 {
 	const struct k_clock *kc = timr->kclock;
 	bool sigev_none;
@@ -855,7 +853,7 @@ retry:
 	return error;
 }
 
-static int common_timer_del(struct k_itimer *timer)
+int common_timer_del(struct k_itimer *timer)
 {
 	const struct k_clock *kc = timer->kclock;
 
diff --git a/kernel/time/posix-timers.h b/kernel/time/posix-timers.h
index b0ad77e..b086f5b 100644
--- a/kernel/time/posix-timers.h
+++ b/kernel/time/posix-timers.h
@@ -33,3 +33,9 @@ extern const struct k_clock clock_thread;
 extern const struct k_clock alarm_clock;
 
 int posix_timer_event(struct k_itimer *timr, int si_private);
+
+void common_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting);
+int common_timer_set(struct k_itimer *timr, int flags,
+		     struct itimerspec64 *new_setting,
+		     struct itimerspec64 *old_setting);
+int common_timer_del(struct k_itimer *timer);

[toc] | [prev] | [next] | [standalone]


#1653593 — [patch 06/26] posix-timers: Avoid gazillions of forward declarations

FromThomas Gleixner <tglx@linutronix.de>
Date2017-05-30 23:50 +0200
Subject[patch 06/26] posix-timers: Avoid gazillions of forward declarations
Message-ID<tMXbB-4e6-49@gated-at.bofh.it>
In reply to#1653571
Move it below the actual implementations as there are new callbacks coming
which would require even more forward declarations.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/time/posix-timers.c |  190 +++++++++++++++++++++------------------------
 1 file changed, 89 insertions(+), 101 deletions(-)

--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -69,6 +69,9 @@ static struct kmem_cache *posix_timers_c
 static DEFINE_HASHTABLE(posix_timers_hashtable, 9);
 static DEFINE_SPINLOCK(hash_lock);
 
+static const struct k_clock * const posix_clocks[];
+static const struct k_clock *clockid_to_kclock(const clockid_t id);
+
 /*
  * we assume that the new SIGEV_THREAD_ID shares no bits with the other
  * SIGEV values.  Here we put out an error if this assumption fails.
@@ -124,20 +127,6 @@ static DEFINE_SPINLOCK(hash_lock);
  *	    have is CLOCK_REALTIME and its high res counter part, both of
  *	    which we beg off on and pass to do_sys_settimeofday().
  */
-
-/*
- * These ones are defined below.
- */
-static int common_nsleep(const clockid_t, int flags, struct timespec64 *t,
-			 struct timespec __user *rmtp);
-static int common_timer_create(struct k_itimer *new_timer);
-static void common_timer_get(struct k_itimer *, struct itimerspec64 *);
-static int common_timer_set(struct k_itimer *, int,
-			    struct itimerspec64 *, struct itimerspec64 *);
-static int common_timer_del(struct k_itimer *timer);
-
-static enum hrtimer_restart posix_timer_fn(struct hrtimer *data);
-
 static struct k_itimer *__lock_timer(timer_t timer_id, unsigned long *flags);
 
 #define lock_timer(tid, flags)						   \
@@ -278,82 +267,6 @@ static int posix_get_hrtimer_res(clockid
 	return 0;
 }
 
-
-static const struct k_clock clock_realtime = {
-	.clock_getres	= posix_get_hrtimer_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,
-	.timer_set	= common_timer_set,
-	.timer_get	= common_timer_get,
-	.timer_del	= common_timer_del,
-};
-
-static const struct k_clock clock_monotonic = {
-	.clock_getres	= posix_get_hrtimer_res,
-	.clock_get	= posix_ktime_get_ts,
-	.nsleep		= common_nsleep,
-	.nsleep_restart	= hrtimer_nanosleep_restart,
-	.timer_create	= common_timer_create,
-	.timer_set	= common_timer_set,
-	.timer_get	= common_timer_get,
-	.timer_del	= common_timer_del,
-};
-
-static const struct k_clock clock_monotonic_raw = {
-	.clock_getres	= posix_get_hrtimer_res,
-	.clock_get	= posix_get_monotonic_raw,
-};
-
-static const struct k_clock clock_realtime_coarse = {
-	.clock_getres	= posix_get_coarse_res,
-	.clock_get	= posix_get_realtime_coarse,
-};
-
-static const struct k_clock clock_monotonic_coarse = {
-	.clock_getres	= posix_get_coarse_res,
-	.clock_get	= posix_get_monotonic_coarse,
-};
-
-static const struct k_clock clock_tai = {
-	.clock_getres	= posix_get_hrtimer_res,
-	.clock_get	= posix_get_tai,
-	.nsleep		= common_nsleep,
-	.nsleep_restart	= hrtimer_nanosleep_restart,
-	.timer_create	= common_timer_create,
-	.timer_set	= common_timer_set,
-	.timer_get	= common_timer_get,
-	.timer_del	= common_timer_del,
-};
-
-static const struct k_clock clock_boottime = {
-	.clock_getres	= posix_get_hrtimer_res,
-	.clock_get	= posix_get_boottime,
-	.nsleep		= common_nsleep,
-	.nsleep_restart	= hrtimer_nanosleep_restart,
-	.timer_create	= common_timer_create,
-	.timer_set	= common_timer_set,
-	.timer_get	= common_timer_get,
-	.timer_del	= common_timer_del,
-};
-
-static const struct k_clock * const posix_clocks[] = {
-	[CLOCK_REALTIME]		= &clock_realtime,
-	[CLOCK_MONOTONIC]		= &clock_monotonic,
-	[CLOCK_PROCESS_CPUTIME_ID]	= &clock_process,
-	[CLOCK_THREAD_CPUTIME_ID]	= &clock_thread,
-	[CLOCK_MONOTONIC_RAW]		= &clock_monotonic_raw,
-	[CLOCK_REALTIME_COARSE]		= &clock_realtime_coarse,
-	[CLOCK_MONOTONIC_COARSE]	= &clock_monotonic_coarse,
-	[CLOCK_BOOTTIME]		= &clock_boottime,
-	[CLOCK_REALTIME_ALARM]		= &alarm_clock,
-	[CLOCK_BOOTTIME_ALARM]		= &alarm_clock,
-	[CLOCK_TAI]			= &clock_tai,
-};
-
 /*
  * Initialize everything, well, just everything in Posix clocks/timers ;)
  */
@@ -567,17 +480,6 @@ static void release_posix_timer(struct k
 	call_rcu(&tmr->it.rcu, k_itimer_rcu_free);
 }
 
-static const struct k_clock *clockid_to_kclock(const clockid_t id)
-{
-	if (id < 0)
-		return (id & CLOCKFD_MASK) == CLOCKFD ?
-			&clock_posix_dynamic : &clock_posix_cpu;
-
-	if (id >= ARRAY_SIZE(posix_clocks) || !posix_clocks[id])
-		return NULL;
-	return posix_clocks[id];
-}
-
 static int common_timer_create(struct k_itimer *new_timer)
 {
 	hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock, 0);
@@ -1129,3 +1031,89 @@ long clock_nanosleep_restart(struct rest
 
 	return kc->nsleep_restart(restart_block);
 }
+
+static const struct k_clock clock_realtime = {
+	.clock_getres	= posix_get_hrtimer_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,
+	.timer_set	= common_timer_set,
+	.timer_get	= common_timer_get,
+	.timer_del	= common_timer_del,
+};
+
+static const struct k_clock clock_monotonic = {
+	.clock_getres	= posix_get_hrtimer_res,
+	.clock_get	= posix_ktime_get_ts,
+	.nsleep		= common_nsleep,
+	.nsleep_restart	= hrtimer_nanosleep_restart,
+	.timer_create	= common_timer_create,
+	.timer_set	= common_timer_set,
+	.timer_get	= common_timer_get,
+	.timer_del	= common_timer_del,
+};
+
+static const struct k_clock clock_monotonic_raw = {
+	.clock_getres	= posix_get_hrtimer_res,
+	.clock_get	= posix_get_monotonic_raw,
+};
+
+static const struct k_clock clock_realtime_coarse = {
+	.clock_getres	= posix_get_coarse_res,
+	.clock_get	= posix_get_realtime_coarse,
+};
+
+static const struct k_clock clock_monotonic_coarse = {
+	.clock_getres	= posix_get_coarse_res,
+	.clock_get	= posix_get_monotonic_coarse,
+};
+
+static const struct k_clock clock_tai = {
+	.clock_getres	= posix_get_hrtimer_res,
+	.clock_get	= posix_get_tai,
+	.nsleep		= common_nsleep,
+	.nsleep_restart	= hrtimer_nanosleep_restart,
+	.timer_create	= common_timer_create,
+	.timer_set	= common_timer_set,
+	.timer_get	= common_timer_get,
+	.timer_del	= common_timer_del,
+};
+
+static const struct k_clock clock_boottime = {
+	.clock_getres	= posix_get_hrtimer_res,
+	.clock_get	= posix_get_boottime,
+	.nsleep		= common_nsleep,
+	.nsleep_restart	= hrtimer_nanosleep_restart,
+	.timer_create	= common_timer_create,
+	.timer_set	= common_timer_set,
+	.timer_get	= common_timer_get,
+	.timer_del	= common_timer_del,
+};
+
+static const struct k_clock * const posix_clocks[] = {
+	[CLOCK_REALTIME]		= &clock_realtime,
+	[CLOCK_MONOTONIC]		= &clock_monotonic,
+	[CLOCK_PROCESS_CPUTIME_ID]	= &clock_process,
+	[CLOCK_THREAD_CPUTIME_ID]	= &clock_thread,
+	[CLOCK_MONOTONIC_RAW]		= &clock_monotonic_raw,
+	[CLOCK_REALTIME_COARSE]		= &clock_realtime_coarse,
+	[CLOCK_MONOTONIC_COARSE]	= &clock_monotonic_coarse,
+	[CLOCK_BOOTTIME]		= &clock_boottime,
+	[CLOCK_REALTIME_ALARM]		= &alarm_clock,
+	[CLOCK_BOOTTIME_ALARM]		= &alarm_clock,
+	[CLOCK_TAI]			= &clock_tai,
+};
+
+static const struct k_clock *clockid_to_kclock(const clockid_t id)
+{
+	if (id < 0)
+		return (id & CLOCKFD_MASK) == CLOCKFD ?
+			&clock_posix_dynamic : &clock_posix_cpu;
+
+	if (id >= ARRAY_SIZE(posix_clocks) || !posix_clocks[id])
+		return NULL;
+	return posix_clocks[id];
+}

[toc] | [prev] | [next] | [standalone]


#1657352 — [tip:timers/core] posix-timers: Avoid gazillions of forward declarations

Fromtip-bot for Thomas Gleixner <tipbot@zytor.com>
Date2017-06-05 10:20 +0200
Subject[tip:timers/core] posix-timers: Avoid gazillions of forward declarations
Message-ID<tOVp0-nU-25@gated-at.bofh.it>
In reply to#1653593
Commit-ID:  6631fa12c105e326bbe5fb215eb216e86c90d1ba
Gitweb:     http://git.kernel.org/tip/6631fa12c105e326bbe5fb215eb216e86c90d1ba
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Tue, 30 May 2017 23:15:39 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 4 Jun 2017 15:40:23 +0200

posix-timers: Avoid gazillions of forward declarations

Move it below the actual implementations as there are new callbacks coming
which would require even more forward declarations.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/20170530211656.238209952@linutronix.de

---
 kernel/time/posix-timers.c | 190 +++++++++++++++++++++------------------------
 1 file changed, 89 insertions(+), 101 deletions(-)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 44d4865..b60b655 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -69,6 +69,9 @@ static struct kmem_cache *posix_timers_cache;
 static DEFINE_HASHTABLE(posix_timers_hashtable, 9);
 static DEFINE_SPINLOCK(hash_lock);
 
+static const struct k_clock * const posix_clocks[];
+static const struct k_clock *clockid_to_kclock(const clockid_t id);
+
 /*
  * we assume that the new SIGEV_THREAD_ID shares no bits with the other
  * SIGEV values.  Here we put out an error if this assumption fails.
@@ -124,20 +127,6 @@ static DEFINE_SPINLOCK(hash_lock);
  *	    have is CLOCK_REALTIME and its high res counter part, both of
  *	    which we beg off on and pass to do_sys_settimeofday().
  */
-
-/*
- * These ones are defined below.
- */
-static int common_nsleep(const clockid_t, int flags, struct timespec64 *t,
-			 struct timespec __user *rmtp);
-static int common_timer_create(struct k_itimer *new_timer);
-static void common_timer_get(struct k_itimer *, struct itimerspec64 *);
-static int common_timer_set(struct k_itimer *, int,
-			    struct itimerspec64 *, struct itimerspec64 *);
-static int common_timer_del(struct k_itimer *timer);
-
-static enum hrtimer_restart posix_timer_fn(struct hrtimer *data);
-
 static struct k_itimer *__lock_timer(timer_t timer_id, unsigned long *flags);
 
 #define lock_timer(tid, flags)						   \
@@ -278,82 +267,6 @@ static int posix_get_hrtimer_res(clockid_t which_clock, struct timespec64 *tp)
 	return 0;
 }
 
-
-static const struct k_clock clock_realtime = {
-	.clock_getres	= posix_get_hrtimer_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,
-	.timer_set	= common_timer_set,
-	.timer_get	= common_timer_get,
-	.timer_del	= common_timer_del,
-};
-
-static const struct k_clock clock_monotonic = {
-	.clock_getres	= posix_get_hrtimer_res,
-	.clock_get	= posix_ktime_get_ts,
-	.nsleep		= common_nsleep,
-	.nsleep_restart	= hrtimer_nanosleep_restart,
-	.timer_create	= common_timer_create,
-	.timer_set	= common_timer_set,
-	.timer_get	= common_timer_get,
-	.timer_del	= common_timer_del,
-};
-
-static const struct k_clock clock_monotonic_raw = {
-	.clock_getres	= posix_get_hrtimer_res,
-	.clock_get	= posix_get_monotonic_raw,
-};
-
-static const struct k_clock clock_realtime_coarse = {
-	.clock_getres	= posix_get_coarse_res,
-	.clock_get	= posix_get_realtime_coarse,
-};
-
-static const struct k_clock clock_monotonic_coarse = {
-	.clock_getres	= posix_get_coarse_res,
-	.clock_get	= posix_get_monotonic_coarse,
-};
-
-static const struct k_clock clock_tai = {
-	.clock_getres	= posix_get_hrtimer_res,
-	.clock_get	= posix_get_tai,
-	.nsleep		= common_nsleep,
-	.nsleep_restart	= hrtimer_nanosleep_restart,
-	.timer_create	= common_timer_create,
-	.timer_set	= common_timer_set,
-	.timer_get	= common_timer_get,
-	.timer_del	= common_timer_del,
-};
-
-static const struct k_clock clock_boottime = {
-	.clock_getres	= posix_get_hrtimer_res,
-	.clock_get	= posix_get_boottime,
-	.nsleep		= common_nsleep,
-	.nsleep_restart	= hrtimer_nanosleep_restart,
-	.timer_create	= common_timer_create,
-	.timer_set	= common_timer_set,
-	.timer_get	= common_timer_get,
-	.timer_del	= common_timer_del,
-};
-
-static const struct k_clock * const posix_clocks[] = {
-	[CLOCK_REALTIME]		= &clock_realtime,
-	[CLOCK_MONOTONIC]		= &clock_monotonic,
-	[CLOCK_PROCESS_CPUTIME_ID]	= &clock_process,
-	[CLOCK_THREAD_CPUTIME_ID]	= &clock_thread,
-	[CLOCK_MONOTONIC_RAW]		= &clock_monotonic_raw,
-	[CLOCK_REALTIME_COARSE]		= &clock_realtime_coarse,
-	[CLOCK_MONOTONIC_COARSE]	= &clock_monotonic_coarse,
-	[CLOCK_BOOTTIME]		= &clock_boottime,
-	[CLOCK_REALTIME_ALARM]		= &alarm_clock,
-	[CLOCK_BOOTTIME_ALARM]		= &alarm_clock,
-	[CLOCK_TAI]			= &clock_tai,
-};
-
 /*
  * Initialize everything, well, just everything in Posix clocks/timers ;)
  */
@@ -567,17 +480,6 @@ static void release_posix_timer(struct k_itimer *tmr, int it_id_set)
 	call_rcu(&tmr->it.rcu, k_itimer_rcu_free);
 }
 
-static const struct k_clock *clockid_to_kclock(const clockid_t id)
-{
-	if (id < 0)
-		return (id & CLOCKFD_MASK) == CLOCKFD ?
-			&clock_posix_dynamic : &clock_posix_cpu;
-
-	if (id >= ARRAY_SIZE(posix_clocks) || !posix_clocks[id])
-		return NULL;
-	return posix_clocks[id];
-}
-
 static int common_timer_create(struct k_itimer *new_timer)
 {
 	hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock, 0);
@@ -1129,3 +1031,89 @@ long clock_nanosleep_restart(struct restart_block *restart_block)
 
 	return kc->nsleep_restart(restart_block);
 }
+
+static const struct k_clock clock_realtime = {
+	.clock_getres	= posix_get_hrtimer_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,
+	.timer_set	= common_timer_set,
+	.timer_get	= common_timer_get,
+	.timer_del	= common_timer_del,
+};
+
+static const struct k_clock clock_monotonic = {
+	.clock_getres	= posix_get_hrtimer_res,
+	.clock_get	= posix_ktime_get_ts,
+	.nsleep		= common_nsleep,
+	.nsleep_restart	= hrtimer_nanosleep_restart,
+	.timer_create	= common_timer_create,
+	.timer_set	= common_timer_set,
+	.timer_get	= common_timer_get,
+	.timer_del	= common_timer_del,
+};
+
+static const struct k_clock clock_monotonic_raw = {
+	.clock_getres	= posix_get_hrtimer_res,
+	.clock_get	= posix_get_monotonic_raw,
+};
+
+static const struct k_clock clock_realtime_coarse = {
+	.clock_getres	= posix_get_coarse_res,
+	.clock_get	= posix_get_realtime_coarse,
+};
+
+static const struct k_clock clock_monotonic_coarse = {
+	.clock_getres	= posix_get_coarse_res,
+	.clock_get	= posix_get_monotonic_coarse,
+};
+
+static const struct k_clock clock_tai = {
+	.clock_getres	= posix_get_hrtimer_res,
+	.clock_get	= posix_get_tai,
+	.nsleep		= common_nsleep,
+	.nsleep_restart	= hrtimer_nanosleep_restart,
+	.timer_create	= common_timer_create,
+	.timer_set	= common_timer_set,
+	.timer_get	= common_timer_get,
+	.timer_del	= common_timer_del,
+};
+
+static const struct k_clock clock_boottime = {
+	.clock_getres	= posix_get_hrtimer_res,
+	.clock_get	= posix_get_boottime,
+	.nsleep		= common_nsleep,
+	.nsleep_restart	= hrtimer_nanosleep_restart,
+	.timer_create	= common_timer_create,
+	.timer_set	= common_timer_set,
+	.timer_get	= common_timer_get,
+	.timer_del	= common_timer_del,
+};
+
+static const struct k_clock * const posix_clocks[] = {
+	[CLOCK_REALTIME]		= &clock_realtime,
+	[CLOCK_MONOTONIC]		= &clock_monotonic,
+	[CLOCK_PROCESS_CPUTIME_ID]	= &clock_process,
+	[CLOCK_THREAD_CPUTIME_ID]	= &clock_thread,
+	[CLOCK_MONOTONIC_RAW]		= &clock_monotonic_raw,
+	[CLOCK_REALTIME_COARSE]		= &clock_realtime_coarse,
+	[CLOCK_MONOTONIC_COARSE]	= &clock_monotonic_coarse,
+	[CLOCK_BOOTTIME]		= &clock_boottime,
+	[CLOCK_REALTIME_ALARM]		= &alarm_clock,
+	[CLOCK_BOOTTIME_ALARM]		= &alarm_clock,
+	[CLOCK_TAI]			= &clock_tai,
+};
+
+static const struct k_clock *clockid_to_kclock(const clockid_t id)
+{
+	if (id < 0)
+		return (id & CLOCKFD_MASK) == CLOCKFD ?
+			&clock_posix_dynamic : &clock_posix_cpu;
+
+	if (id >= ARRAY_SIZE(posix_clocks) || !posix_clocks[id])
+		return NULL;
+	return posix_clocks[id];
+}

[toc] | [prev] | [next] | [standalone]


#1653594 — [patch 12/26] posix-timers: Add timer_rearm() callback

FromThomas Gleixner <tglx@linutronix.de>
Date2017-05-30 23:50 +0200
Subject[patch 12/26] posix-timers: Add timer_rearm() callback
Message-ID<tMXbB-4e6-51@gated-at.bofh.it>
In reply to#1653571
Add a timer_rearm() callback which is used to make the rescheduling of
posix interval timers independent of the underlying clock implementation.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/posix-timers.h |   36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -101,23 +101,27 @@ struct k_itimer {
 	} it;
 };
 
-struct k_clock {
-	int (*clock_getres) (const clockid_t which_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_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 timespec64 *, struct timespec __user *);
-	long (*nsleep_restart) (struct restart_block *restart_block);
-	int (*timer_set) (struct k_itimer *timr, int flags,
-			  struct itimerspec64 *new_setting,
-			  struct itimerspec64 *old_setting);
-	int (*timer_del) (struct k_itimer *timr);
 #define TIMER_RETRY 1
-	void (*timer_get) (struct k_itimer *timr,
-			   struct itimerspec64 *cur_setting);
+
+struct k_clock {
+	int	(*clock_getres)(const clockid_t which_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_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 timespec64 *, struct timespec __user *);
+	long	(*nsleep_restart)(struct restart_block *restart_block);
+	int	(*timer_set)(struct k_itimer *timr, int flags,
+			     struct itimerspec64 *new_setting,
+			     struct itimerspec64 *old_setting);
+	int	(*timer_del)(struct k_itimer *timr);
+	void	(*timer_get)(struct k_itimer *timr,
+			     struct itimerspec64 *cur_setting);
+	void	(*timer_rearm)(struct k_itimer *timr);
 };
 
 void run_posix_cpu_timers(struct task_struct *task);

[toc] | [prev] | [next] | [standalone]


#1657373 — [tip:timers/core] posix-timers: Add timer_rearm() callback

Fromtip-bot for Thomas Gleixner <tipbot@zytor.com>
Date2017-06-05 10:30 +0200
Subject[tip:timers/core] posix-timers: Add timer_rearm() callback
Message-ID<tOVyG-rf-27@gated-at.bofh.it>
In reply to#1653594
Commit-ID:  30802945893bc944b5971b408b37511a03b54e5c
Gitweb:     http://git.kernel.org/tip/30802945893bc944b5971b408b37511a03b54e5c
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Tue, 30 May 2017 23:15:45 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 4 Jun 2017 15:40:25 +0200

posix-timers: Add timer_rearm() callback

Add a timer_rearm() callback which is used to make the rescheduling of
posix interval timers independent of the underlying clock implementation.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/20170530211656.732632167@linutronix.de

---
 kernel/time/posix-timers.h | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/kernel/time/posix-timers.h b/kernel/time/posix-timers.h
index ad2dbd2..02ffd1b 100644
--- a/kernel/time/posix-timers.h
+++ b/kernel/time/posix-timers.h
@@ -1,21 +1,24 @@
 #define TIMER_RETRY 1
 
 struct k_clock {
-	int (*clock_getres) (const clockid_t which_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_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 timespec64 *, struct timespec __user *);
-	long (*nsleep_restart) (struct restart_block *restart_block);
-	int (*timer_set) (struct k_itimer *timr, int flags,
-			  struct itimerspec64 *new_setting,
-			  struct itimerspec64 *old_setting);
-	int (*timer_del) (struct k_itimer *timr);
-	void (*timer_get) (struct k_itimer *timr,
-			   struct itimerspec64 *cur_setting);
+	int	(*clock_getres)(const clockid_t which_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_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 timespec64 *, struct timespec __user *);
+	long	(*nsleep_restart)(struct restart_block *restart_block);
+	int	(*timer_set)(struct k_itimer *timr, int flags,
+			     struct itimerspec64 *new_setting,
+			     struct itimerspec64 *old_setting);
+	int	(*timer_del)(struct k_itimer *timr);
+	void	(*timer_get)(struct k_itimer *timr,
+			     struct itimerspec64 *cur_setting);
+	void	(*timer_rearm)(struct k_itimer *timr);
 };
 
 extern const struct k_clock clock_posix_cpu;

[toc] | [prev] | [next] | [standalone]


Page 2 of 3 — ← Prev page 1 [2] 3  Next page →

Back to top | Article view | linux.kernel


csiph-web