Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp980833pxu; Wed, 6 Jan 2021 09:13:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFDWwWqoLGmwQt7V0ys6ufSq1QBvVHtyp87G7PlftdUqSNA0J8dD/DRiaSXg/zGSJxPPj2 X-Received: by 2002:a50:becf:: with SMTP id e15mr4822652edk.138.1609953232360; Wed, 06 Jan 2021 09:13:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609953232; cv=none; d=google.com; s=arc-20160816; b=fGlzJge4wH/e8fONs6uk7vEN+vBfoy9N+66Q0NabyDKjAZIfTU9xjcTIpxaYeRRDIi O0ozJFATlQkRaZQAW85txRBq3vqN6u2MppjftWWlwyWETFYhpQs550uWNsfK2i9FEp9z HocXjLx4kIePF4GoVMjnzYxT5vByDkjmNHN5b5VK/YokJcMMhcBcmEYvP4EPFgBrvY4o mmlEEi52fV3F+LPNkyu5/rDq6maVzgTDlWdhrTAXgyfypS81SLRGrCjia0b2oFJn1JZd 5LEhJU30Lmj3cL3SRvhc6TXR9neytTz2lUVxdmhoUdOmGFktvJdZcIpHsGxtPjTtvsU/ 244w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YC42Sep418k/6/yhd2iwtUsqtdYGxSoNNfQdhxN7DsU=; b=SDmA1Xz+3SoLeftKQ3Gbv9Hih5rI/sYGPqL+v2J62O2jT8+OQVc/RV316BwOAUQcuj tinstlSTNAyizIc3rL5DnosqkqwWoK14TRW1ka4hC8jghOPjvLfQw7rKXm2RPsYvXxIR qW/ogqPCRrsakuuJ2B/edfE7S4ndkNEwE5XQLsgaElqvp/xSn+Hbqhjb45JSEFFZSVux 0qjVY9t6qA/F1LFMrdtSPsuy4hAIIm11ZJmuwd9JSp8WDdA2PvQ1PDqPytaTZIF4Qd29 0uiqtkRQteYOb2+3s4JCSq20kEXoUCXeYs4ib2MkjQG6osrj/bQ5bchf3ZJUWd+feYlp dAxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=sAWOvCAm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bt28si1130834edb.269.2021.01.06.09.13.28; Wed, 06 Jan 2021 09:13:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=sAWOvCAm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727628AbhAFRMk (ORCPT + 99 others); Wed, 6 Jan 2021 12:12:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726791AbhAFRMj (ORCPT ); Wed, 6 Jan 2021 12:12:39 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5203C06134D for ; Wed, 6 Jan 2021 09:11:59 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id m5so1915585pjv.5 for ; Wed, 06 Jan 2021 09:11:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=YC42Sep418k/6/yhd2iwtUsqtdYGxSoNNfQdhxN7DsU=; b=sAWOvCAm0vRAMKx0jb0ZbDavXsQoFVGkl/YJ0s1P2DN7JAzpDY477tQM+PneBUUDQr W2l0yl2/2OrrLHCT+qj62sNl/ZbbESE8l+x7l3xbQJ0+Tb/CCiiLIrsu0mAYtScyepxz RTCMWoVfYHBpfaRuZ/DPPoK1QsdMPGs+v2UPhzVFi6AO8NqQVWaZY9Fo/Z09n12hp1i7 On3HpQ1Gfz8fLGfdrkctvgJ+5i0jmprJloOk+t75xkrQK10UxLxHv25UBUWcwiGphXcv YeFl9yJOjforR4vlVuxlgggVeeA5SE6xy6WqAd9tYaRxJScR0MXBagFWh8uqL2ym+qre pEFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=YC42Sep418k/6/yhd2iwtUsqtdYGxSoNNfQdhxN7DsU=; b=DNd3L1L1K/t04zcHz3unJrEN8qNLMLuIQ7Jtr4eaKVjq+HuPPvNFPFciyX2Dzai+4S 8B0OcxapOovO7Y6kGo+j7xUiB6lJcrwhSp7vFNoPl+vYYKU0p2rKf3ANC4Y1t2Z4VH1e kdD7S7eSPnJTfwIEYvNS8va/gGUGX41jCHN3dMTTw5Psw31md+SeYl8ww8CxU5/iF2KX 33PSOYcw2n154i/etnpmR6qqHr/wz8jFJT9k1QY91WR9umMpNEoEhGNTg1myMMNKOuY1 jagQMR1DBI5/X4yr16AcgqOYlJiB7/mpTdvHlDVBtBvTOg5F8/rSGo58EMcYFUtqi33p /Acg== X-Gm-Message-State: AOAM53166G6eXXVUmKVeZ/do6te/6GNPsAXN8naiF2a5okYYvYKT1YQP ASmWw9XxrqR4m7OIFqG2AwYfOQ== X-Received: by 2002:a17:90a:193:: with SMTP id 19mr5152267pjc.45.1609953119065; Wed, 06 Jan 2021 09:11:59 -0800 (PST) Received: from google.com ([2620:15c:f:10:1ea0:b8ff:fe73:50f5]) by smtp.gmail.com with ESMTPSA id 84sm3224542pfy.9.2021.01.06.09.11.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 09:11:58 -0800 (PST) Date: Wed, 6 Jan 2021 09:11:52 -0800 From: Sean Christopherson To: Vitaly Kuznetsov Cc: Nitesh Narayan Lal , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, w90p710@gmail.com, pbonzini@redhat.com, Thomas Gleixner Subject: Re: [PATCH] Revert "KVM: x86: Unconditionally enable irqs in guest context" Message-ID: References: <20210105192844.296277-1-nitesh@redhat.com> <874kjuidgp.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <874kjuidgp.fsf@vitty.brq.redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 06, 2021, Vitaly Kuznetsov wrote: > Nitesh Narayan Lal writes: > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > > index 3f7c1fc7a3ce..3e17c9ffcad8 100644 > > --- a/arch/x86/kvm/x86.c > > +++ b/arch/x86/kvm/x86.c > > @@ -9023,18 +9023,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) > > > > kvm_x86_ops.handle_exit_irqoff(vcpu); > > > > - /* > > - * Consume any pending interrupts, including the possible source of > > - * VM-Exit on SVM > > I kind of liked this part of the comment, the new (old) one in > svm_handle_exit_irqoff() doesn't actually explain what's going on. > > > and any ticks that occur between VM-Exit and now. > > Looking back, I don't quite understand why we wanted to account ticks > between vmexit and exiting guest context as 'guest' in the first place; > to my understanging 'guest time' is time spent within VMX non-root > operation, the rest is KVM overhead (system). With tick-based accounting, if the tick IRQ is received after PF_VCPU is cleared then that tick will be accounted to the host/system. The motivation for opening an IRQ window after VM-Exit is to handle the case where the guest is constantly exiting for a different reason _just_ before the tick arrives, e.g. if the guest has its tick configured such that the guest and host ticks get synchronized in a bad way. This is a non-issue when using CONFIG_VIRT_CPU_ACCOUNTING_GEN=y, at least with a stable TSC, as the accounting happens during guest_exit_irqoff() itself. Accounting might be less-than-stellar if TSC is unstable, but I don't think it would be as binary of a failure as tick-based accounting. > It seems to match how the accounting is done nowadays after Tglx's > 87fa7f3e98a1 ("x86/kvm: Move context tracking where it belongs"). > > > - * An instruction is required after local_irq_enable() to fully unblock > > - * interrupts on processors that implement an interrupt shadow, the > > - * stat.exits increment will do nicely. > > - */ > > - kvm_before_interrupt(vcpu); > > - local_irq_enable(); > > ++vcpu->stat.exits; > > - local_irq_disable(); > > - kvm_after_interrupt(vcpu); > > > > if (lapic_in_kernel(vcpu)) { > > s64 delta = vcpu->arch.apic->lapic_timer.advance_expire_delta; > > FWIW, > > Reviewed-by: Vitaly Kuznetsov > > -- > Vitaly >