diff options
author | Stanislaw Gruszka <sgruszka@redhat.com> | 2009-07-29 06:15:28 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-08-03 08:48:36 -0400 |
commit | d1e3b6d195770bd422e3229b88edfc154b6a27dd (patch) | |
tree | 153a0bb49967c4d489a510c9e673d07f4e560a6c /kernel | |
parent | 8356b5f9c424e5831715abbce747197c30d1fd71 (diff) |
itimers: Simplify arm_timer() code a bit
Don't update values in expiration cache when new ones are
equal. Add expire_le() and expire_gt() helpers to simplify the
code.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
LKML-Reference: <1248862529-6063-4-git-send-email-sgruszka@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/posix-cpu-timers.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c index b60d644ea4b3..69c92374355f 100644 --- a/kernel/posix-cpu-timers.c +++ b/kernel/posix-cpu-timers.c | |||
@@ -541,6 +541,17 @@ static void clear_dead_task(struct k_itimer *timer, union cpu_time_count now) | |||
541 | now); | 541 | now); |
542 | } | 542 | } |
543 | 543 | ||
544 | static inline int expires_gt(cputime_t expires, cputime_t new_exp) | ||
545 | { | ||
546 | return cputime_eq(expires, cputime_zero) || | ||
547 | cputime_gt(expires, new_exp); | ||
548 | } | ||
549 | |||
550 | static inline int expires_le(cputime_t expires, cputime_t new_exp) | ||
551 | { | ||
552 | return !cputime_eq(expires, cputime_zero) && | ||
553 | cputime_le(expires, new_exp); | ||
554 | } | ||
544 | /* | 555 | /* |
545 | * Insert the timer on the appropriate list before any timers that | 556 | * Insert the timer on the appropriate list before any timers that |
546 | * expire later. This must be called with the tasklist_lock held | 557 | * expire later. This must be called with the tasklist_lock held |
@@ -585,31 +596,26 @@ static void arm_timer(struct k_itimer *timer, union cpu_time_count now) | |||
585 | */ | 596 | */ |
586 | 597 | ||
587 | if (CPUCLOCK_PERTHREAD(timer->it_clock)) { | 598 | if (CPUCLOCK_PERTHREAD(timer->it_clock)) { |
599 | union cpu_time_count *exp = &nt->expires; | ||
600 | |||
588 | switch (CPUCLOCK_WHICH(timer->it_clock)) { | 601 | switch (CPUCLOCK_WHICH(timer->it_clock)) { |
589 | default: | 602 | default: |
590 | BUG(); | 603 | BUG(); |
591 | case CPUCLOCK_PROF: | 604 | case CPUCLOCK_PROF: |
592 | if (cputime_eq(p->cputime_expires.prof_exp, | 605 | if (expires_gt(p->cputime_expires.prof_exp, |
593 | cputime_zero) || | 606 | exp->cpu)) |
594 | cputime_gt(p->cputime_expires.prof_exp, | 607 | p->cputime_expires.prof_exp = exp->cpu; |
595 | nt->expires.cpu)) | ||
596 | p->cputime_expires.prof_exp = | ||
597 | nt->expires.cpu; | ||
598 | break; | 608 | break; |
599 | case CPUCLOCK_VIRT: | 609 | case CPUCLOCK_VIRT: |
600 | if (cputime_eq(p->cputime_expires.virt_exp, | 610 | if (expires_gt(p->cputime_expires.virt_exp, |
601 | cputime_zero) || | 611 | exp->cpu)) |
602 | cputime_gt(p->cputime_expires.virt_exp, | 612 | p->cputime_expires.virt_exp = exp->cpu; |
603 | nt->expires.cpu)) | ||
604 | p->cputime_expires.virt_exp = | ||
605 | nt->expires.cpu; | ||
606 | break; | 613 | break; |
607 | case CPUCLOCK_SCHED: | 614 | case CPUCLOCK_SCHED: |
608 | if (p->cputime_expires.sched_exp == 0 || | 615 | if (p->cputime_expires.sched_exp == 0 || |
609 | p->cputime_expires.sched_exp > | 616 | p->cputime_expires.sched_exp > exp->sched) |
610 | nt->expires.sched) | ||
611 | p->cputime_expires.sched_exp = | 617 | p->cputime_expires.sched_exp = |
612 | nt->expires.sched; | 618 | exp->sched; |
613 | break; | 619 | break; |
614 | } | 620 | } |
615 | } else { | 621 | } else { |
@@ -623,17 +629,13 @@ static void arm_timer(struct k_itimer *timer, union cpu_time_count now) | |||
623 | default: | 629 | default: |
624 | BUG(); | 630 | BUG(); |
625 | case CPUCLOCK_VIRT: | 631 | case CPUCLOCK_VIRT: |
626 | if (!cputime_eq(sig->it[CPUCLOCK_VIRT].expires, | 632 | if (expires_le(sig->it[CPUCLOCK_VIRT].expires, |
627 | cputime_zero) && | ||
628 | cputime_lt(sig->it[CPUCLOCK_VIRT].expires, | ||
629 | exp->cpu)) | 633 | exp->cpu)) |
630 | break; | 634 | break; |
631 | sig->cputime_expires.virt_exp = exp->cpu; | 635 | sig->cputime_expires.virt_exp = exp->cpu; |
632 | break; | 636 | break; |
633 | case CPUCLOCK_PROF: | 637 | case CPUCLOCK_PROF: |
634 | if (!cputime_eq(sig->it[CPUCLOCK_PROF].expires, | 638 | if (expires_le(sig->it[CPUCLOCK_PROF].expires, |
635 | cputime_zero) && | ||
636 | cputime_lt(sig->it[CPUCLOCK_PROF].expires, | ||
637 | exp->cpu)) | 639 | exp->cpu)) |
638 | break; | 640 | break; |
639 | i = sig->rlim[RLIMIT_CPU].rlim_cur; | 641 | i = sig->rlim[RLIMIT_CPU].rlim_cur; |