Two PV vNUMA patches
cover Two PV vNUMA patches
The first one is just cosmetic change. The second patch fixes a bug.
Wei Liu (2):
libxc: remove trailing newline in xc_dom_panic format string
libxc: fix PV vNUMA guest memory allocation
tools/libxc/xc_dom_x86.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/2 libxc: remove trailing newline in xc_dom_panic format string
xc_dom_panic prints more information after user supplied strings, so don't print a newline.
--- tools/libxc/xc_dom_x86.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/libxc/xc_dom_x86.c +3 -3
@@ -863,7 +863,7 @@ int arch_setup_meminit(struct xc_dom_image *dom)if ( total != dom->total_pages ) {xc_dom_panic (dom->xch,XC_INTERNAL_ERROR , -"%s: vNUMA page count mismatch (0x%" PRIpfn" != 0x%" PRIpfn")\n" , +"%s: vNUMA page count mismatch (0x%" PRIpfn" != 0x%" PRIpfn")" , __func__, total, dom->total_pages);return -EINVAL ; }
@@ -936,11 +936,11 @@ int arch_setup_meminit(struct xc_dom_image *dom) {if ( pnode !=XC_NUMA_NO_NODE )xc_dom_panic (dom->xch,XC_INTERNAL_ERROR , -"%s: failed to allocate 0x%" PRIx64" pages (v=%d, p=%d)\n" , +"%s: failed to allocate 0x%" PRIx64" pages (v=%d, p=%d)" , __func__, pages, i, pnode);else xc_dom_panic (dom->xch,XC_INTERNAL_ERROR , -"%s: failed to allocate 0x%" PRIx64" pages\n" , +"%s: failed to allocate 0x%" PRIx64" pages" , __func__, pages);return rc; }
Signature · 1 line
1.9.1
Re: [PATCH 1/2] libxc: remove trailing newline in xc_dom_panic format string
Quoted 5 lines · Wei Liu
xc_dom_panicprints more information after user supplied strings, so don't print a newline.Signed-off-by Wei Liu <[email protected]>
Reviewed by: Dario Faggioli <[email protected]>
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH 2/2 libxc: fix PV vNUMA guest memory allocation
In reply to Wei LiuIn 415b58c1 (tools/libxc: Batch memory allocations for PV guests) the number of super pages is calculated with the number of total pages. That is wrong. It breaks PV guest vNUMA. The correct number of super pages should be derived from the number of pages within that virtual NUMA node.
Also change the name and type of super page variable to match the naming convention and type of normal page variable. Make the necessary adjustment to make code compile.
---
Cc: Ross Lagerwall <[email protected]>
--- tools/libxc/xc_dom_x86.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
tools/libxc/xc_dom_x86.c +5 -5
@@ -879,9 +879,8 @@ int arch_setup_meminit(struct xc_dom_image *dom)for ( i =0 ; i < nr_vmemranges; i++ ) {unsigned int memflags; -uint64_t pages; +uint64_t pages, super_pages;unsigned int pnode = vnode_to_pnode[vmemranges[i].nid]; -int nr_spages = dom->total_pages >>SUPERPAGE_PFN_SHIFT ;xen_pfn_t extents[SUPERPAGE_BATCH_SIZE ];xen_pfn_t pfn_base_idx;
@@ -891,15 +890,16 @@ int arch_setup_meminit(struct xc_dom_image *dom) pages = (vmemranges[i].end - vmemranges[i].start) >>PAGE_SHIFT ; + super_pages = pages >>SUPERPAGE_PFN_SHIFT ; pfn_base = vmemranges[i].start >>PAGE_SHIFT ;for ( pfn = pfn_base; pfn < pfn_base+pages; pfn++ ) dom->p2m_host[pfn] = pfn; pfn_base_idx = pfn_base; -while (nr_spages) { -int count =min (nr_spages,SUPERPAGE_BATCH_SIZE ); - nr_spages -= count; +while (super_pages) { +int count =min_t (uint64_t, super_pages,SUPERPAGE_BATCH_SIZE ); + super_pages -= count; for ( pfn = pfn_base_idx, j = 0; pfn < pfn_base_idx + (count << SUPERPAGE_PFN_SHIFT);
Signature · 1 line
1.9.1
Re: [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation
Quoted 44 lines · Wei Liu
In
415b58c1(tools/libxc: Batch memory allocations for PV guests) the number of super pages is calculated with the number of total pages. That is wrong. It breaks PV guest vNUMA. The correct number of super pages should be derived from the number of pages within that virtual NUMA node.Also change the name and type of super page variable to match the naming convention and type of normal page variable. Make the necessary adjustment to make code compile.
Reported-by Dario Faggioli <[email protected]>Signed-off-by Wei Liu <[email protected]>---
Cc: Ross Lagerwall <[email protected]>--- tools/libxc/xc_dom_x86.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)tools/libxc/xc_dom_x86.c +2
-2@@ -879,9 +879,8 @@ int arch_setup_meminit(struct xc_dom_image *dom)for ( i =0 ; i < nr_vmemranges; i++ ) {unsigned int memflags; -uint64_t pages; +uint64_t pages, super_pages;unsigned int pnode = vnode_to_pnode[vmemranges[i].nid]; -int nr_spages = dom->total_pages >>SUPERPAGE_PFN_SHIFT ;xen_pfn_t extents[SUPERPAGE_BATCH_SIZE ];xen_pfn_t pfn_base_idx;@@ -891,15 +890,16 @@ int arch_setup_meminit(struct xc_dom_image *dom) pages = (vmemranges[i].end - vmemranges[i].start) >>PAGE_SHIFT ; + super_pages = pages >>SUPERPAGE_PFN_SHIFT ; pfn_base = vmemranges[i].start >>PAGE_SHIFT ;for ( pfn = pfn_base; pfn < pfn_base+pages; pfn++ ) dom->p2m_host[pfn] = pfn;
tools/libxc/xc_dom_x86.c int arch_setup_meminit(struct xc_dom_image *dom) · line 905
Quoted 10 lines
tools/libxc/xc_dom_x86.c +3
-3pfn_base_idx = pfn_base; -while (nr_spages) { -int count =min (nr_spages,SUPERPAGE_BATCH_SIZE ); - nr_spages -= count; +while (super_pages) { +int count =min_t (uint64_t, super_pages,SUPERPAGE_BATCH_SIZE ); + super_pages -= count; for ( pfn = pfn_base_idx, j = 0; pfn < pfn_base_idx + (count << SUPERPAGE_PFN_SHIFT);
Ah yes I forward-ported the patch from 4.5 and didn't test it with vNUMA.
Signature · 1 line
Ross Lagerwall
Re: [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation
In reply to Wei LiuQuoted 39 lines · Wei Liu
In
415b58c1(tools/libxc: Batch memory allocations for PV guests) the number of super pages is calculated with the number of total pages. That is wrong. It breaks PV guest vNUMA. The correct number of super pages should be derived from the number of pages within that virtual NUMA node.Also change the name and type of super page variable to match the naming convention and type of normal page variable. Make the necessary adjustment to make code compile.
Reported-by Dario Faggioli <[email protected]>Signed-off-by Wei Liu <[email protected]>---
Cc: Ross Lagerwall <[email protected]>--- tools/libxc/xc_dom_x86.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)tools/libxc/xc_dom_x86.c +2
-2@@ -879,9 +879,8 @@ int arch_setup_meminit(struct xc_dom_image *dom)for ( i =0 ; i < nr_vmemranges; i++ ) {unsigned int memflags; -uint64_t pages; +uint64_t pages, super_pages;unsigned int pnode = vnode_to_pnode[vmemranges[i].nid]; -int nr_spages = dom->total_pages >>SUPERPAGE_PFN_SHIFT ;xen_pfn_t extents[SUPERPAGE_BATCH_SIZE ];xen_pfn_t pfn_base_idx;@@ -891,15 +890,16 @@ int arch_setup_meminit(struct xc_dom_image *dom) pages = (vmemranges[i].end - vmemranges[i].start) >>PAGE_SHIFT ; + super_pages = pages >>SUPERPAGE_PFN_SHIFT ; pfn_base = vmemranges[i].start >>PAGE_SHIFT ;
tools/libxc/xc_dom_x86.c int arch_setup_meminit(struct xc_dom_image *dom) · line 901
Quoted 10 lines
tools/libxc/xc_dom_x86.c +2
-3for ( pfn = pfn_base; pfn < pfn_base+pages; pfn++ ) dom->p2m_host[pfn] = pfn; pfn_base_idx = pfn_base; -while (nr_spages) { -int count =min (nr_spages,SUPERPAGE_BATCH_SIZE ); - nr_spages -= count; +while (super_pages) { +int count =min_t (uint64_t, super_pages,SUPERPAGE_BATCH_SIZE );
This line alone indicates that int is not an appropriate type for count. unsigned int as as an absolute minimum, as it will be bounded to SUPERPAGE_BATCH_SIZE.
~Andrew
Quoted 4 lines
tools/libxc/xc_dom_x86.c +1
-0+ super_pages -= count; for ( pfn = pfn_base_idx, j = 0; pfn < pfn_base_idx + (count << SUPERPAGE_PFN_SHIFT);
Re: [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation
Quoted 44 lines · Andrew Cooper
Quoted 43 lines · Wei Liu
In
415b58c1(tools/libxc: Batch memory allocations for PV guests) the number of super pages is calculated with the number of total pages. That is wrong. It breaks PV guest vNUMA. The correct number of super pages should be derived from the number of pages within that virtual NUMA node.Also change the name and type of super page variable to match the naming convention and type of normal page variable. Make the necessary adjustment to make code compile.
Reported-by Dario Faggioli <[email protected]>Signed-off-by Wei Liu <[email protected]>---
Cc: Ross Lagerwall <[email protected]>--- tools/libxc/xc_dom_x86.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)tools/libxc/xc_dom_x86.c +2
-2@@ -879,9 +879,8 @@ int arch_setup_meminit(struct xc_dom_image *dom)for ( i =0 ; i < nr_vmemranges; i++ ) {unsigned int memflags; -uint64_t pages; +uint64_t pages, super_pages;unsigned int pnode = vnode_to_pnode[vmemranges[i].nid]; -int nr_spages = dom->total_pages >>SUPERPAGE_PFN_SHIFT ;xen_pfn_t extents[SUPERPAGE_BATCH_SIZE ];xen_pfn_t pfn_base_idx;@@ -891,15 +890,16 @@ int arch_setup_meminit(struct xc_dom_image *dom) pages = (vmemranges[i].end - vmemranges[i].start) >>PAGE_SHIFT ; + super_pages = pages >>SUPERPAGE_PFN_SHIFT ; pfn_base = vmemranges[i].start >>PAGE_SHIFT ;for ( pfn = pfn_base; pfn < pfn_base+pages; pfn++ ) dom->p2m_host[pfn] = pfn;
Quoted 11 lines
tools/libxc/xc_dom_x86.c int arch_setup_meminit(struct xc_dom_image *dom) · line 901
Quoted 6 lines
tools/libxc/xc_dom_x86.c +2
-3pfn_base_idx = pfn_base; -while (nr_spages) { -int count =min (nr_spages,SUPERPAGE_BATCH_SIZE ); - nr_spages -= count; +while (super_pages) { +int count =min_t (uint64_t, super_pages,SUPERPAGE_BATCH_SIZE );This line alone indicates that int is not an appropriate type for count. unsigned int as as an absolute minimum, as it will be bounded to
SUPERPAGE_BATCH_SIZE.
Yes, I also need to make count uint64_t.
Wei.
Quoted 6 lines
~Andrew
Quoted 4 lines
tools/libxc/xc_dom_x86.c +1
-0+ super_pages -= count; for ( pfn = pfn_base_idx, j = 0; pfn < pfn_base_idx + (count << SUPERPAGE_PFN_SHIFT);
Re: [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation
Quoted 57 lines · Wei Liu
Quoted 44 lines · Andrew Cooper
Quoted 43 lines · Wei Liu
In
415b58c1(tools/libxc: Batch memory allocations for PV guests) the number of super pages is calculated with the number of total pages. That is wrong. It breaks PV guest vNUMA. The correct number of super pages should be derived from the number of pages within that virtual NUMA node.Also change the name and type of super page variable to match the naming convention and type of normal page variable. Make the necessary adjustment to make code compile.
Reported-by Dario Faggioli <[email protected]>Signed-off-by Wei Liu <[email protected]>---
Cc: Ross Lagerwall <[email protected]>--- tools/libxc/xc_dom_x86.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)tools/libxc/xc_dom_x86.c +2
-2@@ -879,9 +879,8 @@ int arch_setup_meminit(struct xc_dom_image *dom)for ( i =0 ; i < nr_vmemranges; i++ ) {unsigned int memflags; -uint64_t pages; +uint64_t pages, super_pages;unsigned int pnode = vnode_to_pnode[vmemranges[i].nid]; -int nr_spages = dom->total_pages >>SUPERPAGE_PFN_SHIFT ;xen_pfn_t extents[SUPERPAGE_BATCH_SIZE ];xen_pfn_t pfn_base_idx;@@ -891,15 +890,16 @@ int arch_setup_meminit(struct xc_dom_image *dom) pages = (vmemranges[i].end - vmemranges[i].start) >>PAGE_SHIFT ; + super_pages = pages >>SUPERPAGE_PFN_SHIFT ; pfn_base = vmemranges[i].start >>PAGE_SHIFT ;for ( pfn = pfn_base; pfn < pfn_base+pages; pfn++ ) dom->p2m_host[pfn] = pfn;Quoted 11 lines
tools/libxc/xc_dom_x86.c int arch_setup_meminit(struct xc_dom_image *dom) · line 901
Quoted 6 lines
tools/libxc/xc_dom_x86.c +2
-3pfn_base_idx = pfn_base; -while (nr_spages) { -int count =min (nr_spages,SUPERPAGE_BATCH_SIZE ); - nr_spages -= count; +while (super_pages) { +int count =min_t (uint64_t, super_pages,SUPERPAGE_BATCH_SIZE );This line alone indicates that int is not an appropriate type for count. unsigned int as as an absolute minimum, as it will be bounded to
SUPERPAGE_BATCH_SIZE.
Quoted 2 lines
Yes, I also need to make count
uint64_t.
Is this needed? count should never be larger than 512 (aka SUPERPAGE_BATCH_SIZE).
Signature · 1 line
Ross Lagerwall
Re: [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation
Quoted 58 lines · Ross Lagerwall
Quoted 57 lines · Wei Liu
Quoted 55 lines · Andrew Cooper
Quoted 39 lines · Wei Liu
In
415b58c1(tools/libxc: Batch memory allocations for PV guests) the number of super pages is calculated with the number of total pages. That is wrong. It breaks PV guest vNUMA. The correct number of super pages should be derived from the number of pages within that virtual NUMA node.Also change the name and type of super page variable to match the naming convention and type of normal page variable. Make the necessary adjustment to make code compile.
Reported-by Dario Faggioli <[email protected]>Signed-off-by Wei Liu <[email protected]>---
Cc: Ross Lagerwall <[email protected]>--- tools/libxc/xc_dom_x86.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)tools/libxc/xc_dom_x86.c +2
-2@@ -879,9 +879,8 @@ int arch_setup_meminit(struct xc_dom_image *dom)for ( i =0 ; i < nr_vmemranges; i++ ) {unsigned int memflags; -uint64_t pages; +uint64_t pages, super_pages;unsigned int pnode = vnode_to_pnode[vmemranges[i].nid]; -int nr_spages = dom->total_pages >>SUPERPAGE_PFN_SHIFT ;xen_pfn_t extents[SUPERPAGE_BATCH_SIZE ];xen_pfn_t pfn_base_idx;@@ -891,15 +890,16 @@ int arch_setup_meminit(struct xc_dom_image *dom) pages = (vmemranges[i].end - vmemranges[i].start) >>PAGE_SHIFT ; + super_pages = pages >>SUPERPAGE_PFN_SHIFT ; pfn_base = vmemranges[i].start >>PAGE_SHIFT ;tools/libxc/xc_dom_x86.c int arch_setup_meminit(struct xc_dom_image *dom) · line 901
Quoted 10 lines
tools/libxc/xc_dom_x86.c +2
-3for ( pfn = pfn_base; pfn < pfn_base+pages; pfn++ ) dom->p2m_host[pfn] = pfn; pfn_base_idx = pfn_base; -while (nr_spages) { -int count =min (nr_spages,SUPERPAGE_BATCH_SIZE ); - nr_spages -= count; +while (super_pages) { +int count =min_t (uint64_t, super_pages,SUPERPAGE_BATCH_SIZE );This line alone indicates that int is not an appropriate type for count. unsigned int as as an absolute minimum, as it will be bounded to
SUPERPAGE_BATCH_SIZE.
Quoted 6 lines
Quoted 2 lines
Yes, I also need to make count
uint64_t.Is this needed? count should never be larger than 512 (aka
SUPERPAGE_BATCH_SIZE).
Maybe uint64_t is overkill but I want to be as consistent as possible.
Wei.
Quoted 2 lines
Signature · 1 line
Ross Lagerwall
PATCH v2 1/1 libxc: fix PV vNUMA guest memory allocation
In reply to Wei LiuIn 415b58c1 (tools/libxc: Batch memory allocations for PV guests) the number of super pages is calculated with the number of total pages. That is wrong. It breaks PV guest vNUMA. The correct number of super pages should be derived from the number of pages within that virtual NUMA node.
Also change the name and type of super page variable to match the naming convention and type of normal page variable. Make the necessary adjustment to make code compile.
---
v2: uint64_t for count variable for consistency, no functional changes wrt v1
so I retain the Reviewed-by tag.
--- tools/libxc/xc_dom_x86.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
tools/libxc/xc_dom_x86.c +6 -5
@@ -879,9 +879,8 @@ int arch_setup_meminit(struct xc_dom_image *dom)for ( i =0 ; i < nr_vmemranges; i++ ) {unsigned int memflags; -uint64_t pages; +uint64_t pages, super_pages;unsigned int pnode = vnode_to_pnode[vmemranges[i].nid]; -int nr_spages = dom->total_pages >>SUPERPAGE_PFN_SHIFT ;xen_pfn_t extents[SUPERPAGE_BATCH_SIZE ];xen_pfn_t pfn_base_idx;
@@ -891,15 +890,17 @@ int arch_setup_meminit(struct xc_dom_image *dom) pages = (vmemranges[i].end - vmemranges[i].start) >>PAGE_SHIFT ; + super_pages = pages >>SUPERPAGE_PFN_SHIFT ; pfn_base = vmemranges[i].start >>PAGE_SHIFT ;for ( pfn = pfn_base; pfn < pfn_base+pages; pfn++ ) dom->p2m_host[pfn] = pfn; pfn_base_idx = pfn_base; -while (nr_spages) { -int count =min (nr_spages,SUPERPAGE_BATCH_SIZE ); - nr_spages -= count; +while (super_pages) { +uint64_t count = +min_t (uint64_t, super_pages,SUPERPAGE_BATCH_SIZE ); + super_pages -= count; for ( pfn = pfn_base_idx, j = 0; pfn < pfn_base_idx + (count << SUPERPAGE_PFN_SHIFT);
Signature · 1 line
1.9.1
Re: [PATCH v2] libxc: fix PV vNUMA guest memory allocation
Quoted 10 lines · Wei Liu
In
415b58c1(tools/libxc: Batch memory allocations for PV guests) the number of super pages is calculated with the number of total pages. That is wrong. It breaks PV guest vNUMA. The correct number of super pages should be derived from the number of pages within that virtual NUMA node.Also change the name and type of super page variable to match the naming convention and type of normal page variable. Make the necessary adjustment to make code compile.
Quoted 8 lines
Reported-by Dario Faggioli <[email protected]>Signed-off-by Wei Liu <[email protected]>Reviewed-by Ross Lagerwall <[email protected]>---
v2:uint64_tfor count variable for consistency, no functional changes wrt v1
so I retain the Reviewed-by tag.
---
Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation
In reply to Wei LiuQuoted 6 lines · Wei Liu
In
415b58c1(tools/libxc: Batch memory allocations for PV guests) the number of super pages is calculated with the number of total pages. That is wrong. It breaks PV guest vNUMA. The correct number of super pages should be derived from the number of pages within that virtual NUMA node.
Quoted 7 lines
Also change the name and type of super page variable to match the naming convention and type of normal page variable. Make the necessary adjustment to make code compile.
Reported-by Dario Faggioli <[email protected]>Signed-off-by Wei Liu <[email protected]>
Thanks for looking at this so quickly.
I think I've understood that you're sending a v2, so I'll test that one.
Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 5 lines · Wei Liu
The first one is just cosmetic change. The second patch fixes a bug.
Wei Liu (2):
libxc: remove trailing newline inxc_dom_panicformat string
libxc: fix PV vNUMA guest memory allocation
Acked + applied (the v2 of the latter patch).