[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFTL4hyFiE-G4VvmO+J2MMrJBFtH07ZcYp0GEnqoQ846_eivEQ@mail.gmail.com>
Date: Thu, 25 Oct 2012 09:56:58 +0200
From: Frederic Weisbecker <fweisbec@...il.com>
To: Christian Borntraeger <borntraeger@...ibm.com>
Cc: LKML <linux-kernel@...r.kernel.org>,
Tony Luck <tony.luck@...el.com>,
Fenghua Yu <fenghua.yu@...el.com>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Heiko Carstens <heiko.carstens@...ibm.com>,
Martin Schwidefsky <schwidefsky@...ibm.com>,
Avi Kivity <avi@...hat.com>,
Marcelo Tosatti <mtosatti@...hat.com>,
Joerg Roedel <joerg.roedel@....com>,
Alexander Graf <agraf@...e.de>,
Xiantao Zhang <xiantao.zhang@...el.com>,
Cornelia Huck <cornelia.huck@...ibm.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Steven Rostedt <rostedt@...dmis.org>,
Paul Gortmaker <paul.gortmaker@...driver.com>
Subject: Re: [PATCH 3/5] kvm: Directly account vtime to system on guest switch
2012/10/25 Christian Borntraeger <borntraeger@...ibm.com>:
> On 25/10/12 02:51, Frederic Weisbecker wrote:
>> Switching to or from guest context is done on ioctl context.
>> So by the time we call kvm_guest_enter() or kvm_guest_exit()
>> we know we are not running the idle task.
>>
>> As a result, we can directly account the cputime using
>> vtime_account_system_irqsafe().
>>
>> There are two good reasons to do this:
>>
>> * We avoid some useless checks on guest switch. It optimizes
>> a bit this fast path.
>>
>> * In the case of CONFIG_IRQ_TIME_ACCOUNTING, calling vtime_account()
>> checks for irq time to account. This is pointless since we know
>> we are not in an irq on guest switch. This is wasting cpu cycles
>> for no good reason. vtime_account_system() OTOH is a no-op in
>> this config option.
>>
>> * s390 doesn't disable irqs in its implementation of vtime_account().
>> If vtime_account() in kvm races with an irq, the pending time might
>> be accounted twice. With vtime_account_system_irqsafe() we are protected.
>
> We disable irqs before we call kvm_guest_enter/exit, see kvm-s390.c:
>
>
> [...]
> if (!kvm_is_ucontrol(vcpu->kvm))
> kvm_s390_deliver_pending_interrupts(vcpu);
> vcpu->arch.sie_block->icptcode = 0;
> local_irq_disable();
> kvm_guest_enter();
> local_irq_enable();
> [...]
>
Ah ok. Hmm I still need to keep it irqsafe for the other archs though,
as it is currently with vtime_account(). So perhaps I can remove your
local_irq_disable there and use vtime_account_system_irqsafe()
instead?
thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists