xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] memory: avoid pointless continuation in xenmem_add_to_physmap()
@ 2020-12-04 10:43 Jan Beulich
  2021-01-13 19:09 ` Julien Grall
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2020-12-04 10:43 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu

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")
Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -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;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] memory: avoid pointless continuation in xenmem_add_to_physmap()
  2020-12-04 10:43 [PATCH] memory: avoid pointless continuation in xenmem_add_to_physmap() Jan Beulich
@ 2021-01-13 19:09 ` Julien Grall
  2021-01-14  9:20   ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Julien Grall @ 2021-01-13 19:09 UTC (permalink / raw)
  To: Jan Beulich, xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini, Wei Liu

Hi Jan,

On 04/12/2020 10:43, Jan Beulich wrote:
> 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.

> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Other than my remark about the tag:

Reviewed-by: Julien Grall <jgrall@amazon.com>

Cheers,

> 
> --- a/xen/common/memory.c
> +++ b/xen/common/memory.c
> @@ -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;
> 

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] memory: avoid pointless continuation in xenmem_add_to_physmap()
  2021-01-13 19:09 ` Julien Grall
@ 2021-01-14  9:20   ` Jan Beulich
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Beulich @ 2021-01-14  9:20 UTC (permalink / raw)
  To: Julien Grall
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini,
	Wei Liu, xen-devel

On 13.01.2021 20:09, Julien Grall wrote:
> On 04/12/2020 10:43, Jan Beulich wrote:
>> 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.

>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> Other than my remark about the tag:
> 
> Reviewed-by: Julien Grall <jgrall@amazon.com>

Thanks.

Jan


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-14  9:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-04 10:43 [PATCH] memory: avoid pointless continuation in xenmem_add_to_physmap() Jan Beulich
2021-01-13 19:09 ` Julien Grall
2021-01-14  9:20   ` Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).