From: Frederic Weisbecker <fweisbec@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Oleg Nesterov <oleg@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>
Subject: [PATCH 6/6] posix-timers: Fix full dynticks CPUs kick on timer rescheduling
Date: Thu, 7 Nov 2013 19:16:31 +0100 [thread overview]
Message-ID: <1383848191-30807-7-git-send-email-fweisbec@gmail.com> (raw)
In-Reply-To: <1383848191-30807-1-git-send-email-fweisbec@gmail.com>
A posix CPU timer can be rearmed while it is firing or after it is
notified with a signal. This can happen for example with timers that
were set with a non zero interval in timer_settime().
This rearming can happen in two places:
1) On timer firing time, which happens on the target's tick. If the timer
can't trigger a signal because it is ignored, it reschedules itself
to honour the timer interval.
2) On signal handling from the timer's notification target. This one
can be a different task than the timer's target itself. Once the
signal is notified, the notification target rearms the timer, again
to honour the timer interval.
When a timer is rearmed, we need to notify the full dynticks CPUs
in case they are running tasks that may have a share in elapsing this
timer.
The 1st case above is currently handled but we are missing the 2nd
case.
Lets handle both cases by moving the kick to the rearming common code
in posix_cpu_timer_schedule().
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
---
kernel/posix-cpu-timers.c | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index 35509c5..79747b7 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -1091,7 +1091,8 @@ void posix_cpu_timer_schedule(struct k_itimer *timer)
put_task_struct(p);
timer->it.cpu.task = p = NULL;
timer->it.cpu.expires = 0;
- goto out_unlock;
+ read_unlock(&tasklist_lock);
+ goto out;
} else if (unlikely(p->exit_state) && thread_group_empty(p)) {
/*
* We've noticed that the thread is dead, but
@@ -1100,7 +1101,8 @@ void posix_cpu_timer_schedule(struct k_itimer *timer)
*/
cpu_timer_sample_group(timer->it_clock, p, &now);
clear_dead_task(timer, now);
- goto out_unlock;
+ read_unlock(&tasklist_lock);
+ goto out;
}
spin_lock(&p->sighand->siglock);
cpu_timer_sample_group(timer->it_clock, p, &now);
@@ -1114,10 +1116,11 @@ void posix_cpu_timer_schedule(struct k_itimer *timer)
BUG_ON(!irqs_disabled());
arm_timer(timer);
spin_unlock(&p->sighand->siglock);
-
-out_unlock:
read_unlock(&tasklist_lock);
+ /* Kick full dynticks CPUs in case they need to tick on the new timer */
+ posix_cpu_timer_kick_nohz();
+
out:
timer->it_overrun_last = timer->it_overrun;
timer->it_overrun = -1;
@@ -1257,13 +1260,6 @@ void run_posix_cpu_timers(struct task_struct *tsk)
cpu_timer_fire(timer);
spin_unlock(&timer->it_lock);
}
-
- /*
- * In case some timers were rescheduled after the queue got emptied,
- * wake up full dynticks CPUs.
- */
- if (tsk->signal->cputimer.running)
- posix_cpu_timer_kick_nohz();
}
/*
--
1.8.3.1
next prev parent reply other threads:[~2013-11-07 18:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-07 18:16 [PATCH 0/6] timers: updates for 3.13 preview Frederic Weisbecker
2013-11-07 18:16 ` [PATCH 1/6] nohz: Convert a few places to use local per cpu accesses Frederic Weisbecker
2013-11-07 18:16 ` [PATCH 2/6] trivial: fix spelling in CONTEXT_TRACKING_FORCE help text Frederic Weisbecker
2013-11-07 18:16 ` [PATCH 3/6] context_tracking: Wrap static key check into more intuitive function name Frederic Weisbecker
2013-11-07 18:16 ` [PATCH 4/6] context_tracking: Rename context_tracking_active() to context_tracking_cpu_is_enabled() Frederic Weisbecker
2013-11-07 18:16 ` [PATCH 5/6] posix-timers: Spare workqueue if there is no full dynticks CPU to kick Frederic Weisbecker
2013-11-07 18:16 ` Frederic Weisbecker [this message]
2013-12-03 14:38 [GIT PULL v2] dynticks updates for 3.14 Frederic Weisbecker
2013-12-03 14:38 ` [PATCH 6/6] posix-timers: Fix full dynticks CPUs kick on timer rescheduling Frederic Weisbecker
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=1383848191-30807-7-git-send-email-fweisbec@gmail.com \
--to=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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
all inboxes | Powered by JetHome®