Received: by 10.223.164.202 with SMTP id h10csp4570637wrb; Wed, 29 Nov 2017 08:22:48 -0800 (PST) X-Google-Smtp-Source: AGs4zMaP/B1BufE4HUaah0PeStE/IuySLu/zFvfbYvUcJAfwkJtK/v/tJmLJQ3izhVzPNE2UtuWd X-Received: by 10.98.67.78 with SMTP id q75mr3578285pfa.110.1511972568208; Wed, 29 Nov 2017 08:22:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511972568; cv=none; d=google.com; s=arc-20160816; b=O/kKukWG5c12JfRbx8zR50Hq1A5FRLl5zvNoIBJYMBBQcxrqxT1xpUz2x78LbTSOk2 BGUQ6EHP3tNsHiNTK4KM/Q0oUrbtAedW+NUyeQZfIsJnANcO+nGIZFugQAL7p4pb0l8K coMMs0Igh3UY7WbDQ0Lg0+J3XbEvdgLaErRUx46eOzppnsUWV3pAyoRFMEqSGr3x6R54 iwsWmVc+MQpQFlkTzys+EHOqSOhc2Lf4i/11uvKMGpE9Lozltr9sMWcnFzRYiEPdjQhK Ep/PCV+4189eTB7JJONsQJdy5nn3nZ0DHxgjD1Aa0UFlNpbOeRGUkZlIKpjF+8zuX9IV k5ng== 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=gaHVAkr3Xe6mJGrY19YfmJGOdPyycrjEs1FpPu4vyFs=; b=rsUX67gQloRnO7uGc/lHOi1DBVaUlRXt8CYp2ka2R8mtvUf19psQQoh9uNqZDAZkp1 gRW+ae7dZhLRWvEKzu5Dcd3NdhulWAgWsjRJSo/AEYDsO3EZq/I+sRkDwvjt1BGiB8Lt 2RfcuE0k3KO2CDYb8EUCUFkS7vabd1+8gulRZ+EPCpaDjTtl61vU5JL7aiKPds2nfg4e R5a4UEvqZnlqiAulfjht4FbRvSLCW3Qbnzc71iKDGdAtcgxXmF6eqZ8KuKOb6N74aoCn vacUmEjtknr5bWLEGUmC4JuSC7FYZ0WalS181OY6fQb2tiDbI1dnjDDHeB7SGTroF1Sa Mt5A== 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 p189si1581768pfp.251.2017.11.29.08.22.38; Wed, 29 Nov 2017 08:22:48 -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; 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 S1755630AbdK2QV0 (ORCPT + 69 others); Wed, 29 Nov 2017 11:21:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36654 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932151AbdK2QVY (ORCPT ); Wed, 29 Nov 2017 11:21:24 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 238124A6E5; Wed, 29 Nov 2017 16:21:24 +0000 (UTC) Received: from flask (ovpn-204-21.brq.redhat.com [10.40.204.21]) by smtp.corp.redhat.com (Postfix) with SMTP id E056860C90; Wed, 29 Nov 2017 16:21:20 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Wed, 29 Nov 2017 17:21:19 +0100 Date: Wed, 29 Nov 2017 17:21:19 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Wanpeng Li Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Wanpeng Li , Peter Zijlstra Subject: Re: [PATCH v6 2/4] KVM: X86: Add Paravirt TLB Shootdown Message-ID: <20171129162118.GA10661@flask> References: <1511841955-7375-1-git-send-email-wanpeng.li@hotmail.com> <1511841955-7375-3-git-send-email-wanpeng.li@hotmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1511841955-7375-3-git-send-email-wanpeng.li@hotmail.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 29 Nov 2017 16:21:24 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2017-11-27 20:05-0800, Wanpeng Li: > From: Wanpeng Li > > 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. > > 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. > > 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% > > Cc: Paolo Bonzini > Cc: Radim Krčmář > Cc: Peter Zijlstra > Signed-off-by: Wanpeng Li > --- > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c > @@ -498,6 +498,37 @@ static void __init kvm_apf_trap_init(void) > update_intr_gate(X86_TRAP_PF, async_page_fault); > } > > +static DEFINE_PER_CPU(cpumask_t, __pv_tlb_mask); > + > +static void kvm_flush_tlb_others(const struct cpumask *cpumask, > + const struct flush_tlb_info *info) > +{ > + u8 state; > + int cpu; > + struct kvm_steal_time *src; > + cpumask_t *flushmask = &per_cpu(__pv_tlb_mask, smp_processor_id()); > + > + if (unlikely(!flushmask)) > + return; I don't see how this can be NULL and if it could, we'd have to call native_flush_tlb_others() instead of returning anyway. Also, Peter mentioned that we're wasting memory (default is 1k per CPU) when not running on KVM. Hyper-V hijacks x86_platform.apic_post_init() to achieve late allocation. smp_ops.smp_prepare_cpus seems slightly better for our purposes, but I don't really like either. Couldn't we use use arch_initcall(), or early_initcall() if there are complications with allocating after smp_init()? Thanks. From 1585281270339361580@xxx Tue Nov 28 04:07:11 +0000 2017 X-GM-THRID: 1585281262875379228 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread