From patchwork Mon Sep 20 13:40:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamas K Lengyel X-Patchwork-Id: 12505365 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 80AEBC433F5 for ; Mon, 20 Sep 2021 13:40:43 +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 3CE52601FC for ; Mon, 20 Sep 2021 13:40:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3CE52601FC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.190916.340742 (Exim 4.92) (envelope-from ) id 1mSJX2-00072N-Ep; Mon, 20 Sep 2021 13:40:28 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 190916.340742; Mon, 20 Sep 2021 13:40:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSJX2-00072G-Bw; Mon, 20 Sep 2021 13:40:28 +0000 Received: by outflank-mailman (input) for mailman id 190916; Mon, 20 Sep 2021 13:40:27 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSJX1-00072A-EK for xen-devel@lists.xenproject.org; Mon, 20 Sep 2021 13:40:27 +0000 Received: from mga05.intel.com (unknown [192.55.52.43]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 51f96f64-d30d-42de-add0-92d3bd1e1b81; Mon, 20 Sep 2021 13:40:24 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2021 06:40:22 -0700 Received: from tlengyel-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.213.166.36]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2021 06:40:21 -0700 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: 51f96f64-d30d-42de-add0-92d3bd1e1b81 X-IronPort-AV: E=McAfee;i="6200,9189,10112"; a="308677197" X-IronPort-AV: E=Sophos;i="5.85,308,1624345200"; d="scan'208";a="308677197" X-IronPort-AV: E=Sophos;i="5.85,308,1624345200"; d="scan'208";a="532167160" From: Tamas K Lengyel To: xen-devel@lists.xenproject.org Cc: Tamas K Lengyel , Tamas K Lengyel , Jan Beulich , Andrew Cooper , George Dunlap , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu Subject: [PATCH v2] x86/mem_sharing: don't lock parent during fork reset Date: Mon, 20 Sep 2021 09:40:11 -0400 Message-Id: <8fa3c3e10446f99b75e3d4aef10624cfa2fdf72c.1632145015.git.tamas.lengyel@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 During fork reset operation the parent domain doesn't need to be gathered using rcu_lock_live_remote_domain_by_id, the fork already has the parent pointer. Signed-off-by: Tamas K Lengyel Reviewed-by: Jan Beulich --- v2: NULL the parent pointer early in the fork error path --- xen/arch/x86/mm/mem_sharing.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index 8d5d44bdbc..74d2869c0e 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -1861,9 +1861,9 @@ static int fork(struct domain *cd, struct domain *d) done: if ( rc && rc != -ERESTART ) { + cd->parent = NULL; domain_unpause(d); put_domain(d); - cd->parent = NULL; } return rc; @@ -1879,9 +1879,10 @@ static int fork(struct domain *cd, struct domain *d) * footprints the hypercall continuation should be implemented (or if this * feature needs to be become "stable"). */ -static int mem_sharing_fork_reset(struct domain *d, struct domain *pd) +static int mem_sharing_fork_reset(struct domain *d) { int rc; + struct domain *pd = d->parent; struct p2m_domain *p2m = p2m_get_hostp2m(d); struct page_info *page, *tmp; @@ -2226,8 +2227,6 @@ int mem_sharing_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_sharing_op_t) arg) case XENMEM_sharing_op_fork_reset: { - struct domain *pd; - rc = -EINVAL; if ( mso.u.fork.pad || mso.u.fork.flags ) goto out; @@ -2236,13 +2235,7 @@ int mem_sharing_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_sharing_op_t) arg) if ( !d->parent ) goto out; - rc = rcu_lock_live_remote_domain_by_id(d->parent->domain_id, &pd); - if ( rc ) - goto out; - - rc = mem_sharing_fork_reset(d, pd); - - rcu_unlock_domain(pd); + rc = mem_sharing_fork_reset(d); break; }