Skip to content

Commit

Permalink
xen: Fold exit paths in find_text_region()
Browse files Browse the repository at this point in the history
Despite rcu_read_unlock() being fully inlineable, the optimiser doesn't appear
willing to fold the exit paths.  Rework the logic to do so explicitly.

This compiles to marginally better code in all cases.  No functional change.

Signed-off-by: Andrew Cooper <[email protected]>
Acked-by: Jan Beulich <[email protected]>
  • Loading branch information
andyhhp committed Jan 18, 2024
1 parent c30021b commit b25607e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions xen/common/virtual_region.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ static DEFINE_RCU_READ_LOCK(rcu_virtual_region_lock);

const struct virtual_region *find_text_region(unsigned long addr)
{
const struct virtual_region *region;
const struct virtual_region *iter, *region = NULL;

rcu_read_lock(&rcu_virtual_region_lock);
list_for_each_entry_rcu( region, &virtual_region_list, list )
list_for_each_entry_rcu ( iter, &virtual_region_list, list )
{
if ( (void *)addr >= region->start && (void *)addr < region->end )
if ( (void *)addr >= iter->start && (void *)addr < iter->end )
{
rcu_read_unlock(&rcu_virtual_region_lock);
return region;
region = iter;
break;
}
}
rcu_read_unlock(&rcu_virtual_region_lock);

return NULL;
return region;
}

void register_virtual_region(struct virtual_region *r)
Expand Down

0 comments on commit b25607e

Please sign in to comment.