public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Williams <pwil3058@bigpond.net.au>
To: Con Kolivas <kernel@kolivas.org>
Cc: Mike Galbraith <efault@gmx.de>,
	lkml <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@osdl.org>,
	Nick Piggin <nickpiggin@yahoo.com.au>
Subject: Re: [2.6.16-mm1 patch] throttling tree patches
Date: Sat, 25 Mar 2006 11:25:11 +1100	[thread overview]
Message-ID: <44248DE7.80001@bigpond.net.au> (raw)
In-Reply-To: <200603242237.38100.kernel@kolivas.org>

Con Kolivas wrote:
> On Friday 24 March 2006 22:03, Mike Galbraith wrote:
>> Greetings,
> 
> /me waves
> 
>> Ignore timewarps caused by SMP timestamp rounding.  Also, don't stamp a
>> task with a computed timestamp, stamp with the already called clock.
> 
> Looks good. Actually now < p->timestamp is not going to only happen on SMP. 
> Once every I don't know how often the sched_clock seems to return a value 
> that appears to have been in the past (I believe Peter has instrumented 
> this).

I haven't bothered to check if it still occurs for quite a long while. 
I just check for time deltas being negative and if they are negative I 
make them zero and move on.  As far as I can remember I only ever saw 
this when measuring "delay" (i.e. time on the run queue waiting to get 
on to a CPU which can be quite short :-) when the systems not heavily 
loaded) as other time intervals that I measure (i.e. time on CPU and 
sleep time) are generally long enough for the error in the delta not 
being big enough to make the value negative.

> 
>> Signed-off-by: Mike Galbraith <efault@gmx.de>
> 
>> +		__sleep_time = 0ULL;
> 
> I don't think the ULL is necessary.
> 
>> -	unsigned long long now;
>> +	unsigned long long now, comp;
>>
>> -	now = sched_clock();
>> +	now = comp = sched_clock();
>>  #ifdef CONFIG_SMP
>>  	if (!local) {
>>  		/* Compensate for drifting sched_clock */
>>  		runqueue_t *this_rq = this_rq();
>> -		now = (now - this_rq->timestamp_last_tick)
>> +		comp = (now - this_rq->timestamp_last_tick)
>>  			+ rq->timestamp_last_tick;
>>  	}
>>  #endif
>>
>>  	if (!rt_task(p))
>> -		p->prio = recalc_task_prio(p, now);
>> +		p->prio = recalc_task_prio(p, comp);
> 
> Seems wasteful of a very expensive (on 32bit) unsigned long long on 
> uniprocessor builds.

Unsigned long long is necessary in order to avoid overflow when dealing 
with nano seconds but (if you reorganized the expressions and made the 
desired precedence explicit) you could probably use something smaller 
for the difference between the two timestamp_lats_tick values.  More 
importantly, I think that the original code which used the computed 
"now" was correct as otherwise the task's timestamp will not have the 
correct time for its CPU.

Of course, this all hinges on the differences between the run queues' 
timestamp_last_tick fields being a true measure of the time drift 
between them.  I've never been wholly convinced of that but as long as 
any error is much smaller than the drift it's probably worth doing.

Peter
PS I think that some inline functions to handle timestamp adjustment 
wouldn't hurt.
PPS I'm not sure that the timstamp adjustment in __migrate_task() is 
completely valid as the timestamp will be modified in activate_task() 
using the wrong clock.  I need to study this more to see if I convince 
myself one way or the other.
-- 
Peter Williams                                   pwil3058@bigpond.net.au

"Learning, n. The kind of ignorance distinguishing the studious."
  -- Ambrose Bierce

  reply	other threads:[~2006-03-25  0:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-24 11:03 [2.6.16-mm1 patch] throttling tree patches Mike Galbraith
2006-03-24 11:07 ` Mike Galbraith
2006-03-24 11:16   ` Mike Galbraith
2006-03-24 11:21     ` Mike Galbraith
2006-03-24 11:24       ` Mike Galbraith
2006-03-24 11:28         ` Mike Galbraith
2006-03-24 11:56           ` Con Kolivas
2006-03-24 11:55         ` Con Kolivas
2006-03-24 11:54       ` Con Kolivas
2006-03-24 11:56     ` Con Kolivas
2006-03-24 12:21       ` Mike Galbraith
2006-03-24 12:34         ` Con Kolivas
2006-03-24 13:02           ` Mike Galbraith
2006-03-24 13:52             ` Con Kolivas
2006-03-24 14:10               ` Mike Galbraith
2006-03-24 11:38   ` Con Kolivas
2006-03-24 11:37 ` Con Kolivas
2006-03-25  0:25   ` Peter Williams [this message]
2006-03-25  5:06     ` Mike Galbraith
2006-03-25  6:18       ` [2.6.16-mm1 patch] ignore timewarps Mike Galbraith
2006-03-25  0:37 ` [2.6.16-mm1 patch] throttling tree patches Peter Williams
2006-03-25  5:11   ` Mike Galbraith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44248DE7.80001@bigpond.net.au \
    --to=pwil3058@bigpond.net.au \
    --cc=akpm@osdl.org \
    --cc=efault@gmx.de \
    --cc=kernel@kolivas.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nickpiggin@yahoo.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox