From: Frederic Weisbecker <fweisbec@gmail.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Stanislaw Gruszka <sgruszka@redhat.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ingo Molnar <mingo@elte.hu>, Oleg Nesterov <oleg@redhat.com>,
KOSAKI Motohiro <kosaki.motohiro@gmail.com>,
Olivier Langlois <olivier@trillion01.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 2/7] posix_cpu_timers: consolidate timer list cleanups
Date: Thu, 4 Jul 2013 18:46:20 +0200 [thread overview]
Message-ID: <1372956385-25396-3-git-send-email-fweisbec@gmail.com> (raw)
In-Reply-To: <1372956385-25396-1-git-send-email-fweisbec@gmail.com>
Cleaning up the posix cpu timers on task exit shares some common code
among timer list types, most notably the list traversal and expiry time
update.
Unify this in a common helper.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Stanislaw Gruszka <sgruszka@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
Cc: Olivier Langlois <olivier@trillion01.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
kernel/posix-cpu-timers.c | 48 +++++++++++++++++---------------------------
1 files changed, 19 insertions(+), 29 deletions(-)
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index c3c4ea1..b1450ce 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -399,6 +399,21 @@ static int posix_cpu_timer_del(struct k_itimer *timer)
return ret;
}
+static void cleanup_timers_list(struct list_head *head,
+ unsigned long long curr)
+{
+ struct cpu_timer_list *timer, *next;
+
+ list_for_each_entry_safe(timer, next, head, entry) {
+ list_del_init(&timer->entry);
+ if (timer->expires < curr) {
+ timer->expires = 0;
+ } else {
+ timer->expires -= curr;
+ }
+ }
+}
+
/*
* Clean out CPU timers still ticking when a thread exited. The task
* pointer is cleared, and the expiry time is replaced with the residual
@@ -409,37 +424,12 @@ static void cleanup_timers(struct list_head *head,
cputime_t utime, cputime_t stime,
unsigned long long sum_exec_runtime)
{
- struct cpu_timer_list *timer, *next;
- cputime_t ptime = utime + stime;
- list_for_each_entry_safe(timer, next, head, entry) {
- list_del_init(&timer->entry);
- if (timer->expires < cputime_to_expires(ptime)) {
- timer->expires = 0;
- } else {
- timer->expires -= cputime_to_expires(ptime);
- }
- }
-
- ++head;
- list_for_each_entry_safe(timer, next, head, entry) {
- list_del_init(&timer->entry);
- if (timer->expires < cputime_to_expires(utime)) {
- timer->expires = 0;
- } else {
- timer->expires -= cputime_to_expires(utime);
- }
- }
+ cputime_t ptime = utime + stime;
- ++head;
- list_for_each_entry_safe(timer, next, head, entry) {
- list_del_init(&timer->entry);
- if (timer->expires < sum_exec_runtime) {
- timer->expires = 0;
- } else {
- timer->expires -= sum_exec_runtime;
- }
- }
+ cleanup_timers_list(head, cputime_to_expires(ptime));
+ cleanup_timers_list(++head, cputime_to_expires(utime));
+ cleanup_timers_list(++head, sum_exec_runtime);
}
/*
--
1.7.5.4
next prev parent reply other threads:[~2013-07-04 16:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-04 16:46 [GIT PULL] posix cpu timers updates Frederic Weisbecker
2013-07-04 16:46 ` [PATCH 1/7] posix_cpu_timer: consolidate expiry time type Frederic Weisbecker
2013-07-04 16:46 ` Frederic Weisbecker [this message]
2013-07-04 16:46 ` [PATCH 3/7] posix_cpu_timers: consolidate expired timers check Frederic Weisbecker
2013-07-04 16:46 ` [PATCH 4/7] selftests: add basic posix timers selftests Frederic Weisbecker
2013-07-04 16:46 ` [PATCH 5/7] posix-timers: correctly get dying task time sample in posix_cpu_timer_schedule() Frederic Weisbecker
2013-07-04 16:46 ` [PATCH 6/7] posix_timers: fix racy timer delta caching on task exit Frederic Weisbecker
2013-07-04 16:46 ` [PATCH 7/7] posix-cpu-timers: don't account cpu timer after stopped thread runtime accounting 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=1372956385-25396-3-git-send-email-fweisbec@gmail.com \
--to=fweisbec@gmail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=kosaki.motohiro@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@redhat.com \
--cc=olivier@trillion01.com \
--cc=sgruszka@redhat.com \
--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®