memory: avoid pointless continuation in xenmem_add_to_physmap()
PATCH 1/1 memory: avoid pointless continuation in xenmem_add_to_physmap()
Adjust so we uniformly avoid needlessly arranging for a continuation on the last iteration.
xen/common/memory.c +3 -2
@@ -854,8 +854,9 @@ int xenmem_add_to_physmap(struct domain ++extra.ppage;/* Check for continuation if it's not the last iteration. */ -if ( (++done >=ARRAY_SIZE (pages) && extra.ppage) || - (xatp->size > done &&hypercall_preempt_check ()) ) +if ( xatp->size > ++done && + ((done >=ARRAY_SIZE (pages) && extra.ppage) || +hypercall_preempt_check ()) ) { rc = start + done;break ;
Hi Jan,
Quoted 4 lines · Jan Beulich
Adjust so we uniformly avoid needlessly arranging for a continuation on the last iteration.
Fixes 5777a3742d88 ("IOMMU: hold page ref until after deferred TLB flush")
I view this patch as an optimization because there is nothing wrong with the code. So I think "Fixes" is not entirely suitable here.
Quoted 1 line
Signed-off-by Jan Beulich <[email protected]>
Other than my remark about the tag:
Cheers,
Quoted 16 lines
xen/common/memory.c +3
-2@@ -854,8 +854,9 @@ int xenmem_add_to_physmap(struct domain ++extra.ppage;/* Check for continuation if it's not the last iteration. */ -if ( (++done >=ARRAY_SIZE (pages) && extra.ppage) || - (xatp->size > done &&hypercall_preempt_check ()) ) +if ( xatp->size > ++done && + ((done >=ARRAY_SIZE (pages) && extra.ppage) || +hypercall_preempt_check ()) ) { rc = start + done;break ;
Signature · 1 line
Julien Grall
Quoted 8 lines · Julien Grall
Quoted 4 lines · Jan Beulich
Adjust so we uniformly avoid needlessly arranging for a continuation on the last iteration.
Fixes 5777a3742d88 ("IOMMU: hold page ref until after deferred TLB flush")I view this patch as an optimization because there is nothing wrong with the code. So I think "Fixes" is not entirely suitable here.
Well, yes, I think one can look at it both ways. The code was clearly worse than necessary, performance wise. We should have recognized this (as well as what had caused XSA-355) before XSA-346 was even predisclosed, and the code should never have been the way it is right now. So while it doesn't result in any malfunction (other than the XSA-355 issue), I still view it as a bug. But I can see that one may also view it differently.
Quoted 4 lines
Quoted 1 line
Signed-off-by Jan Beulich <[email protected]>Other than my remark about the tag:
Reviewed-by Julien Grall <[email protected]>
Thanks.
Jan