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=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 A54F5C433B4 for ; Wed, 21 Apr 2021 11:40:00 +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 36511613F0 for ; Wed, 21 Apr 2021 11:40:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 36511613F0 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.114436.218084 (Exim 4.92) (envelope-from ) id 1lZBCs-0008CU-Nj; Wed, 21 Apr 2021 11:39:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 114436.218084; Wed, 21 Apr 2021 11:39:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZBCs-0008CN-Ki; Wed, 21 Apr 2021 11:39:46 +0000 Received: by outflank-mailman (input) for mailman id 114436; Wed, 21 Apr 2021 11:39:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZBCr-0008CI-7g for xen-devel@lists.xenproject.org; Wed, 21 Apr 2021 11:39:45 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 40a5b561-d373-4336-bebb-401d93ce0d82; Wed, 21 Apr 2021 11:39:43 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B5AC3AF1E; Wed, 21 Apr 2021 11:39:42 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 40a5b561-d373-4336-bebb-401d93ce0d82 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1619005182; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ImvxREUdGnlNVdtXxxEQIaXxRab3C6iMtTwjV8onVq4=; b=l/PSTZRygk6DVwGCBA/JWQkdBnCt1TSyNjeBUOe+zNvFUJPfJwE3UtsTSJ6yERsDevS+ce 8DMCsU/XZUL9pVoVe2EA7hZ+i0ASAy6naNOTRFy4FeBw3d7wCf6e7TcS7jPfzuW5VMVFxJ Q71G0JypEmBL+oIl80zMPHCLKFKRkB4= Subject: Re: [PATCH v9 01/13] x86/mm: rewrite virt_to_xen_l*e To: Hongyan Xia Cc: jgrall@amazon.com, Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= , Wei Liu , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , xen-devel@lists.xenproject.org References: <2ceae314e9e634ef7e9bebf7f64653f25fa97dd6.camel@xen.org> From: Jan Beulich Message-ID: Date: Wed, 21 Apr 2021 13:39:42 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <2ceae314e9e634ef7e9bebf7f64653f25fa97dd6.camel@xen.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 21.04.2021 13:33, Hongyan Xia wrote: > On Tue, 2021-04-20 at 14:17 +0200, Jan Beulich wrote: >> On 06.04.2021 13:05, Hongyan Xia wrote: >>> @@ -5305,6 +5339,8 @@ int map_pages_to_xen( >>> pl1e = virt_to_xen_l1e(virt); >>> if ( pl1e == NULL ) >>> goto out; >>> + >>> + UNMAP_DOMAIN_PAGE(pl1e); >>> } >> >> Unmapping the page right after mapping it looks suspicious. I see >> that >> further down we have >> >> pl1e = l2e_to_l1e(*pl2e) + l1_table_offset(virt); >> >> but don't you need to also change that? Actually, you do in patch 2, >> but the latest then the double mapping should imo be avoided. > > I would say the code was already suspicious to begin with, since pl1e > would be overwritten immediately below even before this patch. The > purpose of the virt_to_xen_l1e() is only to populate the L1 table. > > Performance-wise the double map should be pretty harmless since the > mapping is in the cache, so I actually prefer it as is. Alternatively, > I can initialise pl1e to NULL at the beginning of the block and only do > the > > pl1e = l2e_to_l1e(*pl2e) + l1_table_offset(virt); > > when the pl1e is still NULL. If you are okay I will go with this. I'd prefer this alternative, indeed, as it'll make the overall code look less odd. Albeit maybe not here, but in the subsequent patch. Jan