* update on hrtimer based select/poll and range-hrtimers
@ 2008-09-07 18:11 Arjan van de Ven
2008-09-07 20:46 ` Peter Zijlstra
2008-09-08 14:31 ` Ingo Molnar
0 siblings, 2 replies; 4+ messages in thread
From: Arjan van de Ven @ 2008-09-07 18:11 UTC (permalink / raw)
To: linux-kernel; +Cc: mingo, tglx, torvalds, peterz
Hi,
since the last lkml posting I've merged a few fixes and added comments
from Peter, and I've redone the "estimate_accuracy" function.
Rather than reposting the entire series, I'll point to the git tree at
git://git.kernel.org/pub/scm/linux/kernel/git/arjan/linux-2.6-hrtimer.git
and I've pasted the new function below.
Rather than having the hardcoded steps from the "Linus" function, I've
turned it into:
0 for realtime tasks
"0.1% of the time" for not-nice, not realtime tasks
"0.5% of the time" for nice, not realtime tasks
with a cap of 100msec for both.
I would like to request feedback on this approach; I think this is
better than the "hardcoded steps" as before, but maybe someone can come
up with an ever better idea....
static unsigned long __estimate_accuracy(struct timespec *tv)
{
unsigned long slack;
int divfactor = 1000;
if (task_nice(current))
divfactor = divfactor / 5;
slack = tv->tv_nsec / divfactor;
slack += tv->tv_sec * (NSEC_PER_SEC/divfactor);
if (slack > 100 * NSEC_PER_MSEC)
slack = 100 * NSEC_PER_MSEC;
return slack;
}
static unsigned long estimate_accuracy(struct timespec *tv)
{
unsigned long ret;
struct timespec now;
/*
* Realtime tasks get a slack of 0 for obvious reasons.
*/
if (current->policy == SCHED_FIFO ||
current->policy == SCHED_RR)
return 0;
ktime_get_ts(&now);
now = timespec_sub(*tv, now);
ret = __estimate_accuracy(&now);
if (ret < current->timer_slack_ns)
return current->timer_slack_ns;
return ret;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: update on hrtimer based select/poll and range-hrtimers
2008-09-07 18:11 update on hrtimer based select/poll and range-hrtimers Arjan van de Ven
@ 2008-09-07 20:46 ` Peter Zijlstra
2008-09-07 21:07 ` Arjan van de Ven
2008-09-08 14:31 ` Ingo Molnar
1 sibling, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2008-09-07 20:46 UTC (permalink / raw)
To: Arjan van de Ven; +Cc: linux-kernel, mingo, tglx, torvalds
On Sun, 2008-09-07 at 11:11 -0700, Arjan van de Ven wrote:
> Hi,
>
> since the last lkml posting I've merged a few fixes and added comments
> from Peter, and I've redone the "estimate_accuracy" function.
>
> Rather than reposting the entire series, I'll point to the git tree at
>
> git://git.kernel.org/pub/scm/linux/kernel/git/arjan/linux-2.6-hrtimer.git
>
> and I've pasted the new function below.
> Rather than having the hardcoded steps from the "Linus" function, I've
> turned it into:
> 0 for realtime tasks
> "0.1% of the time" for not-nice, not realtime tasks
> "0.5% of the time" for nice, not realtime tasks
> with a cap of 100msec for both.
>
> I would like to request feedback on this approach; I think this is
> better than the "hardcoded steps" as before, but maybe someone can come
> up with an ever better idea....
logarithms pop to mind (again :-)
> static unsigned long __estimate_accuracy(struct timespec *tv)
> {
> unsigned long slack;
> int divfactor = 1000;
>
> if (task_nice(current))
This triggers for both -nice and +nice tasks, it might be worth
differentiating between those.
> divfactor = divfactor / 5;
>
> slack = tv->tv_nsec / divfactor;
> slack += tv->tv_sec * (NSEC_PER_SEC/divfactor);
>
> if (slack > 100 * NSEC_PER_MSEC)
> slack = 100 * NSEC_PER_MSEC;
> return slack;
> }
>
> static unsigned long estimate_accuracy(struct timespec *tv)
> {
> unsigned long ret;
> struct timespec now;
>
> /*
> * Realtime tasks get a slack of 0 for obvious reasons.
> */
>
> if (current->policy == SCHED_FIFO ||
> current->policy == SCHED_RR)
> return 0;
rt_task(current) ?
> ktime_get_ts(&now);
> now = timespec_sub(*tv, now);
> ret = __estimate_accuracy(&now);
> if (ret < current->timer_slack_ns)
> return current->timer_slack_ns;
pull out the max from __estimate_accuracy() and use clamp() here?
> return ret;
> }
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: update on hrtimer based select/poll and range-hrtimers
2008-09-07 20:46 ` Peter Zijlstra
@ 2008-09-07 21:07 ` Arjan van de Ven
0 siblings, 0 replies; 4+ messages in thread
From: Arjan van de Ven @ 2008-09-07 21:07 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: linux-kernel, mingo, tglx, torvalds
On Sun, 07 Sep 2008 22:46:39 +0200
Peter Zijlstra <peterz@infradead.org> wrote:
> > "0.1% of the time" for not-nice, not realtime tasks
> > "0.5% of the time" for nice, not realtime tasks
> > with a cap of 100msec for both.
> >
> > I would like to request feedback on this approach; I think this is
> > better than the "hardcoded steps" as before, but maybe someone can
> > come up with an ever better idea....
>
> logarithms pop to mind (again :-)
and it still doesn't strike me as "oh yeah"
how would you see this work? Can you give a numeric example?
>
> > static unsigned long __estimate_accuracy(struct timespec *tv)
> > {
> > unsigned long slack;
> > int divfactor = 1000;
> >
> > if (task_nice(current))
>
> This triggers for both -nice and +nice tasks, it might be worth
> differentiating between those.
good spotting; will fix.
> >
> > if (current->policy == SCHED_FIFO ||
> > current->policy == SCHED_RR)
> > return 0;
>
> rt_task(current) ?
hmm that's not exactly equivalent.. I can see either but still.
--
If you want to reach me at my work email, use arjan@linux.intel.com
For development, discussion and tips for power savings,
visit http://www.lesswatts.org
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: update on hrtimer based select/poll and range-hrtimers
2008-09-07 18:11 update on hrtimer based select/poll and range-hrtimers Arjan van de Ven
2008-09-07 20:46 ` Peter Zijlstra
@ 2008-09-08 14:31 ` Ingo Molnar
1 sibling, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2008-09-08 14:31 UTC (permalink / raw)
To: Arjan van de Ven; +Cc: linux-kernel, tglx, torvalds, peterz
* Arjan van de Ven <arjan@infradead.org> wrote:
> Hi,
>
> since the last lkml posting I've merged a few fixes and added comments
> from Peter, and I've redone the "estimate_accuracy" function.
>
> Rather than reposting the entire series, I'll point to the git tree at
>
> git://git.kernel.org/pub/scm/linux/kernel/git/arjan/linux-2.6-hrtimer.git
pulled into tip/timers/range-hrtimers, thanks Arjan!
Ingo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-09-08 14:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-07 18:11 update on hrtimer based select/poll and range-hrtimers Arjan van de Ven
2008-09-07 20:46 ` Peter Zijlstra
2008-09-07 21:07 ` Arjan van de Ven
2008-09-08 14:31 ` Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome