Received: by 10.223.176.5 with SMTP id f5csp761698wra; Fri, 9 Feb 2018 06:50:23 -0800 (PST) X-Google-Smtp-Source: AH8x227xIEgg6pNF6WpPhAF2xAB8LREisn5AJJVCYvDMhpioilt8Of8yrnZxw5EKiRvOAAXYeh4B X-Received: by 10.98.219.68 with SMTP id f65mr3032254pfg.25.1518187823789; Fri, 09 Feb 2018 06:50:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518187823; cv=none; d=google.com; s=arc-20160816; b=Lw0jBxEphKuEyI4ZoES7oFr2uz3p20txE1hTUfbOfD4rolp4H9z3/ZiW8B2m6VRY+j x5Xd9lDlcIRB8SGwt9kaCPxe5CnyjjUpDGdEkI3YSO2cq4sUK8P9sjJ6uRpGzCY7brtf 6W+gh0LAMZE0CAymvwz4RbzTrboN/NoyHYWOI9yDCFLtUDrDScc5KqqvbX3RNC1uFo7r ifG9du/RX4R87XrKdWdiVdyoMnnxKNLVhi93BFEDfNAPVrSGd9Qtayvc15UN+Un7+k+V KgMkUh99ZXv3zSQTePmDq9VOcgk6HIvHa2pb7z5z0EdRti2Se5k8m7Sc5/U+isg/key4 pT5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Tj4ayxQDGjhneHQFYvZkaQ2f6/v0ENYa1311YvYLL7A=; b=Z/7pDu15FbDJ9IICHfmvBtKkRAbcd3KF/PVxfFLjP4Iq9vzlJAaQjPhwT+2GbV9aVk g1NxlY2EjKpUm0IOV6glxN8Ewm70jM6EgxQEWXQzssR6/Le9IVgy9ReD48Tq5YUzZBrA RRjMUX1b2GzajMeN7S6+gs8xBNQmudf+3kljPTPwBCq37BIUwcBK0cnt9cgIZS2CgFH3 ZCGnSBodzTE6a0mZAOrZtM0GSwAbQVRsNLRLvlc08F5rZCXYKGc6XNA+a8gXIN88LZGC wB3Mh0p92yz40mrk1zfKezU9Tm4AhYXLzMcAhjMVIwrVibpCoYP/5+GKj19LLeeooYet MQuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ohiyKdX7; 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=QUARANTINE 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 t25si1375907pge.368.2018.02.09.06.50.09; Fri, 09 Feb 2018 06:50:23 -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=ohiyKdX7; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751341AbeBIOtQ (ORCPT + 99 others); Fri, 9 Feb 2018 09:49:16 -0500 Received: from mail-pl0-f68.google.com ([209.85.160.68]:37457 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751047AbeBIOtO (ORCPT ); Fri, 9 Feb 2018 09:49:14 -0500 Received: by mail-pl0-f68.google.com with SMTP id ay8so1561441plb.4; Fri, 09 Feb 2018 06:49:14 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=Tj4ayxQDGjhneHQFYvZkaQ2f6/v0ENYa1311YvYLL7A=; b=ohiyKdX70GNPLW0+VlDgT7cYvZthBnZnhFZIcR2iw1x3G6jCliwFeGgqOGmcRG18Pp gN8iQwWPYzxnHfWyPEZRapVz6fNqGyL3HJ8DvsFk0OYL7nzr00uTWMB4yZB9zkeclnhc EKCNspSbz2PLWEnw9jKUGfCR/wmEuBonS7HRzwL/AB/bNq8/fKrbJvI851n9Y+61s7pe ujxt7x+tNIuZoyu0sBbgWb1B7CjYACkunnAt+Wl17c6t6DGD7UqBLOHiB1xW9vOQKtfF oMm4zM572PCdi8i7L+s1QlLImrttsjYzlfasn7G/oJ+9L26Vcv5/7XOOpr9anXBRW/Uq 717w== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Tj4ayxQDGjhneHQFYvZkaQ2f6/v0ENYa1311YvYLL7A=; b=gpAIQ3yt2kYZIWGtSBO8cI9GBPeTKh05CCvZJcCQ0FkRChSnv2y3/bjRiAXaH2NS6n k/98IHA1r0+1QMLFPkdfrCRkWMTYTyUJjAKY/ej93kv82VbIHgPBjsgzTAxEgsbp2AQJ 9pRKNVYsb9Zw2kHcLIPtWPfHWwVw9XdslaP0pDMbryKjrEa/oZRewxX39N8RNqarvvrO HLS2FvDLj20fqTzOEX+LZb1TAO5bnRp1+m9+S9iFUmVzC94Aj/wDvM/5J2VF0d8sCZ/3 IudbSZQ4QBuUKqNp4yrdCh5fpb5CT8CwUW4tIJeFApoLymW9Mhu51tgxdBmhMOwjSzld GRqw== X-Gm-Message-State: APf1xPD2jHKMg6cy8VsJQs0OtrtqJoe7eiJl0wvD944gKepVs06WOonZ 52sGx78EL3ymVUqcmGIq4raR1g== X-Received: by 2002:a17:902:102:: with SMTP id 2-v6mr2827234plb.178.1518187754201; Fri, 09 Feb 2018 06:49:14 -0800 (PST) Received: from localhost.localdomain ([45.248.77.205]) by smtp.googlemail.com with ESMTPSA id o63sm8098682pfa.101.2018.02.09.06.49.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Feb 2018 06:49:13 -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?= , Eduardo Habkost Subject: [PATCH v2 2/2] KVM: X86: Don't use PV TLB flush with dedicated vCPUs and steal time disabled Date: Fri, 9 Feb 2018 06:47:53 -0800 Message-Id: <1518187673-70832-2-git-send-email-wanpengli@tencent.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518187673-70832-1-git-send-email-wanpengli@tencent.com> References: <1518187673-70832-1-git-send-email-wanpengli@tencent.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wanpeng Li vCPUs are very unlikely to get preempted when they are the only task running on a CPU. PV TLB flush is slower that the native flush in that case. In addition, avoid traversing all the cpus for pv tlb flush when steal time is disabled since pv tlb flush depends on the field in steal time for shared data. Cc: Paolo Bonzini Cc: Radim Krčmář Cc: Eduardo Habkost Signed-off-by: Wanpeng Li --- v1 -> v2: * update to KVM_HINTS_DEDICATED arch/x86/kernel/kvm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 7f4c92d..b92311a 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -545,7 +545,9 @@ static void __init kvm_guest_init(void) pv_time_ops.steal_clock = kvm_steal_clock; } - if (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH)) + if (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) && + !kvm_para_has_feature(KVM_HINTS_DEDICATED) && + !kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) pv_mmu_ops.flush_tlb_others = kvm_flush_tlb_others; if (kvm_para_has_feature(KVM_FEATURE_PV_EOI)) @@ -633,7 +635,9 @@ static __init int kvm_setup_pv_tlb_flush(void) { int cpu; - if (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH)) { + if (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) && + !kvm_para_has_feature(KVM_HINTS_DEDICATED) && + !kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) { for_each_possible_cpu(cpu) { zalloc_cpumask_var_node(per_cpu_ptr(&__pv_tlb_mask, cpu), GFP_KERNEL, cpu_to_node(cpu)); -- 2.7.4