Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp690446ybt; Wed, 1 Jul 2020 07:53:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwv5rKzN3JQHiQWH1j1b34fm7MMxgvsYuINmGI4J1X4H1c1G+AmY3sRtPezYmCdDGB0t3v+ X-Received: by 2002:aa7:ca05:: with SMTP id y5mr2314371eds.204.1593615181301; Wed, 01 Jul 2020 07:53:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593615181; cv=none; d=google.com; s=arc-20160816; b=XDzsPQPdt6SW9JfeXe4JCDEMdSWUN13HiHDYgEyXrKp6zWhAWpBSev/3LbD6CGy0tc Q1PQeQltePVMFCBNZhqTFILU0FIkehu/4V2jYuLrXPOgHNhMf0kDrKVEW+/WwYyrNgHj 2tpa3CR+Euhcxkit/Xa6ePzpQvIHJGYMk56E6uGa9tS+URfUUw1YRvFO9tFw3+5/Dwtw zCgRbB+kCgrJ09Dn9DAAbEj+kbH0LKBiAV7X94hUq5o0Zo/kBBBtWWR2P9FK8YvUdWNG MNV+HxcwD5iN7BS6qz55V2Fcn1y8AAEGzJ1K0328dI4t2gajTGQ/Gb2hkt/i27SGCbJV +3wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=VfENiHNRnwNDgfhjH2onCnBOkQjCEWTV+c8v5VnSwKY=; b=z4p1ELFSbXZM8PdH/xpGgECOBnRrb+q2x9RS1+bEBo5cWAwFMhDVXf0pnZyO8OyXZ/ ESQzC5LWdQLh2EjKLISO+YguTnlc2aWYktlVhBDD2CCkg+Zr0U7iIcJCbAnprYmhl+ju qLRqiG3+gCVEtEZ5hkqkct1nPNVka8Ob/cqgqC2Wtk87V7WQXIFs3F00UXjgCtAJXsDz RbV/c+E470H8Rjgthw+fVDnE113ulVFvuI5CLsp7XnJMaooxqrmBEj+f57OlFqaIc9sp Mv8rQFTn6Z9Mx977ZBvFCaGmg973l79JeZohi2vaIqZsod3TR6UGrED+9MAjVOn5ERS/ NwUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VAXJoyh3; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b4si4074368edk.454.2020.07.01.07.52.37; Wed, 01 Jul 2020 07:53:01 -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=@redhat.com header.s=mimecast20190719 header.b=VAXJoyh3; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731622AbgGAOt5 (ORCPT + 99 others); Wed, 1 Jul 2020 10:49:57 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:48115 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731039AbgGAOt5 (ORCPT ); Wed, 1 Jul 2020 10:49:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593614995; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=VfENiHNRnwNDgfhjH2onCnBOkQjCEWTV+c8v5VnSwKY=; b=VAXJoyh3HUqwMTqJTzlH/sK6sg6JQwIeW7/UjkTdYY4vnByGAcSMw+BMMCHrOJtHOyjW+N 2Xoe8myinWbIOMTImY11pPjm7gROUVl/vDBQCqD0PQVkNsw8TcKUufSdzGsqmaSrXyBWhk PMUw646pG+kw4NB0XgXMWw5zjKFq/y4= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-418-9eIput8GOCWexlF-w2gYNg-1; Wed, 01 Jul 2020 10:49:53 -0400 X-MC-Unique: 9eIput8GOCWexlF-w2gYNg-1 Received: by mail-ej1-f71.google.com with SMTP id g6so15712301ejo.18 for ; Wed, 01 Jul 2020 07:49:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=VfENiHNRnwNDgfhjH2onCnBOkQjCEWTV+c8v5VnSwKY=; b=npvo35BgpSTPCfm6Y12/Br967j2BU63nTqmN0cMVFKA2730Z955e25Wis7VOY4oz93 WHhE8rYLg7qkMB5MOKAJD8Z6Gybeul9AbxSSZhgPZUkFk9nCNyrquzLBbV7tFpm/ix2h ngsydPB/i3LjC6lFemLpHGkmVhrlO5eBk133DFQoxcUDs47vhwIC30CKuc2Nb00mB4yT YA0BePQuKXnZmv+Zf7hYr79iCCBEwBRpuu1zFXgcO9vZGn9DyJpcp7mdDLuKFWPzDSx/ zrus8QgWafuOfBIE+lYbF0BqVG8aB0Hvn+fuRkMHOHcHs61n0JA9bbEXQkztxYPLavXP McVg== X-Gm-Message-State: AOAM530N7XTqpXuoxJdzPgmA0EL7FNKzygICzAVTEDmMzR/4vzSFdPnJ yBJpmAMBWa4jaGqHPTXbiJqPC8ag7eyxSij7vNJ/blhFhH41eucGwjtjUy8ucJtc4IaHpdVd4Tn YBWR9jCK5ZCXASIUw/u1cT0Zh X-Received: by 2002:a17:906:4f87:: with SMTP id o7mr22886626eju.233.1593614991816; Wed, 01 Jul 2020 07:49:51 -0700 (PDT) X-Received: by 2002:a17:906:4f87:: with SMTP id o7mr22886610eju.233.1593614991615; Wed, 01 Jul 2020 07:49:51 -0700 (PDT) Received: from vitty.brq.redhat.com (g-server-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id z25sm4831346ejd.38.2020.07.01.07.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 07:49:50 -0700 (PDT) From: Vitaly Kuznetsov To: Xiaoyao Li , Chenyi Qiang Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , Sean Christopherson , Wanpeng Li , Jim Mattson , Joerg Roedel Subject: Re: [RFC 2/2] KVM: VMX: Enable bus lock VM exit In-Reply-To: References: <20200628085341.5107-1-chenyi.qiang@intel.com> <20200628085341.5107-3-chenyi.qiang@intel.com> <878sg3bo8b.fsf@vitty.brq.redhat.com> <0159554d-82d5-b388-d289-a5375ca91323@intel.com> <87366bbe1y.fsf@vitty.brq.redhat.com> Date: Wed, 01 Jul 2020 16:49:49 +0200 Message-ID: <87zh8j9to2.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Xiaoyao Li writes: > On 7/1/2020 8:44 PM, Vitaly Kuznetsov wrote: >> Xiaoyao Li writes: >> >>> On 7/1/2020 5:04 PM, Vitaly Kuznetsov wrote: >>>> Chenyi Qiang writes: >>> [...] >>>>> static const int kvm_vmx_max_exit_handlers = >>>>> @@ -6830,6 +6838,13 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu) >>>>> if (unlikely(vmx->exit_reason.failed_vmentry)) >>>>> return EXIT_FASTPATH_NONE; >>>>> >>>>> + /* >>>>> + * check the exit_reason to see if there is a bus lock >>>>> + * happened in guest. >>>>> + */ >>>>> + if (vmx->exit_reason.bus_lock_detected) >>>>> + handle_bus_lock(vcpu); >>>> >>>> In case the ultimate goal is to have an exit to userspace on bus lock, >>> >>> I don't think we will need an exit to userspace on bus lock. See below. >>> >>>> the two ways to reach handle_bus_lock() are very different: in case >>>> we're handling EXIT_REASON_BUS_LOCK we can easily drop to userspace by >>>> returning 0 but what are we going to do in case of >>>> exit_reason.bus_lock_detected? The 'higher priority VM exit' may require >>>> exit to userspace too. So what's the plan? Maybe we can ignore the case >>>> when we're exiting to userspace for some other reason as this is slow >>>> already and force the exit otherwise? >>> >>>> And should we actually introduce >>>> the KVM_EXIT_BUS_LOCK and a capability to enable it here? >>>> >>> >>> Introducing KVM_EXIT_BUS_LOCK maybe help nothing. No matter >>> EXIT_REASON_BUS_LOCK or exit_reason.bus_lock_detected, the bus lock has >>> already happened. Exit to userspace cannot prevent bus lock, so what >>> userspace can do is recording and counting as what this patch does in >>> vcpu->stat.bus_locks. >> >> Exiting to userspace would allow to implement custom 'throttling' >> policies to mitigate the 'noisy neighbour' problem. The simplest would >> be to just inject some sleep time. >> > > So you want an exit to userspace for every bus lock and leave it all to > userspace. Yes, it's doable. > In some cases we may not even want to have a VM exit: think e.g. real-time/partitioning case when even in case of bus lock we may not want to add additional latency just to count such events. I'd suggest we make the new capability tri-state: - disabled (no vmexit, default) - stats only (what this patch does) - userspace exit But maybe this is an overkill, I'd like to hear what others think. > As you said, the exit_reason.bus_lock_detected case is the tricky one. > We cannot do the similar to extend vcpu->run->exit_reason, this breaks > ABI. Maybe we can extend the vcpu->run->flags to indicate bus lock > detected for the other exit reason? This is likely the easiest solution. -- Vitaly