Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7080FC433DF for ; Tue, 19 May 2020 09:45:14 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4AFE5207D3 for ; Tue, 19 May 2020 09:45:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4AFE5207D3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jayo4-0003iW-Kt; Tue, 19 May 2020 09:45:04 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jayo3-0003iK-Bq for xen-devel@lists.xenproject.org; Tue, 19 May 2020 09:45:03 +0000 X-Inumbo-ID: 69274883-99b5-11ea-a8eb-12813bfff9fa Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 69274883-99b5-11ea-a8eb-12813bfff9fa; Tue, 19 May 2020 09:45:02 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 3B0DFAD9F; Tue, 19 May 2020 09:45:04 +0000 (UTC) Subject: Re: [PATCH v3 1/5] x86: suppress XPTI-related TLB flushes when possible To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= References: <3ce4ab2c-8cb6-1482-6ce9-3d5b019e10c1@suse.com> <20200518170904.GY54375@Air-de-Roger> <748e3d53-779b-1529-73e8-37f3c2da6e57@suse.com> <20200519091532.GB54375@Air-de-Roger> From: Jan Beulich Message-ID: <25c2a650-8745-19d7-34fc-28570d7dfd65@suse.com> Date: Tue, 19 May 2020 11:45:00 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200519091532.GB54375@Air-de-Roger> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: George Dunlap , "xen-devel@lists.xenproject.org" , Wei Liu , Andrew Cooper Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 19.05.2020 11:15, Roger Pau Monné wrote: > On Tue, May 19, 2020 at 09:55:38AM +0200, Jan Beulich wrote: >> On 18.05.2020 19:09, Roger Pau Monné wrote: >>> On Wed, Sep 25, 2019 at 05:23:11PM +0200, Jan Beulich wrote: >>>> @@ -310,7 +313,16 @@ int pv_domain_initialise(struct domain * >>>> /* 64-bit PV guest by default. */ >>>> d->arch.is_32bit_pv = d->arch.has_32bit_shinfo = 0; >>>> >>>> - d->arch.pv.xpti = is_hardware_domain(d) ? opt_xpti_hwdom : opt_xpti_domu; >>>> + if ( is_hardware_domain(d) && opt_xpti_hwdom ) >>>> + { >>>> + d->arch.pv.xpti = true; >>>> + ++opt_xpti_hwdom; >>>> + } >>>> + if ( !is_hardware_domain(d) && opt_xpti_domu ) >>>> + { >>>> + d->arch.pv.xpti = true; >>>> + opt_xpti_domu = 2; >>> >>> I wonder whether a store fence is needed here in order to guarantee >>> that opt_xpti_domu is visible to flush_area_local before proceeding >>> any further with domain creation. >> >> The changed behavior of flush_area_local() becomes relevant only >> once the new domain runs. This being x86 code, the write can't >> remain invisible for longer than the very latest when the function >> returns, as the store can't be deferred past that (in reality it >> can't be deferred even until after the next [real] function call >> or the next barrier()). And due to x86'es cache coherent nature >> (for WB memory) the moment the store insn completes the new value >> is visible to all other CPUs. > > Yes, I think it's fine because this is x86 specific code. A comment > in that regard might be nice, but I'm not going to make this a strong > request. > > Reviewed-by: Roger Pau Monné Thanks. > I also think that turning opt_xpti_domu into a proper atomic and > increasing/decreasing (maybe a cmpxg would be needed) upon PV domain > creation/destruction should be able to accurately keep track of PV > domUs and hence could be used to further reduce the flushes when no PV > domains are running? Possibly, which would take care of (c) in the reasons the commit message gives. (a) and in particular (b) would then still need addressing. Jan