Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3550100pxb; Wed, 14 Apr 2021 08:03:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7nUTrLc4AS5iPlITqC0jwomhD4Vkd5PguW0iulzsepZ5pul7PCHjcvFuNiuISTn2GRYwA X-Received: by 2002:a17:906:d81:: with SMTP id m1mr8088271eji.105.1618412582685; Wed, 14 Apr 2021 08:03:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618412582; cv=none; d=google.com; s=arc-20160816; b=qFldxN0cMzarc/+OAZAzei9bn1TcyVfgEbOCHTCbIg4udjzdCY4sefKA00RqzgAHKE sXHrnMWdhElrbPLlcn5A94z3y7qXUU/kVTSM1FZvAZtuEFdZgpMs4Nj4uokIHF9V/4Mf Uh9gQfkzQDZXdl9Qgkz2boM0fP+Uw/3x07oPyfFmrgKPRbqhOjDEWYr4C27J2artNB5M /SynMcjeSObcRxdN9HZpy050HGsOxGZbLNQUWN5v9VwtxZbK8MedyDjhfHAQNfEZVXQi nQ5i6So92r0z3x8bZskGlWw9FvEh+cfatbtXjB1fUVJtgm52+PxixzX6+pWiuizq5ulk 9kvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=LvbZE0bzJgrJNxl8GOScMXc9Qv71H83ehJgok/+nI18=; b=rXqZuQoUKAFKkAVp6MZnPQS3/s7uYEHYR50oprLpiGC2kmJLvKdJuRTPMWqLE3H3R4 YWDc2DNryvgkCzxTqXgw6BURQ9QKPrnPXN2ZMJZdgUlaAU5sfGggotTzfu0Z901BgQVY HRAZEievs2Xhp4P38+MxWKjIWAddGfj7FkLg254el9bjnV9UpMaRcFhonUziTS9xlcxD JzrVB6tDKF7TB79v3K3M+1/mjRy0fnqFz2+hrLS7czqodQ97rYuqdjF9mqn2p3TxqxXl NZDE2Kctb7rsMNUmozX6lNazVevOw3ea2meARFDNMGQFE1Z6Khv3UW2XTFxZePb7cyFO vAlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZccMPBQp; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dv21si5053074ejb.434.2021.04.14.08.02.38; Wed, 14 Apr 2021 08:03:02 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=ZccMPBQp; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231749AbhDNJgr (ORCPT + 99 others); Wed, 14 Apr 2021 05:36:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229914AbhDNJgr (ORCPT ); Wed, 14 Apr 2021 05:36:47 -0400 Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D0E9C061574; Wed, 14 Apr 2021 02:36:26 -0700 (PDT) Received: by mail-ot1-x32c.google.com with SMTP id i16-20020a9d68d00000b0290286edfdfe9eso8159022oto.3; Wed, 14 Apr 2021 02:36:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LvbZE0bzJgrJNxl8GOScMXc9Qv71H83ehJgok/+nI18=; b=ZccMPBQpA/Tr1GdFRu5OeEnZtZAquSH6eVDJrQ7DgAUzXxScqEoMmprhaKWWnZZLd+ kSZ1Zzj8EV07gP5pRwhXrt2ty6rNIjSb7C2Jm3f0uxROrwj+iNevPSvcyS8zCV6mNOQB 8Zlt2Ut5MPYj7fEF6eYDfNMOjQgaVu+GVqJkd8v3HektiFEb1GzjuzLqBA3WV/HGOpK1 JdVN8Q6sLHswNma4VUoBRZnZ5bsdMSQxtqvlEB+gSaF+8fuRi6rrzAzKSPzzN5jKsreH o0difFaPjNG4Rc2VtaY5+ZmhXQ0spDVkZjL8Nj1RqSRg7H7sYOchnJne9VdgmMAZTTbv kA6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LvbZE0bzJgrJNxl8GOScMXc9Qv71H83ehJgok/+nI18=; b=oih2VjPHBvt89xwvdR+6b2dcK8PXmf3CHh8v8z46N0+HvYPWxNSP7GolirkcTvTzbm xgYuNb4y8YItqI0NzQnKRrTOi+vhW32nhuVNLRq7axpEl5XZczaOoPRIj6fFK3Tc+Y2b 9+HhT7bFwlLKPmnbPlA7M9yGcv8NqgQkMja/J9rT/qwajqjDYYW1/efUmyNiFZ9te6re QP9Fd2Pe/0GXWJbOW3DxQPjuNzLv0NCr86cWoPB9qotuJuxZPjbUllZBgmQyJutI/Tmj 7jGRB+9fS1PSBe26MV4yPeTCugJMX67M/rmaDLb6UhVnWPbVTacd9WWFGPssv90Qp5G7 NLYA== X-Gm-Message-State: AOAM532dR2OkNZU2z8hIW6QKXVGRzNOAShOkvw0lqxYGQ06WJBOQIMAl rkppBDrhrsPQYmyRKSO49cnnp4PVCcFrh2+PIiQZROsq3UI= X-Received: by 2002:a9d:66c9:: with SMTP id t9mr2617447otm.56.1618392985669; Wed, 14 Apr 2021 02:36:25 -0700 (PDT) MIME-Version: 1.0 References: <1618298169-3831-1-git-send-email-wanpengli@tencent.com> In-Reply-To: From: Wanpeng Li Date: Wed, 14 Apr 2021 17:36:14 +0800 Message-ID: Subject: Re: [PATCH v2 0/3] KVM: Properly account for guest CPU time To: Sean Christopherson Cc: LKML , kvm , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Michael Tokarev Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 14 Apr 2021 at 01:25, Sean Christopherson wrote: > > On Tue, Apr 13, 2021, Wanpeng Li wrote: > > The bugzilla https://bugzilla.kernel.org/show_bug.cgi?id=209831 > > reported that the guest time remains 0 when running a while true > > loop in the guest. > > > > The commit 87fa7f3e98a131 ("x86/kvm: Move context tracking where it > > belongs") moves guest_exit_irqoff() close to vmexit breaks the > > tick-based time accouting when the ticks that happen after IRQs are > > disabled are incorrectly accounted to the host/system time. This is > > because we exit the guest state too early. > > > > This patchset splits both context tracking logic and the time accounting > > logic from guest_enter/exit_irqoff(), keep context tracking around the > > actual vmentry/exit code, have the virt time specific helpers which > > can be placed at the proper spots in kvm. In addition, it will not > > break the world outside of x86. > > IMO, this is going in the wrong direction. Rather than separate context tracking, > vtime accounting, and KVM logic, this further intertwines the three. E.g. the > context tracking code has even more vtime accounting NATIVE vs. GEN vs. TICK > logic baked into it. > > Rather than smush everything into context_tracking.h, I think we can cleanly > split the context tracking and vtime accounting code into separate pieces, which > will in turn allow moving the wrapping logic to linux/kvm_host.h. Once that is > done, splitting the context tracking and time accounting logic for KVM x86 > becomes a KVM detail as opposed to requiring dedicated logic in the context > tracking code. > > I have untested code that compiles on x86, I'll send an RFC shortly. We need an easy to backport fix and then we might have some further cleanups on top. Wanpeng