Following Keir suggestion, this is set of patches to add a new version
of find_domain_by_id() which does not increment the domain reference
counter. This reduces the overhead and can be used by any function which
does not need to keep a domain reference beyond its current invocation,
as the rcu mechanism prevents the domain from being removed under our
feet. Of course, this can only be applied after the RCU patch posted
earlier.
Beyond adding the function the patch also replaces most invocations to
find_domain_by_id() with the new function find_domain_by_id_noref().
Only a few places needed to continue using the old function as the
reference was kept beyond the function invocation.
I only did minor tests on x86-32. Xen and dom0 boots fine and I can
create and destroy domains. But, no more exaustive tests were done. I
carefully checked if I removed all put_domain() associated with each
modified invocation of find_domain_by_id but mistakes are always
possible. It would be good to put this to some more exhaustive tests
before pushing it to the main tree. Waiting for post 3.0.4 release is
strongly suggested.
I also decomposed the patch in multiple parts so that the mantainers of
each architecture can review changes in their subtree, test and apply
them at their convenience.
This patch:
6/6: replace find_domain_by_id on arch/ia64
=======================================
Signed-off-by: Jose Renato Santos <jsantos@xxxxxxxxxx>
# HG changeset patch
# User root@xxxxxxxxxxxxxxxxxxx
# Node ID 643df4ebaae2179d8a5c251c60115c2facc29390
# Parent d7517609b3042fe073525501beeef96a926e1d18
Replace find_domain_by_id() with find_domain_by_id_noref() for ia64 arch
files
diff -r d7517609b304 -r 643df4ebaae2 xen/arch/ia64/vmx/vmx_hypercall.c
--- a/xen/arch/ia64/vmx/vmx_hypercall.c Fri Dec 8 18:19:22 2006 -0800
+++ b/xen/arch/ia64/vmx/vmx_hypercall.c Fri Dec 8 18:25:21 2006 -0800
@@ -59,7 +59,7 @@ do_hvm_op(unsigned long op, XEN_GUEST_HA
d = current->domain;
}
else if (IS_PRIV(current->domain)) {
- d = find_domain_by_id(a.domid);
+ d = find_domain_by_id_noref(a.domid);
if (d == NULL)
return -ESRCH;
}
@@ -75,7 +75,6 @@ do_hvm_op(unsigned long op, XEN_GUEST_HA
rc = copy_to_guest(arg, &a, 1) ? -EFAULT : 0;
}
- put_domain(d);
break;
}
@@ -90,7 +89,7 @@ do_hvm_op(unsigned long op, XEN_GUEST_HA
if (!IS_PRIV(current->domain))
return -EPERM;
- d = find_domain_by_id(op.domid);
+ d = find_domain_by_id_noref(op.domid);
if (d == NULL)
return -ESRCH;
@@ -100,7 +99,6 @@ do_hvm_op(unsigned long op, XEN_GUEST_HA
rc = 0;
}
- put_domain(d);
break;
}
diff -r d7517609b304 -r 643df4ebaae2 xen/arch/ia64/xen/dom0_ops.c
--- a/xen/arch/ia64/xen/dom0_ops.c Fri Dec 8 18:19:22 2006 -0800
+++ b/xen/arch/ia64/xen/dom0_ops.c Fri Dec 8 18:25:21 2006 -0800
@@ -40,7 +40,7 @@ long arch_do_domctl(xen_domctl_t *op, XE
case XEN_DOMCTL_getmemlist:
{
unsigned long i;
- struct domain *d = find_domain_by_id(op->domain);
+ struct domain *d = find_domain_by_id_noref(op->domain);
unsigned long start_page = op->u.getmemlist.start_pfn;
unsigned long nr_pages = op->u.getmemlist.max_pfns;
unsigned long mfn;
@@ -68,15 +68,13 @@ long arch_do_domctl(xen_domctl_t *op, XE
op->u.getmemlist.num_pfns = i;
if (copy_to_guest(u_domctl, op, 1))
ret = -EFAULT;
-
- put_domain(d);
}
break;
case XEN_DOMCTL_arch_setup:
{
xen_domctl_arch_setup_t *ds = &op->u.arch_setup;
- struct domain *d = find_domain_by_id(op->domain);
+ struct domain *d = find_domain_by_id_noref(op->domain);
if ( d == NULL) {
ret = -EINVAL;
@@ -127,8 +125,6 @@ long arch_do_domctl(xen_domctl_t *op, XE
}
}
}
-
- put_domain(d);
}
break;
@@ -136,11 +132,10 @@ long arch_do_domctl(xen_domctl_t *op, XE
{
struct domain *d;
ret = -ESRCH;
- d = find_domain_by_id(op->domain);
+ d = find_domain_by_id_noref(op->domain);
if ( d != NULL )
{
ret = shadow_mode_control(d, &op->u.shadow_op);
- put_domain(d);
copy_to_guest(u_domctl, op, 1);
}
}
@@ -154,7 +149,7 @@ long arch_do_domctl(xen_domctl_t *op, XE
unsigned int lp = fp + np - 1;
ret = -ESRCH;
- d = find_domain_by_id(op->domain);
+ d = find_domain_by_id_noref(op->domain);
if (unlikely(d == NULL))
break;
@@ -166,8 +161,6 @@ long arch_do_domctl(xen_domctl_t *op, XE
else
ret = ioports_deny_access(d, fp, lp);
}
-
- put_domain(d);
}
break;
default:
diff -r d7517609b304 -r 643df4ebaae2 xen/arch/ia64/xen/mm.c
--- a/xen/arch/ia64/xen/mm.c Fri Dec 8 18:19:22 2006 -0800
+++ b/xen/arch/ia64/xen/mm.c Fri Dec 8 18:25:21 2006 -0800
@@ -1250,7 +1250,7 @@ dom0vp_add_physmap(struct domain* d, uns
if (flags & (ASSIGN_nocache | ASSIGN_pgc_allocated))
return -EINVAL;
- rd = find_domain_by_id(domid);
+ rd = find_domain_by_id_noref(domid);
if (unlikely(rd == NULL)) {
switch (domid) {
case DOMID_XEN:
@@ -1283,7 +1283,6 @@ dom0vp_add_physmap(struct domain* d, uns
//don't update p2m table because this page belongs to rd, not d.
perfc_incrc(dom0vp_add_physmap);
out1:
- put_domain(rd);
return error;
}
@@ -2011,12 +2010,11 @@ arch_memory_op(int op, XEN_GUEST_HANDLE(
}
else if (!IS_PRIV(current->domain))
return -EPERM;
- else if ((d = find_domain_by_id(xatp.domid)) == NULL)
+ else if ((d = find_domain_by_id_noref(xatp.domid)) == NULL)
return -ESRCH;
/* This hypercall is used for VT-i domain only */
if (!VMX_DOMAIN(d->vcpu[0])) {
- put_domain(d);
return -ENOSYS;
}
@@ -2056,8 +2054,6 @@ arch_memory_op(int op, XEN_GUEST_HANDLE(
UNLOCK_BIGLOCK(d);
- put_domain(d);
-
break;
}
find_domain_by_id_noref_6.patch
Description: find_domain_by_id_noref_6.patch
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|