diff options
author | Jan Beulich <jbeulich@suse.com> | 2012-09-07 17:58:12 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2012-09-07 17:58:12 +0200 |
commit | 79e6ef8c0cf1dd0820c950bb653985a8beb04203 (patch) | |
tree | 39960fa3732cea2ee65b769523951b9b240a7729 /xen/common/memory.c | |
parent | 42599de39a98fd826b6b6bac0738a8a0d9df18fe (diff) | |
download | xen-79e6ef8c0cf1dd0820c950bb653985a8beb04203.tar.gz xen-79e6ef8c0cf1dd0820c950bb653985a8beb04203.tar.bz2 xen-79e6ef8c0cf1dd0820c950bb653985a8beb04203.zip |
adjust a few RCU domain locking calls
x86's do_physdev_op() had a case where the locking was entirely
superfluous. Its physdev_map_pirq() further had a case where the lock
was being obtained too early, needlessly complicating early exit paths.
Grant table code had two open coded instances of
rcu_lock_target_domain_by_id(), and a third code section could be
consolidated by using the newly introduced helper function.
The memory hypercall code had two more instances of open coding
rcu_lock_target_domain_by_id(), but note that here this is not just
cleanup, but also fixes an error return path in memory_exchange() to
actually return an error.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'xen/common/memory.c')
-rw-r--r-- | xen/common/memory.c | 35 |
1 files changed, 5 insertions, 30 deletions
diff --git a/xen/common/memory.c b/xen/common/memory.c index 5d64cb6db5..8779d6bd7d 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -329,22 +329,9 @@ static long memory_exchange(XEN_GUEST_HANDLE(xen_memory_exchange_t) arg) out_chunk_order = exch.in.extent_order - exch.out.extent_order; } - if ( likely(exch.in.domid == DOMID_SELF) ) - { - d = rcu_lock_current_domain(); - } - else - { - if ( (d = rcu_lock_domain_by_id(exch.in.domid)) == NULL ) - goto fail_early; - - if ( !IS_PRIV_FOR(current->domain, d) ) - { - rcu_unlock_domain(d); - rc = -EPERM; - goto fail_early; - } - } + rc = rcu_lock_target_domain_by_id(exch.in.domid, &d); + if ( rc ) + goto fail_early; memflags |= MEMF_bits(domain_clamp_alloc_bitsize( d, @@ -583,20 +570,8 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE(void) arg) && (reservation.mem_flags & XENMEMF_populate_on_demand) ) args.memflags |= MEMF_populate_on_demand; - if ( likely(reservation.domid == DOMID_SELF) ) - { - d = rcu_lock_current_domain(); - } - else - { - if ( (d = rcu_lock_domain_by_id(reservation.domid)) == NULL ) - return start_extent; - if ( !IS_PRIV_FOR(current->domain, d) ) - { - rcu_unlock_domain(d); - return start_extent; - } - } + if ( unlikely(rcu_lock_target_domain_by_id(reservation.domid, &d)) ) + return start_extent; args.domain = d; rc = xsm_memory_adjust_reservation(current->domain, d); |