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.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_2 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 80751C47255 for ; Mon, 11 May 2020 10:56:01 +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 4440320735 for ; Mon, 11 May 2020 10:56:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xen.org header.i=@xen.org header.b="coif0YvS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4440320735 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org 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 1jY65z-0007PM-1R; Mon, 11 May 2020 10:55:39 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jY65y-0007PH-9F for xen-devel@lists.xenproject.org; Mon, 11 May 2020 10:55:38 +0000 X-Inumbo-ID: f27d400a-9375-11ea-ae69-bc764e2007e4 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f27d400a-9375-11ea-ae69-bc764e2007e4; Mon, 11 May 2020 10:55:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Mime-Version:Content-Type: References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=HAToxlyt/mFYVlJ7+5L4GLnIWhxntlLpjFjlfawAXfM=; b=coif0YvS/myvScrZfU0V8kmzMd wWq6eHqILV/Pc9KmZEHzCNp3b2xUBusgWBtB4r2OFahUuU8+Ib3QQ82DwFiyMNpaoRSgUpAHnEIuG /N3SjgLkBF1g4C1TuomPAQ49hV16CmEJqAIyWKX9jGz/Qz1EGqwl0tQN5nQbnEVZ//zE=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jY65v-0003n3-Ff; Mon, 11 May 2020 10:55:35 +0000 Received: from 54-240-197-238.amazon.com ([54.240.197.238] helo=u1bbd043a57dd5a.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1jY65v-0002pC-4V; Mon, 11 May 2020 10:55:35 +0000 Message-ID: Subject: Re: [PATCH v6 12/15] x86/smpboot: switch pl*e to use new APIs in clone_mapping From: Hongyan Xia To: Jan Beulich Date: Mon, 11 May 2020 11:55:33 +0100 In-Reply-To: <88709097-661e-ce7b-1a46-1dcecf029428@suse.com> References: <88709097-661e-ce7b-1a46-1dcecf029428@suse.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 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: xen-devel@lists.xenproject.org, Roger Pau =?ISO-8859-1?Q?Monn=E9?= , julien@xen.org, Wei Liu , Andrew Cooper Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On Thu, 2020-04-30 at 17:15 +0200, Jan Beulich wrote: > On 24.04.2020 16:09, Hongyan Xia wrote: > > From: Wei Liu > > Nit: Why the emphasis on pl*e in the title? Is there anything left > unconverted in the function? IOW how about "switch clone_mapping() > to new page table APIs"? The title seems stale. Will fix. > ... > > @@ -724,48 +724,61 @@ static int clone_mapping(const void *ptr, > > root_pgentry_t *rpt) > > } > > } > > > > + UNMAP_DOMAIN_PAGE(pl1e); > > + UNMAP_DOMAIN_PAGE(pl2e); > > + UNMAP_DOMAIN_PAGE(pl3e); > > + > > if ( !(root_get_flags(rpt[root_table_offset(linear)]) & > > _PAGE_PRESENT) ) > > { > > - pl3e = alloc_xen_pagetable(); > > - if ( !pl3e ) > > + mfn_t l3mfn = alloc_xen_pagetable_new(); > > + > > + if ( mfn_eq(l3mfn, INVALID_MFN) ) > > goto out; > > + > > + pl3e = map_domain_page(l3mfn); > > Seeing this recur (from other patches) I wonder whether we wouldn't > better make map_domain_page() accept INVALID_MFN and return NULL in > this case. In cases like the one here it would eliminate the need > for several local variables. Of course the downside of this is that > then we'll have to start checking map_domain_page()'s return value. > A middle ground could be to have > > void *alloc_mapped_pagetable(mfn_t *mfn); > > allowing to pass in NULL if the MFN is of no interest. I would say that when the caller requires a new Xen page table allocation, almost all the time both the mfn and the virt are needed (on top of my head I cannot think of a case where we pass in NULL, you almost always need the mfn to write new page table entries), so I think the benefit of this is just compressing two calls into one, which I am not quite sure is worth it. > > @@ -781,6 +794,9 @@ static int clone_mapping(const void *ptr, > > root_pgentry_t *rpt) > > > > rc = 0; > > out: > > + UNMAP_DOMAIN_PAGE(pl1e); > > + UNMAP_DOMAIN_PAGE(pl2e); > > + UNMAP_DOMAIN_PAGE(pl3e); > > return rc; > > } > > I don't think the writing of NULL into the variables is necessary > here. And if the needed if()-s are of concern, then perhaps we > should consider making unmap_domain_page() finally accept NULL as > input? I usually don't have a problem with this because a sane compiler would definitely remove the unnecessary clearing, so I would use the macro version as much as possible. I am okay with moving the NULL check into unmap() itself, but note that this also needs changes on Arm side. Hongyan