All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] x86/mem_sharing: don't lock parent during fork reset
@ 2021-09-20 13:40 Tamas K Lengyel
  2021-09-20 14:14 ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Tamas K Lengyel @ 2021-09-20 13:40 UTC (permalink / raw)
  To: xen-devel
  Cc: Tamas K Lengyel, Tamas K Lengyel, Jan Beulich, Andrew Cooper,
	George Dunlap, Roger Pau Monné,
	Wei Liu

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 <tamas.lengyel@intel.com>
---
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;
     }
 
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] x86/mem_sharing: don't lock parent during fork reset
  2021-09-20 13:40 [PATCH v2] x86/mem_sharing: don't lock parent during fork reset Tamas K Lengyel
@ 2021-09-20 14:14 ` Jan Beulich
  2021-09-20 20:02   ` Tamas K Lengyel
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2021-09-20 14:14 UTC (permalink / raw)
  To: Tamas K Lengyel
  Cc: Tamas K Lengyel, Andrew Cooper, George Dunlap,
	Roger Pau Monné,
	Wei Liu, xen-devel

On 20.09.2021 15:40, Tamas K Lengyel wrote:
> 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 <tamas.lengyel@intel.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] x86/mem_sharing: don't lock parent during fork reset
  2021-09-20 14:14 ` Jan Beulich
@ 2021-09-20 20:02   ` Tamas K Lengyel
  0 siblings, 0 replies; 3+ messages in thread
From: Tamas K Lengyel @ 2021-09-20 20:02 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Tamas K Lengyel, Andrew Cooper, George Dunlap,
	Roger Pau Monné,
	Wei Liu, Xen-devel

On Mon, Sep 20, 2021 at 10:15 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 20.09.2021 15:40, Tamas K Lengyel wrote:
> > 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 <tamas.lengyel@intel.com>
>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>

Thanks!


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-20 20:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-20 13:40 [PATCH v2] x86/mem_sharing: don't lock parent during fork reset Tamas K Lengyel
2021-09-20 14:14 ` Jan Beulich
2021-09-20 20:02   ` Tamas K Lengyel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.