Received: by 10.223.164.202 with SMTP id h10csp82278wrb; Thu, 30 Nov 2017 07:16:42 -0800 (PST) X-Google-Smtp-Source: AGs4zMYEW3C+7Nsnvp/FGoTQCU8mNd0itE9wsou7JnsmZn+PKzO04WjB+Xo97CQWtI2C3rcB0dB8 X-Received: by 10.98.9.209 with SMTP id 78mr6973473pfj.59.1512055002060; Thu, 30 Nov 2017 07:16:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512055002; cv=none; d=google.com; s=arc-20160816; b=G6Byn5DB2maPC6IeHDZ2f3SeOytaNjjC8aU21aEFrW4h3T+1BWnUTAX2Jmwa6xqiXi KAurlr+xEp5LNtCFijVSocki8xt2K36B5Hlk/lJJTjFXBWrwKRZYiXovkba9hBAKwtJK P+vgULlSFmzBEiMbSsGtTyxox/Ps1PCCsNecY9ggcxtDHh1xBo3jAiTQT6DBg/F5D7PZ oKH4ZrmleQN2U1oNNNHc7MW36eYOOzQ5v3/fh7hzYeiFa9hHcyABFzouRdOcdh4Ec0qG l4HR/93xADr5C/Y/xZS97EuYs9Uxn0iICqq+4i0en9qGyFbfG6ModOWQCOOhjkVKAEwM RB4g== 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=ee1fJ9iIVcG6zgdUauF3uwT5sOAP4bEdI8KgEwbQ+vk=; b=AO0WtS2PdZveFPoKJ/j9reQNUGB1WwFt1oVl8SUzrmDgpleMSXZLdaSRb7cfFV8l8R PBGmShEU427EsDT2UHc8zMiveUGYPtaxC4tCxXTlyofZLYtq5dMwUbs0viM7Fu9WL7O4 qk/4e60AMiHkWGONPbe5uDTkZoficDTv4GLHwtaeesRJLzLrjZWGSm7gcj1udG/JIuR3 3nQw61PgdCUuD3A77Jy475Rp6l6ONXWbXtFO/rNFLd3YV+IlPLBItcA6UTbQY6kwWd9F gu+yJ0ORpRziOoPaHQJ8Ygs3bbzuAbo7SPmMsZpWnoR/tUsZfPGVNUWIJqwiAd1ZwMJ4 /I0A== 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 az8si3198115plb.717.2017.11.30.07.16.08; Thu, 30 Nov 2017 07:16:42 -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 S1752589AbdK3PPA (ORCPT + 99 others); Thu, 30 Nov 2017 10:15:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43184 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751443AbdK3PO6 (ORCPT ); Thu, 30 Nov 2017 10:14:58 -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 A1C94C0008CE; Thu, 30 Nov 2017 15:14:58 +0000 (UTC) Received: from flask (ovpn-204-21.brq.redhat.com [10.40.204.21]) by smtp.corp.redhat.com (Postfix) with SMTP id 786BF60BE1; Thu, 30 Nov 2017 15:14:54 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Thu, 30 Nov 2017 16:14:53 +0100 Date: Thu, 30 Nov 2017 16:14:53 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Wanpeng Li Cc: "linux-kernel@vger.kernel.org" , kvm , Paolo Bonzini , Wanpeng Li , Peter Zijlstra Subject: Re: [PATCH v6 2/4] KVM: X86: Add Paravirt TLB Shootdown Message-ID: <20171130151452.GA1606@flask> References: <1511841955-7375-1-git-send-email-wanpeng.li@hotmail.com> <1511841955-7375-3-git-send-email-wanpeng.li@hotmail.com> <20171129162118.GA10661@flask> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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.31]); Thu, 30 Nov 2017 15:14:58 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2017-11-30 14:24+0800, Wanpeng Li: > 2017-11-30 0:21 GMT+08:00 Radim Krčmář : > > 2017-11-27 20:05-0800, Wanpeng Li: > >> From: 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()? > > Do it in v7. In addition, move pv_mmu_ops.flush_tlb_others = > kvm_flush_tlb_others to the arch_initcall() fails to work even if I > disable rodata through grub. So I continue to keep the callback > replacement in kvm_guest_init() and late allocation in > arch_initcall(). I think it has to do with the patching -- you'd need to re-patch flush_tlb_others callsites for the change to take effect or add a hypervisor late init just before check_bugs(), where the patching is currently done. Not sure how either of those is acceptable, though. From 1585471136530057874@xxx Thu Nov 30 06:25:02 +0000 2017 X-GM-THRID: 1585281262875379228 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread