Received: by 10.213.65.68 with SMTP id h4csp989575imn; Wed, 14 Mar 2018 06:28:24 -0700 (PDT) X-Google-Smtp-Source: AG47ELt82Q4qzaLOUUXJkQW+NjEenofSG9KrIyRnGvssk4GQsDCe8KeUPRMRzHTljJj/9Mzuaa8o X-Received: by 10.101.96.141 with SMTP id t13mr3774317pgu.427.1521034103935; Wed, 14 Mar 2018 06:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521034103; cv=none; d=google.com; s=arc-20160816; b=MIYh8Du0nP+asaZi+lqs8kJj1QibHR07Ck1ozA3V07PSxwpo6WbMflPIhmZh6PR1J4 9HCcrNmr55SPHqY9isJ+0H99QTIT3x4ZPLULd3VC8+4n73oMkSqbbxZSgaAKeYhXe6TO O4rchZT7eAnFGxTxNWgEyLGYI879TZMgZGrD7BLTk//74k30G99CaWiKUIeeRqPA5Kgy ljKRYsL0hVoyp7JgmauIRJvfnLp+w7IGo5iqRiV2zZRBfKeyETgdJBtp3/YXglBWtKnI J4U3sqc2CPXw1HSLIwBTSLMQQXuUyVAKwgbHNBfYkP1u1sd8Kfydu98gObq+xKJKRIur o4Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=f7ijGwPwzMqT9yfe9gcWyQStU4egqhu3qQa0R1xAexE=; b=wRJloIA3xHc00wy+kpcHBRhVepGygS4RAszsXsIcdSTiM4LkStF7D33AiRd/x5U2TV 0X4l8RaGz2rw3xEHmRNKMsv07+K+w5T6hn3FREkY8WEhAP/7mDrf1vHoFZ4VpPKXFx18 JGEHf6zlfmg9McXdF8x7+yKK5R+gZz8hGgnNgo2YWEE1ZO2WSMX9LmFTXy5XRgIhtqhY C+xXMZ5iXc1iiZHmHThlZJqhRzM3PsV57kSJgqcuP/fvZ74nGM7qb7sd/41ng6IOgRz7 m3yxehMqauVpvfgoaFctPm4yVVVdhfjsyZ/ViCFXAH5sBTXSDL3ArpJBUlbiiRjC3vXo MNHA== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v3si1862769pgq.608.2018.03.14.06.28.08; Wed, 14 Mar 2018 06:28:23 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752011AbeCNN1E (ORCPT + 99 others); Wed, 14 Mar 2018 09:27:04 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34952 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751559AbeCNN1C (ORCPT ); Wed, 14 Mar 2018 09:27:02 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 73E9C42F0B8E; Wed, 14 Mar 2018 13:27:01 +0000 (UTC) Received: from flask (unknown [10.40.205.109]) by smtp.corp.redhat.com (Postfix) with SMTP id 94EC72166BAE; Wed, 14 Mar 2018 13:26:57 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Wed, 14 Mar 2018 14:26:14 +0100 Date: Wed, 14 Mar 2018 14:26:14 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: "Moger, Babu" Cc: "joro@8bytes.org" , "tglx@linutronix.de" , "mingo@redhat.com" , "hpa@zytor.com" , "x86@kernel.org" , "pbonzini@redhat.com" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [RFC 3/3] arch/x86/kvm: SVM: Introduce pause loop exit logic in SVM Message-ID: <20180314132613.GB28943@flask> References: <1520007456-85293-1-git-send-email-babu.moger@amd.com> <1520007456-85293-4-git-send-email-babu.moger@amd.com> <20180309181233.GO12290@flask> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 14 Mar 2018 13:27:01 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 14 Mar 2018 13:27:01 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'rkrcmar@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2018-03-10 05:07+0000, Moger, Babu: > Radim, > Thanks for the comments. Taken care of most of the comments. > I have few questions/comments. Please see inline. > > > -----Original Message----- > > From: Radim Krčmář > > Sent: Friday, March 9, 2018 12:13 PM > > To: Moger, Babu > > Cc: joro@8bytes.org; tglx@linutronix.de; mingo@redhat.com; > > hpa@zytor.com; x86@kernel.org; pbonzini@redhat.com; > > kvm@vger.kernel.org; linux-kernel@vger.kernel.org > > Subject: Re: [RFC 3/3] arch/x86/kvm: SVM: Introduce pause loop exit logic in > > SVM > > > > 2018-03-02 11:17-0500, Babu Moger: > > > Bring the PLE(pause loop exit) logic to AMD svm driver. > > > We have noticed it help in situations where numerous pauses are > > generated > > > due to spinlock or other scenarios. Tested it with idle=poll and noticed > > > pause interceptions go down considerably. > > > > > > Signed-off-by: Babu Moger > > > --- > > > @@ -1046,6 +1095,58 @@ static int avic_ga_log_notifier(u32 ga_tag) > > > return 0; > > > } > > > > > > +static void grow_ple_window(struct kvm_vcpu *vcpu) > > > +{ > > > + struct vcpu_svm *svm = to_svm(vcpu); > > > + struct vmcb_control_area *control = &svm->vmcb->control; > > > + int old = control->pause_filter_count; > > > + > > > + control->pause_filter_count = __grow_ple_window(old, > > > + pause_filter_count, > > > + ple_window_grow, > > > + > > ple_window_actual_max); > > > + > > > + if (control->pause_filter_count != old) > > > + mark_dirty(svm->vmcb, VMCB_INTERCEPTS); > > > + > > > + trace_kvm_ple_window_grow(vcpu->vcpu_id, > > > + control->pause_filter_count, old); > > > > Please move the tracing into __shrink_ple_window to share the code. > > This probably belongs to patch [2/3]. > > I will have to pass vcpu_id, and have to make few changes to display old and new values. > I am afraid it might add few more extra instructions. Right, vcpu_id isn't available in that function. Keeping it like this is ok. > > > > > +/* > > > + * ple_window_actual_max is computed to be one grow_ple_window() > > below > > > + * ple_window_max. (See __grow_ple_window for the reason.) > > > + * This prevents overflows, because ple_window_max is int. > > > + * ple_window_max effectively rounded down to a multiple of > > ple_window_grow in > > > + * this process. > > > + * ple_window_max is also prevented from setting control- > > >pause_filter_count < > > > + * pause_filter_count. > > > + */ > > > +static void update_ple_window_actual_max(void) > > > +{ > > > + ple_window_actual_max = > > > + __shrink_ple_window(max(ple_window_max, > > pause_filter_count), > > > > (I have no idea what I was thinking when I wrote that for VMX. :[ > > I'll write a patch to get rid of ple_window_actual_max, because its > > benefits are really minuscule and the logic is complicated.) > > If you are thinking of just straight forward removal, I can take care of it. And tweaking the overflow handling to account for that. Go ahead if you'd like to. > > > > > + pause_filter_count, > > > + ple_window_grow, SHRT_MIN); > > > +} > > > static __init int svm_hardware_setup(void) > > > { > > > int cpu; > > > @@ -1309,7 +1412,11 @@ static void init_vmcb(struct vcpu_svm *svm) > > > svm->vcpu.arch.hflags = 0; > > > > > > if (boot_cpu_has(X86_FEATURE_PAUSEFILTER)) { > > > - control->pause_filter_count = 3000; > > > + control->pause_filter_count = pause_filter_count; > > > + if (boot_cpu_has(X86_FEATURE_PFTHRESHOLD)) > > > + control->pause_filter_thresh = pause_filter_thresh; > > > + else > > > + pause_filter_thresh = 0; > > > > Please move this to hardware_setup and also clear pause_filter_count if > > Moving this to hardware_setup will be a problem. We don't have access to svm data structure in hardware_setup. I mean just the pause_filter_thresh = 0 and pause_filter_count = 0 logic based on boot_cpu_has (it's weird if the user-visible parameters are corrected after starting a VM); VMCB configuration stays, thanks.