提交 1a7fa510 编写于 作者: F Frederic Weisbecker

posix_cpu_timers: consolidate timer list cleanups

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: NFrederic 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: NAndrew Morton <akpm@linux-foundation.org>
上级 55ccb616
...@@ -399,6 +399,21 @@ static int posix_cpu_timer_del(struct k_itimer *timer) ...@@ -399,6 +399,21 @@ static int posix_cpu_timer_del(struct k_itimer *timer)
return ret; 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 * Clean out CPU timers still ticking when a thread exited. The task
* pointer is cleared, and the expiry time is replaced with the residual * pointer is cleared, and the expiry time is replaced with the residual
...@@ -409,37 +424,12 @@ static void cleanup_timers(struct list_head *head, ...@@ -409,37 +424,12 @@ static void cleanup_timers(struct list_head *head,
cputime_t utime, cputime_t stime, cputime_t utime, cputime_t stime,
unsigned long long sum_exec_runtime) 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) { cputime_t ptime = utime + stime;
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);
}
}
++head; cleanup_timers_list(head, cputime_to_expires(ptime));
list_for_each_entry_safe(timer, next, head, entry) { cleanup_timers_list(++head, cputime_to_expires(utime));
list_del_init(&timer->entry); cleanup_timers_list(++head, sum_exec_runtime);
if (timer->expires < sum_exec_runtime) {
timer->expires = 0;
} else {
timer->expires -= sum_exec_runtime;
}
}
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册