From nobody Tue May 7 13:30:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 163214525026082.76244495598883; Mon, 20 Sep 2021 06:40:50 -0700 (PDT) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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=20Pau=20Monn=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 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1632145251614100001 Content-Type: text/plain; charset="utf-8" During fork reset operation the parent domain doesn't need to be gathered u= sing 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 !=3D -ERESTART ) { + cd->parent =3D NULL; domain_unpause(d); put_domain(d); - cd->parent =3D NULL; } =20 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 =3D d->parent; struct p2m_domain *p2m =3D p2m_get_hostp2m(d); struct page_info *page, *tmp; =20 @@ -2226,8 +2227,6 @@ int mem_sharing_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_= sharing_op_t) arg) =20 case XENMEM_sharing_op_fork_reset: { - struct domain *pd; - rc =3D -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; =20 - rc =3D rcu_lock_live_remote_domain_by_id(d->parent->domain_id, &pd= ); - if ( rc ) - goto out; - - rc =3D mem_sharing_fork_reset(d, pd); - - rcu_unlock_domain(pd); + rc =3D mem_sharing_fork_reset(d); break; } =20 --=20 2.25.1