Re: update on hrtimer based select/poll and range-hrtimers

Previous thread: [PATCH] x86: cpu make amd.c more like amd_64.c v2 by Yinghai Lu on Sunday, September 7, 2008 - 10:20 am. (1 message)

Next thread: Various OOps with 2.6.27-rc5 by Alejandro Riveira on Sunday, September 7, 2008 - 12:21 pm. (5 messages)
From: Arjan van de Ven
Date: Sunday, September 7, 2008 - 11:11 am

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;
}
--

From: Peter Zijlstra
Date: Sunday, September 7, 2008 - 1:46 pm

This triggers for both -nice and +nice tasks, it might be worth




--

From: Arjan van de Ven
Date: Sunday, September 7, 2008 - 2:07 pm

On Sun, 07 Sep 2008 22:46:39 +0200

and it still doesn't strike me as "oh yeah"



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
--

From: Ingo Molnar
Date: Monday, September 8, 2008 - 7:31 am

pulled into tip/timers/range-hrtimers, thanks Arjan!

	Ingo
--

Previous thread: [PATCH] x86: cpu make amd.c more like amd_64.c v2 by Yinghai Lu on Sunday, September 7, 2008 - 10:20 am. (1 message)

Next thread: Various OOps with 2.6.27-rc5 by Alejandro Riveira on Sunday, September 7, 2008 - 12:21 pm. (5 messages)