Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933591Ab2JYHvn (ORCPT ); Thu, 25 Oct 2012 03:51:43 -0400 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:54220 "EHLO e06smtp15.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756431Ab2JYHvk (ORCPT ); Thu, 25 Oct 2012 03:51:40 -0400 Message-ID: <5088EF85.4080002@de.ibm.com> Date: Thu, 25 Oct 2012 09:51:33 +0200 From: Christian Borntraeger User-Agent: Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 MIME-Version: 1.0 To: Frederic Weisbecker CC: LKML , Tony Luck , Fenghua Yu , Benjamin Herrenschmidt , Paul Mackerras , Heiko Carstens , Martin Schwidefsky , Avi Kivity , Marcelo Tosatti , Joerg Roedel , Alexander Graf , Xiantao Zhang , Cornelia Huck , Peter Zijlstra , Ingo Molnar , Thomas Gleixner , Steven Rostedt , Paul Gortmaker Subject: Re: [PATCH 3/5] kvm: Directly account vtime to system on guest switch References: <1351126313-17804-1-git-send-email-fweisbec@gmail.com> <1351126313-17804-4-git-send-email-fweisbec@gmail.com> In-Reply-To: <1351126313-17804-4-git-send-email-fweisbec@gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit x-cbid: 12102507-0342-0000-0000-00000332EEBE Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1474 Lines: 40 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(); [...] -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/