LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH resend4 3/3] itimers: simplify arm_timer() code a bit
@ 2009-05-22 13:43 Stanislaw Gruszka
2009-05-22 14:30 ` Thomas Gleixner
0 siblings, 1 reply; 4+ messages in thread
From: Stanislaw Gruszka @ 2009-05-22 13:43 UTC (permalink / raw)
To: Thomas Gleixner
Cc: linux-kernel, Oleg Nesterov, Peter Zijlstra, Ingo Molnar, Andrew Morton
Don't update values in expiration cache when new ones are equal. Add
expire_le() helper to simplify code. Make similar control flow on all
arm_timer() function.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
kernel/posix-cpu-timers.c | 46 ++++++++++++++++++++++----------------------
1 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index b60d644..ce16e22 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -541,6 +541,13 @@ static void clear_dead_task(struct k_itimer *timer, union cpu_time_count now)
now);
}
+static inline int expires_le(cputime_t expires, cputime_t new_exp)
+{
+ if (!cputime_eq(expires, cputime_zero) && cputime_le(expires, new_exp))
+ return 1;
+ return 0;
+}
+
/*
* Insert the timer on the appropriate list before any timers that
* expire later. This must be called with the tasklist_lock held
@@ -585,31 +592,28 @@ static void arm_timer(struct k_itimer *timer, union cpu_time_count now)
*/
if (CPUCLOCK_PERTHREAD(timer->it_clock)) {
+ union cpu_time_count *exp = &nt->expires;
+
switch (CPUCLOCK_WHICH(timer->it_clock)) {
default:
BUG();
case CPUCLOCK_PROF:
- if (cputime_eq(p->cputime_expires.prof_exp,
- cputime_zero) ||
- cputime_gt(p->cputime_expires.prof_exp,
- nt->expires.cpu))
- p->cputime_expires.prof_exp =
- nt->expires.cpu;
+ if (expires_le(p->cputime_expires.prof_exp,
+ exp->cpu))
+ break;
+ p->cputime_expires.prof_exp = exp->cpu;
break;
case CPUCLOCK_VIRT:
- if (cputime_eq(p->cputime_expires.virt_exp,
- cputime_zero) ||
- cputime_gt(p->cputime_expires.virt_exp,
- nt->expires.cpu))
- p->cputime_expires.virt_exp =
- nt->expires.cpu;
+ if (expires_le(p->cputime_expires.virt_exp,
+ exp->cpu))
+ break;
+ p->cputime_expires.virt_exp = exp->cpu;
break;
case CPUCLOCK_SCHED:
- if (p->cputime_expires.sched_exp == 0 ||
- p->cputime_expires.sched_exp >
- nt->expires.sched)
- p->cputime_expires.sched_exp =
- nt->expires.sched;
+ if (p->cputime_expires.sched_exp == 0 &&
+ p->cputime_expires.sched_exp <= exp->sched)
+ break;
+ p->cputime_expires.sched_exp = exp->sched;
break;
}
} else {
@@ -623,17 +627,13 @@ static void arm_timer(struct k_itimer *timer, union cpu_time_count now)
default:
BUG();
case CPUCLOCK_VIRT:
- if (!cputime_eq(sig->it[CPUCLOCK_VIRT].expires,
- cputime_zero) &&
- cputime_lt(sig->it[CPUCLOCK_VIRT].expires,
+ if (expires_le(sig->it[CPUCLOCK_VIRT].expires,
exp->cpu))
break;
sig->cputime_expires.virt_exp = exp->cpu;
break;
case CPUCLOCK_PROF:
- if (!cputime_eq(sig->it[CPUCLOCK_PROF].expires,
- cputime_zero) &&
- cputime_lt(sig->it[CPUCLOCK_PROF].expires,
+ if (expires_le(sig->it[CPUCLOCK_PROF].expires,
exp->cpu))
break;
i = sig->rlim[RLIMIT_CPU].rlim_cur;
--
1.5.5.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH resend4 3/3] itimers: simplify arm_timer() code a bit
2009-05-22 13:43 [PATCH resend4 3/3] itimers: simplify arm_timer() code a bit Stanislaw Gruszka
@ 2009-05-22 14:30 ` Thomas Gleixner
2009-05-22 14:36 ` Stanislaw Gruszka
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Gleixner @ 2009-05-22 14:30 UTC (permalink / raw)
To: Stanislaw Gruszka
Cc: linux-kernel, Oleg Nesterov, Peter Zijlstra, Ingo Molnar, Andrew Morton
On Fri, 22 May 2009, Stanislaw Gruszka wrote:
> case CPUCLOCK_PROF:
> - if (cputime_eq(p->cputime_expires.prof_exp,
> - cputime_zero) ||
> - cputime_gt(p->cputime_expires.prof_exp,
> - nt->expires.cpu))
> - p->cputime_expires.prof_exp =
> - nt->expires.cpu;
> + if (expires_le(p->cputime_expires.prof_exp,
> + exp->cpu))
> + break;
Why the reverse logic and the extra break ?
> + p->cputime_expires.prof_exp = exp->cpu;
> break;
Thanks,
tglx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH resend4 3/3] itimers: simplify arm_timer() code a bit
2009-05-22 14:30 ` Thomas Gleixner
@ 2009-05-22 14:36 ` Stanislaw Gruszka
2009-05-22 16:59 ` Thomas Gleixner
0 siblings, 1 reply; 4+ messages in thread
From: Stanislaw Gruszka @ 2009-05-22 14:36 UTC (permalink / raw)
To: Thomas Gleixner
Cc: linux-kernel, Oleg Nesterov, Peter Zijlstra, Ingo Molnar, Andrew Morton
On Fri, 22 May 2009 16:30:09 +0200 (CEST)
Thomas Gleixner <tglx@linutronix.de> wrote:
> On Fri, 22 May 2009, Stanislaw Gruszka wrote:
> > case CPUCLOCK_PROF:
> > - if (cputime_eq(p->cputime_expires.prof_exp,
> > - cputime_zero) ||
> > - cputime_gt(p->cputime_expires.prof_exp,
> > - nt->expires.cpu))
> > - p->cputime_expires.prof_exp =
> > - nt->expires.cpu;
> > + if (expires_le(p->cputime_expires.prof_exp,
> > + exp->cpu))
> > + break;
>
> Why the reverse logic and the extra break ?
Just to use helper and to make similar logic in all cases in this funcion.
Thanks
Stanislaw
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH resend4 3/3] itimers: simplify arm_timer() code a bit
2009-05-22 14:36 ` Stanislaw Gruszka
@ 2009-05-22 16:59 ` Thomas Gleixner
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Gleixner @ 2009-05-22 16:59 UTC (permalink / raw)
To: Stanislaw Gruszka
Cc: linux-kernel, Oleg Nesterov, Peter Zijlstra, Ingo Molnar, Andrew Morton
On Fri, 22 May 2009, Stanislaw Gruszka wrote:
> On Fri, 22 May 2009 16:30:09 +0200 (CEST)
> Thomas Gleixner <tglx@linutronix.de> wrote:
>
> > On Fri, 22 May 2009, Stanislaw Gruszka wrote:
> > > case CPUCLOCK_PROF:
> > > - if (cputime_eq(p->cputime_expires.prof_exp,
> > > - cputime_zero) ||
> > > - cputime_gt(p->cputime_expires.prof_exp,
> > > - nt->expires.cpu))
> > > - p->cputime_expires.prof_exp =
> > > - nt->expires.cpu;
> > > + if (expires_le(p->cputime_expires.prof_exp,
> > > + exp->cpu))
> > > + break;
> >
> > Why the reverse logic and the extra break ?
>
> Just to use helper and to make similar logic in all cases in this funcion.
Well, you can do that the other way round as well :)
Thanks,
tglx
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-05-22 17:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-22 13:43 [PATCH resend4 3/3] itimers: simplify arm_timer() code a bit Stanislaw Gruszka
2009-05-22 14:30 ` Thomas Gleixner
2009-05-22 14:36 ` Stanislaw Gruszka
2009-05-22 16:59 ` Thomas Gleixner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).