Received: by 10.223.164.202 with SMTP id h10csp273789wrb; Wed, 29 Nov 2017 22:03:53 -0800 (PST) X-Google-Smtp-Source: AGs4zMYfz6wYRjUUq3ebAoxQWv3Y0RMc29cpCmr7UYb4seTSJDbtU6HCEL9P56dyRko2c0YLljyN X-Received: by 10.84.138.193 with SMTP id 59mr1486257plp.446.1512021833307; Wed, 29 Nov 2017 22:03:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512021833; cv=none; d=google.com; s=arc-20160816; b=Xp4UxaQ0Rwu6a2HCZo63NEurmd3YUzgZgzqy2HXKASeqObphKkKMuRufQkt3SYvUi4 7pgNhPObzckdGwa6KVh+GQ+n1Z+1KtrVC7slYROKkRmhM6NsO3Gry8Gu3rrhBK9l7A6y HLFom5xXgcCsbKvNK4G8eacZQfDYnLQS5RyFmN35roHW5L9Kfx5ruhW4mzd1sk+mNPK/ 1TJrk5NiDBC6jO1JNKFWS/wRL4emTmwVCEEs7ramMQg9o5b+Pga3GmQNEEh8diBx/jtn b2k3ezrhVp53kTRrlbgojiHs32t2VnofDx/vta3jKF400QAgIXOTvEMVmNtf0o2mm26+ mD2Q== 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=UL+ltUodHUoRW/yLYdVvOGIaaedxaRRK9f+L5r8ObJo=; b=Icrd64zhyTWNmjOvWaizYvBIZTw2uB0MmwM9EkLTxLx0AZ2TDVP4RjW6ZZTPN55rUK 44SxfAASrvTJSMEIBQkSJmoPmBizqOOjzzzkT+0LmFryH93RWvhghdvjfaZSFv3XtPGh tF/omJ4ErpRc8KFaE9F/VuAuvuNoTM2AzVP3M1gsrIPEMpYrRo6qyuU0sj3DgQkEdt3V CHevRS1oV9vjGLXbAvhoCX1o5t7m0TXVkSWyLjK7HTavPyeueMy7YZ773sc2XAuOIz5S V3eicKPgE+gMKunV41AagDuUdAOgNYlXdHNKpdodz0C+hkyAuUMzS4SQY/5oqU5+HxWJ MYQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KE/PNLzY; 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 w10si2470110pgr.259.2017.11.29.22.03.40; Wed, 29 Nov 2017 22:03:53 -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=KE/PNLzY; 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 S1751655AbdK3GBU (ORCPT + 99 others); Thu, 30 Nov 2017 01:01:20 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:41738 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750994AbdK3GBS (ORCPT ); Thu, 30 Nov 2017 01:01:18 -0500 Received: by mail-pl0-f66.google.com with SMTP id g2so3642455pli.8; Wed, 29 Nov 2017 22:01:18 -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=UL+ltUodHUoRW/yLYdVvOGIaaedxaRRK9f+L5r8ObJo=; b=KE/PNLzYRpztYIxGJHP6/iQWHxV/sfvCRxfaWWP5EmdKqP6BRKNDbtDjADDAxsCODj p6dcjHh5uGc7X2oYBEuk1xH66ySjt5xPyP7ZFiREC71E/xKHLXn+grip7GH4Y9tpsA0l 7obBT8uENLLNId+hDbv1ZXcwiSkDE4TiesbbFTj8WjaobwtYSDmx1zo+4OGf1ASU8U2r tbKQp7eoLOjIXrX3ThERsCcGQgnwaLGVk4UCgRbsucwg4e/MCDlXijLO4AvLxwCwFfeW L5e5+qRzPa4yLLCZ13OIP6SiBuJNX86iSz3M9wF7SwfgfFDSg0jAgh8ad3eux2Av6EbP dBZA== 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=UL+ltUodHUoRW/yLYdVvOGIaaedxaRRK9f+L5r8ObJo=; b=M7GOYyjfXSkAB/GayAjBcRACmnmbW14GjYzkNmOTrfdbNSVBnI+8ccBoLp8Mx12xOk +eIfcRq49NqJDXiywKRpVGuH8OxGgkX9/qo2gAlwEx7b9JphEvs+56ux7vmCHyITPp0y 1SnAPY29XmkORnnUJpGEFNnSjLuFQ4+E92pyjfJHl1afIIulx7RLhlZf92XpsaQTo58m UK09mUT4i4kvnuP6mApfUyGnxLG3ISQzBec/YYqgN/7tq5qZKmo8aMt/hz62edoGOQPm N7g1F0wirgmjAHZAFqdF8FA8/hwZRnQnjFd/fxM/PBTRRp3XSOyWPLvCROLHIy36tGqq OnCg== X-Gm-Message-State: AJaThX6Uh5kgJP5pX/9rfGtux7/K4k5I9KEVph8uI5ZSM/2N8xru0U+X 9k1GJrpAQP8kUXgNjYbs+pszRg== X-Received: by 10.84.204.136 with SMTP id b8mr1468190ple.319.1512021677586; Wed, 29 Nov 2017 22:01:17 -0800 (PST) Received: from localhost ([203.205.141.123]) by smtp.gmail.com with ESMTPSA id s29sm5437788pgo.48.2017.11.29.22.01.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Nov 2017 22:01:16 -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?= , Peter Zijlstra , Wanpeng Li Subject: [PATCH v7 0/4] KVM: X86: Add Paravirt TLB Shootdown Date: Wed, 29 Nov 2017 22:01:10 -0800 Message-Id: <1512021674-9880-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. v6 -> v7: * don't check !flushmask * use arch_initcall() to achieve late allocate percpu mask 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 | 49 +++++++++++++++++++++++++++++++++++- 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, 94 insertions(+), 29 deletions(-) -- 2.7.4 From 1585469692856919567@xxx Thu Nov 30 06:02:05 +0000 2017 X-GM-THRID: 1585469692856919567 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread