Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1831048ybn; Thu, 26 Sep 2019 02:54:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqz1lSg6r55UaHkd4qqoIys+Pc4+I67WsBQla1f2CgAelAvIttnUX0uEtqCC9sbnW23k3yBy X-Received: by 2002:a17:906:1c05:: with SMTP id k5mr2273614ejg.286.1569491691476; Thu, 26 Sep 2019 02:54:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569491691; cv=none; d=google.com; s=arc-20160816; b=xQDiH4j1t5mbN89MxQOjGDv8+OX528vsGWWzWhKZRSVbf5T4+idUIiO6hW8Ab7ChAm JiDt5QpSXxPEVp4rRFO7WYvmhbrs/1RtuSSayOpz+8CYdUmVo9/QSu3xTGBe1X2AFwMp cT/pKoVXml3XQpNA+Disn0xEHKH7/7MNayddGmhKFCFD1BZeUmR8Dg/Iq578woKuv+4Z AgIBNlV8q4HP+3UIPdMCgxuDsi1oC47rtKNGujgFNA7H+GtZVRrn3WRWouJ5dtxx3jLY 2E58BYc3ggYcxsGT1APYrLnxpFtoBs6PYsqMQkXsnxY7aHBsJs3gNx7zA2Nmjg5tVqO9 5NOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=oCxDn+oFWrwcU4T30RHZfDZEZPb8x7j3q5fGyPbnwl0=; b=KCYWIM9GyZyrr9aOeT1MiGUnLG+BJpDaevy9Q9mHJ9xELDGGhRk8UDC21BJYNc6y5e kg/zasYsyNS7WDSjBZOBTBhEnpuc12wYpNPOpLlA5vD/s9VX/Rf2Z+AuDMCXB98o0h8r M1HvuPQ31y2kk0DYSRq0lVvbDtDtSRRz6L8cPSUjivWg5JNIaMCHqioycJ6NyampP5tc icjUyEj5zj7Zl+teTvlf7NxT0PQPKvmilLcoGyegc/HRPIadgAOpqWjVwqrWKC17y5O3 jh6R6uYXmkNJxb26nTDabjY6qJc3FBnZOl3FpMfpnSTitBI33P49+t6nlHQKmncwJv9l SDAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q28si947729eda.322.2019.09.26.02.54.28; Thu, 26 Sep 2019 02:54:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732860AbfIYT3u (ORCPT + 99 others); Wed, 25 Sep 2019 15:29:50 -0400 Received: from mga02.intel.com ([134.134.136.20]:10678 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729004AbfIYT3u (ORCPT ); Wed, 25 Sep 2019 15:29:50 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Sep 2019 12:29:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,549,1559545200"; d="scan'208";a="196094863" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.41]) by FMSMGA003.fm.intel.com with ESMTP; 25 Sep 2019 12:29:49 -0700 Date: Wed, 25 Sep 2019 12:29:49 -0700 From: Sean Christopherson To: Wanpeng Li Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel Subject: Re: [PATCH] KVM: LAPIC: Loose fluctuation filter for auto tune lapic_timer_advance_ns Message-ID: <20190925192949.GM31852@linux.intel.com> References: <1569390424-22031-1-git-send-email-wanpengli@tencent.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1569390424-22031-1-git-send-email-wanpengli@tencent.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 25, 2019 at 01:47:04PM +0800, Wanpeng Li wrote: > From: Wanpeng Li > > 5000 guest cycles delta is easy to encounter on desktop, per-vCPU > lapic_timer_advance_ns always keeps at 1000ns initial value, lets > loose fluctuation filter a bit to make auto tune can make some > progress. > > Signed-off-by: Wanpeng Li > --- > arch/x86/kvm/lapic.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > index 3a3a685..258407e 100644 > --- a/arch/x86/kvm/lapic.c > +++ b/arch/x86/kvm/lapic.c > @@ -67,7 +67,7 @@ > > static bool lapic_timer_advance_dynamic __read_mostly; > #define LAPIC_TIMER_ADVANCE_ADJUST_MIN 100 > -#define LAPIC_TIMER_ADVANCE_ADJUST_MAX 5000 > +#define LAPIC_TIMER_ADVANCE_ADJUST_MAX 10000 > #define LAPIC_TIMER_ADVANCE_ADJUST_INIT 1000 > /* step-by-step approximation to mitigate fluctuation */ > #define LAPIC_TIMER_ADVANCE_ADJUST_STEP 8 > @@ -1504,7 +1504,7 @@ static inline void adjust_lapic_timer_advance(struct kvm_vcpu *vcpu, > timer_advance_ns += ns/LAPIC_TIMER_ADVANCE_ADJUST_STEP; > } > > - if (unlikely(timer_advance_ns > LAPIC_TIMER_ADVANCE_ADJUST_MAX)) > + if (unlikely(timer_advance_ns > LAPIC_TIMER_ADVANCE_ADJUST_MAX/2)) Doh, missed that these are two different time domains in the original review, i.e. ns vs. cycles. We should use separate defines for the filter since that check is done in cycles. Not sure what names to use to keep things somewhat clear. Maybe s/ADJUST/EXPIRE for the cycles, and s/ADJUST/NS for the ns ones? E.g.: #define LAPIC_TIMER_ADVANCE_EXPIRE_MIN 100 #define LAPIC_TIMER_ADVANCE_EXPIRE_MAX 10000 #define LAPIC_TIMER_ADVANCE_NS_MAX 5000 #define LAPIC_TIMER_ADVANCE_NS_INIT 1000 > timer_advance_ns = LAPIC_TIMER_ADVANCE_ADJUST_INIT; > apic->lapic_timer.timer_advance_ns = timer_advance_ns; > } > -- > 2.7.4 >