From mboxrd@z Thu Jan 1 00:00:00 1970 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.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 80C86C433DF for ; Wed, 17 Jun 2020 13:37: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 5BAFF21655 for ; Wed, 17 Jun 2020 13:37:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5BAFF21655 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 1jlYFR-0005xU-Vq; Wed, 17 Jun 2020 13:37:01 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jlYFQ-0005xL-Jy for xen-devel@lists.xenproject.org; Wed, 17 Jun 2020 13:37:00 +0000 X-Inumbo-ID: 9ea26d9c-b09f-11ea-bb8b-bc764e2007e4 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 9ea26d9c-b09f-11ea-bb8b-bc764e2007e4; Wed, 17 Jun 2020 13:37:00 +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 11187AD71; Wed, 17 Jun 2020 13:37:03 +0000 (UTC) Subject: Re: [PATCH for-4.14] x86/hap: use get_gfn_type in hap_update_paging_modes To: Tamas K Lengyel References: <6a2ae3bae4a4ad32bc7caecd8af2655a76a9fb19.1592335579.git.tamas.lengyel@intel.com> <4b06e4f3-2b23-359a-9d80-c881016c0d91@suse.com> <47abe61b-76e1-4491-f539-60c427c2ffc8@suse.com> From: Jan Beulich Message-ID: <17dab1c9-175a-3faa-3937-9102e09f72b0@suse.com> Date: Wed, 17 Jun 2020 15:36:59 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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: Tamas K Lengyel , Wei Liu , Andrew Cooper , George Dunlap , Xen-devel , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 17.06.2020 15:31, Tamas K Lengyel wrote: > On Wed, Jun 17, 2020 at 7:28 AM Jan Beulich wrote: >> >> On 17.06.2020 15:21, Tamas K Lengyel wrote: >>> On Wed, Jun 17, 2020 at 7:04 AM Jan Beulich wrote: >>>> >>>> On 17.06.2020 15:00, Tamas K Lengyel wrote: >>>>> On Wed, Jun 17, 2020 at 3:59 AM Jan Beulich wrote: >>>>>> If there are code paths of both kinds, which approach to use in >>>>>> vmx_load_pdptrs() may need to be chosen based on what >>>>>> paging_locked_by_me() returns. Or perhaps an unlocked query is >>>>>> fine in either case? >>>>> >>>>> Perhaps adjusting vmx_load_pdptrs to chose the unlocked query would be >>>>> fine. But at that point what is the reason for having the lock >>>>> ordering at all? Why not just have a single recursive lock and avoid >>>>> issues like this altogether? >>>> >>>> With just a single lock, contention problems we already know we >>>> have would be even worse. When the current locking model was >>>> introduced, there was actually a plan to make gfn_lock() more >>>> fine-grained (i.e. not simply "de-generate" to p2m_lock()), for >>>> example. >>> >>> Sigh. Well, I've been checking and adjust vmx_load_pdptrs to use an >>> unlocked query doesn't seem as straightforward because, well, there is >>> no unlocked version of p2m_get_page_from_gfn which would also do the >>> "fixups". >> >> Which fixups do we need here, in particular? Of course, whenever >> any fixups get done, the operation can't be lock-less. >> >>> What seems redundant to me though is that >>> hap_update_paging_modes takes both the p2m_lock via get_gfn PLUS the >>> paging_lock. Does it really need to take the paging_lock? >> >> From mm-locks.h's comments: >> >> * For HAP, it protects the NPT/EPT tables and mode changes. > > We do the population of the EPT as part of fork_page() if there was a > hole in the p2m when the query was issued using P2M_ALLOC (or > P2M_UNSHARE). I checked and without the paging lock held it throws up > at hap_alloc's ASSERT.. So yea, currently I don't think we have a > better route then what I currently sent in. You didn't answer my question regarding the "fixups" needed, so for the moment it's not clear to me yet whether indeed there's no better way. Jan