Re: [libvirt] [PATCH v3 3/4] NUMA: cleanup for numa related codes
On 2013年03月18日 17:04, Gao feng wrote: Intend to reduce the redundant code,use virNumaSetupMemoryPolicy to replace virLXCControllerSetupNUMAPolicy and qemuProcessInitNumaMemoryPolicy. This patch also moves the numa related codes to the file virnuma.c and virnuma.h Signed-off-by: Gao fenggaof...@cn.fujitsu.com --- include/libvirt/libvirt.h.in | 15 -- src/conf/domain_conf.c | 25 +++-- src/conf/domain_conf.h | 17 +- src/libvirt_private.syms | 9 ++-- src/lxc/lxc_controller.c | 114 +-- src/qemu/qemu_cgroup.c | 6 +-- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_process.c | 121 + src/util/virnuma.c | 125 +++ src/util/virnuma.h | 45 tools/virsh-domain.c | 4 +- 11 files changed, 192 insertions(+), 291 deletions(-) diff --git PATCH v3include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index f6a7aff..b3bfd1d 100644 --- PATCH v3include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -1762,21 +1762,6 @@ typedef enum { /* Manage numa parameters */ /** - * virDomainNumatuneMemMode: - * Representation of the various modes in thenumatune element of - * a domain. - */ -typedef enum { -VIR_DOMAIN_NUMATUNE_MEM_STRICT = 0, -VIR_DOMAIN_NUMATUNE_MEM_PREFERRED = 1, -VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE = 2, - -#ifdef VIR_ENUM_SENTINELS -VIR_DOMAIN_NUMATUNE_MEM_LAST /* This constant is subject to change */ -#endif -} virDomainNumatuneMemMode; - NACK, this will introduce backward compatibility problems. They should *not* be changed or removed. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 3/4] NUMA: cleanup for numa related codes
On 2013/03/18 17:34, Osier Yang wrote: On 2013年03月18日 17:04, Gao feng wrote: Intend to reduce the redundant code,use virNumaSetupMemoryPolicy to replace virLXCControllerSetupNUMAPolicy and qemuProcessInitNumaMemoryPolicy. This patch also moves the numa related codes to the file virnuma.c and virnuma.h Signed-off-by: Gao fenggaof...@cn.fujitsu.com --- include/libvirt/libvirt.h.in | 15 -- src/conf/domain_conf.c | 25 +++-- src/conf/domain_conf.h | 17 +- src/libvirt_private.syms | 9 ++-- src/lxc/lxc_controller.c | 114 +-- src/qemu/qemu_cgroup.c | 6 +-- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_process.c | 121 + src/util/virnuma.c | 125 +++ src/util/virnuma.h | 45 tools/virsh-domain.c | 4 +- 11 files changed, 192 insertions(+), 291 deletions(-) diff --git PATCH v3include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index f6a7aff..b3bfd1d 100644 --- PATCH v3include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -1762,21 +1762,6 @@ typedef enum { /* Manage numa parameters */ /** - * virDomainNumatuneMemMode: - * Representation of the various modes in thenumatune element of - * a domain. - */ -typedef enum { -VIR_DOMAIN_NUMATUNE_MEM_STRICT = 0, -VIR_DOMAIN_NUMATUNE_MEM_PREFERRED = 1, -VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE = 2, - -#ifdef VIR_ENUM_SENTINELS -VIR_DOMAIN_NUMATUNE_MEM_LAST /* This constant is subject to change */ -#endif -} virDomainNumatuneMemMode; - NACK, this will introduce backward compatibility problems. They should *not* be changed or removed. So what we should do is just move them from domain_conf to virnuma? The rename will cause compatibility problems. I am right? Thanks! -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 3/4] NUMA: cleanup for numa related codes
On 2013年03月18日 18:06, Gao feng wrote: On 2013/03/18 17:34, Osier Yang wrote: On 2013年03月18日 17:04, Gao feng wrote: Intend to reduce the redundant code,use virNumaSetupMemoryPolicy to replace virLXCControllerSetupNUMAPolicy and qemuProcessInitNumaMemoryPolicy. This patch also moves the numa related codes to the file virnuma.c and virnuma.h Signed-off-by: Gao fenggaof...@cn.fujitsu.com --- include/libvirt/libvirt.h.in | 15 -- src/conf/domain_conf.c | 25 +++-- src/conf/domain_conf.h | 17 +- src/libvirt_private.syms | 9 ++-- src/lxc/lxc_controller.c | 114 +-- src/qemu/qemu_cgroup.c | 6 +-- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_process.c | 121 + src/util/virnuma.c | 125 +++ src/util/virnuma.h | 45 tools/virsh-domain.c | 4 +- 11 files changed, 192 insertions(+), 291 deletions(-) diff --git PATCH v3include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index f6a7aff..b3bfd1d 100644 --- PATCH v3include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -1762,21 +1762,6 @@ typedef enum { /* Manage numa parameters */ /** - * virDomainNumatuneMemMode: - * Representation of the various modes in thenumatune element of - * a domain. - */ -typedef enum { -VIR_DOMAIN_NUMATUNE_MEM_STRICT = 0, -VIR_DOMAIN_NUMATUNE_MEM_PREFERRED = 1, -VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE = 2, - -#ifdef VIR_ENUM_SENTINELS -VIR_DOMAIN_NUMATUNE_MEM_LAST /* This constant is subject to change */ -#endif -} virDomainNumatuneMemMode; - NACK, this will introduce backward compatibility problems. They should *not* be changed or removed. So what we should do is just move them from domain_conf to virnuma? The rename will cause compatibility problems. I am right? The point is not to change/remove the stuffs which is exported to public, removing/changing on the internal files (e.g. domain_conf.{c,h}) is fine. Thanks! -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 3/4] NUMA: cleanup for numa related codes
On Mon, Mar 18, 2013 at 05:04:03PM +0800, Gao feng wrote: Intend to reduce the redundant code,use virNumaSetupMemoryPolicy to replace virLXCControllerSetupNUMAPolicy and qemuProcessInitNumaMemoryPolicy. This patch also moves the numa related codes to the file virnuma.c and virnuma.h Signed-off-by: Gao feng gaof...@cn.fujitsu.com --- include/libvirt/libvirt.h.in | 15 -- src/conf/domain_conf.c | 25 +++-- src/conf/domain_conf.h | 17 +- src/libvirt_private.syms | 9 ++-- src/lxc/lxc_controller.c | 114 +-- src/qemu/qemu_cgroup.c | 6 +-- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_process.c | 121 + src/util/virnuma.c | 125 +++ src/util/virnuma.h | 45 tools/virsh-domain.c | 4 +- 11 files changed, 192 insertions(+), 291 deletions(-) diff --git PATCH v3include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index f6a7aff..b3bfd1d 100644 --- PATCH v3include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -1762,21 +1762,6 @@ typedef enum { /* Manage numa parameters */ /** - * virDomainNumatuneMemMode: - * Representation of the various modes in the numatune element of - * a domain. - */ -typedef enum { -VIR_DOMAIN_NUMATUNE_MEM_STRICT = 0, -VIR_DOMAIN_NUMATUNE_MEM_PREFERRED = 1, -VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE = 2, - -#ifdef VIR_ENUM_SENTINELS -VIR_DOMAIN_NUMATUNE_MEM_LAST /* This constant is subject to change */ -#endif -} virDomainNumatuneMemMode; - NACK, as Osier said, it is forbidden to delete or rename any structs / enums / etc in libvirt.h.in diff --git PATCH v3src/libvirt_private.syms b/src/libvirt_private.syms index 1374470..9bf35a8 100644 --- PATCH v3src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -252,10 +252,10 @@ virDomainNetRemove; virDomainNetTypeToString; virDomainNostateReasonTypeFromString; virDomainNostateReasonTypeToString; -virDomainNumatuneMemModeTypeFromString; -virDomainNumatuneMemModeTypeToString; -virDomainNumatuneMemPlacementModeTypeFromString; -virDomainNumatuneMemPlacementModeTypeToString; +virNumatuneMemModeTypeFromString; +virNumatuneMemModeTypeToString; +virNumatuneMemPlacementModeTypeFromString; +virNumatuneMemPlacementModeTypeToString; virDomainObjAssignDef; virDomainObjCopyPersistentDef; virDomainObjGetPersistentDef; If you had run 'make check' you'd see that this change is not valid because it is not alphabetically sorted anymore. diff --git PATCH v3src/util/virnuma.c b/src/util/virnuma.c index f6a6eb2..0601dcc 100644 --- PATCH v3src/util/virnuma.c +++ b/src/util/virnuma.c @@ -21,12 +21,29 @@ #include config.h +#if WITH_NUMACTL +# define NUMA_VERSION1_COMPATIBILITY 1 +# include numa.h +#endif + #include virnuma.h #include vircommand.h #include virerror.h +#include virlog.h #define VIR_FROM_THIS VIR_FROM_NONE +VIR_ENUM_IMPL(virNumatuneMemPlacementMode, + VIR_NUMATUNE_MEM_PLACEMENT_MODE_LAST, + default, + static, + auto); + +VIR_ENUM_IMPL(virNumatuneMemMode, VIR_NUMATUNE_MEM_LAST, + strict, + preferred, + interleave); + #if HAVE_NUMAD char * virNumaGetAutoPlacementAdvice(unsigned short vcpus, @@ -59,3 +76,111 @@ virNumaGetAutoPlacementAdvice(unsigned short vcpus ATTRIBUTE_UNUSED, return NULL; } #endif + +#if WITH_NUMACTL +int +virNumaSetupMemoryPolicy(virNumatuneDef numatune, + virBitmapPtr nodemask) +{ +nodemask_t mask; +int mode = -1; +int node = -1; +int ret = -1; +int i = 0; +int maxnode = 0; +bool warned = false; +virBitmapPtr tmp_nodemask = NULL; + +if (numatune.memory.placement_mode == +VIR_NUMATUNE_MEM_PLACEMENT_MODE_STATIC) { +if (!numatune.memory.nodemask) +return 0; +VIR_DEBUG(Set NUMA memory policy with specified nodeset); +tmp_nodemask = numatune.memory.nodemask; +} else if (numatune.memory.placement_mode == + VIR_NUMATUNE_MEM_PLACEMENT_MODE_AUTO) { +VIR_DEBUG(Set NUMA memory policy with advisory nodeset from numad); +tmp_nodemask = nodemask; +} else { +return 0; +} + +if (numa_available() 0) { +virReportError(VIR_ERR_INTERNAL_ERROR, + %s, _(Host kernel is not aware of NUMA.)); +return -1; +} + +maxnode = numa_max_node() + 1; +/* Convert nodemask to NUMA bitmask. */ +nodemask_zero(mask); +i = -1; +while ((i = virBitmapNextSetBit(tmp_nodemask, i)) = 0) { +if (i NUMA_NUM_NODES) { +virReportError(VIR_ERR_INTERNAL_ERROR, + _(Host cannot
Re: [libvirt] [PATCH v3 3/4] NUMA: cleanup for numa related codes
On 2013/03/18 19:33, Osier Yang wrote: On 2013年03月18日 18:06, Gao feng wrote: On 2013/03/18 17:34, Osier Yang wrote: On 2013年03月18日 17:04, Gao feng wrote: Intend to reduce the redundant code,use virNumaSetupMemoryPolicy to replace virLXCControllerSetupNUMAPolicy and qemuProcessInitNumaMemoryPolicy. This patch also moves the numa related codes to the file virnuma.c and virnuma.h Signed-off-by: Gao fenggaof...@cn.fujitsu.com --- include/libvirt/libvirt.h.in | 15 -- src/conf/domain_conf.c | 25 +++-- src/conf/domain_conf.h | 17 +- src/libvirt_private.syms | 9 ++-- src/lxc/lxc_controller.c | 114 +-- src/qemu/qemu_cgroup.c | 6 +-- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_process.c | 121 + src/util/virnuma.c | 125 +++ src/util/virnuma.h | 45 tools/virsh-domain.c | 4 +- 11 files changed, 192 insertions(+), 291 deletions(-) diff --git PATCH v3include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index f6a7aff..b3bfd1d 100644 --- PATCH v3include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -1762,21 +1762,6 @@ typedef enum { /* Manage numa parameters */ /** - * virDomainNumatuneMemMode: - * Representation of the various modes in thenumatune element of - * a domain. - */ -typedef enum { -VIR_DOMAIN_NUMATUNE_MEM_STRICT = 0, -VIR_DOMAIN_NUMATUNE_MEM_PREFERRED = 1, -VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE = 2, - -#ifdef VIR_ENUM_SENTINELS -VIR_DOMAIN_NUMATUNE_MEM_LAST /* This constant is subject to change */ -#endif -} virDomainNumatuneMemMode; - NACK, this will introduce backward compatibility problems. They should *not* be changed or removed. So what we should do is just move them from domain_conf to virnuma? The rename will cause compatibility problems. I am right? The point is not to change/remove the stuffs which is exported to public, removing/changing on the internal files (e.g. domain_conf.{c,h}) is fine. Get it,thanks you guys. I will rework this one and rebase 4/4 on this one. Thanks! -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list