[patch 3/5] posix-cpu-timers: Split run_posix_cpu_timers()

From: Thomas Gleixner
Date: Thu Aug 01 2019 - 10:38:27 EST


Split run_posix_cpu_timers() into two pieces, the hard interrupt context
part and the actual timer evaluation/expiry part.

The hard interrupt context part contains only the lockless fast path check
and for now calls the expiry part as before.

No functional change. Preparatory change to move the expiry part into task
context.

Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Oleg Nesterov <oleg@xxxxxxxxxx>

---
kernel/time/posix-cpu-timers.c | 37 +++++++++++++++++++++----------------
1 file changed, 21 insertions(+), 16 deletions(-)

--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -1127,25 +1127,11 @@ static inline int fastpath_timer_check(s
return 0;
}

-/*
- * This is called from the timer interrupt handler. The irq handler has
- * already updated our counts. We need to check if any timers fire now.
- * Interrupts are disabled.
- */
-void run_posix_cpu_timers(struct task_struct *tsk)
+static void __run_posix_cpu_timers(struct task_struct *tsk)
{
- LIST_HEAD(firing);
struct k_itimer *timer, *next;
unsigned long flags;
-
- lockdep_assert_irqs_disabled();
-
- /*
- * The fast path checks that there are no expired thread or thread
- * group timers. If that's so, just return.
- */
- if (!fastpath_timer_check(tsk))
- return;
+ LIST_HEAD(firing);

if (!lock_task_sighand(tsk, &flags))
return;
@@ -1193,6 +1179,25 @@ void run_posix_cpu_timers(struct task_st
}

/*
+ * This is called from the timer interrupt handler. The irq handler has
+ * already updated our counts. We need to check if any timers fire now.
+ * Interrupts are disabled.
+ */
+void run_posix_cpu_timers(struct task_struct *tsk)
+{
+ lockdep_assert_irqs_disabled();
+
+ /*
+ * The fast path checks that there are no expired thread or thread
+ * group timers. If that's so, just return.
+ */
+ if (!fastpath_timer_check(tsk))
+ return;
+
+ __run_posix_cpu_timers(tsk);
+}
+
+/*
* Set one of the process-wide special case CPU timers or RLIMIT_CPU.
* The tsk->sighand->siglock must be held by the caller.
*/