Received: by 10.223.164.202 with SMTP id h10csp2563596wrb; Mon, 27 Nov 2017 20:07:04 -0800 (PST) X-Google-Smtp-Source: AGs4zMao3HMMxzfCLxrN7UoHGADJDlKSZyg/knQONy/tjyTzO8XtJ237L/g0L9Ql4vorAW3gE8QZ X-Received: by 10.98.220.79 with SMTP id t76mr39247685pfg.165.1511842024739; Mon, 27 Nov 2017 20:07:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511842024; cv=none; d=google.com; s=arc-20160816; b=IT518JmuoybOULnuyWyBHTXl6RG4BejrvfDg69ctw1cyDqGuhBzmsGL1Q+4y/bKVX8 r65oyHLOej6sH9unF7o/jo2HZ8FRw6FY/smQyjYLllZyFZMyQpoyxbmJnT1dj5Gw8Ark 7ar/ZUOG6MKJX/Jk0du8eWMnH+J8UFhS57uUXG3kL4zcemZ0yo83lawAaYjmuyI1Fi2O qeyliN8ns0v0yHnpwH5mDeHJaz/13OnqgEqIFQO3JqEYXpdKCNcxopjivqtU8/EPkvDn GrkYwFfRv4V8Gml79+Zf7HgrDBjrygPJqC5wtNvrFURgPrul8evZJkn/WehKVw8COyHs 7ikw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=PeW4NOVUbDC9OVLNV21Pjhw4KgneDdqa9tccEVOybV8=; b=pFgfIVMPDYXmFS2j5Kgy2xf8wab+v3nyqiL+lgOXotmh2Y8AMu2LX3mLVySI4s8hdn YhALZHe8FAM1E6LX5RciVEaFcACD+GfCcl8puo321z6Ix+jpULH0RA7DiKYVPED4DoSk 6XtTwUY5j0HAizpYjLAUC5ng2ZFPN5zVwpYBsEKCfukCulVQm7SbVEpBfSjTIRONBmwE UVAgdOoNcYQ7jqC/TslyYSKSvnKKHx/V505CMcRvahMxkxp7Yz3oaEpqDVg6K8Bj1Mkc btC+cvCGzMq6sxu5QRivlc3gE1HiohKHXWgweEPfNEUYxs5OGI1NzPDVzKjZbovZpAoI GspA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nmaHpvkf; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u8si1718825pgp.346.2017.11.27.20.06.53; Mon, 27 Nov 2017 20:07:04 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nmaHpvkf; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753571AbdK1EGH (ORCPT + 77 others); Mon, 27 Nov 2017 23:06:07 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:35511 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753398AbdK1EGD (ORCPT ); Mon, 27 Nov 2017 23:06:03 -0500 Received: by mail-pg0-f68.google.com with SMTP id l19so19726252pgo.2; Mon, 27 Nov 2017 20:06:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=PeW4NOVUbDC9OVLNV21Pjhw4KgneDdqa9tccEVOybV8=; b=nmaHpvkfcMzwaeUzsMkylNlCfR9qSufIhwOZ3QC9r8qvvz7wUyHCGruk9IKqSnQ8Oy 35AO31dBlJQ2mkWH3DDCa6JF0SMJlgEIWo8RsDvvx9+TZiRKz+YX3gd4E66YcioGfMSo iyC+Y9qdjZKuF2lkgt9jSN+in+MEp2lAiecHKYg9ptcVpz5gUrTZXFiQ6dHNhTL3uWhh +0/v9GStDbPjJTjQbO8yd30p/dNNsfKLVAY4fGRLvJpSr0VK1ZhyL0Uw8aea7x/cZXGE 5DZUKqQnTf0jH1lO20kqllnYUfNWXkR05l9FmZ/H0W+Dt0/88+FmkN851b0I07rrhmO/ /ROg== 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:date:message-id; bh=PeW4NOVUbDC9OVLNV21Pjhw4KgneDdqa9tccEVOybV8=; b=aZtWHEbQc8xq+udEAlYRZn30CsTKrsM0WPsPx0gFt042rFaJw9egz+S7kaYOMX5Qha AbkrJB+vNDu3LKiOZnxDnaAKNURovaXt8fN29/LPKU8jcVSX5DUKK2oikH/dY67h6aLN ButpxiBGDujRfb2LYtDUTNMoHwiVLgf3QEsInvrSPM/TDuS7M+pVBy4BV4BiIK5KMUvQ uRZLpOGcJiBy24/bgtfpI1Sti4HRjU8Q3RQJEoirdE2wdwwjW7pc0n5H7dO8hShFu2j4 CpQdLrQrQTqwb1tggPdKbZeyNZHPP95tJN8LbfrjBll9Iac1vnHHrd7+haGHanWgCgCr tUfQ== X-Gm-Message-State: AJaThX7rQtpP6v/F9sa0ejmCP3ZKXzw8H8tSzv77GK0//KGrzwmYrZBJ tRDvmjJ7GISYozEtrnrP3dTWXA== X-Received: by 10.101.69.76 with SMTP id x12mr39659607pgr.284.1511841962333; Mon, 27 Nov 2017 20:06:02 -0800 (PST) Received: from localhost ([203.205.141.123]) by smtp.gmail.com with ESMTPSA id x188sm49330023pgx.33.2017.11.27.20.06.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Nov 2017 20:06:01 -0800 (PST) From: Wanpeng Li X-Google-Original-From: Wanpeng Li To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Wanpeng Li Subject: [PATCH v6 0/4] KVM: X86: Add Paravirt TLB Shootdown Date: Mon, 27 Nov 2017 20:05:51 -0800 Message-Id: <1511841955-7375-1-git-send-email-wanpeng.li@hotmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remote flushing api's does a busy wait which is fine in bare-metal scenario. But with-in the guest, the vcpus might have been pre-empted or blocked. In this scenario, the initator vcpu would end up busy-waiting for a long amount of time. This patch set implements para-virt flush tlbs making sure that it does not wait for vcpus that are sleeping. And all the sleeping vcpus flush the tlb on guest enter. Idea was discussed here: https://lkml.org/lkml/2012/2/20/157 The best result is achieved when we're overcommiting the host by running multiple vCPUs on each pCPU. In this case PV tlb flush avoids touching vCPUs which are not scheduled and avoid the wait on the main CPU. In addition, thanks for commit 9e52fc2b50d ("x86/mm: Enable RCU based page table freeing (CONFIG_HAVE_RCU_TABLE_FREE=y)") Testing on a Xeon Gold 6142 2.6GHz 2 sockets, 32 cores, 64 threads, so 64 pCPUs, and each VM is 64 vCPUs. ebizzy -M vanilla optimized boost 1VM 46799 48670 4% 2VM 23962 42691 78% 3VM 16152 37539 132% Note: The patchset is not rebased against "locking/qspinlock/x86: Avoid test-and-set when PV_DEDICATED is set" v3 since I can still observe a little improvement for 64 vCPUs on 64 pCPUs, it is due to the system is not completely isolated, there are many housekeeping tasks work sporadically, and vCPUs are preemted some times, I also confirm this when adding some print to the kvm_flush_tlb_others. After PV_DEDICATED is merged, we can disable pv tlb flush when not overcommiting if it is needed. v5 -> v6: * fix the percpu mask * rebase against latest kvm/queue v4 -> v5: * flushmask instead of cpumask v3 -> v4: * use READ_ONCE() * use try_cmpxchg instead of cmpxchg * add {} to if * no FLUSH flags to preserve during set_preempted * "KVM: X86" prefix to patch subject v2 -> v3: * percpu cpumask v1 -> v2: * a new CPUID feature bit * fix cmpxchg check * use kvm_vcpu_flush_tlb() to get the statistics right * just OR the KVM_VCPU_PREEMPTED in kvm_steal_time_set_preempted * add a new bool argument to kvm_x86_ops->tlb_flush * __cpumask_clear_cpu() instead of cpumask_clear_cpu() * not put cpumask_t on stack * rebase the patchset against "locking/qspinlock/x86: Avoid test-and-set when PV_DEDICATED is set" v3 Wanpeng Li (4): KVM: X86: Add vCPU running/preempted state KVM: X86: Add Paravirt TLB Shootdown KVM: X86: introduce invalidate_gpa argument to tlb flush KVM: X86: Add flush_on_enter before guest enter Documentation/virtual/kvm/cpuid.txt | 4 ++++ arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/include/uapi/asm/kvm_para.h | 5 +++++ arch/x86/kernel/kvm.c | 36 +++++++++++++++++++++++++++++++++++- arch/x86/kvm/cpuid.c | 3 ++- arch/x86/kvm/svm.c | 14 +++++++------- arch/x86/kvm/vmx.c | 21 +++++++++++---------- arch/x86/kvm/x86.c | 25 ++++++++++++++++--------- 8 files changed, 81 insertions(+), 29 deletions(-) -- 2.7.4 From 1585497865341280799@xxx Thu Nov 30 13:29:52 +0000 2017 X-GM-THRID: 1584579468645715159 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread