More vNUMA fixes
v2 cover More vNUMA fixes
Wei Liu (3):
xl: fix vNUMA vdistance parsing
xl: error out if vNUMA specifies more vcpus than pcpus
libxc: fix vNUMA memory allocation
tools/libxc/xc_hvm_build_x86.c | 6 ++++-- tools/libxl/xl_cmdimpl.c | 26 +++++++++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-)
Signature · 1 line
2.1.4
PATCH v2 1/3 xl: fix vNUMA vdistance parsing
We should parse the output from splitting function, not the original string.
--- tools/libxl/xl_cmdimpl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/xl_cmdimpl.c +1 -1
@@ -1188,7 +1188,7 @@ static void parse_vnuma_config(const XLU_Config *config, len =libxl_string_list_length (&vdist);for (j =0 ; j < len; j++) { - val =parse_ulong (value); + val =parse_ulong (vdist[j]); p->distances[j] = val; }libxl_string_list_dispose (&vdist);
Signature · 1 line
2.1.4
Re: [PATCH for-4.6 v2 1/3] xl: fix vNUMA vdistance parsing
Quoted 2 lines · Wei Liu
We should parse the output from splitting function, not the original string.
What is the previous incorrect behaviour in practice? It is useful to say this so that when someone comes along and says I'm seeing strange behaviour $FOO there is some chance of either remembering this or spotting it in the commit message.
It would also inform my opinion as to whether/why this change is correct.
Quoted 21 lines
Signed-off-by Wei Liu <[email protected]>Reviewed-by Dario Faggioli <[email protected]>--- tools/libxl/xl_cmdimpl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/libxl/xl_cmdimpl.c +1
-1@@ -1188,7 +1188,7 @@ static void parse_vnuma_config(const XLU_Config *config, len =libxl_string_list_length (&vdist);for (j =0 ; j < len; j++) { - val =parse_ulong (value); + val =parse_ulong (vdist[j]); p->distances[j] = val; }libxl_string_list_dispose(&vdist);
PATCH v2 2/3 xl: error out if vNUMA specifies more vcpus than pcpus
In reply to Wei Liu... but allow user to override that check by specifying maxvcpus= in xl configuration file.
--- tools/libxl/xl_cmdimpl.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
tools/libxl/xl_cmdimpl.c +20 -4
@@ -1202,11 +1202,27 @@ static void parse_vnuma_config(const XLU_Config *config, }/* User has specified maxvcpus= */ -if (b_info->max_vcpus !=0 && b_info->max_vcpus != max_vcpus) { -fprintf (stderr,"xl: vnuma vcpus and maxvcpus= mismatch\n" ); -exit (1 ); - }else +if (b_info->max_vcpus !=0 ) { +if (b_info->max_vcpus != max_vcpus) { +fprintf (stderr,"xl: vnuma vcpus and maxvcpus= mismatch\n" ); +exit (1 ); + } + }else { +int host_cpus =libxl_get_online_cpus (ctx); + +if (host_cpus <0 ) { +fprintf (stderr,"Failed to get online cpus\n" ); +exit (1 ); + } + +if (host_cpus < max_vcpus) { +fprintf (stderr,"xl: vnuma specifies more vcpus than pcpus, " \ +"use maxvcpus= to override this check.\n" ); +exit (1 ); + } + b_info->max_vcpus = max_vcpus; + }/* User has specified maxmem= */ if (b_info->max_memkb != LIBXL_MEMKB_DEFAULT &&
Signature · 1 line
2.1.4
Re: [PATCH for-4.6 v2 2/3] xl: error out if vNUMA specifies more vcpus than pcpus
Quoted 3 lines · Wei Liu
... but allow user to override that check by specifying maxvcpus= in xl configuration file.
Ok, from the discussion on v1, and from the subject of this new submission, I now see that what you're after the "more vcpus (in a single guest) than pcpus" case.
This is so uncommon, IMO, that it did not even cross my mind while looking at v1.. Sorry for this. :-)
That being said, I agree with IanC's view, as he expressed it during v1 review, and I find this new version of the patch much better!
However, although I like the idea, as I said...
Quoted 19 lines
tools/libxl/xl_cmdimpl.c +7
-4@@ -1202,11 +1202,27 @@ static void parse_vnuma_config(const XLU_Config *config, }/* User has specified maxvcpus= */ -if (b_info->max_vcpus !=0 && b_info->max_vcpus != max_vcpus) { -fprintf (stderr,"xl: vnuma vcpus and maxvcpus= mismatch\n" ); -exit (1 ); - }else +if (b_info->max_vcpus !=0 ) { +if (b_info->max_vcpus != max_vcpus) { +fprintf (stderr,"xl: vnuma vcpus and maxvcpus= mismatch\n" ); +exit (1 ); + } + }else { +int host_cpus =libxl_get_online_cpus (ctx);
tools/libxl/xl_cmdimpl.c static void parse_vnuma_config(const XLU_Config *config, · line 1221
Quoted 10 lines
tools/libxl/xl_cmdimpl.c +9
-0+ +if (host_cpus <0 ) { +fprintf (stderr,"Failed to get online cpus\n" ); +exit (1 ); + } + +if (host_cpus < max_vcpus) { +fprintf (stderr,"xl: vnuma specifies more vcpus than pcpus, " \ +"use maxvcpus= to override this check.\n" );
...isn't it too late, when we get to here?
In fact, if b_info->max_vcpus is 0, the elements of vcpu_parsed are sized against the host pcpus, and we risk to call libxl_bitmap_set() for vcpus beyond that limit, while parsing the "vcpus" subsection of the vnode specification (which happens _before_ this check).
Or am I missing something?
Assuming I'm not, it seems to me that a solution could be to check for this situation _inside_ the 'else if (!strcmp("vcpus", option))'. In fact, if "maxvcpus" has not been specified, as soon as the end of one of the ranges --as returned by parse_range()-- is beyond host_cpus, we know we'd be going past the limit of the corresponding element of vcpu_parsed, and we can error out.
It'll most likely be a bit uglier than this patch, but probably still less complex than v1. :-)
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 for-4.6 v2 2/3] xl: error out if vNUMA specifies more vcpus than pcpus
Quoted 47 lines · Dario Faggioli
Quoted 3 lines · Wei Liu
... but allow user to override that check by specifying maxvcpus= in xl configuration file.
Ok, from the discussion on v1, and from the subject of this new submission, I now see that what you're after the "more vcpus (in a single guest) than pcpus" case.
This is so uncommon, IMO, that it did not even cross my mind while looking at v1.. Sorry for this. :-)
That being said, I agree with IanC's view, as he expressed it during v1 review, and I find this new version of the patch much better!
However, although I like the idea, as I said...
Quoted 19 lines
tools/libxl/xl_cmdimpl.c +7
-4@@ -1202,11 +1202,27 @@ static void parse_vnuma_config(const XLU_Config *config, }/* User has specified maxvcpus= */ -if (b_info->max_vcpus !=0 && b_info->max_vcpus != max_vcpus) { -fprintf (stderr,"xl: vnuma vcpus and maxvcpus= mismatch\n" ); -exit (1 ); - }else +if (b_info->max_vcpus !=0 ) { +if (b_info->max_vcpus != max_vcpus) { +fprintf (stderr,"xl: vnuma vcpus and maxvcpus= mismatch\n" ); +exit (1 ); + } + }else { +int host_cpus =libxl_get_online_cpus (ctx);tools/libxl/xl_cmdimpl.c static void parse_vnuma_config(const XLU_Config *config, · line 1221
Quoted 10 lines
tools/libxl/xl_cmdimpl.c +9
-0+ +if (host_cpus <0 ) { +fprintf (stderr,"Failed to get online cpus\n" ); +exit (1 ); + } + +if (host_cpus < max_vcpus) { +fprintf (stderr,"xl: vnuma specifies more vcpus than pcpus, " \ +"use maxvcpus= to override this check.\n" );...isn't it too late, when we get to here?
Quoted 7 lines
In fact, if
b_info->max_vcpusis 0, the elements ofvcpu_parsedare sized against the host pcpus, and we risk to calllibxl_bitmap_set()for vcpus beyond that limit, while parsing the "vcpus" subsection of the vnode specification (which happens _before_ this check).Or am I missing something?
That's fine because that function has no effect when you try to set a bit beyond its size.
Quoted 10 lines
Assuming I'm not, it seems to me that a solution could be to check for this situation _inside_ the 'else if (!strcmp("vcpus", option))'. In fact, if "maxvcpus" has not been specified, as soon as the end of one of the ranges --as returned by parse_range()-- is beyond
host_cpus, we know we'd be going past the limit of the corresponding element ofvcpu_parsed, and we can error out.It'll most likely be a bit uglier than this patch, but probably still less complex than v1. :-)
That doesn't make any difference in terms of functionality. I would rather leave the parsing bit as it is and deal with fallout separately. That would make code cleaner IMHO.
Wei.
Quoted 7 lines
Regards,
DarioSignature · 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)
Dario Faggioli
Reviewed-byRe: [PATCH for-4.6 v2 2/3] xl: error out if vNUMA specifies more vcpus than pcpus
Quoted 32 lines · Wei Liu
Quoted 20 lines · Dario Faggioli
Quoted 20 lines
tools/libxl/xl_cmdimpl.c +10
-4@@ -1202,11 +1202,27 @@ static void parse_vnuma_config(const XLU_Config *config, }/* User has specified maxvcpus= */ -if (b_info->max_vcpus !=0 && b_info->max_vcpus != max_vcpus) { -fprintf (stderr,"xl: vnuma vcpus and maxvcpus= mismatch\n" ); -exit (1 ); - }else +if (b_info->max_vcpus !=0 ) { +if (b_info->max_vcpus != max_vcpus) { +fprintf (stderr,"xl: vnuma vcpus and maxvcpus= mismatch\n" ); +exit (1 ); + } + }else { +int host_cpus =libxl_get_online_cpus (ctx); + +if (host_cpus <0 ) { +fprintf (stderr,"Failed to get online cpus\n" );Quoted 9 lines
tools/libxl/xl_cmdimpl.c static void parse_vnuma_config(const XLU_Config *config, · line 1226
Quoted 7 lines
tools/libxl/xl_cmdimpl.c +6
-0+exit (1 ); + } + +if (host_cpus < max_vcpus) { +fprintf (stderr,"xl: vnuma specifies more vcpus than pcpus, " \ +"use maxvcpus= to override this check.\n" );...isn't it too late, when we get to here?
Quoted 3 lines
That's fine because that function has no effect when you try to set a bit beyond its size.
Well, right. Fair enough.
Quoted 7 lines
Quoted 7 lines
Assuming I'm not, it seems to me that a solution could be to check for this situation _inside_ the 'else if (!strcmp("vcpus", option))'. In fact, if "maxvcpus" has not been specified, as soon as the end of one of the ranges --as returned by parse_range()-- is beyond
host_cpus, we know we'd be going past the limit of the corresponding element ofvcpu_parsed, and we can error out.
Quoted 8 lines
Quoted 3 lines
It'll most likely be a bit uglier than this patch, but probably still less complex than v1. :-)
That doesn't make any difference in terms of functionality. I would rather leave the parsing bit as it is and deal with fallout separately. That would make code cleaner IMHO.
It's certainly cleaner as it is right now, in this version of the patch.
I still find the thing above a bit confusing, although correct because of the fact that bitmap set is a nop if performed out of range.
Perhaps a short comment? Anyway, I don't have a strong opinion on this so, with or without it (the comment):
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 for-4.6 v2 2/3] xl: error out if vNUMA specifies more vcpus than pcpus
In reply to Wei LiuQuoted 10 lines · Wei Liu
Quoted 7 lines
In fact, if
b_info->max_vcpusis 0, the elements ofvcpu_parsedare sized against the host pcpus, and we risk to calllibxl_bitmap_set()for vcpus beyond that limit, while parsing the "vcpus" subsection of the vnode specification (which happens _before_ this check).Or am I missing something?
That's fine because that function has no effect when you try to set a bit beyond its size.
This sort of subtlety is worthy of a comment in either the code of the commit message.
Quoted 6 lines
Quoted 6 lines
Assuming I'm not, it seems to me that a solution could be to check for this situation _inside_ the 'else if (!strcmp("vcpus", option))'. In fact, if "maxvcpus" has not been specified, as soon as the end of one of the ranges --as returned by parse_range()-- is beyond
host_cpus, we know we'd be going past the limit of the corresponding element ofvcpu_parsed, and we can error out.
FWIW that's what I was expecting to happen...
Quoted 7 lines
Quoted 2 lines
It'll most likely be a bit uglier than this patch, but probably still less complex than v1. :-)
That doesn't make any difference in terms of functionality. I would rather leave the parsing bit as it is and deal with fallout separately.
That would make code cleaner IMHO.
... It's a bit wasteful to keep parsing after things have already failed, but I suppose that's not too bad and we can live with it.
Ian
Re: [PATCH for-4.6 v2 2/3] xl: error out if vNUMA specifies more vcpus than pcpus
Quoted 27 lines · Ian Campbell
Quoted 10 lines · Wei Liu
Quoted 7 lines
In fact, if
b_info->max_vcpusis 0, the elements ofvcpu_parsedare sized against the host pcpus, and we risk to calllibxl_bitmap_set()for vcpus beyond that limit, while parsing the "vcpus" subsection of the vnode specification (which happens _before_ this check).Or am I missing something?
That's fine because that function has no effect when you try to set a bit beyond its size.
This sort of subtlety is worthy of a comment in either the code of the commit message.
Quoted 6 lines
Quoted 6 lines
Assuming I'm not, it seems to me that a solution could be to check for this situation _inside_ the 'else if (!strcmp("vcpus", option))'. In fact, if "maxvcpus" has not been specified, as soon as the end of one of the ranges --as returned by parse_range()-- is beyond
host_cpus, we know we'd be going past the limit of the corresponding element ofvcpu_parsed, and we can error out.FWIW that's what I was expecting to happen...
Quoted 2 lines
Quoted 2 lines
It'll most likely be a bit uglier than this patch, but probably still less complex than v1. :-)
Quoted 8 lines
Quoted 4 lines
That doesn't make any difference in terms of functionality. I would rather leave the parsing bit as it is and deal with fallout separately.
That would make code cleaner IMHO.... It's a bit wasteful to keep parsing after things have already failed, but I suppose that's not too bad and we can live with it.
I will add comments and resend.
Wei.
Quoted 1 line
Ian
PATCH v2 3/3 libxc: fix vNUMA memory allocation
In reply to Wei LiuWe should use new_memflags in xc_domain_populate_physmap. That variable contains node information.
--- tools/libxc/xc_hvm_build_x86.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/libxc/xc_hvm_build_x86.c +4 -2
@@ -486,7 +486,8 @@ static int setup_guest(xc_interface *xch, done =xc_domain_populate_physmap (xch, dom, nr_extents,SUPERPAGE_1GB_SHIFT , - memflags, sp_extents); + new_memflags, + sp_extents);if ( done >0 ) {
@@ -526,7 +527,8 @@ static int setup_guest(xc_interface *xch, done =xc_domain_populate_physmap (xch, dom, nr_extents,SUPERPAGE_2MB_SHIFT , - memflags, sp_extents); + new_memflags, + sp_extents);if ( done >0 ) {
Signature · 1 line
2.1.4
Re: [PATCH for-4.6 v2 3/3] libxc: fix vNUMA memory allocation
Quoted 3 lines · Wei Liu
We should use
new_memflagsinxc_domain_populate_physmap. That variable
contains node information.
Same question as v1.
Quoted 39 lines
Reported-by Boris Ostrovsky <[email protected]>Signed-off-by Wei Liu <[email protected]>Reviewed-by Dario Faggioli <[email protected]>--- tools/libxc/xc_hvm_build_x86.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)tools/libxc/xc_hvm_build_x86.c +2
-1@@ -486,7 +486,8 @@ static int setup_guest(xc_interface *xch, done =xc_domain_populate_physmap (xch, dom, nr_extents,SUPERPAGE_1GB_SHIFT , - memflags, sp_extents); + new_memflags, + sp_extents);if ( done > 0 ) {tools/libxc/xc_hvm_build_x86.c +2
-1@@ -526,7 +527,8 @@ static int setup_guest(xc_interface *xch, done =xc_domain_populate_physmap (xch, dom, nr_extents,SUPERPAGE_2MB_SHIFT , - memflags, sp_extents); + new_memflags, + sp_extents);if ( done > 0 ) {
Empty memory nodes in VNUMA
In reply to Wei LiuWhat is the purpose of 'nr_vmemranges < nr_vnodes' test in xc_domain_setvnuma()? Can't we have nodes with no memory?
If that's the case, this check will still miss configurations when a node spans multiple memory ranges.
For example, this fails:
vcpus = 4
vnuma = [ [ "pnode=0","size=2048","vcpus=0-1" ],
[ "pnode=1","size=1800" ],
[ "pnode=2","size=0","vcpus=2-3" ],
[ "pnode=3","size=100" ] ]but this
vcpus = 4
vnuma = [ [ "pnode=0","size=2048","vcpus=0-1" ],
[ "pnode=1","size=1801" ],
[ "pnode=2","size=0","vcpus=2-3" ],
[ "pnode=3","size=100" ] ]does not: because of MMIO hole this will cause a second 1MB range to be created on node 1 (in libxl__vnuma_build_vmemrange_hvm()).
Can we drop this check?
-boris
Re: Empty memory nodes in VNUMA
Quoted 18 lines · Boris Ostrovsky
What is the purpose of '
nr_vmemranges<nr_vnodes' test inxc_domain_setvnuma()? Can't we have nodes with no memory?If that's the case, this check will still miss configurations when a node spans multiple memory ranges.
For example, this fails:
vcpus = 4
vnuma = [ [ "pnode=0","size=2048","vcpus=0-1" ],[ "pnode=1","size=1800" ], [ "pnode=2","size=0","vcpus=2-3" ], [ "pnode=3","size=100" ] ]but this
vcpus = 4
vnuma = [ [ "pnode=0","size=2048","vcpus=0-1" ],
Quoted 9 lines
[ "pnode=1","size=1801" ], [ "pnode=2","size=0","vcpus=2-3" ], [ "pnode=3","size=100" ] ]does not: because of MMIO hole this will cause a second 1MB range to be created on node 1 (in
libxl__vnuma_build_vmemrange_hvm()).Can we drop this check?
I would say yes. There is certainly such hardware that some NUMA node has 0 memory.
Note that this function was written in the early day of vNUMA (4.5). I think that function has the assumption that each vnode has one vmemrange.
Try removing that check and see what happens?
But, how far are you willing to go? Do you want system with no vmemranges at all (that means, no memory at all)? If so that nr_vmemranges == 0 check should also be removed. Just kidding...
Wei.
Quoted 2 lines
-boris
Re: Empty memory nodes in VNUMA
Quoted 28 lines · Wei Liu
Quoted 18 lines · Boris Ostrovsky
What is the purpose of '
nr_vmemranges<nr_vnodes' test inxc_domain_setvnuma()? Can't we have nodes with no memory?If that's the case, this check will still miss configurations when a node spans multiple memory ranges.
For example, this fails:
vcpus = 4
vnuma = [ [ "pnode=0","size=2048","vcpus=0-1" ],[ "pnode=1","size=1800" ], [ "pnode=2","size=0","vcpus=2-3" ], [ "pnode=3","size=100" ] ]but this
vcpus = 4
vnuma = [ [ "pnode=0","size=2048","vcpus=0-1" ],Quoted 9 lines
[ "pnode=1","size=1801" ], [ "pnode=2","size=0","vcpus=2-3" ], [ "pnode=3","size=100" ] ]does not: because of MMIO hole this will cause a second 1MB range to be created on node 1 (in
libxl__vnuma_build_vmemrange_hvm()).Can we drop this check?
Quoted 8 lines
I would say yes. There is certainly such hardware that some NUMA node has 0 memory.
Note that this function was written in the early day of vNUMA (4.5). I think that function has the assumption that each vnode has one vmemrange.
Try removing that check and see what happens?
I already did --- you think I'd ask without first trying? ;-) Yes, it works fine --- one a couple of tests that I tried.
Do you want me to send a patch?
-boris
Quoted 8 lines
But, how far are you willing to go? Do you want system with no vmemranges at all (that means, no memory at all)? If so that
nr_vmemranges== 0 check should also be removed. Just kidding...Wei.
Quoted 1 line
-boris
Re: Empty memory nodes in VNUMA
Quoted 32 lines · Boris Ostrovsky
Quoted 31 lines · Wei Liu
Quoted 18 lines · Boris Ostrovsky
What is the purpose of '
nr_vmemranges<nr_vnodes' test inxc_domain_setvnuma()? Can't we have nodes with no memory?If that's the case, this check will still miss configurations when a node spans multiple memory ranges.
For example, this fails:
vcpus = 4
vnuma = [ [ "pnode=0","size=2048","vcpus=0-1" ],[ "pnode=1","size=1800" ], [ "pnode=2","size=0","vcpus=2-3" ], [ "pnode=3","size=100" ] ]but this
vcpus = 4
vnuma = [ [ "pnode=0","size=2048","vcpus=0-1" ],Quoted 9 lines
[ "pnode=1","size=1801" ], [ "pnode=2","size=0","vcpus=2-3" ], [ "pnode=3","size=100" ] ]does not: because of MMIO hole this will cause a second 1MB range to be created on node 1 (in
libxl__vnuma_build_vmemrange_hvm()).Can we drop this check?
I would say yes. There is certainly such hardware that some NUMA node has 0 memory.
Quoted 9 lines
Quoted 5 lines
Note that this function was written in the early day of vNUMA (4.5). I think that function has the assumption that each vnode has one vmemrange.
Try removing that check and see what happens?
I already did --- you think I'd ask without first trying? ;-) Yes, it works fine --- one a couple of tests that I tried.
Cool. :-)
Quoted 2 lines
Do you want me to send a patch?
Sure. Much appreciated.
Wei.
Quoted 10 lines
-boris
Quoted 8 lines
But, how far are you willing to go? Do you want system with no vmemranges at all (that means, no memory at all)? If so that
nr_vmemranges== 0 check should also be removed. Just kidding...Wei.
Quoted 1 line
-boris