All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xen-devel] [PATCH] x86/shadow: fold p2m page accounting into sh_min_allocation()
@ 2019-09-05  8:34 Jan Beulich
  2019-09-06 11:27 ` Roger Pau Monné
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jan Beulich @ 2019-09-05  8:34 UTC (permalink / raw)
  To: xen-devel
  Cc: George Dunlap, Andrew Cooper, Tim Deegan, Wei Liu, Roger Pau Monné

This is to make the function live up to the promise its name makes. And
it simplifies all callers.

Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/mm/shadow/common.c
+++ b/xen/arch/x86/mm/shadow/common.c
@@ -1256,29 +1256,26 @@ static unsigned int sh_min_allocation(co
      * up of slot zero and an LAPIC page), plus one for HVM's 1-to-1 pagetable.
      */
     return shadow_min_acceptable_pages(d) +
-           max(d->tot_pages / 256,
-               is_hvm_domain(d) ? CONFIG_PAGING_LEVELS + 2 : 0U) +
-           is_hvm_domain(d);
+           max(max(d->tot_pages / 256,
+                   is_hvm_domain(d) ? CONFIG_PAGING_LEVELS + 2 : 0U) +
+               is_hvm_domain(d),
+               d->arch.paging.shadow.p2m_pages);
 }
 
 int shadow_set_allocation(struct domain *d, unsigned int pages, bool *preempted)
 {
     struct page_info *sp;
-    unsigned int lower_bound;
 
     ASSERT(paging_locked_by_me(d));
 
     if ( pages > 0 )
     {
         /* Check for minimum value. */
-        if ( pages < d->arch.paging.shadow.p2m_pages )
-            pages = 0;
-        else
-            pages -= d->arch.paging.shadow.p2m_pages;
+        unsigned int lower_bound = sh_min_allocation(d);
 
-        lower_bound = sh_min_allocation(d);
         if ( pages < lower_bound )
             pages = lower_bound;
+        pages -= d->arch.paging.shadow.p2m_pages;
     }
 
     SHADOW_PRINTK("current %i target %i\n",
@@ -2607,7 +2604,7 @@ int shadow_enable(struct domain *d, u32
 
     /* Init the shadow memory allocation if the user hasn't done so */
     old_pages = d->arch.paging.shadow.total_pages;
-    if ( old_pages < sh_min_allocation(d) + d->arch.paging.shadow.p2m_pages )
+    if ( old_pages < sh_min_allocation(d) )
     {
         paging_lock(d);
         rv = shadow_set_allocation(d, 1024, NULL); /* Use at least 4MB */
@@ -2864,8 +2861,7 @@ static int shadow_one_bit_enable(struct
 
     mode |= PG_SH_enable;
 
-    if ( d->arch.paging.shadow.total_pages <
-         sh_min_allocation(d) + d->arch.paging.shadow.p2m_pages )
+    if ( d->arch.paging.shadow.total_pages < sh_min_allocation(d) )
     {
         /* Init the shadow memory allocation if the user hasn't done so */
         if ( shadow_set_allocation(d, 1, NULL) != 0 )

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH] x86/shadow: fold p2m page accounting into sh_min_allocation()
  2019-09-05  8:34 [Xen-devel] [PATCH] x86/shadow: fold p2m page accounting into sh_min_allocation() Jan Beulich
@ 2019-09-06 11:27 ` Roger Pau Monné
  2019-09-06 12:14 ` Andrew Cooper
  2019-09-11  7:14 ` Tim Deegan
  2 siblings, 0 replies; 4+ messages in thread
From: Roger Pau Monné @ 2019-09-06 11:27 UTC (permalink / raw)
  To: Jan Beulich; +Cc: George Dunlap, xen-devel, Tim Deegan, Wei Liu, Andrew Cooper

On Thu, Sep 05, 2019 at 10:34:47AM +0200, Jan Beulich wrote:
> This is to make the function live up to the promise its name makes. And
> it simplifies all callers.
> 
> Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

Thanks.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH] x86/shadow: fold p2m page accounting into sh_min_allocation()
  2019-09-05  8:34 [Xen-devel] [PATCH] x86/shadow: fold p2m page accounting into sh_min_allocation() Jan Beulich
  2019-09-06 11:27 ` Roger Pau Monné
@ 2019-09-06 12:14 ` Andrew Cooper
  2019-09-11  7:14 ` Tim Deegan
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Cooper @ 2019-09-06 12:14 UTC (permalink / raw)
  To: Jan Beulich, xen-devel
  Cc: George Dunlap, Tim Deegan, Wei Liu, Roger Pau Monné

On 05/09/2019 09:34, Jan Beulich wrote:
> This is to make the function live up to the promise its name makes. And
> it simplifies all callers.
>
> Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>

I haven't looked at the calculations in detail, but from an end code
point of view, this is much better.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH] x86/shadow: fold p2m page accounting into sh_min_allocation()
  2019-09-05  8:34 [Xen-devel] [PATCH] x86/shadow: fold p2m page accounting into sh_min_allocation() Jan Beulich
  2019-09-06 11:27 ` Roger Pau Monné
  2019-09-06 12:14 ` Andrew Cooper
@ 2019-09-11  7:14 ` Tim Deegan
  2 siblings, 0 replies; 4+ messages in thread
From: Tim Deegan @ 2019-09-11  7:14 UTC (permalink / raw)
  To: Jan Beulich
  Cc: George Dunlap, xen-devel, Roger Pau Monné, Wei Liu, Andrew Cooper

At 10:34 +0200 on 05 Sep (1567679687), Jan Beulich wrote:
> This is to make the function live up to the promise its name makes. And
> it simplifies all callers.
> 
> Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Tim Deegan <tim@xen.org>


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

end of thread, other threads:[~2019-09-11  7:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-05  8:34 [Xen-devel] [PATCH] x86/shadow: fold p2m page accounting into sh_min_allocation() Jan Beulich
2019-09-06 11:27 ` Roger Pau Monné
2019-09-06 12:14 ` Andrew Cooper
2019-09-11  7:14 ` Tim Deegan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.