From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753445AbcCNQz5 (ORCPT ); Mon, 14 Mar 2016 12:55:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48410 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752900AbcCNQzy (ORCPT ); Mon, 14 Mar 2016 12:55:54 -0400 Date: Mon, 14 Mar 2016 17:54:22 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Suravee Suthikulpanit Cc: pbonzini@redhat.com, joro@8bytes.org, bp@alien8.de, gleb@kernel.org, alex.williamson@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, wei@redhat.com, sherry.hurwitz@amd.com Subject: Re: [PART1 RFC v2 10/10] svm: Manage vcpu load/unload when enable AVIC Message-ID: <20160314165422.GA10013@potion.brq.redhat.com> References: <1457124368-2025-1-git-send-email-Suravee.Suthikulpanit@amd.com> <1457124368-2025-11-git-send-email-Suravee.Suthikulpanit@amd.com> <20160309214629.GE19459@potion.brq.redhat.com> <20160310140141.GA23501@potion.brq.redhat.com> <56E6A74D.8090807@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <56E6A74D.8090807@amd.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 14 Mar 2016 16:54:27 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2016-03-14 18:58+0700, Suravee Suthikulpanit: > On 03/10/2016 09:01 PM, Radim Krčmář wrote: >>Well, we haven't reached an agreement on is_running yet. The situation: >>if we don't unset vcpu1.is_running when vcpu1 is scheduled out and vcpu2 >>gets scheduled on vcpu1's physical core, then vcpu2 would receive a >>doorbell intended to vcpu1. > > That's why, in V2, I added the logic to check if the is_running bit is set > for the current vcpu (e.g. vcpu1) when unloaded, then restore the bit during > loading later of if it was set during previous unloaded. This way, when we > load the new vcpu (e.g. vcpu2), the is_running will be set as it was before > unloading. Yes, that's a good solution and I'm leaning towards it. The downside is that IPIs from other VCPUs exit, even though KVM can't do anything, because the vCPU is already going to run as soon as it can. Keeping is_running set during unload would prevent meaningless exits. >>We'd like to keep is_running set when there is no reason to vmexit, but >>not if a guest can negatively affect other guests. > > Not sure how this can affect other guests? If is_running is set, then the doorbell is sent to a physical core, so any running task/vCPU will receive it. This is safe, but a difference can be seen in performance. >>How does receiving a stray doorbell affect the performance? > > As far as I know, the doorbell only affects the CPU during vmrun. Yeah, I guess that receiving a doorbell outside of vmrun has no overhead. > Once > received, it will check the IRR in vAPIC backing page. So, I think if IRR > bit is not set, the affect should be rather minimal. Even empty IRR still needs to be rescanned every time a doorbell arrives, which might affect the execution pipeline. After re-reading all relevant quotes, I think that hardware wasn't designed with this use in mind, so it's safer to assume an adverse effect and go with solution we have now. (It'd be hard to measure anyway.) Sorry for the tangent.