Skip to contentSkip to conversation

PVH dom0 memory setup

DISCUSSION Boris Ostrovsky 3 participants 5 messages Sep 8, 2017 – Sep 11, 2017

lore
Share & tools
lore
#0 lore raw

I am slightly confused by the use of 'need_paging' variable in dom0_compute_nr_pages().

Because paging_mode_hap() and iommu_hap_pt_share are (almost?) always true, we are not reducing available memory for PVH dom0 by page tables size. But then in pvh_setup_p2m() we do use this memory by paging_set_allocation(). And from what I've seen we then may run our of heap pages when populating memory map (in the 'for' loop below).

Am I not reading this correctly?

Thanks.
-boris

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#1 lore raw
Quoted 10 lines · Boris Ostrovsky

I am slightly confused by the use of 'need_paging' variable in dom0_compute_nr_pages().

Because paging_mode_hap() and iommu_hap_pt_share are (almost?) always true, we are not reducing available memory for PVH dom0 by page tables size. But then in pvh_setup_p2m() we do use this memory by paging_set_allocation(). And from what I've seen we then may run our of heap pages when populating memory map (in the 'for' loop below).

Am I not reading this correctly?

Yes, I think you are reading this correctly. dom0_compute_nr_pages should set need_paging if the domain type is hvm AFAICT, because hap also consumes memory for it's page tables. Do you have a reliable way to trigger this?

I was thinking of a fix along the lines of:

---8<---

xen/arch/x86/dom0_build.c +1 -2
index f616b99ddc..424192a7c4 100644
@@ -263,8 +263,7 @@ unsigned long __init dom0_compute_nr_pages(
             avail -= max_pdx >> s;
     }
 
-    need_paging = is_hvm_domain(d) &&
-        (!iommu_hap_pt_share || !paging_mode_hap(d));
+    need_paging = is_hvm_domain(d);
     for ( ; ; need_paging = false )
     {
         nr_pages = dom0_nrpages;

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw
Quoted 10 lines · Roger Pau Monné
Quoted 9 lines · Boris Ostrovsky

I am slightly confused by the use of 'need_paging' variable in dom0_compute_nr_pages().

Because paging_mode_hap() and iommu_hap_pt_share are (almost?) always true, we are not reducing available memory for PVH dom0 by page tables size. But then in pvh_setup_p2m() we do use this memory by paging_set_allocation(). And from what I've seen we then may run our of heap pages when populating memory map (in the 'for' loop below).

Quoted 7 lines
Quoted 1 line

Am I not reading this correctly?

Yes, I think you are reading this correctly. dom0_compute_nr_pages should set need_paging if the domain type is hvm AFAICT, because hap also consumes memory for it's page tables. Do you have a reliable way to trigger this?

I was thinking of a fix along the lines of:

Yes, this is essentially what I ended up doing and yes it does fix this problem.

I wasn't sure whether this would work for !HAP case (which we still support).

-boris

Quoted 8 lines

---8<---

xen/arch/x86/dom0_build.c +0 -0
index f616b99ddc..424192a7c4 100644

xen/arch/x86/dom0_build.c unsigned long __init dom0_compute_nr_pages( · line 269

Quoted 9 lines
xen/arch/x86/dom0_build.c +1 -2
@@ -263,8 +263,7 @@ unsigned long __init dom0_compute_nr_pages(
             avail -= max_pdx >> s;
     }
 
-    need_paging = is_hvm_domain(d) &&
-        (!iommu_hap_pt_share || !paging_mode_hap(d));
+    need_paging = is_hvm_domain(d);
     for ( ; ; need_paging = false )
     {
         nr_pages = dom0_nrpages;

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
Quoted 17 lines · Boris Ostrovsky
Quoted 16 lines · Roger Pau Monné
Quoted 10 lines · Boris Ostrovsky

I am slightly confused by the use of 'need_paging' variable in dom0_compute_nr_pages().

Because paging_mode_hap() and iommu_hap_pt_share are (almost?) always true, we are not reducing available memory for PVH dom0 by page tables size. But then in pvh_setup_p2m() we do use this memory by paging_set_allocation(). And from what I've seen we then may run our of heap pages when populating memory map (in the 'for' loop below).

Am I not reading this correctly?

Yes, I think you are reading this correctly. dom0_compute_nr_pages should set need_paging if the domain type is hvm AFAICT, because hap also consumes memory for it's page tables. Do you have a reliable way to trigger this?

Quoted 7 lines
Quoted 1 line

I was thinking of a fix along the lines of:

Yes, this is essentially what I ended up doing and yes it does fix this problem.

I wasn't sure whether this would work for !HAP case (which we still support).

It should work fine in both cases, but we should check whether the calculation of the reservation is done in the same way as libxl.

AFAICT even with the change proposed I don't think dom0_compute_nr_pages will handle the !iommu_hap_pt_share case properly (ie: I don't see specific memory for the IOMMU pages tables being reserved anywhere).

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 11.09.17 at 10:49, <[email protected]> wrote:

AFAICT even with the change proposed I don't think dom0_compute_nr_pages will handle the !iommu_hap_pt_share case properly (ie: I don't see specific memory for the IOMMU pages tables being reserved anywhere).

Which (sadly) is in line with what the tool stack does (or really fails to do), despite me having pointed this out a few times before.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel