public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Rik van Riel <riel@redhat.com>
To: Glauber Costa <glommer@gmail.com>,
	lwcheng@cs.hku.hk, Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [BUG] Paravirtual time accounting / IRQ time accounting
Date: Fri, 21 Mar 2014 07:31:58 -0400	[thread overview]
Message-ID: <532C232E.5000607@redhat.com> (raw)
In-Reply-To: <CAA6-i6p-=4Dk9-ujvL36EVpm80MS-BiYjw+V9JQ8g4AypBJeZw@mail.gmail.com>

On 03/20/2014 11:01 AM, Glauber Costa wrote:
> On Wed, Mar 19, 2014 at 6:42 AM,  <lwcheng@cs.hku.hk> wrote:

>> ------------
>> [src/kernel/sched/core.c]
>> static void update_rq_clock_task(struct rq *rq, s64 delta)
>> {
>>     ... ...
>> #ifdef CONFIG_IRQ_TIME_ACCOUNTING
>>     irq_delta = irq_time_read(cpu_of(rq)) - rq->prev_irq_time;
>>     ... ...
>>     rq->prev_irq_time += irq_delta;
>>     delta -= irq_delta;
>> #endif
>>
>> #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
>>     if (static_key_false((&paravirt_steal_rq_enabled))) {
>>         steal = paravirt_steal_clock(cpu_of(rq));
>>         steal -= rq->prev_steal_time_rq;
>>         ... ...
>>         rq->prev_steal_time_rq += steal;
>>         delta -= steal;
>>     }
>> #endif
>>
>>     rq->clock_task += delta;
>>     ... ...
>> }
>> --
>> "delta" -> the intended increment to rq->clock_task
>> "irq_delta" -> the time spent on serving IRQ (hard + soft)
>> "steal" -> the time stolen by the underlying hypervisor
>> --
>> "irq_delta" is calculated based on sched_clock_cpu(), which is vulnerable
>> to VM scheduling delays.
> 
> This looks like a real problem indeed. The main problem in searching
> for a solution, is that of course not all of the irq time is steal
> time and vice versa. In this case, we could subtract irq_time from
> steal, and add only the steal part time that is in excess. I don't
> think this is 100 % guaranteed, but maybe it is a good approximation.
> 
> Rik, do you have an opinion on this ?

The other way around may be better, since steal time (when it
happens) is likely to be of "time slice" magnitude, while irq
time will happen more frequently, and in dozens-of-microseconds
intervals.

Furthermore, we have no way to measure what the irq time is,
except by looking at how much real time elapsed. For steal time,
however, the hypervisor tells us exactly how much time was stolen.

That means when steal time and irq time happen simultaneously,
the amount of steal time should always be smaller than the
calculated irq time for that period.

actual irq_time = calculated irq time - reported steal time;

-- 
All rights reversed

  parent reply	other threads:[~2014-03-21 11:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-19  9:42 [BUG] Paravirtual time accounting / IRQ time accounting lwcheng
2014-03-20 15:01 ` Glauber Costa
2014-03-21  5:50   ` Mike Galbraith
2014-03-22  6:47     ` lwcheng
2014-03-22  7:44       ` Mike Galbraith
2014-03-21 11:31   ` Rik van Riel [this message]
2014-03-22  7:15     ` lwcheng
2014-03-22 14:57       ` Rik van Riel

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=532C232E.5000607@redhat.com \
    --to=riel@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=glommer@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lwcheng@cs.hku.hk \
    /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