|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 09/11] 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>
---
RFC: Strictly speaking accessing ->up ahead of checking that the type
actually has an "up" pointer is UB, as only the last written field
of a union may be read. But we have violations of this rule in many
other places, so I guess we can assume to be okay-ish here as well.
--- a/xen/arch/x86/mm/shadow/private.h
+++ b/xen/arch/x86/mm/shadow/private.h
@@ -586,9 +586,7 @@ static inline int sh_get_ref(struct doma
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;
@@ -607,10 +605,11 @@ static inline void sh_put_ref(struct dom
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;
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |