[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] x86: don't pointlessly use get_domain_by_id()
commit 37c709a16f8b6ab145d4a6dce171464837bd72a7 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Thu Jan 7 15:08:51 2021 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Thu Jan 7 15:08:51 2021 +0100 x86: don't pointlessly use get_domain_by_id() For short-lived references rcu_lock_domain_by_id() is the better (slightly cheaper) alternative. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- xen/arch/x86/cpu/mcheck/mcaction.c | 7 ++++--- xen/arch/x86/cpu/mcheck/mce.c | 21 ++++++++++----------- xen/arch/x86/debug.c | 4 ++-- xen/arch/x86/irq.c | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/cpu/mcheck/mcaction.c b/xen/arch/x86/cpu/mcheck/mcaction.c index 69332fb84d..f4f265c1bc 100644 --- a/xen/arch/x86/cpu/mcheck/mcaction.c +++ b/xen/arch/x86/cpu/mcheck/mcaction.c @@ -87,7 +87,7 @@ mc_memerr_dhandler(struct mca_binfo *binfo, BUG_ON( bank->mc_domid == DOMID_COW ); if ( bank->mc_domid != DOMID_XEN ) { - d = get_domain_by_id(bank->mc_domid); + d = rcu_lock_domain_by_id(bank->mc_domid); ASSERT(d); gfn = get_gpfn_from_mfn((bank->mc_addr) >> PAGE_SHIFT); @@ -132,6 +132,8 @@ mc_memerr_dhandler(struct mca_binfo *binfo, goto vmce_failed; } + rcu_unlock_domain(d); + /* * Impacted domain go on with domain's recovery job * if the domain has its own MCA handler. @@ -139,12 +141,11 @@ mc_memerr_dhandler(struct mca_binfo *binfo, * its own recovery job. */ *result = MCER_RECOVERED; - put_domain(d); return; vmce_failed: - put_domain(d); domain_crash(d); + rcu_unlock_domain(d); } } } diff --git a/xen/arch/x86/cpu/mcheck/mce.c b/xen/arch/x86/cpu/mcheck/mce.c index 0e84368ae2..3a92e9db4e 100644 --- a/xen/arch/x86/cpu/mcheck/mce.c +++ b/xen/arch/x86/cpu/mcheck/mce.c @@ -1497,7 +1497,6 @@ long do_mca(XEN_GUEST_HANDLE_PARAM(xen_mc_t) u_xen_mc) if ( mc_msrinject->mcinj_flags & MC_MSRINJ_F_GPADDR ) { - domid_t domid; struct domain *d; struct mcinfo_msr *msr; unsigned int i; @@ -1505,17 +1504,17 @@ long do_mca(XEN_GUEST_HANDLE_PARAM(xen_mc_t) u_xen_mc) unsigned long gfn, mfn; p2m_type_t t; - domid = (mc_msrinject->mcinj_domid == DOMID_SELF) ? - current->domain->domain_id : mc_msrinject->mcinj_domid; - if ( domid >= DOMID_FIRST_RESERVED ) - return x86_mcerr("do_mca inject: incompatible flag " - "MC_MSRINJ_F_GPADDR with domain %d", - -EINVAL, domid); - - d = get_domain_by_id(domid); + d = rcu_lock_domain_by_any_id(mc_msrinject->mcinj_domid); if ( d == NULL ) + { + if ( mc_msrinject->mcinj_domid >= DOMID_FIRST_RESERVED ) + return x86_mcerr("do_mca inject: incompatible flag " + "MC_MSRINJ_F_GPADDR with domain %d", + -EINVAL, domid); + return x86_mcerr("do_mca inject: bad domain id %d", -EINVAL, domid); + } for ( i = 0, msr = &mc_msrinject->mcinj_msr[0]; i < mc_msrinject->mcinj_count; @@ -1528,7 +1527,7 @@ long do_mca(XEN_GUEST_HANDLE_PARAM(xen_mc_t) u_xen_mc) if ( mfn == mfn_x(INVALID_MFN) ) { put_gfn(d, gfn); - put_domain(d); + rcu_unlock_domain(d); return x86_mcerr("do_mca inject: bad gfn %#lx of domain %d", -EINVAL, gfn, domid); } @@ -1538,7 +1537,7 @@ long do_mca(XEN_GUEST_HANDLE_PARAM(xen_mc_t) u_xen_mc) put_gfn(d, gfn); } - put_domain(d); + rcu_unlock_domain(d); } if ( !x86_mc_msrinject_verify(mc_msrinject) ) diff --git a/xen/arch/x86/debug.c b/xen/arch/x86/debug.c index 5d8acdad71..4356039ed2 100644 --- a/xen/arch/x86/debug.c +++ b/xen/arch/x86/debug.c @@ -164,13 +164,13 @@ unsigned int dbg_rw_mem(void * __user addr, void * __user buf, unsigned int len, domid_t domid, bool toaddr, uint64_t pgd3) { - struct domain *d = get_domain_by_id(domid); + struct domain *d = rcu_lock_domain_by_id(domid); if ( d ) { if ( !d->is_dying ) len = dbg_rw_guest_mem(d, addr, buf, len, toaddr, pgd3); - put_domain(d); + rcu_unlock_domain(d); } return len; diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c index e315fef4a6..13b1af57f3 100644 --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -323,7 +323,7 @@ void destroy_irq(unsigned int irq) if ( desc->arch.creator_domid != DOMID_INVALID ) { - struct domain *d = get_domain_by_id(desc->arch.creator_domid); + struct domain *d = rcu_lock_domain_by_id(desc->arch.creator_domid); if ( d ) { @@ -334,7 +334,7 @@ void destroy_irq(unsigned int irq) "Could not revoke %pd access to IRQ%u (error %d)\n", d, irq, err); - put_domain(d); + rcu_unlock_domain(d); } desc->arch.creator_domid = DOMID_INVALID; -- generated by git-patchbot for /home/xen/git/xen.git#staging
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |