From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 619C6C04A6B for ; Wed, 8 May 2019 21:43:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 364842173B for ; Wed, 8 May 2019 21:43:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727041AbfEHVno (ORCPT ); Wed, 8 May 2019 17:43:44 -0400 Received: from mga02.intel.com ([134.134.136.20]:47687 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726506AbfEHVno (ORCPT ); Wed, 8 May 2019 17:43:44 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 May 2019 14:43:43 -0700 X-ExtLoop1: 1 Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.36]) by orsmga007.jf.intel.com with ESMTP; 08 May 2019 14:43:43 -0700 Date: Wed, 8 May 2019 14:43:43 -0700 From: Sean Christopherson To: Wanpeng Li Cc: Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , kvm , Liran Alon , Wanpeng Li Subject: Re: [PATCH v4 0/4] KVM: lapic: Fix a variety of timer adv issues Message-ID: <20190508214343.GF19656@linux.intel.com> References: <20190417171534.10385-1-sean.j.christopherson@intel.com> <20190430193102.GA4523@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Sun, May 05, 2019 at 08:43:24AM +0800, Wanpeng Li wrote: > On Wed, 1 May 2019 at 03:31, Sean Christopherson > wrote: > > > > On Sun, Apr 28, 2019 at 08:54:30AM +0800, Wanpeng Li wrote: > > > Hi Sean, > > > On Thu, 18 Apr 2019 at 01:18, Sean Christopherson > > > wrote: > > > > > > > > KVM's recently introduced adaptive tuning of lapic_timer_advance_ns has > > > > several critical flaws: > > > [.../...] > > > > > > > > - TSC scaling is done on a per-vCPU basis, while the advancement value > > > > is global. This issue is also present without adaptive tuning, but > > > > is now more pronounced. > > > > > > Did you test this against overcommit scenario? Your per-vCPU variable > > > can be a large number(yeah, below your 5000ns) when neighbour VMs on > > > the same host consume cpu heavily, however, kvm will wast a lot of > > > time to wait when the neighbour VMs are idle. My original patch > > > evaluate the conservative hypervisor overhead when the first VM is > > > deployed on the host. It doesn't matter whether or not the VMs on this > > > host alter their workload behaviors later. Unless you tune the > > > per-vCPU variable always, however, I think it will introduce more > > > overhead. So Liran's patch "Consider LAPIC TSC-Deadline Timer expired > > > if deadline too short" also can't depend on this. > > > > I didn't test it in overcommit scenarios. I wasn't aware of how the > > I think it should be considered. > > > automatic adjustments were being used in real deployments. > > > > The best option I can think of is to expose a vCPU's advance time to > > userspace (not sure what mechanism would be best). This would allow > > userspace to run a single vCPU VM with auto-tuning enabled, snapshot > > the final adjusted advancment, and then update KVM's parameter to set > > an explicit advancement and effectively disable auto-tuning. > > This step is too complex to deploy in real environment, the same as > w/o auto-tuning. My auto-tuning patch evaluates the conservative > hypervisor overhead when the first VM is deployed on the host, and > auto-tuning it only once for the whole machine. But even then the advancement could be corrupted or wildly inaccurate unless that first VM has a single vCPU. I thought of an idea that will hopefully fix the overcommit scenario and in general reduce the time spent auto-adjusting. Patch incoming...