[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] x86/shadow: simplify conditionals in sh_{get,put}_ref()
commit e4fb1750487b296858dfd6f9ed3c306b25100388 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Mon Jan 9 14:26:12 2023 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Mon Jan 9 14:26:12 2023 +0100 x86/shadow: simplify conditionals in sh_{get,put}_ref() In both cases the "entry_pa != 0" check is redundant; storing 0 when the field already is 0 is quite fine. Move the cheaper remaining part first in sh_get_ref(). In sh_put_ref() convert the has-up-pointer check into an assertion (requiring the zero check to be retained there). Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- xen/arch/x86/mm/shadow/private.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/mm/shadow/private.h b/xen/arch/x86/mm/shadow/private.h index 2c2c18985d..e5329e0d0c 100644 --- a/xen/arch/x86/mm/shadow/private.h +++ b/xen/arch/x86/mm/shadow/private.h @@ -583,9 +583,7 @@ static inline int sh_get_ref(struct domain *d, mfn_t smfn, paddr_t entry_pa) sp->u.sh.count = nx; /* We remember the first shadow entry that points to each shadow. */ - if ( entry_pa != 0 - && sh_type_has_up_pointer(d, sp->u.sh.type) - && sp->up == 0 ) + if ( !sp->up && sh_type_has_up_pointer(d, sp->u.sh.type) ) sp->up = entry_pa; return 1; @@ -604,10 +602,11 @@ static inline void sh_put_ref(struct domain *d, mfn_t smfn, paddr_t entry_pa) ASSERT(!(sp->count_info & PGC_count_mask)); /* If this is the entry in the up-pointer, remove it */ - if ( entry_pa != 0 - && sh_type_has_up_pointer(d, sp->u.sh.type) - && sp->up == entry_pa ) + if ( sp->up == entry_pa ) + { + ASSERT(!entry_pa || sh_type_has_up_pointer(d, sp->u.sh.type)); sp->up = 0; + } x = sp->u.sh.count; nx = x - 1; -- generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |