All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Tony Luck <tony.luck@intel.com>,
	Fenghua Yu <fenghua.yu@intel.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Avi Kivity <avi@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	Joerg Roedel <joerg.roedel@amd.com>,
	Alexander Graf <agraf@suse.de>,
	Xiantao Zhang <xiantao.zhang@intel.com>,
	Cornelia Huck <cornelia.huck@de.ibm.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Steven Rostedt <rostedt@goodmis.org>,
	Paul Gortmaker <paul.gortmaker@windriver.com>
Subject: Re: [PATCH 3/5] kvm: Directly account vtime to system on guest switch
Date: Thu, 25 Oct 2012 09:51:33 +0200	[thread overview]
Message-ID: <5088EF85.4080002@de.ibm.com> (raw)
In-Reply-To: <1351126313-17804-4-git-send-email-fweisbec@gmail.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();
[...]


  reply	other threads:[~2012-10-25  7:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-25  0:51 [PATCH 0/5] cputime: Moar cleanups / enhancements v2 Frederic Weisbecker
2012-10-25  0:51 ` [PATCH 1/5] vtime: Gather vtime declarations to their own header file Frederic Weisbecker
2012-10-25  0:51 ` [PATCH 2/5] vtime: Provide an irq safe version of vtime_account_system() Frederic Weisbecker
2012-10-25  7:48   ` Ingo Molnar
2012-10-25  0:51 ` [PATCH 3/5] kvm: Directly account vtime to system on guest switch Frederic Weisbecker
2012-10-25  7:51   ` Christian Borntraeger [this message]
2012-10-25  7:56     ` Frederic Weisbecker
2012-10-25  7:59       ` Christian Borntraeger
2012-10-25  0:51 ` [PATCH 4/5] cputime: Specialize irq vtime hooks Frederic Weisbecker
2012-10-25  0:51 ` [PATCH 5/5] cputime: Separate irqtime accounting from generic vtime Frederic Weisbecker
  -- strict thread matches above, loose matches on Subject: below --
2012-10-25 17:47 [PATCH 0/5] cputime: Moar cleanups / enhancements v3 Frederic Weisbecker
2012-10-25 17:48 ` [PATCH 3/5] kvm: Directly account vtime to system on guest switch Frederic Weisbecker
2012-10-26 13:55   ` Frederic Weisbecker

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=5088EF85.4080002@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=agraf@suse.de \
    --cc=avi@redhat.com \
    --cc=benh@kernel.crashing.org \
    --cc=cornelia.huck@de.ibm.com \
    --cc=fenghua.yu@intel.com \
    --cc=fweisbec@gmail.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=joerg.roedel@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=paul.gortmaker@windriver.com \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=xiantao.zhang@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.