Virtual NUMA for PV and HVM
v2 cover Virtual NUMA for PV and HVM
Hi all
This is version 2 of this series.
This patch series implements virtual NUMA support for both PV and HVM guest. That is, admin can configure via libxl what virtual NUMA topology the guest sees.
This is the stage 1 (basic vNUMA support) and part of stage 2 (vNUMA-ware ballooning, hypervisor side) described in my previous email to xen-devel [0].
This series is broken into several parts:
1. xen patches: vNUMA debug output and vNUMA-aware memory hypercall support.
2. libxc/libxl support for PV vNUMA.
3. libxc/libxl/hypervisor support for HVM vNUMA.
4. xl vNUMA configuration documentation and parser.
I think one significant difference from Elena's work is that this patch series makes use of multiple vmemranges should there be a memory hole, instead of shrinking ram. This matches the behaviour of real hardware.
The vNUMA auto placement algorithm is missing at the moment and Dario is working on it.
This series can be found at:
git://xenbits.xen.org/people/liuw/xen.git wip.vnuma-v2
With this series, the following configuration can be used to enabled virtual NUMA support, and it works for both PV and HVM guests.
memory = 6000vnuma_memory = [3000, 3000]vnuma_vcpu_map = [0, 1]vnuma_pnode_map = [0, 0]vnuma_vdistances = [ [10,30], [30,10] ]
For example output of guest NUMA information, please look at [1].
Wei.
[0] <[email protected]>
[1] <[email protected]>
Changes in v2:
1. Make vnuma_vdistances mandatory.
2. Use nested list to specify distances among nodes.
3. Hvmloader uses hypercall to retrieve vNUMA information.
4. Fix some problems spotted by Jan.
Wei Liu (19):
xen: dump vNUMA information with debug key "u"
xen: make two memory hypercalls vNUMA-aware
libxc: allocate memory with vNUMA information for PV guest
libxl: add emacs local variables in libxl_{x86,arm}.c
libxl: introduce vNUMA types
libxl: add vmemrange to libxl__domain_build_state
libxl: introduce libxl__vnuma_config_check
libxl: x86: factor out e820_host_sanitize
libxl: functions to build vmemranges for PV guest
libxl: build, check and pass vNUMA info to Xen for PV guest
xen: handle XENMEMF_get_vnumainfo in compat_memory_op
hvmloader: retrieve vNUMA information from hypervisor
hvmloader: construct SRAT
hvmloader: construct SLIT
libxc: allocate memory with vNUMA information for HVM guest
libxl: build, check and pass vNUMA info to Xen for HVM guest
libxl: disallow memory relocation when vNUMA is enabled
libxlutil: nested list support
xl: vNUMA support
docs/man/xl.cfg.pod.5 | 39 ++++++ tools/firmware/hvmloader/Makefile | 2 +- tools/firmware/hvmloader/acpi/acpi2_0.h | 61 +++++++++ tools/firmware/hvmloader/acpi/build.c | 109 +++++++++++++++ tools/firmware/hvmloader/hvmloader.c | 3 + tools/firmware/hvmloader/vnuma.c | 84 ++++++++++++ tools/firmware/hvmloader/vnuma.h | 56 ++++++++ tools/libxc/include/xc_dom.h | 5 + tools/libxc/include/xenguest.h | 7 + tools/libxc/xc_dom_x86.c | 72 ++++++++-- tools/libxc/xc_hvm_build_x86.c | 224 +++++++++++++++++++----------- tools/libxc/xc_private.h | 2 + tools/libxl/Makefile | 2 +- tools/libxl/libxl_arch.h | 6 + tools/libxl/libxl_arm.c | 17 +++ tools/libxl/libxl_create.c | 9 ++ tools/libxl/libxl_dm.c | 6 +- tools/libxl/libxl_dom.c | 99 ++++++++++++++ tools/libxl/libxl_internal.h | 18 +++ tools/libxl/libxl_types.idl | 9 ++ tools/libxl/libxl_vnuma.c | 228 +++++++++++++++++++++++++++++++ tools/libxl/libxl_x86.c | 113 +++++++++++++-- tools/libxl/libxlu_cfg.c | 180 ++++++++++++++---------- tools/libxl/libxlu_cfg_i.h | 15 +- tools/libxl/libxlu_cfg_y.c | 110 +++++++-------- tools/libxl/libxlu_cfg_y.h | 2 +- tools/libxl/libxlu_cfg_y.y | 19 ++- tools/libxl/libxlu_internal.h | 24 +++- tools/libxl/libxlutil.h | 11 +- tools/libxl/xl_cmdimpl.c | 147 ++++++++++++++++++++ xen/arch/x86/numa.c | 47 ++++++- xen/common/compat/memory.c | 38 ++++++ xen/common/kernel.c | 1 + xen/common/memory.c | 58 +++++++- xen/include/public/features.h | 3 + xen/include/public/memory.h | 2 + xen/include/xlat.lst | 2 + 37 files changed, 1568 insertions(+), 262 deletions(-) create mode 100644 tools/firmware/hvmloader/vnuma.c create mode 100644 tools/firmware/hvmloader/vnuma.h create mode 100644 tools/libxl/libxl_vnuma.c
Signature · 1 line
1.7.10.4
PATCH v2 1/19 xen: dump vNUMA information with debug key "u"
---
Changes in v2:
1. Use unsigned int for loop vars.
2. Use strlcpy.
3. Properly align output.
--- xen/arch/x86/numa.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-)
xen/arch/x86/numa.c +46 -1
@@ -363,10 +363,13 @@ EXPORT_SYMBOL(node_data);static void dump_numa (unsigned char key) {s_time_t now =NOW (); -int i; +unsigned int i, j, n; +int err;struct domain *d;struct page_info *page;unsigned int page_num_node[MAX_NUMNODES ]; +uint64_t mem; +struct vnuma_info *vnuma;printk ("'%c' pressed -> dumping numa info (now-0x%X:%08X)\n" , key, (u32)(now>>32 ), (u32 )now);
@@ -408,6 +411,48 @@ static void dump_numa(unsigned char key) for_each_online_node ( i ) printk(" Node %u: %u\n", i, page_num_node[i]); + +if ( !d->vnuma ) +continue ; + + vnuma = d->vnuma; +printk (" %u vnodes, %u vcpus:\n" , vnuma->nr_vnodes, d->max_vcpus); +for ( i =0 ; i < vnuma->nr_vnodes; i++ ) + { + err =snprintf (keyhandler_scratch,12 ,"%3u" , + vnuma->vnode_to_pnode[i]); +if ( err <0 || vnuma->vnode_to_pnode[i] ==NUMA_NO_NODE ) +strlcpy (keyhandler_scratch,"???" ,3 ); + +printk (" vnode %3u - pnode %s\n" , i, keyhandler_scratch); +for ( j =0 ; j < vnuma->nr_vmemranges; j++ ) + { +if ( vnuma->vmemrange[j].nid == i ) + { + mem = vnuma->vmemrange[j].end - vnuma->vmemrange[j].start; +printk ("%16" PRIu64" MB: %#016" PRIx64" - %#016" PRIx64"\n" , + mem >>20 , + vnuma->vmemrange[j].start, + vnuma->vmemrange[j].end); + } + } + +printk (" vcpus: " ); +for ( j =0 , n =0 ; j < d->max_vcpus; j++ ) + { +if ( vnuma->vcpu_to_vnode[j] == i ) + { +if ( (n +1 ) %8 ==0 ) +printk ("%3d\n" , j); +else if ( !(n %8 ) && n !=0 ) +printk ("%17d " , j); +else +printk ("%3d " , j); + n++; + } + } +printk ("\n" ); + } }rcu_read_unlock (&domlist_read_lock);
Signature · 1 line
1.7.10.4
Re: [PATCH v2 01/19] xen: dump vNUMA information with debug key "u"
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 01.12.14 at 16:33, <[email protected]> wrote:
xen/arch/x86/numa.c +0
-0@@ -363,10 +363,13 @@ EXPORT_SYMBOL(node_data);static void dump_numa (unsigned char key)
xen/arch/x86/numa.c EXPORT_SYMBOL(node_data); · line 372
Quoted 10 lines
xen/arch/x86/numa.c +4
-1{s_time_t now =NOW (); -int i; +unsigned int i, j, n; +int err;struct domain *d;struct page_info *page;unsigned int page_num_node[MAX_NUMNODES ]; +uint64_t mem; +struct vnuma_info *vnuma;
If this can be const, it should be in a pure dumping function.
Quoted 14 lines
xen/arch/x86/numa.c +10
-0@@ -408,6 +411,48 @@ static void dump_numa(unsigned char key) for_each_online_node ( i ) printk(" Node %u: %u\n", i, page_num_node[i]); + +if ( !d->vnuma ) +continue ; + + vnuma = d->vnuma; +printk (" %u vnodes, %u vcpus:\n" , vnuma->nr_vnodes, d->max_vcpus); +for ( i =0 ; i < vnuma->nr_vnodes; i++ ) + { + err =snprintf (keyhandler_scratch,12 ,"%3u" , + vnuma->vnode_to_pnode[i]);
xen/arch/x86/numa.c static void dump_numa(unsigned char key) · line 433
Quoted 10 lines
xen/arch/x86/numa.c +10
-0+if ( err <0 || vnuma->vnode_to_pnode[i] ==NUMA_NO_NODE ) +strlcpy (keyhandler_scratch,"???" ,3 ); + +printk (" vnode %3u - pnode %s\n" , i, keyhandler_scratch); +for ( j =0 ; j < vnuma->nr_vmemranges; j++ ) + { +if ( vnuma->vmemrange[j].nid == i ) + { + mem = vnuma->vmemrange[j].end - vnuma->vmemrange[j].start; + printk("%16"PRIu64" MB: %#016"PRIx64" - %#016"PRIx64"\n",
Am I misremembering that these were just "0x%"PRIx64 originally? I ask because converting to the 0-padded fixed width form makes no sense together with the # modifier. For these ranges I think it's quite obvious that the numbers are hex, so I'd suggest dropping the #s without replacement. And to be honest I'm also against printing duplicate information: The memory range already specifies how much memory this is.
Quoted 9 lines
xen/arch/x86/numa.c +9
-0+ mem >>20 , + vnuma->vmemrange[j].start, + vnuma->vmemrange[j].end); + } + } + +printk (" vcpus: " ); +for ( j =0 , n =0 ; j < d->max_vcpus; j++ ) + {
xen/arch/x86/numa.c static void dump_numa(unsigned char key) · line 452
Quoted 10 lines
xen/arch/x86/numa.c +10
-0+if ( vnuma->vcpu_to_vnode[j] == i ) + { +if ( (n +1 ) %8 ==0 ) +printk ("%3d\n" , j); +else if ( !(n %8 ) && n !=0 ) +printk ("%17d " , j); +else +printk ("%3d " , j); + n++; + }
Please consider very-many-vCPU guests here - see Andrew's commit 9cf71226 ("process softirqs while dumping domains").
Jan
Re: [PATCH v2 01/19] xen: dump vNUMA information with debug key "u"
On Mon, Dec 08, 2014 at 05:01:29PM +0000, Jan Beulich wrote:
[...]
Quoted 15 lines
Quoted 4 lines
xen/arch/x86/numa.c +4
-0+for ( i =0 ; i < vnuma->nr_vnodes; i++ ) + { + err =snprintf (keyhandler_scratch,12 ,"%3u" , + vnuma->vnode_to_pnode[i]);xen/arch/x86/numa.c static void dump_numa(unsigned char key) · line 433
Quoted 10 lines
xen/arch/x86/numa.c +10
-0+if ( err <0 || vnuma->vnode_to_pnode[i] ==NUMA_NO_NODE ) +strlcpy (keyhandler_scratch,"???" ,3 ); + +printk (" vnode %3u - pnode %s\n" , i, keyhandler_scratch); +for ( j =0 ; j < vnuma->nr_vmemranges; j++ ) + { +if ( vnuma->vmemrange[j].nid == i ) + { + mem = vnuma->vmemrange[j].end - vnuma->vmemrange[j].start; + printk("%16"PRIu64" MB: %#016"PRIx64" - %#016"PRIx64"\n",
Quoted 1 line
Am I misremembering that these were just "0x%"PRIx64 originally?
Yes.
Quoted 2 lines
I ask because converting to the 0-padded fixed width form makes no sense together with the # modifier. For these ranges I think it's
OK.
Quoted 5 lines
quite obvious that the numbers are hex, so I'd suggest dropping the #s without replacement. And to be honest I'm also against printing duplicate information: The memory range already specifies how much memory this is.
Is this what you want?
+ if ( vnuma->vmemrange[j].nid == i )
+ {
+ printk(" %016"PRIx64" - %016"PRIx64"\n",
+ vnuma->vmemrange[j].start,
+ vnuma->vmemrange[j].end);
+ }
And it prints out something like:
(XEN) 2 vnodes, 2 vcpus:
(XEN) vnode 0 - pnode 0
(XEN) 0000000000000000 - 00000000bb800000
(XEN) vcpus: 0
Wei.
Re: [PATCH v2 01/19] xen: dump vNUMA information with debug key "u"
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 09.12.14 at 12:22, <[email protected]> wrote:
Is this what you want?
xen/arch/x86/numa.c +6
-0+if ( vnuma->vmemrange[j].nid == i ) + { +printk (" %016" PRIx64" - %016" PRIx64"\n" , + vnuma->vmemrange[j].start, + vnuma->vmemrange[j].end); + }
Quoted 6 lines
And it prints out something like:
(XEN) 2 vnodes, 2 vcpus:
(XEN) vnode 0 - pnode 0
(XEN) 0000000000000000 -00000000bb800000
(XEN) vcpus: 0
This looks fine, yes.
Jan
PATCH v2 2/19 xen: make two memory hypercalls vNUMA-aware
In reply to Wei LiuMake XENMEM_increase_reservation and XENMEM_populate_physmap vNUMA-aware.
That is, if guest requests Xen to allocate memory for specific vnode, Xen can translate vnode to pnode using vNUMA information of that guest.
XENMEMF_vnode is introduced for the guest to mark the node number is in fact virtual node number and should be translated by Xen.
XENFEAT_memory_op_vnode_supported is introduced to indicate that Xen is able to translate virtual node to physical node.
---
Changes in v2:
1. Return start_extent when vnode translation fails.
2. Expose new feature bit to guest.
3. Fix typo in comment.
--- xen/common/kernel.c | 1 + xen/common/memory.c | 58 ++++++++++++++++++++++++++++++++++++++--- xen/include/public/features.h | 3 +++ xen/include/public/memory.h | 2 ++ 4 files changed, 60 insertions(+), 4 deletions(-)
xen/common/kernel.c +1 -0
@@ -302,6 +302,7 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) {case 0 : fi.submap =0 ; + fi.submap |= (1U << XENFEAT_memory_op_vnode_supported);if (VM_ASSIST (d, VMASST_TYPE_pae_extended_cr3) ) fi.submap |= (1U << XENFEAT_pae_pgdir_above_4gb);if (paging_mode_translate (current->domain) )
xen/common/memory.c +54 -4
76 lines not on this page · raw message
xen/include/public/features.h +3 -0
@@ -99,6 +99,9 @@#define XENFEAT_grant_map_identity 12 */ +/* Guest can use XENMEMF_vnode to specify virtual node for memory op. */ +#define XENFEAT_memory_op_vnode_supported 13 +#define XENFEAT_NR_SUBMAPS 1#endif /* __XEN_PUBLIC_FEATURES_H__ */
xen/include/public/memory.h +2 -0
@@ -55,6 +55,8 @@/* Flag to request allocation only from the node specified */ #define XENMEMF_exact_node_request (1<<17)#define XENMEMF_exact_node (n) (XENMEMF_node(n) | XENMEMF_exact_node_request) +/* Flag to indicate the node specified is virtual node */ +#define XENMEMF_vnode (1<<18)#endif struct xen_memory_reservation {
Signature · 1 line
1.7.10.4
Re: [PATCH v2 02/19] xen: make two memory hypercalls vNUMA-aware
xen/common/kernel.c DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) · line 305
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 01.12.14 at 16:33, <[email protected]> wrote:
xen/common/kernel.c +1
-0@@ -302,6 +302,7 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) {case 0 : fi.submap =0 ; + fi.submap |= (1U << XENFEAT_memory_op_vnode_supported);
Why don't you just replace the assignment above?
Quoted 4 lines
xen/common/memory.c +0
-0@@ -692,6 +692,49 @@ out:return rc;
xen/common/memory.c out: · line 702
Quoted 10 lines
xen/common/memory.c +8
-0} +static int translate_vnode_to_pnode (struct domain *d, +struct xen_memory_reservation *r, +struct memop_args *a) +{ +int rc =0 ; +unsigned int vnode, pnode; + +/* Note: we don't strictly require non-supported bits set to zero,
Coding style.
With these fixed,
PATCH v2 3/19 libxc: allocate memory with vNUMA information for PV guest
In reply to Wei Liu--- tools/libxc/include/xc_dom.h | 5 +++ tools/libxc/xc_dom_x86.c | 72 +++++++++++++++++++++++++++++++++++------- tools/libxc/xc_private.h | 2 ++ 3 files changed, 68 insertions(+), 11 deletions(-)
tools/libxc/include/xc_dom.h +5 -0
@@ -167,6 +167,11 @@ struct xc_dom_image {struct xc_dom_loader *kernel_loader;void *private_loader; +/* vNUMA information */ +unsigned int *vnode_to_pnode; +uint64_t *vnode_size; +unsigned int nr_vnodes; +/* kernel loader */ struct xc_dom_arch *arch_hooks;/* allocate up to virt_alloc_end */
tools/libxc/xc_dom_x86.c +61 -11
86 lines not on this page · raw message
tools/libxc/xc_private.h +2 -0
@@ -35,6 +35,8 @@#include <xen/sys/privcmd.h> +#define XC_VNUMA_NO_NODE (~0U) +#if defined(HAVE_VALGRIND_MEMCHECK_H ) && !defined(NDEBUG ) && !defined(__MINIOS__)/* Compile in Valgrind client requests? */ #include <valgrind/memcheck.h>
Signature · 1 line
1.7.10.4
Re: [PATCH v2 03/19] libxc: allocate memory with vNUMA information for PV guest
On Mon, 2014-12-01 at 15:33 +0000, Wei Liu wrote:
No longer description of what is going on? Or at least comments on what the new fields mean. (I figure two of them form an array mapping v to p, I'm not sure what the other one is...)
Quoted 44 lines
Signed-off-by Wei Liu <[email protected]>Cc Ian Campbell <[email protected]>Cc Ian Jackson <[email protected]>Cc Dario Faggioli <[email protected]>Cc Elena Ufimtseva <[email protected]>--- tools/libxc/include/xc_dom.h | 5 +++ tools/libxc/xc_dom_x86.c | 72 +++++++++++++++++++++++++++++++++++------- tools/libxc/xc_private.h | 2 ++ 3 files changed, 68 insertions(+), 11 deletions(-)tools/libxc/include/xc_dom.h +5
-0@@ -167,6 +167,11 @@ struct xc_dom_image {struct xc_dom_loader *kernel_loader;void *private_loader; +/* vNUMA information */ +unsigned int *vnode_to_pnode; +uint64_t *vnode_size; +unsigned int nr_vnodes; +/* kernel loader */ struct xc_dom_arch *arch_hooks;/* allocate up to virt_alloc_end */ tools/libxc/xc_dom_x86.c +2
-1@@ -759,7 +759,8 @@ static int x86_shadow(xc_interface *xch, domid_t domid)int arch_setup_meminit (struct xc_dom_image *dom) {int rc; -xen_pfn_t pfn, allocsz, i, j, mfn; +xen_pfn_t pfn, allocsz, mfn, total, pfn_base; +int i, j; rc =x86_compat (dom->xch, dom->guest_domid, dom->guest_type);if ( rc )@@ -811,18 +812,67 @@ int arch_setup_meminit(struct xc_dom_image *dom)/* setup initial p2m */ for ( pfn =0 ; pfn < dom->total_pages; pfn++ )
tools/libxc/xc_dom_x86.c int arch_setup_meminit(struct xc_dom_image *dom) · line 822
Quoted 10 lines
tools/libxc/xc_dom_x86.c +8
-1dom->p2m_host[pfn] = pfn; - + +/* setup dummy vNUMA information if it's not provided */ +if ( dom->nr_vnodes ==0 ) + { + dom->nr_vnodes =1 ; + dom->vnode_to_pnode =xc_dom_malloc (dom, +sizeof (*dom->vnode_to_pnode)); + dom->vnode_to_pnode[0 ] =XC_VNUMA_NO_NODE ;
Does this indicate there is no vnode 0, or that vnode 0 maps to an arbitrary (but unknown) pnode?
tools/libxc/xc_dom_x86.c int arch_setup_meminit(struct xc_dom_image *dom) · line 823
Quoted 1 line
tools/libxc/xc_dom_x86.c +1
-0+ dom->vnode_size =xc_dom_malloc (dom,sizeof (*dom->vnode_size));
Might as well to &dummy_foo, which is an on stack thing of the right dummy type.
tools/libxc/xc_dom_x86.c int arch_setup_meminit(struct xc_dom_image *dom) · line 824
Quoted 1 line
tools/libxc/xc_dom_x86.c +1
-0+ dom->vnode_size[0 ] = ((dom->total_pages <<PAGE_SHIFT ) >>20 );
One unnecessary set of ()s
tools/libxc/xc_dom_x86.c int arch_setup_meminit(struct xc_dom_image *dom) · line 833
Quoted 9 lines
tools/libxc/xc_dom_x86.c +9
-0+ } + + total =0 ; +for ( i =0 ; i < dom->nr_vnodes; i++ ) + total += ((dom->vnode_size[i] <<20 ) >>PAGE_SHIFT ); +if ( total != dom->total_pages ) + { + xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, + "%s: number of pages requested by vNUMA (0x%"PRIpfn") mismatches number of pages configured for domain (0x%"PRIpfn")\n",
Can you formulate a terser message and avoid the long line?
Perhaps "vNUMA page count mismatch 0x%PRIpfn != 0x%PRIpfn" conveys all the useful bits?
Alternatively what if we were to mandate that dom->total_pages must be set to zero by the caller iff they are passing nr_vnodes != 0? Then calculate total_pages internally.
Might have too many knockon effects on callers?
Quoted 34 lines
tools/libxc/xc_dom_x86.c +23
-9+ __FUNCTION__, total, dom->total_pages); +return -EINVAL ; + } +/* allocate guest memory */ -for ( i = rc = allocsz =0 ; - (i < dom->total_pages) && !rc; - i += allocsz ) + pfn_base =0 ; +for ( i =0 ; i < dom->nr_vnodes; i++ ) { - allocsz = dom->total_pages - i; -if ( allocsz >1024 *1024 ) - allocsz =1024 *1024 ; - rc =xc_domain_populate_physmap_exact ( - dom->xch, dom->guest_domid, allocsz, -0 ,0 , &dom->p2m_host[i]); +unsigned int memflags; +uint64_t pages; + + memflags =0 ; +if ( dom->vnode_to_pnode[i] !=XC_VNUMA_NO_NODE ) + { + memflags |=XENMEMF_exact_node (dom->vnode_to_pnode[i]); + memflags |= XENMEMF_exact_node_request; + } + + pages = (dom->vnode_size[i] <<20 ) >>PAGE_SHIFT ; + +for ( j =0 ; j < pages; j += allocsz ) + { + allocsz = pages - j; +if ( allocsz >1024 *1024 ) + allocsz =1024 *1024 ;
tools/libxc/xc_dom_x86.c int arch_setup_meminit(struct xc_dom_image *dom) · line 868
Quoted 10 lines
tools/libxc/xc_dom_x86.c +10
-0+ + rc =xc_domain_populate_physmap_exact (dom->xch, + dom->guest_domid, allocsz,0 , memflags, + &dom->p2m_host[pfn_base+j]); + +if ( rc ) + { +if ( dom->vnode_to_pnode[i] !=XC_VNUMA_NO_NODE ) + xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, + "%s: fail to allocate 0x%"PRIx64" pages for vnode %d on pnode %d out of 0x%"PRIpfn"\n",
"vNUMA: failed to allocate 0x%"PRIx64"/0x%"PRIx64" pages (v=%d, p=%d)."?
Ian.
PATCH v2 4/19 libxl: add emacs local variables in libxl_{x86, arm}.c
In reply to Wei Liu--- tools/libxl/libxl_arm.c | 8 ++++++++ tools/libxl/libxl_x86.c | 8 ++++++++ 2 files changed, 16 insertions(+)
tools/libxl/libxl_arm.c +8 -0
@@ -706,3 +706,11 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc,return 0 ; } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_x86.c +8 -0
@@ -324,3 +324,11 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc, {return 0 ; } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
1.7.10.4
Re: [PATCH v2 04/19] libxl: add emacs local variables in libxl_{x86, arm}.c
Quoted 5 lines · Wei Liu
Signed-off-by Wei Liu <[email protected]>Cc Ian Campbell <[email protected]>Cc Ian Jackson <[email protected]>Cc Dario Faggioli <[email protected]>Cc Elena Ufimtseva <[email protected]>
Acked + applied.
PATCH v2 5/19 libxl: introduce vNUMA types
In reply to Wei Liu--- tools/libxl/libxl_types.idl | 9 +++++++++ 1 file changed, 9 insertions(+)
tools/libxl/libxl_types.idl +9 -0
@@ -353,6 +353,13 @@ libxl_domain_sched_params = Struct("domain_sched_params",[ ("budget", integer, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_BUDGET_DEFAULT'}), ]) +libxl_vnode_info = Struct("vnode_info", [ + ("mem", uint64), # memory size of this node, in MiB + ("distances", Array(uint32, "num_distances")), # distances from this node to other nodes + ("pnode", uint32), # physical node of this node + ("vcpus", libxl_bitmap), # vcpus in this node + ]) + libxl_domain_build_info = Struct("domain_build_info",[ ("max_vcpus", integer), ("avail_vcpus", libxl_bitmap),
@@ -373,6 +380,8 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("disable_migrate", libxl_defbool), ("cpuid", libxl_cpuid_policy_list), ("blkdev_start", string), + + ("vnuma_nodes", Array(libxl_vnode_info, "num_vnuma_nodes")), ("device_model_version", libxl_device_model_version), ("device_model_stubdomain", libxl_defbool),
Signature · 1 line
1.7.10.4
Re: [PATCH v2 05/19] libxl: introduce vNUMA types
On Mon, 2014-12-01 at 15:33 +0000, Wei Liu wrote:
Looking ahead a few patches I see a disturbing trend to include little or no commit message in this series. I also see no overview of what the design for vnuma at the libxl level is going to look like, just a bunch of moving parts in isolation, which are rather hard to review.
Please can you flesh out the descriptions of these patches, and maybe take a look at the series structure. e.g. I'm not sure why the next patch "libxl: add vmemrange to libxl__domain_build_state" needs to be alone, instead of adding the struct field in the patch which adds support for the field.
Ian.
Re: [PATCH v2 05/19] libxl: introduce vNUMA types
Quoted 7 lines · Ian Campbell
On Mon, 2014-12-01 at 15:33 +0000, Wei Liu wrote:
Looking ahead a few patches I see a disturbing trend to include little or no commit message in this series. I also see no overview of what the design for vnuma at the libxl level is going to look like, just a bunch of moving parts in isolation, which are rather hard to review.
Quoted 6 lines
Please can you flesh out the descriptions of these patches, and maybe take a look at the series structure. e.g. I'm not sure why the next patch "libxl: add vmemrange to
libxl__domain_build_state" needs to be alone, instead of adding the struct field in the patch which adds support for the field.
I will provide more information and resend.
Wei.
Quoted 1 line
Ian.
Re: [PATCH v2 05/19] libxl: introduce vNUMA types
Quoted 8 lines · Wei Liu
Quoted 7 lines · Ian Campbell
On Mon, 2014-12-01 at 15:33 +0000, Wei Liu wrote:
Looking ahead a few patches I see a disturbing trend to include little or no commit message in this series. I also see no overview of what the design for vnuma at the libxl level is going to look like, just a bunch of moving parts in isolation, which are rather hard to review.
Quoted 8 lines
Quoted 6 lines
Please can you flesh out the descriptions of these patches, and maybe take a look at the series structure. e.g. I'm not sure why the next patch "libxl: add vmemrange to
libxl__domain_build_state" needs to be alone, instead of adding the struct field in the patch which adds support for the field.I will provide more information and resend.
Thanks.
PATCH v2 6/19 libxl: add vmemrange to libxl__domain_build_state
In reply to Wei LiuCurrently we haven't exported vmemrange interface to libxl user. Vmemranges are generated during domain build.
--- tools/libxl/libxl_internal.h | 3 +++ 1 file changed, 3 insertions(+)
tools/libxl/libxl_internal.h +3 -0
@@ -971,6 +971,9 @@ typedef struct {libxl__file_reference pv_ramdisk;const char * pv_cmdline;bool pvh_enabled; + +xen_vmemrange_t *vmemranges; +uint32_t num_vmemranges; } libxl__domain_build_state; _hidden int libxl__build_pre(libxl__gc *gc, uint32_t domid,
Signature · 1 line
1.7.10.4
PATCH v2 7/19 libxl: introduce libxl__vnuma_config_check
In reply to Wei LiuThis vNUMA function (and future ones) is placed in a new file called libxl_vnuma.c
--- tools/libxl/Makefile | 2 +- tools/libxl/libxl_internal.h | 5 ++ tools/libxl/libxl_vnuma.c | 138 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 tools/libxl/libxl_vnuma.c
tools/libxl/Makefile +1 -1
@@ -93,7 +93,7 @@ LIBXL_LIBS += -lyajl LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \ libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o \ libxl_internal.o libxl_utils.o libxl_uuid.o \ - libxl_json.o libxl_aoutils.o libxl_numa.o \ + libxl_json.o libxl_aoutils.o libxl_numa.o libxl_vnuma.o \ libxl_save_callout.o _libxl_save_msgs_callout.o \ libxl_qmp.o libxl_event.o libxl_fork.o $(LIBXL_OBJS-y) LIBXL_OBJS += libxl_genid.o
tools/libxl/libxl_internal.h +5 -0
@@ -3392,6 +3392,11 @@ void libxl__numa_candidate_put_nodemap(libxl__gc *gc,libxl_bitmap_copy (CTX , &cndt->nodemap, nodemap); } +/* Check if vNUMA config is valid. Returns 0 if valid. */ +int libxl__vnuma_config_check (libxl__gc *gc, +const libxl_domain_build_info *b_info, +const libxl__domain_build_state *state); + _hidden int libxl__ms_vm_genid_set(libxl__gc *gc, uint32_t domid,const libxl_ms_vm_genid *id);
tools/libxl/libxl_vnuma.c new file +138 -0
138 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v2 8/19 libxl: x86: factor out e820_host_sanitize
In reply to Wei LiuThis function gets the machine E820 map and sanitize it according to PV guest configuration.
This will be used in later patch.
--- tools/libxl/libxl_x86.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-)
tools/libxl/libxl_x86.c +22 -9
@@ -207,6 +207,27 @@ static int e820_sanitize(libxl_ctx *ctx, struct e820entry src[],return 0 ; } +static int e820_host_sanitize (libxl__gc *gc, +libxl_domain_build_info *b_info, +struct e820entry map[], +uint32_t *nr) +{ +int rc; + + rc =xc_get_machine_memory_map (CTX ->xch, map,E820MAX ); +if (rc <0 ) { + errno = rc; +return ERROR_FAIL ; + } + + *nr = rc; + + rc =e820_sanitize (CTX , map, nr, b_info->target_memkb, + (b_info->max_memkb - b_info->target_memkb) + + b_info->u.pv.slack_memkb); +return rc; +} +static int libxl__e820_alloc (libxl__gc *gc,uint32_t domid,libxl_domain_config *d_config) {
@@ -223,15 +244,7 @@ static int libxl__e820_alloc(libxl__gc *gc, uint32_t domid,if (!libxl_defbool_val (b_info->u.pv.e820_host))return ERROR_INVAL ; - rc =xc_get_machine_memory_map (ctx->xch, map,E820MAX ); -if (rc <0 ) { - errno = rc; -return ERROR_FAIL ; - } - nr = rc; - rc =e820_sanitize (ctx, map, &nr, b_info->target_memkb, - (b_info->max_memkb - b_info->target_memkb) + - b_info->u.pv.slack_memkb); + rc =e820_host_sanitize (gc, b_info, map, &nr);if (rc)return ERROR_FAIL ;
Signature · 1 line
1.7.10.4
PATCH v2 9/19 libxl: functions to build vmemranges for PV guest
In reply to Wei LiuOne vmemrange is generated for each vnode. And for those guests who care about machine E820 map, vmemranges are further split to accommodate memory holes.
--- tools/libxl/libxl_arch.h | 6 ++++ tools/libxl/libxl_arm.c | 9 +++++ tools/libxl/libxl_internal.h | 5 +++ tools/libxl/libxl_vnuma.c | 34 +++++++++++++++++++ tools/libxl/libxl_x86.c | 74 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 128 insertions(+)
tools/libxl/libxl_arch.h +6 -0
@@ -27,4 +27,10 @@ int libxl__arch_domain_init_hw_description(libxl__gc *gc,int libxl__arch_domain_finalise_hw_description (libxl__gc *gc,libxl_domain_build_info *info,struct xc_dom_image *dom); + +/* build vNUMA vmemrange with arch specific information */ +int libxl__arch_vnuma_build_vmemrange (libxl__gc *gc, +uint32_t domid, +libxl_domain_build_info *b_info, +libxl__domain_build_state *state);#endif
tools/libxl/libxl_arm.c +9 -0
@@ -707,6 +707,15 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc,return 0 ; } +int libxl__arch_vnuma_build_vmemrange (libxl__gc *gc, +uint32_t domid, +libxl_domain_build_info *info, +libxl__domain_build_state *state) +{ +/* Don't touch anything. */ +return 0 ; +} +/* * Local variables: * mode: C
tools/libxl/libxl_internal.h +5 -0
@@ -3397,6 +3397,11 @@ int libxl__vnuma_config_check(libxl__gc *gc,const libxl_domain_build_info *b_info, const libxl__domain_build_state *state); +int libxl__vnuma_build_vmemrange_pv (libxl__gc *gc, +uint32_t domid, +libxl_domain_build_info *b_info, +libxl__domain_build_state *state); + _hidden int libxl__ms_vm_genid_set(libxl__gc *gc, uint32_t domid,const libxl_ms_vm_genid *id);
tools/libxl/libxl_vnuma.c +34 -0
@@ -14,6 +14,7 @@*/ #include "libxl_osdeps.h" /* must come before any other headers */ #include "libxl_internal.h" +#include "libxl_arch.h" #include <stdlib.h> /* Sort vmemranges in ascending order with "start" */
@@ -129,6 +130,39 @@ out:return rc; } +/* Build vmemranges for PV guest */ +int libxl__vnuma_build_vmemrange_pv (libxl__gc *gc, +uint32_t domid, +libxl_domain_build_info *b_info, +libxl__domain_build_state *state) +{ +int i; +uint64_t next; +xen_vmemrange_t *v =NULL ; + +assert (state->vmemranges ==NULL ); + +/* Generate one vmemrange for each virtual node. */ + next =0 ; +for (i =0 ; i < b_info->num_vnuma_nodes; i++) { +libxl_vnode_info *p = &b_info->vnuma_nodes[i]; + + v =libxl__realloc (gc, v,sizeof (*v) * (i+1 )); + + v[i].start = next; + v[i].end = next + (p->mem <<20 );/* mem is in MiB */ + v[i].flags =0 ; + v[i].nid = i; + + next = v[i].end; + } + + state->vmemranges = v; + state->num_vmemranges = i; + +return libxl__arch_vnuma_build_vmemrange (gc, domid, b_info, state); +} +/* * Local variables: * mode: C
tools/libxl/libxl_x86.c +74 -0
80 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v2 10/19 libxl: build, check and pass vNUMA info to Xen for PV guest
In reply to Wei Liu--- tools/libxl/libxl_dom.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+)
tools/libxl/libxl_dom.c +71 -0
@@ -512,6 +512,51 @@ retry_transaction:return 0 ; } +static int set_vnuma_info (libxl__gc *gc,uint32_t domid, +const libxl_domain_build_info *info, +const libxl__domain_build_state *state) +{ +int rc =0 ; +int i, nr_vdistance; +unsigned int *vcpu_to_vnode, *vnode_to_pnode, *vdistance =NULL ; + + vcpu_to_vnode =libxl__calloc (gc, info->max_vcpus, +sizeof (unsigned int )); + vnode_to_pnode =libxl__calloc (gc, info->num_vnuma_nodes, +sizeof (unsigned int )); + + nr_vdistance = info->num_vnuma_nodes * info->num_vnuma_nodes; + vdistance =libxl__calloc (gc, nr_vdistance,sizeof (unsigned int )); + +for (i =0 ; i < info->num_vnuma_nodes; i++) { +libxl_vnode_info *v = &info->vnuma_nodes[i]; +int bit; + +/* vnode to pnode mapping */ + vnode_to_pnode[i] = v->pnode; + +/* vcpu to vnode mapping */ +libxl_for_each_set_bit (bit, v->vcpus) + vcpu_to_vnode[bit] = i; + +/* node distances */ +assert (info->num_vnuma_nodes == v->num_distances); +memcpy (vdistance + (i * info->num_vnuma_nodes), + v->distances, + v->num_distances *sizeof (unsigned int )); + } + +if (xc_domain_setvnuma (CTX ->xch, domid, info->num_vnuma_nodes, + state->num_vmemranges, info->max_vcpus, + state->vmemranges, vdistance, + vcpu_to_vnode, vnode_to_pnode) <0 ) { +LOGE (ERROR ,"xc_domain_setvnuma failed" ); + rc =ERROR_FAIL ; + } + +return rc; +} +int libxl__build_pv (libxl__gc *gc,uint32_t domid,libxl_domain_build_info *info,libxl__domain_build_state *state) {
@@ -569,6 +614,32 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid, dom->xenstore_domid = state->store_domid; dom->claim_enabled =libxl_defbool_val (info->claim_mode); +if (info->num_vnuma_nodes !=0 ) { +int i; + + ret =libxl__vnuma_build_vmemrange_pv (gc, domid, info, state); +if (ret) { +LOGE (ERROR ,"cannot build vmemranges" ); + goto out; + } + ret =libxl__vnuma_config_check (gc, info, state); +if (ret) goto out; + + ret =set_vnuma_info (gc, domid, info, state); +if (ret) goto out; + + dom->nr_vnodes = info->num_vnuma_nodes; + dom->vnode_to_pnode =xc_dom_malloc (dom,sizeof (*dom->vnode_to_pnode) * + dom->nr_vnodes); + dom->vnode_size =xc_dom_malloc (dom,sizeof (*dom->vnode_size) * + dom->nr_vnodes); + +for (i =0 ; i < dom->nr_vnodes; i++) { + dom->vnode_to_pnode[i] = info->vnuma_nodes[i].pnode; + dom->vnode_size[i] = info->vnuma_nodes[i].mem; + } + } +if ( (ret =xc_dom_boot_xen_init (dom, ctx->xch, domid)) !=0 ) {LOGE (ERROR ,"xc_dom_boot_xen_init failed" ); goto out;
Signature · 1 line
1.7.10.4
PATCH v2 11/19 xen: handle XENMEMF_get_vnumainfo in compat_memory_op
In reply to Wei Liu--- xen/common/compat/memory.c | 38 ++++++++++++++++++++++++++++++++++++++ xen/include/xlat.lst | 2 ++ 2 files changed, 40 insertions(+)
xen/common/compat/memory.c +38 -0
@@ -15,6 +15,7 @@ CHECK_TYPE(domid);#undef xen_domid_t CHECK_mem_access_op; +CHECK_vmemrange;int compat_memory_op (unsigned int cmd,XEN_GUEST_HANDLE_PARAM (void ) compat) {
@@ -32,12 +33,14 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) compat)struct xen_add_to_physmap *atp;struct xen_add_to_physmap_batch *atpb;struct xen_remove_from_physmap *xrfp; +struct xen_vnuma_topology_info *vnuma; } nat;union {struct compat_memory_reservation rsrv;struct compat_memory_exchange xchg;struct compat_add_to_physmap atp;struct compat_add_to_physmap_batch atpb; +struct compat_vnuma_topology_info vnuma; } cmp;set_xen_guest_handle (nat.hnd,COMPAT_ARG_XLAT_VIRT_BASE );
@@ -273,6 +276,33 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) compat)break ; } +case XENMEM_get_vnumainfo: + { +enum XLAT_vnuma_topology_info_vdistance vdistance = + XLAT_vnuma_topology_info_vdistance_h; +enum XLAT_vnuma_topology_info_vcpu_to_vnode vcpu_to_vnode = + XLAT_vnuma_topology_info_vcpu_to_vnode_h; +enum XLAT_vnuma_topology_info_vmemrange vmemrange = + XLAT_vnuma_topology_info_vmemrange_h; + +if (copy_from_guest (&cmp.vnuma, compat,1 ) ) +return -EFAULT ; + +#define XLAT_vnuma_topology_info_HNDL_vdistance_h (_d_, _s_) \ + guest_from_compat_handle((_d_)->vdistance.h, (_s_)->vdistance.h) +#define XLAT_vnuma_topology_info_HNDL_vcpu_to_vnode_h (_d_, _s_) \ + guest_from_compat_handle((_d_)->vcpu_to_vnode.h, (_s_)->vcpu_to_vnode.h) +#define XLAT_vnuma_topology_info_HNDL_vmemrange_h (_d_, _s_) \ + guest_from_compat_handle((_d_)->vmemrange.h, (_s_)->vmemrange.h) + +XLAT_vnuma_topology_info (nat.vnuma, &cmp.vnuma); + +#undef XLAT_vnuma_topology_info_HNDL_vdistance_h +#undef XLAT_vnuma_topology_info_HNDL_vcpu_to_vnode_h +#undef XLAT_vnuma_topology_info_HNDL_vmemrange_h +break ; + } +default :return compat_arch_memory_op (cmd, compat); }
@@ -398,6 +428,14 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) compat)case XENMEM_remove_from_physmap:break ; +case XENMEM_get_vnumainfo: + cmp.vnuma.nr_vnodes = nat.vnuma->nr_vnodes; + cmp.vnuma.nr_vcpus = nat.vnuma->nr_vcpus; + cmp.vnuma.nr_vmemranges = nat.vnuma->nr_vmemranges; +if (__copy_to_guest (compat, &cmp.vnuma,1 ) ) + rc = -EFAULT ; +break ; +default :domain_crash (current->domain); split =0 ;
xen/include/xlat.lst +2 -0
@@ -64,6 +64,8 @@ ? mem_access_op memory.h ! pod_target memory.h ! remove_from_physmap memory.h +? vmemrange memory.h +! vnuma_topology_info memory.h ? physdev_eoi physdev.h ? physdev_get_free_pirq physdev.h ? physdev_irq physdev.h
Signature · 1 line
1.7.10.4
Re: [PATCH v2 11/19] xen: handle XENMEMF_get_vnumainfo in compat_memory_op
xen/common/compat/memory.c int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) compat) · line 280
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 01.12.14 at 16:33, <[email protected]> wrote:
xen/common/compat/memory.c +2
-0@@ -273,6 +276,33 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) compat)break ; } +case XENMEM_get_vnumainfo: + {
Hard tab.
Quoted 14 lines
xen/common/compat/memory.c +14
-0+enum XLAT_vnuma_topology_info_vdistance vdistance = + XLAT_vnuma_topology_info_vdistance_h; +enum XLAT_vnuma_topology_info_vcpu_to_vnode vcpu_to_vnode = + XLAT_vnuma_topology_info_vcpu_to_vnode_h; +enum XLAT_vnuma_topology_info_vmemrange vmemrange = + XLAT_vnuma_topology_info_vmemrange_h; + +if (copy_from_guest (&cmp.vnuma, compat,1 ) ) +return -EFAULT ; + +#define XLAT_vnuma_topology_info_HNDL_vdistance_h (_d_, _s_) \ + guest_from_compat_handle((_d_)->vdistance.h, (_s_)->vdistance.h) +#define XLAT_vnuma_topology_info_HNDL_vcpu_to_vnode_h (_d_, _s_) \ + guest_from_compat_handle((_d_)->vcpu_to_vnode.h, (_s_)->vcpu_to_vnode.h)
xen/common/compat/memory.c int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) compat) · line 304
Quoted 10 lines
xen/common/compat/memory.c +10
-0+#define XLAT_vnuma_topology_info_HNDL_vmemrange_h (_d_, _s_) \ + guest_from_compat_handle((_d_)->vmemrange.h, (_s_)->vmemrange.h) + +XLAT_vnuma_topology_info (nat.vnuma, &cmp.vnuma); + +#undef XLAT_vnuma_topology_info_HNDL_vdistance_h +#undef XLAT_vnuma_topology_info_HNDL_vcpu_to_vnode_h +#undef XLAT_vnuma_topology_info_HNDL_vmemrange_h +break ; + }
Again.
With these two fixed and the subject adjusted to name the sub-op correctly,
Jan
PATCH v2 12/19 hvmloader: retrieve vNUMA information from hypervisor
In reply to Wei LiuHvmloader issues XENMEM_get_vnumainfo hypercall and stores the information retrieved in scratch space for later use.
--- tools/firmware/hvmloader/Makefile | 2 +- tools/firmware/hvmloader/hvmloader.c | 3 ++ tools/firmware/hvmloader/vnuma.c | 84 ++++++++++++++++++++++++++++++++++ tools/firmware/hvmloader/vnuma.h | 56 +++++++++++++++++++++++ 4 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 tools/firmware/hvmloader/vnuma.c create mode 100644 tools/firmware/hvmloader/vnuma.h
tools/firmware/hvmloader/Makefile +1 -1
@@ -29,7 +29,7 @@ LOADADDR = 0x100000 CFLAGS += $(CFLAGS_xeninclude) OBJS = hvmloader.o mp_tables.o util.o smbios.o -OBJS += smp.o cacheattr.o xenbus.o +OBJS += smp.o cacheattr.o xenbus.o vnuma.o OBJS += e820.o pci.o pir.o ctype.o OBJS += hvm_param.o ifeq ($(debug),y)
tools/firmware/hvmloader/hvmloader.c +3 -0
@@ -26,6 +26,7 @@#include "pci_regs.h" #include "apic_regs.h" #include "acpi/acpi2_0.h" +#include "vnuma.h" #include <xen/version.h> #include <xen/hvm/params.h>
@@ -261,6 +262,8 @@ int main(void)init_hypercalls (); +init_vnuma_info (); +xenbus_setup (); bios =detect_bios ();
tools/firmware/hvmloader/vnuma.c new file +84 -0
84 lines not on this page · raw message
tools/firmware/hvmloader/vnuma.h new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Re: [PATCH v2 12/19] hvmloader: retrieve vNUMA information from hypervisor
tools/firmware/hvmloader/hvmloader.c int main(void) · line 265
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 01.12.14 at 16:33, <[email protected]> wrote:
tools/firmware/hvmloader/hvmloader.c +1
-0@@ -261,6 +262,8 @@ int main(void)init_hypercalls (); +init_vnuma_info ();
This is very early, and I don't think it needs to be - I guess it could be done right before doing ACPI stuff?
Quoted 24 lines
tools/firmware/hvmloader/vnuma.c new file +21
-0@@ -0,0 +1,84 @@ +/* +* vnuma.c: obtain vNUMA information from hypervisor +* +* Copyright (c) 2014 Wei Liu, Citrix Systems (R&D) Ltd. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* +* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
tools/firmware/hvmloader/vnuma.c line 31
Quoted 10 lines
tools/firmware/hvmloader/vnuma.c new file +10
-0+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +*/ + +#include "util.h" +#include "hypercall.h" +#include "vnuma.h" +#include <errno.h>
This is the system header, not the Xen one. See the discussion at
http://lists.xenproject.org/archives/html/xen-devel/2014-10/msg03206.html
and perhaps build on the resulting patch
http://lists.xenproject.org/archives/html/xen-devel/2014-12/msg00013.html.
Quoted 24 lines
tools/firmware/hvmloader/vnuma.c new file +24
-0+ +unsigned int nr_vnodes, nr_vmemranges; +unsigned int *vcpu_to_vnode, *vdistance; +xen_vmemrange_t *vmemrange; + +void init_vnuma_info (void ) +{ +int rc, retry =0 ; +struct xen_vnuma_topology_info vnuma_topo = { + .domid =DOMID_SELF , + }; + + vcpu_to_vnode =scratch_alloc (sizeof (uint32_t ) * hvm_info->nr_vcpus,0 ); + vdistance =scratch_alloc (sizeof (uint32_t ) *MAX_VDISTANCE ,0 ); + vmemrange =scratch_alloc (sizeof (xen_vmemrange_t) *MAX_VMEMRANGES ,0 ); + + vnuma_topo.nr_vnodes =MAX_VNODES ; + vnuma_topo.nr_vcpus = hvm_info->nr_vcpus; + vnuma_topo.nr_vmemranges =MAX_VMEMRANGES ; + +set_xen_guest_handle (vnuma_topo.vdistance.h, vdistance); +set_xen_guest_handle (vnuma_topo.vcpu_to_vnode.h, vcpu_to_vnode); +set_xen_guest_handle (vnuma_topo.vmemrange.h, vmemrange); +
tools/firmware/hvmloader/vnuma.c line 65
Quoted 10 lines
tools/firmware/hvmloader/vnuma.c new file +10
-0+ rc =hypercall_memory_op (XENMEM_get_vnumainfo, &vnuma_topo); +while ( rc == -EAGAIN && retry <10 ) + { + rc =hypercall_memory_op (XENMEM_get_vnumainfo, &vnuma_topo); + retry++; + } +if ( rc <0 ) + { +printf ("Failed to retrieve vNUMA information, rc = %d\n" , rc); + goto out;
return;
tools/firmware/hvmloader/vnuma.c line 72
Quoted 7 lines
tools/firmware/hvmloader/vnuma.c new file +7
-0+ } + + nr_vnodes = vnuma_topo.nr_vnodes; + nr_vmemranges = vnuma_topo.nr_vmemranges; + +out: +return ;
Drop these two (or really three) unnecessary lines please.
Quoted 31 lines
tools/firmware/hvmloader/vnuma.h new file +28
-0@@ -0,0 +1,56 @@ +/****************************************************************************** +* vnuma.h +* +* Copyright (c) 2014, Wei Liu +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation; or, when distributed +* separately from the Linux kernel or incorporated into other +* software packages, subject to the following license: +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this source file (the "Software"), to deal in the Software without +* restriction, including without limitation the rights to use, copy, modify, +* merge, publish, distribute, sublicense, and/or sell copies of the Software, +* and to permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE.
tools/firmware/hvmloader/vnuma.h line 38
Quoted 10 lines
tools/firmware/hvmloader/vnuma.h new file +10
-0+*/ + +#ifndef __HVMLOADER_VNUMA_H__ +#define __HVMLOADER_VNUMA_H__ + +#include <xen/memory.h> + +#define MAX_VNODES 64 +#define MAX_VDISTANCE (MAX_VNODES * MAX_VNODES) +#define MAX_VMEMRANGES (MAX_VNODES * 2)
These look arbitrary - please add a (brief) comment giving some rationale so that people needing to change them know eventual consequences. Would it perhaps make sense to derive MAX_VNODES from HVM_MAX_VCPUS? Additionally I think the code wouldn't become much more difficult if you didn't build in static upper limits.
Jan
Re: [PATCH v2 12/19] hvmloader: retrieve vNUMA information from hypervisor
Quoted 10 lines · Jan Beulich
tools/firmware/hvmloader/hvmloader.c int main(void) · line 265
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 01.12.14 at 16:33, <[email protected]> wrote:
tools/firmware/hvmloader/hvmloader.c +1
-0@@ -261,6 +262,8 @@ int main(void)init_hypercalls (); +init_vnuma_info ();This is very early, and I don't think it needs to be - I guess it could be done right before doing ACPI stuff?
Yes, it can be moved right before ACPI stuff.
Quoted 31 lines
Quoted 31 lines
tools/firmware/hvmloader/vnuma.c new file +28
-0@@ -0,0 +1,84 @@ +/* +* vnuma.c: obtain vNUMA information from hypervisor +* +* Copyright (c) 2014 Wei Liu, Citrix Systems (R&D) Ltd. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* +* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +*/ + +#include "util.h"
Quoted 9 lines
tools/firmware/hvmloader/vnuma.c line 31
Quoted 3 lines
tools/firmware/hvmloader/vnuma.c new file +3
-0+#include "hypercall.h" +#include "vnuma.h" +#include <errno.h> This is the system header, not the Xen one. See the discussion at
http://lists.xenproject.org/archives/html/xen-devel/2014-10/msg03206.html
and perhaps build on the resulting patch
http://lists.xenproject.org/archives/html/xen-devel/2014-12/msg00013.html.
I will cherry pick that patch and build on top of it.
Quoted 5 lines
Quoted 5 lines
tools/firmware/hvmloader/vnuma.c new file +5
-0+ +unsigned int nr_vnodes, nr_vmemranges; +unsigned int *vcpu_to_vnode, *vdistance; +xen_vmemrange_t *vmemrange; +
[...]
Quoted 7 lines
Quoted 7 lines
+ */
tools/firmware/hvmloader/vnuma.c new file +6
-0+ +#ifndef __HVMLOADER_VNUMA_H__ +#define __HVMLOADER_VNUMA_H__ + +#include <xen/memory.h> +
Quoted 8 lines
tools/firmware/hvmloader/vnuma.c
Quoted 3 lines
tools/firmware/hvmloader/vnuma.c new file +3
-0+#define MAX_VNODES 64 +#define MAX_VDISTANCE (MAX_VNODES * MAX_VNODES) +#define MAX_VMEMRANGES (MAX_VNODES * 2)These look arbitrary - please add a (brief) comment giving some rationale so that people needing to change them know eventual consequences. Would it perhaps make sense to derive
MAX_VNODESfromHVM_MAX_VCPUS? Additionally I think the
I don't think these two have very strong connection though.
And I remember you saying HVM_MAX_VCPUS will be removed.
Quoted 3 lines
code wouldn't become much more difficult if you didn't build in static upper limits.
Yes I can make two hypercalls. First one to retrieve the number of nodes / vmemranges configured, allocate memory then fill in those arrays with second hypercall.
Wei.
Quoted 1 line
Jan
Re: [PATCH v2 12/19] hvmloader: retrieve vNUMA information from hypervisor
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 09.12.14 at 18:52, <[email protected]> wrote:
Quoted 16 lines · Jan Beulich
tools/firmware/hvmloader/vnuma.h line 38
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 01.12.14 at 16:33, <[email protected]> wrote:
+ */
tools/firmware/hvmloader/vnuma.h new file +9
-0+ +#ifndef __HVMLOADER_VNUMA_H__ +#define __HVMLOADER_VNUMA_H__ + +#include <xen/memory.h> + +#define MAX_VNODES 64 +#define MAX_VDISTANCE (MAX_VNODES * MAX_VNODES) +#define MAX_VMEMRANGES (MAX_VNODES * 2)These look arbitrary - please add a (brief) comment giving some rationale so that people needing to change them know eventual consequences. Would it perhaps make sense to derive
MAX_VNODESfromHVM_MAX_VCPUS? Additionally I think the
Quoted 3 lines
I don't think these two have very strong connection though.
And I remember you saying
HVM_MAX_VCPUSwill be removed.
Removed? I recall myself saying increased...
Quoted 7 lines
Quoted 3 lines
code wouldn't become much more difficult if you didn't build in static upper limits.
Yes I can make two hypercalls. First one to retrieve the number of nodes / vmemranges configured, allocate memory then fill in those arrays with second hypercall.
That'd be great, as it would eliminate the point above at once.
Jan
PATCH v2 13/19 hvmloader: construct SRAT
In reply to Wei Liu---
Changes in v2:
1. Remove explicit zero initializers.
2. Adapt to new vNUMA retrieval routine.
3. Move SRAT very late in secondary table build.
--- tools/firmware/hvmloader/acpi/acpi2_0.h | 53 +++++++++++++++++++++++ tools/firmware/hvmloader/acpi/build.c | 71 +++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+)
tools/firmware/hvmloader/acpi/acpi2_0.h +53 -0
@@ -364,6 +364,57 @@ struct acpi_20_madt_intsrcovr { };/* +* System Resource Affinity Table header definition (SRAT) +*/ +struct acpi_20_srat { +struct acpi_header header; +uint32_t table_revision; +uint32_t reserved2[2 ]; +}; + +#define ACPI_SRAT_TABLE_REVISION 1 + +/* +* System Resource Affinity Table structure types. +*/ +#define ACPI_PROCESSOR_AFFINITY 0x0 +#define ACPI_MEMORY_AFFINITY 0x1 +struct acpi_20_srat_processor { +uint8_t type; +uint8_t length; +uint8_t domain; +uint8_t apic_id; +uint32_t flags; +uint8_t sapic_id; +uint8_t domain_hi[3 ]; +uint32_t reserved; +}; + +/* +* Local APIC Affinity Flags. All other bits are reserved and must be 0. +*/ +#define ACPI_LOCAL_APIC_AFFIN_ENABLED (1 << 0) + +struct acpi_20_srat_memory { +uint8_t type; +uint8_t length; +uint32_t domain; +uint16_t reserved; +uint64_t base_address; +uint64_t mem_length; +uint32_t reserved2; +uint32_t flags; +uint64_t reserved3; +}; + +/* +* Memory Affinity Flags. All other bits are reserved and must be 0. +*/ +#define ACPI_MEM_AFFIN_ENABLED (1 << 0) +#define ACPI_MEM_AFFIN_HOTPLUGGABLE (1 << 1) +#define ACPI_MEM_AFFIN_NONVOLATILE (1 << 2) + +/* * Table Signatures. */ #define ACPI_2_0_RSDP_SIGNATURE ASCII64('R','S','D',' ','P','T','R',' ')
@@ -375,6 +426,7 @@ struct acpi_20_madt_intsrcovr {#define ACPI_2_0_TCPA_SIGNATURE ASCII32('T','C','P','A')#define ACPI_2_0_HPET_SIGNATURE ASCII32('H','P','E','T')#define ACPI_2_0_WAET_SIGNATURE ASCII32('W','A','E','T') +#define ACPI_2_0_SRAT_SIGNATURE ASCII32('S','R','A','T')/* * Table revision numbers.
@@ -388,6 +440,7 @@ struct acpi_20_madt_intsrcovr {#define ACPI_2_0_HPET_REVISION 0x01#define ACPI_2_0_WAET_REVISION 0x01#define ACPI_1_0_FADT_REVISION 0x01 +#define ACPI_2_0_SRAT_REVISION 0x01#pragma pack ()
tools/firmware/hvmloader/acpi/build.c +71 -0
95 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Re: [PATCH v2 13/19] hvmloader: construct SRAT
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 01.12.14 at 16:33, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/build.c +5
-0@@ -203,6 +204,65 @@ static struct acpi_20_waet *construct_waet(void)return waet; } +static struct acpi_20_srat *construct_srat (void ) +{ +struct acpi_20_srat *srat; +struct acpi_20_srat_processor *processor; +struct acpi_20_srat_memory *memory;
tools/firmware/hvmloader/acpi/build.c static struct acpi_20_waet *construct_waet(void) · line 221
Quoted 10 lines
tools/firmware/hvmloader/acpi/build.c +10
-0+unsigned int size; +void *p; +int i; +uint64_t mem; + + size =sizeof (*srat) +sizeof (*processor) * hvm_info->nr_vcpus + +sizeof (*memory) * nr_vmemranges; + + p =mem_alloc (size,16 ); +if (!p)return NULL ;
Coding style (despite you likely copied it from elsewhere).
Quoted 18 lines
tools/firmware/hvmloader/acpi/build.c +18
-0+ + srat = p; +memset (srat,0 ,sizeof (*srat)); + srat->header.signature =ACPI_2_0_SRAT_SIGNATURE ; + srat->header.revision =ACPI_2_0_SRAT_REVISION ; +fixed_strcpy (srat->header.oem_id,ACPI_OEM_ID ); +fixed_strcpy (srat->header.oem_table_id,ACPI_OEM_TABLE_ID ); + srat->header.oem_revision =ACPI_OEM_REVISION ; + srat->header.creator_id =ACPI_CREATOR_ID ; + srat->header.creator_revision =ACPI_CREATOR_REVISION ; + srat->table_revision =ACPI_SRAT_TABLE_REVISION ; + + processor = (struct acpi_20_srat_processor *)(srat +1 ); +for ( i =0 ; i < hvm_info->nr_vcpus; i++ ) + { +memset (processor,0 ,sizeof (*processor)); + processor->type =ACPI_PROCESSOR_AFFINITY ; + processor->length =sizeof (*processor);
tools/firmware/hvmloader/acpi/build.c static struct acpi_20_waet *construct_waet(void) · line 249
Quoted 10 lines
tools/firmware/hvmloader/acpi/build.c +10
-0+ processor->domain = vcpu_to_vnode[i]; + processor->apic_id =LAPIC_ID (i); + processor->flags =ACPI_LOCAL_APIC_AFFIN_ENABLED ; + processor++; + } + + memory = (struct acpi_20_srat_memory *)processor; +for ( i =0 ; i < nr_vmemranges; i++ ) + { + mem = vmemrange[i].end - vmemrange[i].start;
Do you really need this helper variable?
tools/firmware/hvmloader/acpi/build.c static struct acpi_20_waet *construct_waet(void) · line 260
Quoted 11 lines
tools/firmware/hvmloader/acpi/build.c +11
-0+memset (memory,0 ,sizeof (*memory)); + memory->type =ACPI_MEMORY_AFFINITY ; + memory->length =sizeof (*memory); + memory->domain = vmemrange[i].nid; + memory->flags =ACPI_MEM_AFFIN_ENABLED ; + memory->base_address = vmemrange[i].start; + memory->mem_length = mem; + memory++; + } + + srat->header.length = size;
Mind checking size == memory - p here?
tools/firmware/hvmloader/acpi/build.c static int construct_secondary_tables(unsigned long *table_ptrs, · line 414
Quoted 9 lines
tools/firmware/hvmloader/acpi/build.c +5
-0@@ -346,6 +407,16 @@ static int construct_secondary_tables(unsigned long *table_ptrs, } } +/* SRAT */ +if ( nr_vnodes >0 ) + { + srat =construct_srat (); +if (srat)
Coding style again.
Jan
Re: [PATCH v2 13/19] hvmloader: construct SRAT
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 01.12.14 at 16:33, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/build.c +9
-0@@ -203,6 +204,65 @@ static struct acpi_20_waet *construct_waet(void)return waet; } +static struct acpi_20_srat *construct_srat (void ) +{ +struct acpi_20_srat *srat; +struct acpi_20_srat_processor *processor; +struct acpi_20_srat_memory *memory; +unsigned int size; +void *p; +int i; +uint64_t mem;
Quoted 9 lines
tools/firmware/hvmloader/acpi/build.c static struct acpi_20_waet *construct_waet(void) · line 221
Quoted 6 lines
tools/firmware/hvmloader/acpi/build.c +6
-0+ + size =sizeof (*srat) +sizeof (*processor) * hvm_info->nr_vcpus + +sizeof (*memory) * nr_vmemranges; + + p =mem_alloc (size,16 ); +if (!p)return NULL ;Coding style (despite you likely copied it from elsewhere).
Fixed.
Quoted 22 lines
Quoted 22 lines
tools/firmware/hvmloader/acpi/build.c +22
-0+ + srat = p; +memset (srat,0 ,sizeof (*srat)); + srat->header.signature =ACPI_2_0_SRAT_SIGNATURE ; + srat->header.revision =ACPI_2_0_SRAT_REVISION ; +fixed_strcpy (srat->header.oem_id,ACPI_OEM_ID ); +fixed_strcpy (srat->header.oem_table_id,ACPI_OEM_TABLE_ID ); + srat->header.oem_revision =ACPI_OEM_REVISION ; + srat->header.creator_id =ACPI_CREATOR_ID ; + srat->header.creator_revision =ACPI_CREATOR_REVISION ; + srat->table_revision =ACPI_SRAT_TABLE_REVISION ; + + processor = (struct acpi_20_srat_processor *)(srat +1 ); +for ( i =0 ; i < hvm_info->nr_vcpus; i++ ) + { +memset (processor,0 ,sizeof (*processor)); + processor->type =ACPI_PROCESSOR_AFFINITY ; + processor->length =sizeof (*processor); + processor->domain = vcpu_to_vnode[i]; + processor->apic_id =LAPIC_ID (i); + processor->flags =ACPI_LOCAL_APIC_AFFIN_ENABLED ; + processor++;
Quoted 9 lines
tools/firmware/hvmloader/acpi/build.c static struct acpi_20_waet *construct_waet(void) · line 249
Quoted 6 lines
tools/firmware/hvmloader/acpi/build.c +6
-0+ } + + memory = (struct acpi_20_srat_memory *)processor; +for ( i =0 ; i < nr_vmemranges; i++ ) + { + mem = vmemrange[i].end - vmemrange[i].start;Do you really need this helper variable?
Removed.
Quoted 12 lines
tools/firmware/hvmloader/acpi/build.c static struct acpi_20_waet *construct_waet(void) · line 260
Quoted 11 lines
tools/firmware/hvmloader/acpi/build.c +11
-0+memset (memory,0 ,sizeof (*memory)); + memory->type =ACPI_MEMORY_AFFINITY ; + memory->length =sizeof (*memory); + memory->domain = vmemrange[i].nid; + memory->flags =ACPI_MEM_AFFIN_ENABLED ; + memory->base_address = vmemrange[i].start; + memory->mem_length = mem; + memory++; + } + + srat->header.length = size;
Quoted 2 lines
Mind checking size == memory - p here?
Why? There doesn't seem to be anything that would cause memory -p != size in between during runtime.
Quoted 4 lines
Quoted 4 lines
(quoted diff) +0
-0@@ -346,6 +407,16 @@ static int construct_secondary_tables(unsigned long *table_ptrs, } }
Quoted 8 lines
tools/firmware/hvmloader/acpi/build.c static int construct_secondary_tables(unsigned long *table_ptrs, · line 414
Quoted 5 lines
tools/firmware/hvmloader/acpi/build.c +5
-0+/* SRAT */ +if ( nr_vnodes >0 ) + { + srat =construct_srat (); +if (srat)Coding style again.
Fixed.
Wei.
Quoted 1 line
Jan
Re: [PATCH v2 13/19] hvmloader: construct SRAT
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 09.12.14 at 19:06, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 01.12.14 at 16:33, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/build.c +11
-0+memset (memory,0 ,sizeof (*memory)); + memory->type =ACPI_MEMORY_AFFINITY ; + memory->length =sizeof (*memory); + memory->domain = vmemrange[i].nid; + memory->flags =ACPI_MEM_AFFIN_ENABLED ; + memory->base_address = vmemrange[i].start; + memory->mem_length = mem; + memory++; + } + + srat->header.length = size;
Quoted 5 lines
Quoted 2 lines
Mind checking size == memory - p here?
Why? There doesn't seem to be anything that would cause memory -p != size in between during runtime.
Except for that original calculation being wrong - that's what I would mean such a check to verify.
Jan
Re: [PATCH v2 13/19] hvmloader: construct SRAT
Quoted 15 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 09.12.14 at 19:06, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 01.12.14 at 16:33, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/build.c +11
-0+memset (memory,0 ,sizeof (*memory)); + memory->type =ACPI_MEMORY_AFFINITY ; + memory->length =sizeof (*memory); + memory->domain = vmemrange[i].nid; + memory->flags =ACPI_MEM_AFFIN_ENABLED ; + memory->base_address = vmemrange[i].start; + memory->mem_length = mem; + memory++; + } + + srat->header.length = size;
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Mind checking size == memory - p here?
Why? There doesn't seem to be anything that would cause memory -p != size in between during runtime.
Except for that original calculation being wrong - that's what I would mean such a check to verify.
Do you mean the code is wrong? I don't think so.
Even if I have
+ if ( ((unsigned long)memory) - ((unsigned long)p) != size )
+ return NULL;
+
Hvmloader doesn't complain, i.e. I don't see error message printed out in the construct_secondary_tables.
Anyway, if the above snippet is what you want, I can add it.
Wei.
Quoted 1 line
Jan
Re: [PATCH v2 13/19] hvmloader: construct SRAT
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 10.12.14 at 11:54, <[email protected]> wrote:
Quoted 18 lines · Jan Beulich
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 09.12.14 at 19:06, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich
tools/firmware/hvmloader/acpi/build.c static struct acpi_20_waet *construct_waet(void) · line 260
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 01.12.14 at 16:33, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/build.c +11
-0+memset (memory,0 ,sizeof (*memory)); + memory->type =ACPI_MEMORY_AFFINITY ; + memory->length =sizeof (*memory); + memory->domain = vmemrange[i].nid; + memory->flags =ACPI_MEM_AFFIN_ENABLED ; + memory->base_address = vmemrange[i].start; + memory->mem_length = mem; + memory++; + } + + srat->header.length = size;Mind checking size == memory - p here?
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Why? There doesn't seem to be anything that would cause memory -p != size in between during runtime.
Except for that original calculation being wrong - that's what I would mean such a check to verify.
Do you mean the code is wrong? I don't think so.
No, the code looks right. It's just that two disconnected calculations easily get out of sync when someone later changes them.
Quoted 10 lines
Even if I have
(quoted diff) +3
-0+ if ( ((unsigned long)memory) - ((unsigned long)p) != size ) + return NULL; +Hvmloader doesn't complain, i.e. I don't see error message printed out in the
construct_secondary_tables.Anyway, if the above snippet is what you want, I can add it.
I was actually more after a BUG_ON() / ASSERT() kind of thing.
Jan
Re: [PATCH v2 13/19] hvmloader: construct SRAT
Quoted 27 lines · Jan Beulich
Quoted 27 lines
Quoted 1 line
Quoted 1 line · On 10.12.14 at 11:54, <[email protected]> wrote:
Quoted 24 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 09.12.14 at 19:06, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 01.12.14 at 16:33, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/build.c +11
-0+memset (memory,0 ,sizeof (*memory)); + memory->type =ACPI_MEMORY_AFFINITY ; + memory->length =sizeof (*memory); + memory->domain = vmemrange[i].nid; + memory->flags =ACPI_MEM_AFFIN_ENABLED ; + memory->base_address = vmemrange[i].start; + memory->mem_length = mem; + memory++; + } + + srat->header.length = size;Quoted 5 lines
Quoted 2 lines
Mind checking size == memory - p here?
Why? There doesn't seem to be anything that would cause memory -p != size in between during runtime.
Except for that original calculation being wrong - that's what I would mean such a check to verify.
Quoted 6 lines
Quoted 1 line
Do you mean the code is wrong? I don't think so.
No, the code looks right. It's just that two disconnected calculations easily get out of sync when someone later changes them.
I see.
Quoted 6 lines
Quoted 6 lines
Even if I have
(quoted diff) +3
-0+ if ( ((unsigned long)memory) - ((unsigned long)p) != size ) + return NULL; +
Quoted 6 lines
Quoted 4 lines
Hvmloader doesn't complain, i.e. I don't see error message printed out in the
construct_secondary_tables.Anyway, if the above snippet is what you want, I can add it.
I was actually more after a
BUG_ON()/ASSERT()kind of thing.
Ack.
Quoted 2 lines
Jan
PATCH v2 14/19 hvmloader: construct SLIT
In reply to Wei Liu---
Changes in v2:
1. Adapt to new vNUMA retrieval routine.
2. Move SLIT very late in secondary table build.
--- tools/firmware/hvmloader/acpi/acpi2_0.h | 8 +++++++ tools/firmware/hvmloader/acpi/build.c | 40 ++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-)
tools/firmware/hvmloader/acpi/acpi2_0.h +8 -0
@@ -414,6 +414,12 @@ struct acpi_20_srat_memory {#define ACPI_MEM_AFFIN_HOTPLUGGABLE (1 << 1)#define ACPI_MEM_AFFIN_NONVOLATILE (1 << 2) +struct acpi_20_slit { +struct acpi_header header; +uint64_t localities; +uint8_t entry[0 ]; +}; +/* * Table Signatures. */
@@ -427,6 +433,7 @@ struct acpi_20_srat_memory {#define ACPI_2_0_HPET_SIGNATURE ASCII32('H','P','E','T')#define ACPI_2_0_WAET_SIGNATURE ASCII32('W','A','E','T')#define ACPI_2_0_SRAT_SIGNATURE ASCII32('S','R','A','T') +#define ACPI_2_0_SLIT_SIGNATURE ASCII32('S','L','I','T')/* * Table revision numbers.
@@ -441,6 +448,7 @@ struct acpi_20_srat_memory {#define ACPI_2_0_WAET_REVISION 0x01#define ACPI_1_0_FADT_REVISION 0x01#define ACPI_2_0_SRAT_REVISION 0x01 +#define ACPI_2_0_SLIT_REVISION 0x01#pragma pack ()
tools/firmware/hvmloader/acpi/build.c +39 -1
@@ -263,6 +263,38 @@ static struct acpi_20_srat *construct_srat(void)return srat; } +static struct acpi_20_slit *construct_slit (void ) +{ +struct acpi_20_slit *slit; +unsigned int num, size; +int i; + + num = nr_vnodes * nr_vnodes; + size =sizeof (*slit) + num *sizeof (uint8_t ); + + slit =mem_alloc (size,16 ); +if (!slit)return NULL ; + +memset (slit,0 , size); + slit->header.signature =ACPI_2_0_SLIT_SIGNATURE ; + slit->header.revision =ACPI_2_0_SLIT_REVISION ; +fixed_strcpy (slit->header.oem_id,ACPI_OEM_ID ); +fixed_strcpy (slit->header.oem_table_id,ACPI_OEM_TABLE_ID ); + slit->header.oem_revision =ACPI_OEM_REVISION ; + slit->header.creator_id =ACPI_CREATOR_ID ; + slit->header.creator_revision =ACPI_CREATOR_REVISION ; + +for ( i =0 ; i < num; i++ ) + slit->entry[i] = vdistance[i]; + + slit->localities = nr_vnodes; + + slit->header.length = size; +set_checksum (slit, offsetof(struct acpi_header , checksum), size); + +return slit; +} +static int construct_passthrough_tables (unsigned long *table_ptrs,int nr_tables) {
@@ -318,6 +350,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,struct acpi_20_waet *waet;struct acpi_20_tcpa *tcpa;struct acpi_20_srat *srat; +struct acpi_20_slit *slit;unsigned char *ssdt;static const uint16_t tis_signature[] = {0x0001 ,0x0001 ,0x0001 };uint16_t *tis_hdr;
@@ -407,7 +440,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs, } } -/* SRAT */ +/* SRAT and SLIT */ if ( nr_vnodes >0 ) { srat =construct_srat ();
@@ -415,6 +448,11 @@ static int construct_secondary_tables(unsigned long *table_ptrs, table_ptrs[nr_tables++] = (unsigned long )srat; else printf("Failed to build SRAT, skipping...\n"); + slit =construct_slit (); +if (srat) + table_ptrs[nr_tables++] = (unsigned long )slit; +else +printf ("Failed to build SLIT, skipping...\n" ); }/* Load any additional tables passed through. */
Signature · 1 line
1.7.10.4
Re: [PATCH v2 14/19] hvmloader: construct SLIT
tools/firmware/hvmloader/acpi/build.c static struct acpi_20_srat *construct_srat(void) · line 270
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 01.12.14 at 16:33, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/build.c +5
-0@@ -263,6 +263,38 @@ static struct acpi_20_srat *construct_srat(void)return srat; } +static struct acpi_20_slit *construct_slit (void ) +{ +struct acpi_20_slit *slit; +unsigned int num, size; +int i;
unsigned int please. Plus similar coding style issues further down as in the previous patch.
tools/firmware/hvmloader/acpi/build.c static int construct_secondary_tables(unsigned long *table_ptrs, · line 452
Quoted 6 lines
tools/firmware/hvmloader/acpi/build.c +2
-0@@ -415,6 +448,11 @@ static int construct_secondary_tables(unsigned long *table_ptrs, table_ptrs[nr_tables++] = (unsigned long )srat; else printf("Failed to build SRAT, skipping...\n"); + slit =construct_slit (); +if (srat)
DYM slit?
Jan
Re: [PATCH v2 14/19] hvmloader: construct SLIT
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 01.12.14 at 16:33, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/build.c +0
-0@@ -263,6 +263,38 @@ static struct acpi_20_srat *construct_srat(void)return srat; }
Quoted 9 lines
tools/firmware/hvmloader/acpi/build.c static struct acpi_20_srat *construct_srat(void) · line 270
Quoted 5 lines
tools/firmware/hvmloader/acpi/build.c +5
-0+static struct acpi_20_slit *construct_slit (void ) +{ +struct acpi_20_slit *slit; +unsigned int num, size; +int i;unsigned int please. Plus similar coding style issues further down as in the previous patch.
Fixed.
Quoted 9 lines
tools/firmware/hvmloader/acpi/build.c static int construct_secondary_tables(unsigned long *table_ptrs, · line 452
Quoted 6 lines
tools/firmware/hvmloader/acpi/build.c +2
-0@@ -415,6 +448,11 @@ static int construct_secondary_tables(unsigned long *table_ptrs, table_ptrs[nr_tables++] = (unsigned long )srat; else printf("Failed to build SRAT, skipping...\n"); + slit =construct_slit (); +if (srat)DYM slit?
Yes. :-/
Wei.
Quoted 1 line
Jan
PATCH v2 15/19 libxc: allocate memory with vNUMA information for HVM guest
In reply to Wei LiuAnd then returns low memory end, high memory end and mmio start to caller.
--- tools/libxc/include/xenguest.h | 7 ++ tools/libxc/xc_hvm_build_x86.c | 224 ++++++++++++++++++++++++++-------------- 2 files changed, 151 insertions(+), 80 deletions(-)
tools/libxc/include/xenguest.h +7 -0
@@ -230,6 +230,13 @@ struct xc_hvm_build_args {struct xc_hvm_firmware_module smbios_module;/* Whether to use claim hypercall (1 - enable, 0 - disable). */ int claim_enabled; +unsigned int nr_vnodes; +unsigned int *vnode_to_pnode; +uint64_t *vnode_size;; +/* Out parameters */ +uint64_t lowmem_end; +uint64_t highmem_end; +uint64_t mmio_start; };/**
tools/libxc/xc_hvm_build_x86.c +144 -80
306 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v2 16/19 libxl: build, check and pass vNUMA info to Xen for HVM guest
In reply to Wei LiuLibxc has more involvement in building vmemranges in HVM case. The building of vmemranges is placed after xc_hvm_build returns, because it relies on memory hole information provided by xc_hvm_build.
--- tools/libxl/libxl_create.c | 9 +++++++ tools/libxl/libxl_dom.c | 28 +++++++++++++++++++++ tools/libxl/libxl_internal.h | 5 ++++ tools/libxl/libxl_vnuma.c | 56 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+)
tools/libxl/libxl_create.c +9 -0
@@ -845,6 +845,15 @@ static void initiate_domain_create(libxl__egc *egc, goto error_out; } +/* Disallow PoD and vNUMA to be enabled at the same time because PoD +* pool is not vNUMA-aware yet. +*/ +if (pod_enabled && d_config->b_info.num_vnuma_nodes) { + ret =ERROR_INVAL ; +LOG (ERROR ,"Cannot enable PoD and vNUMA at the same time" ); + goto error_out; + } + ret =libxl__domain_create_info_setdefault (gc, &d_config->c_info);if (ret) goto error_out;
tools/libxl/libxl_dom.c +28 -0
@@ -884,12 +884,40 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid, goto out; } +if (info->num_vnuma_nodes !=0 ) { +int i; + + args.nr_vnodes = info->num_vnuma_nodes; + args.vnode_to_pnode =libxl__malloc (gc,sizeof (*args.vnode_to_pnode) * + args.nr_vnodes); + args.vnode_size =libxl__malloc (gc,sizeof (*args.vnode_size) * + args.nr_vnodes); +for (i =0 ; i < args.nr_vnodes; i++) { + args.vnode_to_pnode[i] = info->vnuma_nodes[i].pnode; + args.vnode_size[i] = info->vnuma_nodes[i].mem; + } + +/* Consider video ram belongs to node 0 */ + args.vnode_size[0 ] -= (info->video_memkb >>10 ); + } + ret =xc_hvm_build (ctx->xch, domid, &args);if (ret) {LOGEV (ERROR , ret,"hvm building failed" ); goto out; } +if (info->num_vnuma_nodes !=0 ) { + ret =libxl__vnuma_build_vmemrange_hvm (gc, domid, info, state, &args); +if (ret) { +LOGEV (ERROR , ret,"hvm build vmemranges failed" ); + goto out; + } + ret =libxl__vnuma_config_check (gc, info, state); +if (ret) goto out; + ret =set_vnuma_info (gc, domid, info, state); +if (ret) goto out; + } ret = hvm_build_set_params(ctx->xch, domid, info, state->store_port, &state->store_mfn, state->console_port, &state->console_mfn, state->store_domid,
tools/libxl/libxl_internal.h +5 -0
@@ -3401,6 +3401,11 @@ int libxl__vnuma_build_vmemrange_pv(libxl__gc *gc,uint32_t domid, libxl_domain_build_info *b_info, libxl__domain_build_state *state); +int libxl__vnuma_build_vmemrange_hvm (libxl__gc *gc, +uint32_t domid, +libxl_domain_build_info *b_info, +libxl__domain_build_state *state, +struct xc_hvm_build_args *args); _hidden int libxl__ms_vm_genid_set(libxl__gc *gc, uint32_t domid,const libxl_ms_vm_genid *id);
tools/libxl/libxl_vnuma.c +56 -0
62 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v2 17/19 libxl: disallow memory relocation when vNUMA is enabled
In reply to Wei LiuDisallow memory relocation when vNUMA is enabled, because relocated memory ends up off node. Further more, even if we dynamically expand node coverage in hvmloader, low memory and high memory may reside in different physical nodes, blindly relocating low memory to high memory gives us a sub-optimal configuration.
--- tools/libxl/libxl_dm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/libxl/libxl_dm.c +4 -2
@@ -1345,13 +1345,15 @@ void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state *dmss)libxl__sprintf (gc,"%s/hvmloader/bios" , path), "%s", libxl_bios_type_to_string(b_info->u.hvm.bios));/* Disable relocating memory to make the MMIO hole larger -* unless we're running qemu-traditional */ +* unless we're running qemu-traditional and vNUMA is not +* configured. */ libxl__xs_write (gc,XBT_NULL ,libxl__sprintf (gc,"%s/hvmloader/allow-memory-relocate" , path),"%d" , - b_info->device_model_version==LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL ); + b_info->device_model_version==LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL && + !b_info->num_vnuma_nodes);free (path); }
Signature · 1 line
1.7.10.4
PATCH v2 18/19 libxlutil: nested list support
In reply to Wei LiuThis is done with three major changes:
1. Rework internal representation of setting.
2. Extend grammar of parser.
3. Introduce new APIs.
New APIs introduced:
1. xlu_cfg_value_type
2. xlu_cfg_value_get_string
3. xlu_cfg_value_get_list
4. xlu_cfg_get_listitem2
Previous APIs work as before.
--- tools/libxl/libxlu_cfg.c | 180 +++++++++++++++++++++++++---------------- tools/libxl/libxlu_cfg_i.h | 15 +++- tools/libxl/libxlu_cfg_y.c | 110 +++++++++++-------------- tools/libxl/libxlu_cfg_y.h | 2 +- tools/libxl/libxlu_cfg_y.y | 19 +++-- tools/libxl/libxlu_internal.h | 24 ++++-- tools/libxl/libxlutil.h | 11 ++- 7 files changed, 208 insertions(+), 153 deletions(-)
tools/libxl/libxlu_cfg.c +110 -70
@@ -132,13 +132,9 @@ int xlu_cfg_readdata(XLU_Config *cfg, const char *data, int length) { }void xlu__cfg_set_free (XLU_ConfigSetting *set) { -int i; -if (!set)return ; +xlu__cfg_value_free (set->value);free (set->name); -for (i=0 ; i<set->nvalues; i++) -free (set->values[i]); -free (set->values);free (set); }
@@ -173,7 +169,7 @@ static int find_atom(const XLU_Config *cfg, const char *n, set=find (cfg,n);if (!set)return ESRCH ; -if (set->avalues!=1 ) { +if (set->value->type!=XLU_STRING ) {if (!dont_warn)fprintf (cfg->report, "%s:%d: warning: parameter `%s' is"
@@ -185,13 +181,30 @@ static int find_atom(const XLU_Config *cfg, const char *n,return 0 ; } +enum XLU_ConfigValueType xlu_cfg_value_type (const XLU_ConfigValue *value) +{ +return value->type; +} + +const char *xlu_cfg_value_get_string (const XLU_ConfigValue *value) +{ +assert (value->type ==XLU_STRING ); +return value->u.string; +} + +const XLU_ConfigList *xlu_cfg_value_get_list (const XLU_ConfigValue *value) +{ +assert (value->type ==XLU_LIST ); +return &value->u.list; +} +int xlu_cfg_get_string (const XLU_Config *cfg,const char *n,const char **value_r,int dont_warn) {XLU_ConfigSetting *set;int e; e=find_atom (cfg,n,&set,dont_warn);if (e)return e; - *value_r= set->values[0 ]; + *value_r= set->value->u.string;return 0 ; }
@@ -202,7 +215,7 @@ int xlu_cfg_replace_string(const XLU_Config *cfg, const char *n, e=find_atom (cfg,n,&set,dont_warn);if (e)return e;free (*value_r); - *value_r=strdup (set->values[0 ]); + *value_r=strdup (set->value->u.string);return 0 ; }
@@ -214,7 +227,7 @@ int xlu_cfg_get_long(const XLU_Config *cfg, const char *n,char *ep; e=find_atom (cfg,n,&set,dont_warn);if (e)return e; - errno=0 ; l=strtol (set->values[0 ], &ep,0 ); + errno=0 ; l=strtol (set->value->u.string, &ep,0 ); e= errno;if (errno) { e= errno;
@@ -226,7 +239,7 @@ int xlu_cfg_get_long(const XLU_Config *cfg, const char *n, cfg->config_source, set->lineno, n, strerror(e));return e; } -if (*ep || ep==set->values[0 ]) { +if (*ep || ep==set->value->u.string) {if (!dont_warn) fprintf(cfg->report, "%s:%d: warning: parameter `%s' is not a valid number\n",
@@ -253,7 +266,7 @@ int xlu_cfg_get_list(const XLU_Config *cfg, const char *n, XLU_ConfigList **list_r, int *entries_r, int dont_warn) {XLU_ConfigSetting *set; set=find (cfg,n);if (!set)return ESRCH ; -if (set->avalues==1 ) { +if (set->value->type!=XLU_LIST ) {if (!dont_warn) {fprintf (cfg->report, "%s:%d: warning: parameter `%s' is a single value"
@@ -262,8 +275,8 @@ int xlu_cfg_get_list(const XLU_Config *cfg, const char *n, }return EINVAL ; } -if (list_r) *list_r= set; -if (entries_r) *entries_r= set->nvalues; +if (list_r) *list_r= &set->value->u.list; +if (entries_r) *entries_r= set->value->u.list.nvalues;return 0 ; }
@@ -290,72 +303,29 @@ int xlu_cfg_get_list_as_string_list(const XLU_Config *cfg, const char *n,return 0 ; } -const char *xlu_cfg_get_listitem (const XLU_ConfigList *set,int entry) { -if (entry <0 || entry >= set->nvalues)return 0 ; -return set->values[entry]; +const char *xlu_cfg_get_listitem (const XLU_ConfigList *list,int entry) { +if (entry <0 || entry >= list->nvalues)return 0 ; +if (list->values[entry]->type !=XLU_STRING )return 0 ; +return list->values[entry]->u.string; } - -XLU_ConfigSetting *xlu__cfg_set_mk (CfgParseContext *ctx, -int alloc,char *atom) { -XLU_ConfigSetting *set=0 ; - -if (ctx->err) goto x; -assert (!!alloc == !!atom); - - set=malloc (sizeof (*set)); -if (!set) goto xe; - - set->name=0 ;/* tbd */ - set->avalues= alloc; - -if (!alloc) { - set->nvalues=0 ; - set->values=0 ; - }else { - set->values=malloc (sizeof (*set->values) * alloc); -if (!set->values) goto xe; - - set->nvalues=1 ; - set->values[0 ]= atom; - } -return set; - - xe: - ctx->err= errno; - x: -free (set); -free (atom); -return 0 ; -} - -void xlu__cfg_set_add (CfgParseContext *ctx,XLU_ConfigSetting *set, -char *atom) { -if (ctx->err)return ; - -assert (atom); - -if (set->nvalues >= set->avalues) { -int new_avalues; -char **new_values; - -if (set->avalues >INT_MAX /100 ) { ctx->err=ERANGE ;return ; } - new_avalues= set->avalues *4 ; - new_values=realloc (set->values, -sizeof (*new_values) * new_avalues); -if (!new_values) { ctx->err= errno;free (atom);return ; } - set->values= new_values; - set->avalues= new_avalues; - } - set->values[set->nvalues++]= atom; +const XLU_ConfigValue *xlu_cfg_get_listitem2 (const XLU_ConfigList *list, +int entry) +{ +if (entry <0 || entry >= list->nvalues)return NULL ; +return list->values[entry]; }void xlu__cfg_set_store (CfgParseContext *ctx,char *name, -XLU_ConfigSetting *set,int lineno) { +XLU_ConfigValue *val,int lineno) { +XLU_ConfigSetting *set;if (ctx->err)return ;assert (name); + set =malloc (sizeof (*set)); +assert (set); set->name= name; + set->value = val; set->lineno= lineno; set->next= ctx->cfg->settings; ctx->cfg->settings= set;
@@ -473,6 +443,76 @@ void xlu__cfg_yyerror(YYLTYPE *loc, CfgParseContext *ctx, char const *msg) {if (!ctx->err) ctx->err=EINVAL ; } +XLU_ConfigValue *xlu__cfg_make_string (CfgParseContext *ctx, +char *src) +{ +XLU_ConfigValue *ret; + + ret =malloc (sizeof (*ret)); +assert (ret); + ret->type =XLU_STRING ; + ret->u.string = src; + +return ret; +} + +XLU_ConfigValue *xlu__cfg_make_list (CfgParseContext *ctx, +XLU_ConfigValue *val) +{ +XLU_ConfigValue *ret; + + ret =malloc (sizeof (*ret)); +assert (ret); + ret->type =XLU_LIST ; + ret->u.list.nvalues =1 ; + ret->u.list.values =malloc (sizeof (*ret->u.list.values)); + ret->u.list.values[0 ] = val; + +return ret; +} + +XLU_ConfigValue *xlu__cfg_list_append (CfgParseContext *ctx, +XLU_ConfigValue *list, +XLU_ConfigValue *val) +{ +XLU_ConfigValue **new_val; + +assert (list->type ==XLU_LIST ); + + new_val =realloc (list->u.list.values, +sizeof (*new_val) * (list->u.list.nvalues+1 )); +if (!new_val) { + ctx->err = errno; +xlu__cfg_value_free (val); +return list; + } + + list->u.list.values = new_val; + list->u.list.values[list->u.list.nvalues] = val; + list->u.list.nvalues++; + +return list; +} + +void xlu__cfg_value_free (XLU_ConfigValue *val) +{ +int i; + +if (!val)return ; + +switch (val->type) { +case XLU_STRING : +free (val->u.string); +break ; +case XLU_LIST : +for (i =0 ; i < val->u.list.nvalues; i++) { +xlu__cfg_value_free (val->u.list.values[i]); + } +free (val->u.list.values); + } +free (val); +} +/* * Local variables: * mode: C
tools/libxl/libxlu_cfg_i.h +12 -3
@@ -23,10 +23,8 @@#include "libxlu_cfg_y.h" void xlu__cfg_set_free (XLU_ConfigSetting *set); -XLU_ConfigSetting *xlu__cfg_set_mk (CfgParseContext *,int alloc,char *atom); -void xlu__cfg_set_add (CfgParseContext *,XLU_ConfigSetting *set,char *atom);void xlu__cfg_set_store (CfgParseContext *,char *name, -XLU_ConfigSetting *set,int lineno); +XLU_ConfigValue *val,int lineno);char *xlu__cfgl_strdup (CfgParseContext *,const char *src);char *xlu__cfgl_dequote (CfgParseContext *,const char *src);
@@ -36,7 +34,18 @@ void xlu__cfgl_lexicalerror(CfgParseContext*, char const *msg);void xlu__cfgl_likely_python (CfgParseContext *ctx); +XLU_ConfigValue *xlu__cfg_make_string (CfgParseContext *,char *src); +XLU_ConfigValue *xlu__cfg_make_list (CfgParseContext *, +XLU_ConfigValue *val); + + + +XLU_ConfigValue *xlu__cfg_list_append (CfgParseContext *ctx, +XLU_ConfigValue *list, +XLU_ConfigValue *val); + +void xlu__cfg_value_free (struct XLU_ConfigValue *val);/* Why oh why does bison not declare this in its autogenerated .h ? */ int xlu__cfg_yyparse (CfgParseContext *ctx);
tools/libxl/libxlu_cfg_y.c +48 -62
266 lines not on this page · raw message
tools/libxl/libxlu_cfg_y.h +1 -1
@@ -54,7 +54,7 @@ typedef union YYSTYPE#line 25 "libxlu_cfg_y.y"char *string; -XLU_ConfigSetting *setting; +XLU_ConfigValue *value;
tools/libxl/libxlu_cfg_y.y +9 -10
@@ -24,7 +24,7 @@ %union { char *string; - XLU_ConfigSetting *setting; + XLU_ConfigValue *value; } %locations
@@ -39,8 +39,8 @@ %type <string> atom %destructor { free($$); } atom IDENT STRING NUMBER -%type <setting> value valuelist values -%destructor { xlu__cfg_set_free($$); } value valuelist values +%type <value> value list values +%destructor { xlu__cfg_value_free($$); } value list values %%
@@ -59,18 +59,17 @@ assignment: IDENT '=' value { xlu__cfg_set_store(ctx,$1,$3,@3.first_line); } endstmt: NEWLINE | ';' -value: atom { $$= xlu__cfg_set_mk(ctx,1,$1); } - | '[' nlok valuelist ']' { $$= $3; } +value: atom { $$= xlu__cfg_make_string(ctx,$1); } + | list atom: STRING { $$= $1; } | NUMBER { $$= $1; } -valuelist: /* empty */ { $$= xlu__cfg_set_mk(ctx,0,0); } - | values { $$= $1; } - | values ',' nlok { $$= $1; } +list: '[' nlok values ']' { $$= $3; } -values: atom nlok { $$= xlu__cfg_set_mk(ctx,2,$1); } - | values ',' nlok atom nlok { xlu__cfg_set_add(ctx,$1,$4); $$= $1; } +values: /* empty */ { $$= xlu__cfg_make_list(ctx,NULL); } + | value nlok { $$= xlu__cfg_make_list(ctx,$1); } + | values ',' nlok value nlok { xlu__cfg_list_append(ctx,$1,$4); $$= $1;} nlok: /* nothing */
tools/libxl/libxlu_internal.h +18 -6
@@ -23,17 +23,29 @@#include <assert.h> #include <regex.h> -#define XLU_ConfigList XLU_ConfigSetting -#include "libxlutil.h" -struct XLU_ConfigSetting {/* transparent */ +typedef struct XLU_ConfigValue XLU_ConfigValue ; + +typedef struct XLU_ConfigList { +int nvalues; +XLU_ConfigValue **values; +}XLU_ConfigList ; + +typedef struct XLU_ConfigValue { +enum XLU_ConfigValueType type; +union { +char *string; +XLU_ConfigList list; + } u; +}XLU_ConfigValue ; + +typedef struct XLU_ConfigSetting {/* transparent */ struct XLU_ConfigSetting *next;char *name; -int nvalues, avalues;/* lists have avalues>1 */ -char **values; +struct XLU_ConfigValue *value;int lineno; -}; +}XLU_ConfigSetting ;struct XLU_Config {XLU_ConfigSetting *settings;
tools/libxl/libxlutil.h +10 -1
@@ -23,6 +23,15 @@/* Unless otherwise stated, all functions return an errno value. */ typedef struct XLU_Config XLU_Config ;typedef struct XLU_ConfigList XLU_ConfigList ; +typedef struct XLU_ConfigValue XLU_ConfigValue ; +enum XLU_ConfigValueType { +XLU_STRING , +XLU_LIST , +}; + +enum XLU_ConfigValueType xlu_cfg_value_type (const XLU_ConfigValue *value); +const char *xlu_cfg_value_get_string (const XLU_ConfigValue *value); +const XLU_ConfigList *xlu_cfg_value_get_list (const XLU_ConfigValue *value);XLU_Config *xlu_cfg_init (FILE *report,const char *report_filename);/* 0 means we got ENOMEM. */
@@ -65,7 +74,7 @@ int xlu_cfg_get_list_as_string_list(const XLU_Config *cfg, const char *n,const char *xlu_cfg_get_listitem (const XLU_ConfigList *,int entry);/* xlu_cfg_get_listitem cannot fail, except that if entry is * out of range it returns 0 (not setting errno) */ - +const XLU_ConfigValue *xlu_cfg_get_listitem2 (const XLU_ConfigList *,int entry);/* * Disk specification parsing.
Signature · 1 line
1.7.10.4
PATCH v2 19/19 xl: vNUMA support
In reply to Wei LiuThis patch includes configuration options parser and documentation.
---
Changes in v2:
1. Make vnuma_vdistances mandatory.
2. Use nested list to specify vdistances.
3. Update documentation.
--- docs/man/xl.cfg.pod.5 | 39 ++++++++++++ tools/libxl/xl_cmdimpl.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 186 insertions(+)
docs/man/xl.cfg.pod.5 +39 -0
@@ -266,6 +266,45 @@ it will crash. =back +=head3 Virtual NUMA Memory Allocation + +=over 4 + +=item B<vnuma_memory=[ NUMBER, NUMBER, ... ]> + +Specify the size of memory covered by each virtual NUMA node. The number of +elements in the list also implicitly defines the number of virtual NUMA nodes. + +The sum of all elements in this list should be equal to memory size specified +by B<maxmem=> in guest configuration file, or B<memory=> if B<maxmem=> is not +specified. + +=item B<vnuma_vcpu_map=[ NUMBER, NUMBER, ... ]> + +Specifiy which virutal NUMA node a specific vcpu belongs to. The number of +elements in this list should be equal to B<maxvcpus=> in guest configuration +file, or B<vcpus=> if B<maxvcpus=> is not specified. + +=item B<vnuma_pnode_map=[ NUMBER, NUMBER, ... ]> + +Specifiy which physical NUMA node a specific virtual NUMA node maps to. The +number of elements in this list should be equal to the number of virtual +NUMA nodes defined in B<vnuma_memory=>. + +=item B<vnuma_vdistance=[ [NUMBER, ..., NUMBER], [NUMBER, ..., NUMBER], ... ]> + +Two dimensional list to specify distances among nodes. + +The number of elements in the first dimension list equals the number of virtual +nodes. Each element in position B<i> is a list that specifies the distances +from node B<i> to other nodes. + +For example, for a guest with 2 virtual nodes, user can specify: + + vnuma_vdistance = [ [10, 20], [20, 10] ] + +=back + =head3 Event Actions =over 4
tools/libxl/xl_cmdimpl.c +147 -0
159 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Ping?
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 08.12.14 at 10:58, <[email protected]> wrote:
Ping?
Please be a little more patient - with this series not to go into 4.5, there's no need to urgently review it. The hypervisor side parts sit in my to-be-reviewed queue.
Jan