Skip to contentSkip to conversation

libxc bitmap utils and vcpu-affinity

PATCH In review Dulloor 3 participants 12 messages Mar 22, 2010 – Mar 30, 2010 Arm/actions semi architecture

lore
Share & tools
lore

Dulloor

author
#0 lore raw

PATCH 1/1 libxc bitmap utils and vcpu-affinity

This patch adds :

* A byte-based cpumask type(xenctl_cpumask) for setting vcpu-affinity as well as numa-node-affinity, etc in libxc.

* Add common bitmap utils to libxc, which can be used both for xenctl_cpumask (and with small changes for xenctl_cpumap, if desired), so that we can do common operations on cpumask easily.

As opposed to xenctl_cpumap, xenctl_cpumask is a static structure (just 4 bytes larger for 128 cpus), but keeps the interface/code cleaner. The domctl_interface version keeps the size of xenctl_cpumask consistent between xen and xen-tools.

-dulloor

tools/libxc/Makefile +1 -0
diff -r 04cb0829d138 tools/libxc/Makefile
@@ -25,6 +25,7 @@
 CTRL_SRCS-y       += xc_mem_event.c
 CTRL_SRCS-y       += xc_mem_paging.c
 CTRL_SRCS-y       += xc_memshr.c
+CTRL_SRCS-y       += xc_bitmap.c
 CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c
 CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c
 CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c
tools/libxc/xc_bitmap.c new file +250 -0

250 lines not on this page · raw message

tools/libxc/xc_bitmap.h new file +193 -0

193 lines not on this page · raw message

tools/libxc/xc_cpumask.h new file +211 -0

211 lines not on this page · raw message

tools/libxc/xc_domain.c +6 -46

90 lines not on this page · raw message

tools/libxc/xenctrl.h +2 -4
diff -r 04cb0829d138 tools/libxc/xenctrl.h
@@ -309,13 +309,11 @@
 int xc_vcpu_setaffinity(int xc_handle,
                         uint32_t domid,
                         int vcpu,
-                        uint64_t *cpumap,
-                        int cpusize);
+                        struct xenctl_cpumask *cpumask);
 int xc_vcpu_getaffinity(int xc_handle,
                         uint32_t domid,
                         int vcpu,
-                        uint64_t *cpumap,
-                        int cpusize);
+                        struct xenctl_cpumask *cpumask);
 
 /**
  * This function will return information about one or more domains. It is
tools/python/xen/lowlevel/xc/xc.c +10 -55

126 lines not on this page · raw message

xen/common/domctl.c +38 -5

59 lines not on this page · raw message

xen/include/public/domctl.h +24 -3
diff -r 04cb0829d138 xen/include/public/domctl.h
@@ -35,11 +35,32 @@
 #include "xen.h"
 #include "grant_table.h"
 
-#define XEN_DOMCTL_INTERFACE_VERSION 0x00000006
+#define XEN_DOMCTL_INTERFACE_VERSION 0x00000007
+
+#define XENCTL_NR_CPUS          128
+#define XENCTL_BITS_PER_BYTE    8
+
+#define XENCTL_BITS_TO_BYTES(bits) \
+    (((bits)+XENCTL_BITS_PER_BYTE-1)/XENCTL_BITS_PER_BYTE)
+#define XENCTL_DECLARE_BITMAP(name,bits) \
+    uint8_t name[XENCTL_BITS_TO_BYTES(bits)]
+
+/* xenctl_cpumask :
+ * This is a static structure as opposed to xenctl_cpumap.
+ * We don't pass any nr_cpus parameter, but XENCTL_NR_CPUS is kept consistent
+ * between xen and xen-tools through interface versions.
+ * However, XENCTL_NR_CPUS and NR_CPUS should be equal.
+ */
+
+#define xc_cpumask_bits(maskp) ((maskp)->bits)
+#define xc_cpumask_len(maskp) (XENCTL_NR_CPUS)
+struct xenctl_cpumask {
+    XENCTL_DECLARE_BITMAP(bits, XENCTL_NR_CPUS);
+};
 
 struct xenctl_cpumap {
+    uint32_t nr_cpus;
     XEN_GUEST_HANDLE_64(uint8) bitmap;
-    uint32_t nr_cpus;
 };
 
 /*
@@ -285,7 +306,7 @@
 /* XEN_DOMCTL_getvcpuaffinity */
 struct xen_domctl_vcpuaffinity {
     uint32_t  vcpu;              /* IN */
-    struct xenctl_cpumap cpumap; /* IN/OUT */
+    struct xenctl_cpumask cpumask; /* IN/OUT */
 };
 typedef struct xen_domctl_vcpuaffinity xen_domctl_vcpuaffinity_t;
 DEFINE_XEN_GUEST_HANDLE(xen_domctl_vcpuaffinity_t);
xen/include/xen/cpumask.h +8 -1
diff -r 04cb0829d138 xen/include/xen/cpumask.h
@@ -425,8 +425,15 @@
 /* Copy to/from cpumap provided by control tools. */
 struct xenctl_cpumap;
 void cpumask_to_xenctl_cpumap(
-    struct xenctl_cpumap *enctl_cpumap, cpumask_t *cpumask);
+    struct xenctl_cpumap *xenctl_cpumap, cpumask_t *cpumask);
 void xenctl_cpumap_to_cpumask(
     cpumask_t *cpumask, struct xenctl_cpumap *enctl_cpumap);
 
+/* Copy to/from cpumask used by control tools. */
+struct xenctl_cpumask;
+void cpumask_to_xenctl_cpumask(
+    struct xenctl_cpumask *xenctl_cpumask, cpumask_t *cpumask);
+void xenctl_cpumask_to_cpumask(
+    cpumask_t *cpumask, struct xenctl_cpumask *xenctl_cpumask);
+
 #endif /* __XEN_CPUMASK_H */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 5 lines · Dulloor

This patch adds :

* A byte-based cpumask type(xenctl_cpumask) for setting vcpu-affinity as well as numa-node-affinity, etc in libxc.

Quoted 8 lines

* Add common bitmap utils to libxc, which can be used both for xenctl_cpumask (and with small changes for xenctl_cpumap, if desired), so that we can do common operations on cpumask easily.

As opposed to xenctl_cpumap, xenctl_cpumask is a static structure (just 4 bytes larger for 128 cpus), but keeps the interface/code cleaner. The domctl_interface version keeps the size of xenctl_cpumask consistent between xen and xen-tools.

I'm missing the motivation for this. It sounds less good than what we have already.

-- Keir

author
#2 lore raw
Quoted 2 lines

I'm missing the motivation for this. It sounds less good than what we have already.

xenctl_cpumap is dynamic and could work for any size, but there are many reasons for adding xenctl_cpumask.

Motivation for new data type and bitmap utils in libxc :
- xenctl_cpumask is a simple and useful data type in xen-tools. We deal with cpumasks at several places and the need increases with numa (for instance, node selection with guest numa).
- The bitmap utils in the patch could work with both xenctl_cpumap as well as xenctl_cpumask structure. So, that part is independent of the new structure. And, I can just submit that part alone, if we decide to stay with xenctl_cpumap.

Motivation for using xenctl_cpumask in Xen interfaces :
- xenctl_cpumap is just 4 bytes smaller than static xenctl_cpumask for 128 cpus (128 would be good for quite some time). However, the new data type cleans up the code considerably, as you can see from its use in vcpu_(set|get)affinity - no need to read physinfo, lock pages separately, etc.
- Maintaining the size of xenctl_cpumask consistent between xen and xen-tools is simple. And, conversion between xenctl_cpumask and cpumask inside xen is simple too (not much different from before).
- There are other interfaces where xenctl_cpumask could be used. For pv guest numa, I pass cpumasks in the start-info and the structure needs to be static. The size of the structure is kept consistent through a numa-interface version.

-dulloor

Quoted 23 lines · Keir Fraser
Quoted 5 lines · Dulloor

This patch adds :

* A byte-based cpumask type(xenctl_cpumask) for setting vcpu-affinity as well as numa-node-affinity, etc in libxc.

Quoted 8 lines

* Add common bitmap utils to libxc, which can be used both for xenctl_cpumask (and with small changes for xenctl_cpumap, if desired), so that we can do common operations on cpumask easily.

As opposed to xenctl_cpumap, xenctl_cpumask is a static structure (just 4 bytes larger for 128 cpus), but keeps the interface/code cleaner. The domctl_interface version keeps the size of xenctl_cpumask consistent between xen and xen-tools.

I'm missing the motivation for this. It sounds less good than what we have already.

 -- Keir

#3 lore raw
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Dulloor <[email protected]> 22.03.10 18:44 >>>

Motivation for using xenctl_cpumask in Xen interfaces :
- xenctl_cpumap is just 4 bytes smaller than static xenctl_cpumask for 128 cpus (128 would be good for quite some time). However, the new

I don't buy this (we're already building for 256 CPUs, looking forward to further bump this in the not too distant future), and I'm generally opposed to introducing hard coded limits in a public interface.

Jan

#4 lore raw
Quoted 8 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Dulloor <[email protected]> 22.03.10 18:44 >>>

Motivation for using xenctl_cpumask in Xen interfaces :
- xenctl_cpumap is just 4 bytes smaller than static xenctl_cpumask for 128 cpus (128 would be good for quite some time). However, the new

I don't buy this (we're already building for 256 CPUs, looking forward to further bump this in the not too distant future), and I'm generally opposed to introducing hard coded limits in a public interface.

We should use xenctl_cpumask everywhere for specifying physical CPU bitmaps, even into guest NUMA interfaces if appropriate. I don't really care if it is a bit harder to use than a static bitmap.

-- Keir

author
#5 lore raw

Fine, I agree with you both. Attached is a patch adding utils for xenctl_bitmap (to libxc) and using the same in vcpu_(get|set)affinity. For the guest-numa interface, I will see if I can use xenctl_cpumap.

-dulloor

Quoted 11 lines · Keir Fraser
Quoted 8 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Dulloor <[email protected]> 22.03.10 18:44 >>>

Motivation for using xenctl_cpumask in Xen interfaces :
- xenctl_cpumap is just 4 bytes smaller than static xenctl_cpumask for 128 cpus (128 would be good for quite some time). However, the new

I don't buy this (we're already building for 256 CPUs, looking forward to further bump this in the not too distant future), and I'm generally opposed to introducing hard coded limits in a public interface.

Quoted 8 lines

We should use xenctl_cpumask everywhere for specifying physical CPU bitmaps, even into guest NUMA interfaces if appropriate. I don't really care if it is a bit harder to use than a static bitmap.

 -- Keir

tools/libxc/Makefile +1 -0
diff -r 04cb0829d138 tools/libxc/Makefile
@@ -25,6 +25,7 @@
 CTRL_SRCS-y       += xc_mem_event.c
 CTRL_SRCS-y       += xc_mem_paging.c
 CTRL_SRCS-y       += xc_memshr.c
+CTRL_SRCS-y       += xc_bitmap.c
 CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c
 CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c
 CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c
tools/libxc/xc_bitmap.c new file +250 -0

250 lines not on this page · raw message

tools/libxc/xc_bitmap.h new file +193 -0

193 lines not on this page · raw message

tools/libxc/xc_cpumap.h new file +274 -0

274 lines not on this page · raw message

tools/libxc/xc_domain.c +10 -33

92 lines not on this page · raw message

tools/libxc/xenctrl.h +2 -4
diff -r 04cb0829d138 tools/libxc/xenctrl.h
@@ -309,13 +309,11 @@
 int xc_vcpu_setaffinity(int xc_handle,
                         uint32_t domid,
                         int vcpu,
-                        uint64_t *cpumap,
-                        int cpusize);
+                        struct xenctl_cpumap *cpumap);
 int xc_vcpu_getaffinity(int xc_handle,
                         uint32_t domid,
                         int vcpu,
-                        uint64_t *cpumap,
-                        int cpusize);
+                        struct xenctl_cpumap *cpumap);
 
 /**
  * This function will return information about one or more domains. It is
tools/python/xen/lowlevel/xc/xc.c +17 -50

127 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

author
#6 lore raw

I meant utils for **xenctl_cpumap**

Quoted 27 lines · Dulloor

Fine, I agree with you both. Attached is a patch adding utils for xenctl_bitmap (to libxc) and using the same in vcpu_(get|set)affinity. For the guest-numa interface, I will see if I can use xenctl_cpumap.

-dulloor

Quoted 19 lines · Keir Fraser
Quoted 8 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Dulloor <[email protected]> 22.03.10 18:44 >>>

Motivation for using xenctl_cpumask in Xen interfaces :
- xenctl_cpumap is just 4 bytes smaller than static xenctl_cpumask for 128 cpus (128 would be good for quite some time). However, the new

I don't buy this (we're already building for 256 CPUs, looking forward to further bump this in the not too distant future), and I'm generally opposed to introducing hard coded limits in a public interface.

We should use xenctl_cpumask everywhere for specifying physical CPU bitmaps, even into guest NUMA interfaces if appropriate. I don't really care if it is a bit harder to use than a static bitmap.

 -- Keir

author
#7 lore raw

Please use this patch, in which length of bitmap is (physinfo.max_cpu_id+1), rather than (physinfo.nr_cpus).

-dulloor

Quoted 31 lines · Dulloor

I meant utils for **xenctl_cpumap**

Quoted 27 lines · Dulloor

Fine, I agree with you both. Attached is a patch adding utils for xenctl_bitmap (to libxc) and using the same in vcpu_(get|set)affinity. For the guest-numa interface, I will see if I can use xenctl_cpumap.

-dulloor

Quoted 19 lines · Keir Fraser
Quoted 8 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Dulloor <[email protected]> 22.03.10 18:44 >>>

Motivation for using xenctl_cpumask in Xen interfaces :
- xenctl_cpumap is just 4 bytes smaller than static xenctl_cpumask for 128 cpus (128 would be good for quite some time). However, the new

I don't buy this (we're already building for 256 CPUs, looking forward to further bump this in the not too distant future), and I'm generally opposed to introducing hard coded limits in a public interface.

We should use xenctl_cpumask everywhere for specifying physical CPU bitmaps, even into guest NUMA interfaces if appropriate. I don't really care if it is a bit harder to use than a static bitmap.

 -- Keir

tools/libxc/Makefile +1 -0
diff -r 04cb0829d138 tools/libxc/Makefile
@@ -25,6 +25,7 @@
 CTRL_SRCS-y       += xc_mem_event.c
 CTRL_SRCS-y       += xc_mem_paging.c
 CTRL_SRCS-y       += xc_memshr.c
+CTRL_SRCS-y       += xc_bitmap.c
 CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c
 CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c
 CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c
tools/libxc/xc_bitmap.c new file +250 -0

250 lines not on this page · raw message

tools/libxc/xc_bitmap.h new file +193 -0

193 lines not on this page · raw message

tools/libxc/xc_cpumap.h new file +274 -0

274 lines not on this page · raw message

tools/libxc/xc_domain.c +10 -33

92 lines not on this page · raw message

tools/libxc/xenctrl.h +2 -4
diff -r 04cb0829d138 tools/libxc/xenctrl.h
@@ -309,13 +309,11 @@
 int xc_vcpu_setaffinity(int xc_handle,
                         uint32_t domid,
                         int vcpu,
-                        uint64_t *cpumap,
-                        int cpusize);
+                        struct xenctl_cpumap *cpumap);
 int xc_vcpu_getaffinity(int xc_handle,
                         uint32_t domid,
                         int vcpu,
-                        uint64_t *cpumap,
-                        int cpusize);
+                        struct xenctl_cpumap *cpumap);
 
 /**
  * This function will return information about one or more domains. It is
tools/python/xen/lowlevel/xc/xc.c +17 -50

127 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

author
#8 lore raw

PATCH 1/1 libxc bitmap utils and vcpu-affinity

Resubmitting the patch.

-dulloor

---------- Forwarded message ----------
From: Dulloor <[email protected]>
Date: Tue, Mar 23, 2010 at 12:55 PM
Subject: Re: [Xen-devel][PATCH] libxc bitmap utils and vcpu-affinity
To: Keir Fraser <[email protected]>
Cc: Jan Beulich <[email protected]>, "[email protected]" <[email protected]>

Please use this patch, in which length of bitmap is (physinfo.max_cpu_id+1), rather than (physinfo.nr_cpus).

-dulloor

Quoted 31 lines · Dulloor

I meant utils for **xenctl_cpumap**

Quoted 27 lines · Dulloor

Fine, I agree with you both. Attached is a patch adding utils for xenctl_bitmap (to libxc) and using the same in vcpu_(get|set)affinity. For the guest-numa interface, I will see if I can use xenctl_cpumap.

-dulloor

Quoted 19 lines · Keir Fraser
Quoted 8 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Dulloor <[email protected]> 22.03.10 18:44 >>>

Motivation for using xenctl_cpumask in Xen interfaces :
- xenctl_cpumap is just 4 bytes smaller than static xenctl_cpumask for 128 cpus (128 would be good for quite some time). However, the new

I don't buy this (we're already building for 256 CPUs, looking forward to further bump this in the not too distant future), and I'm generally opposed to introducing hard coded limits in a public interface.

We should use xenctl_cpumask everywhere for specifying physical CPU bitmaps, even into guest NUMA interfaces if appropriate. I don't really care if it is a bit harder to use than a static bitmap.

 -- Keir

tools/libxc/Makefile +1 -0
diff -r 04cb0829d138 tools/libxc/Makefile
@@ -25,6 +25,7 @@
 CTRL_SRCS-y       += xc_mem_event.c
 CTRL_SRCS-y       += xc_mem_paging.c
 CTRL_SRCS-y       += xc_memshr.c
+CTRL_SRCS-y       += xc_bitmap.c
 CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c
 CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c
 CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c
tools/libxc/xc_bitmap.c new file +250 -0

250 lines not on this page · raw message

tools/libxc/xc_bitmap.h new file +193 -0

193 lines not on this page · raw message

tools/libxc/xc_cpumap.h new file +274 -0

274 lines not on this page · raw message

tools/libxc/xc_domain.c +10 -33

92 lines not on this page · raw message

tools/libxc/xenctrl.h +2 -4
diff -r 04cb0829d138 tools/libxc/xenctrl.h
@@ -309,13 +309,11 @@
 int xc_vcpu_setaffinity(int xc_handle,
                         uint32_t domid,
                         int vcpu,
-                        uint64_t *cpumap,
-                        int cpusize);
+                        struct xenctl_cpumap *cpumap);
 int xc_vcpu_getaffinity(int xc_handle,
                         uint32_t domid,
                         int vcpu,
-                        uint64_t *cpumap,
-                        int cpusize);
+                        struct xenctl_cpumap *cpumap);
 
 /**
  * This function will return information about one or more domains. It is
tools/python/xen/lowlevel/xc/xc.c +17 -50

127 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#9 lore raw

No changeset comment. No signed-off-by line. It actually bloats the libraries by a net 650 LOC (747 added, 87 deleted according to diffstat). And below I append the very first function I read: it doesn't inspire confidence that the implementation is over-complicated/long and unnecessarily handles 16-bit values. Why should I show your patch some love?

-- Keir

+static inline int __xc_ffs(uint8_t byte)
+{
+ int num = 0;
+
+ if ((byte & 0xff) == 0) {
+ num += 8;
+ byte >>= 8;
+ }
+ if ((byte & 0xf) == 0) {
+ num += 4;
+ byte >>= 4;
+ }
+ if ((byte & 0x3) == 0) {
+ num += 2;
+ byte >>= 2;
+ }
+ if ((byte & 0x1) == 0)
+ num += 1;
+ return num;
+}

Quoted 53 lines · Dulloor

Resubmitting the patch.

-dulloor

---------- Forwarded message ----------
From: Dulloor <[email protected]>
Date: Tue, Mar 23, 2010 at 12:55 PM
Subject: Re: [Xen-devel][PATCH] libxc bitmap utils and vcpu-affinity
To: Keir Fraser <[email protected]>
Cc: Jan Beulich <[email protected]>, "[email protected]" <[email protected]>

Please use this patch, in which length of bitmap is (physinfo.max_cpu_id+1), rather than (physinfo.nr_cpus).

-dulloor

Quoted 34 lines · Dulloor

I meant utils for **xenctl_cpumap**

Quoted 30 lines · Dulloor

Fine, I agree with you both. Attached is a patch adding utils for xenctl_bitmap (to libxc) and using the same in vcpu_(get|set)affinity. For the guest-numa interface, I will see if I can use xenctl_cpumap.

-dulloor

Quoted 21 lines · Keir Fraser
Quoted 8 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Dulloor <[email protected]> 22.03.10 18:44 >>>

Motivation for using xenctl_cpumask in Xen interfaces :
- xenctl_cpumap is just 4 bytes smaller than static xenctl_cpumask for 128 cpus (128 would be good for quite some time). However, the new

I don't buy this (we're already building for 256 CPUs, looking forward to further bump this in the not too distant future), and I'm generally opposed to introducing hard coded limits in a public interface.

We should use xenctl_cpumask everywhere for specifying physical CPU bitmaps,
even into guest NUMA interfaces if appropriate. I don't really care if it is
a bit harder to use than a static bitmap.

 -- Keir

author
#10 lore raw
Quoted 1 line

No changeset comment. No signed-off-by line.

Sorry, I forgot. Will do once we finalize on the patch.

Quoted 2 lines

It actually bloats the libraries by a net 650 LOC
(747 added, 87 deleted according to diffstat).

In the patch, we have used the library only for vcpu get/set affinity. There are clearly other opportunities (right now and in future) to use most of the functions provided by the library, which will offset this. Also, this provides a cleaner/standard way of using the cpumap structure in libxc.

Quoted 3 lines

And below I append the very first function I read: it doesn't inspire confidence that the implementation is over-complicated/long and unnecessarily handles 16-bit values.

I guess you mean 8-bit values. The library works with byte-based bitmap structures, instead of "uint32_t or uint64_t" bitmap structures, so that we don't need to convert when using the bitmap-library with xenctl_cpumap. Please let know if you would rather that we keep the bitmap utilities separate from xenctl_cpumap and provide for conversion functions. That would be a small change.

The function that you quote is inspired from linux kernel implementation (as mentioned) and is a simple generic function. And I have tested the library thoroughly.

Quoted 1 line

Why should I show your patch some love?

We can work towards that ;)

-dulloor

Quoted 87 lines · Keir Fraser

No changeset comment. No signed-off-by line. It actually bloats the libraries by a net 650 LOC (747 added, 87 deleted according to diffstat). And below I append the very first function I read: it doesn't inspire confidence that the implementation is over-complicated/long and unnecessarily handles 16-bit values. Why should I show your patch some love?

 -- Keir

tools/libxc/xc_bitmap.c new file +20 -0
+static inline int __xc_ffs(uint8_t byte)
+{
+       int num = 0;
+
+       if ((byte & 0xff) == 0) {
+               num += 8;
+               byte >>= 8;
+       }
+       if ((byte & 0xf) == 0) {
+               num += 4;
+               byte >>= 4;
+       }
+       if ((byte & 0x3) == 0) {
+               num += 2;
+               byte >>= 2;
+       }
+       if ((byte & 0x1) == 0)
+               num += 1;
+       return num;
+}
Quoted 53 lines · Dulloor

Resubmitting the patch.

-dulloor

---------- Forwarded message ----------
From: Dulloor <[email protected]>
Date: Tue, Mar 23, 2010 at 12:55 PM
Subject: Re: [Xen-devel][PATCH] libxc bitmap utils and vcpu-affinity
To: Keir Fraser <[email protected]>
Cc: Jan Beulich <[email protected]>, "[email protected]" <[email protected]>

Please use this patch, in which length of bitmap is (physinfo.max_cpu_id+1), rather than (physinfo.nr_cpus).

-dulloor

Quoted 34 lines · Dulloor

I meant utils for **xenctl_cpumap**

Quoted 30 lines · Dulloor

Fine, I agree with you both. Attached is a patch adding utils for xenctl_bitmap (to libxc) and using the same in vcpu_(get|set)affinity. For the guest-numa interface, I will see if I can use xenctl_cpumap.

-dulloor

Quoted 21 lines · Keir Fraser
Quoted 8 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Dulloor <[email protected]> 22.03.10 18:44 >>>

Motivation for using xenctl_cpumask in Xen interfaces :
- xenctl_cpumap is just 4 bytes smaller than static xenctl_cpumask for 128 cpus (128 would be good for quite some time). However, the new

I don't buy this (we're already building for 256 CPUs, looking forward to further bump this in the not too distant future), and I'm generally opposed to introducing hard coded limits in a public interface.

We should use xenctl_cpumask everywhere for specifying physical CPU bitmaps,
even into guest NUMA interfaces if appropriate. I don't really care if it is
a bit harder to use than a static bitmap.

 -- Keir

#11 lore raw
Quoted 7 lines · Dulloor
Quoted 2 lines

It actually bloats the libraries by a net 650 LOC
(747 added, 87 deleted according to diffstat).

In the patch, we have used the library only for vcpu get/set affinity. There are clearly other opportunities (right now and in future) to use most of the functions provided by the library, which will offset this. Also, this provides a cleaner/standard way of using the cpumap structure in libxc.

Clearly it's not a simplicity win right now as it net adds a lot of code. I'd rather see this as part of a patch series that actually uses it more substantially. And even then I'd bet that half of this patch could be removed as unused. If NUMA changes end up manipulating cpumaps in, say, a dozen places then I could see this approach being useful, instead of pointless abstraction (how it appears currently).

-- Keir