libxl: use xc_topologyinfo to figure out how many CPUs we actually have
PATCH 1/1 libxl: use xc_topologyinfo to figure out how many CPUs we actually have
Within libxl_get_cpu_topology(), considering all the CPUs the hypervisor supports to be valid topology entries might lead to misleading and incorrect behaviours, e.g., the output of `xl info -n' below on a 16 cores machine:
...cpu_topology :
cpu: core socket node
0: 0 1 0 1: 0 1 0 2: 1 1 0 3: 1 1 0 4: 9 1 0 5: 9 1 0 6: 10 1 0 7: 10 1 0 8: 0 0 1 9: 0 0 1 10: 1 0 1 11: 1 0 1 12: 9 0 1 13: 9 0 1 14: 10 0 1 15: 10 0 1 16: 0 0 0 17: 0 0 0 18: 0 0 0 19: 0 0 0 20: 0 0 0 ... ... 62: 0 0 0 63: 0 0 0
However, xc_topologyinfo() tells us (in max_cpu_index) how many entries arrays it returns corresponds to actually valid CPUs, so let's use that information.
tools/libxl/libxl.c +2 -1
@@ -2903,7 +2903,8 @@ libxl_cputopology *libxl_get_cpu_topolog }for (i =0 ; i < max_cpus; i++) { -#define V (map, i) (map[i] == INVALID_TOPOLOGY_ID) ? \ +#define V (map, i) (i > tinfo.max_cpu_index || \ + map[i] == INVALID_TOPOLOGY_ID) ? \ LIBXL_CPUTOPOLOGY_INVALID_ENTRY : map[i] ret[i].core =V (coremap, i); ret[i].socket =V (socketmap, i);
Quoted 6 lines · Darrio Faggioli
Within
libxl_get_cpu_topology(), considering all the CPUs the hypervisor supports to be valid topology entries might lead to misleading and incorrect behaviours, e.g., the output of `xl info -n' below on a 16 cores machine:
...
<snip>
Quoted 6 lines
However,
xc_topologyinfo()tells us (inmax_cpu_index) how many entries arrays it returns corresponds to actually valid CPUs, so let's use that information.Signed-off-by Dario Faggioli <[email protected]>
And, as it is an actual bugfix and very very small in size, not to forget that I'd need that for the NUMA placement series, I'm proposing this for 4.2... Does it make sense?
Thanks and Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://retis.sssup.it/people/faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
tools/libxl/libxl.c libxl_cputopology *libxl_get_cpu_topolog · line 2907
Quoted 10 lines · Darrio Faggioli
tools/libxl/libxl.c +2
-1@@ -2903,7 +2903,8 @@ libxl_cputopology *libxl_get_cpu_topolog }for (i =0 ; i < max_cpus; i++) { -#define V (map, i) (map[i] == INVALID_TOPOLOGY_ID) ? \ +#define V (map, i) (i > tinfo.max_cpu_index || \ + map[i] == INVALID_TOPOLOGY_ID) ? \
This ensures that cpus entries above max_cpu_index are INVALID_TOPOLOGY_ID but do you also want to size the return array using tinfo.max_cpu_index too? And also return that in *nr instead of?
(I don't know the answer, either of max-possible- and max-online-cpus is a reasonable size for this array)
Quoted 3 lines
tools/libxl/libxl.c +0
-0LIBXL_CPUTOPOLOGY_INVALID_ENTRY : map[i] ret[i].core = V(coremap, i); ret[i].socket =V (socketmap, i);
Quoted 7 lines · Ian Campbell
Quoted 6 lines · Darrio Faggioli
tools/libxl/libxl.c +0
-0@@ -2903,7 +2903,8 @@ libxl_cputopology *libxl_get_cpu_topolog }
Quoted 8 lines
tools/libxl/libxl.c libxl_cputopology *libxl_get_cpu_topolog · line 2907
Quoted 4 lines
tools/libxl/libxl.c +2
-1for (i =0 ; i < max_cpus; i++) { -#define V (map, i) (map[i] == INVALID_TOPOLOGY_ID) ? \ +#define V (map, i) (i > tinfo.max_cpu_index || \ + map[i] == INVALID_TOPOLOGY_ID) ? \This ensures that cpus entries above
max_cpu_indexareINVALID_TOPOLOGY_ID
Yep, thus giving consumers of this call the chance to figure out what the valid entries are. It looked the most natural way of doing this, given output_topology (for instance) already check for LIBXL_CPUTOPOLOGY_INVALID_ENTRY entries and skip them.
Also, the get-cpu-topology command in xenpm, which always worked properly on my testbox, does exactly that.
Quoted 6 lines
but do you also want to size the return array using tinfo.max_cpu_index too? And also return that in *nr instead of?
(I don't know the answer, either of max-possible- and max-online-cpus is a reasonable size for this array)
Well, I really don't know either. This is the minimum impact working version. For sure, I'd like very much to return that value via *nr, as it will give me something more sensible to work with... You know what, I'm sending a patch doing exactly that, as I think what you're suggesting is actually better.
Thanks,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://retis.sssup.it/people/faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Dario Faggioli writes ("Re: [PATCH] libxl: use xc_topologyinfo to figure out how many CPUs we actually have"):
Quoted 3 lines
And, as it is an actual bugfix and very very small in size, not to forget that I'd need that for the NUMA placement series, I'm proposing this for 4.2... Does it make sense?
It seems to to me that this is indeed 4.2 material.
Ian.
Quoted 7 lines · Ian Jackson
Dario Faggioli writes ("Re: [PATCH] libxl: use
xc_topologyinfoto figure out how many CPUs we actually have"):Quoted 3 lines
And, as it is an actual bugfix and very very small in size, not to forget that I'd need that for the NUMA placement series, I'm proposing this for 4.2... Does it make sense?
It seems to to me that this is indeed 4.2 material.
Cool. :-) Aside from that, any comments (better if on the v2 here
http://permalink.gmane.org/gmane.comp.emulators.xen.devel/130218) ?
Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://retis.sssup.it/people/faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel