* [PATCH v3 ]libxl: allow to allocate cpumap with specific size
@ 2012-06-28 2:38 Zhang, Yang Z
2012-06-28 14:54 ` Ian Jackson
2012-06-28 16:52 ` Ian Jackson
0 siblings, 2 replies; 7+ messages in thread
From: Zhang, Yang Z @ 2012-06-28 2:38 UTC (permalink / raw)
To: xen-devel; +Cc: Ian Campbell
Change from v2:
Rebase on top of latest head.
Currently, libxl_cpumap_alloc()allocate the cpumap with size of number of physical cpus. In some place, we may want to allocate specific size of cpumap.
This patch allow to pass a argument to specific the size that you want to allocate. If pass 0, it means the size is equal to number of physical cpus.
Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
diff -r c6c9d20963d7 -r 079fce9e5557 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Tue Jun 26 17:00:20 2012 +0100
+++ b/tools/libxl/libxl.c Wed Jun 27 10:38:16 2012 +0800
@@ -570,7 +570,7 @@ static int cpupool_info(libxl__gc *gc,
info->poolid = xcinfo->cpupool_id;
info->sched = xcinfo->sched_id;
info->n_dom = xcinfo->n_dom;
- if (libxl_cpumap_alloc(CTX, &info->cpumap))
+ if (libxl_cpumap_alloc(CTX, &info->cpumap, 0))
goto out;
memcpy(info->cpumap.map, xcinfo->cpumap, info->cpumap.size);
@@ -3287,7 +3287,7 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ct
}
for (*nb_vcpu = 0; *nb_vcpu <= domaininfo.max_vcpu_id; ++*nb_vcpu, ++ptr) {
- if (libxl_cpumap_alloc(ctx, &ptr->cpumap)) {
+ if (libxl_cpumap_alloc(ctx, &ptr->cpumap, 0)) {
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "allocating cpumap");
return NULL;
}
@@ -4040,8 +4040,8 @@ int libxl_cpupool_destroy(libxl_ctx *ctx
if ((info->cpupool_id != poolid) || (info->n_dom))
goto out;
- rc = ERROR_NOMEM;
- if (libxl_cpumap_alloc(ctx, &cpumap))
+ rc = libxl_cpumap_alloc(ctx, &cpumap, 0);
+ if (rc)
goto out;
memcpy(cpumap.map, info->cpumap, cpumap.size);
diff -r c6c9d20963d7 -r 079fce9e5557 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c Tue Jun 26 17:00:20 2012 +0100
+++ b/tools/libxl/libxl_create.c Wed Jun 27 10:38:16 2012 +0800
@@ -205,8 +205,8 @@ int libxl__domain_build_info_setdefault(
b_info->cur_vcpus = 1;
if (!b_info->cpumap.size) {
- if (libxl_cpumap_alloc(CTX, &b_info->cpumap))
- return ERROR_NOMEM;
+ if (libxl_cpumap_alloc(CTX, &b_info->cpumap, 0))
+ return ERROR_FAIL;
libxl_cpumap_set_any(&b_info->cpumap);
}
diff -r c6c9d20963d7 -r 079fce9e5557 tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c Tue Jun 26 17:00:20 2012 +0100
+++ b/tools/libxl/libxl_utils.c Wed Jun 27 10:38:16 2012 +0800
@@ -489,19 +489,19 @@ int libxl_mac_to_device_nic(libxl_ctx *c
return rc;
}
-int libxl_cpumap_alloc(libxl_ctx *ctx, libxl_cpumap *cpumap)
+int libxl_cpumap_alloc(libxl_ctx *ctx, libxl_cpumap *cpumap, int max_cpus)
{
- int max_cpus;
int sz;
- max_cpus = libxl_get_max_cpus(ctx);
+ if (max_cpus < 0)
+ return ERROR_INVAL;
+ if (max_cpus == 0)
+ max_cpus = libxl_get_max_cpus(ctx);
if (max_cpus == 0)
return ERROR_FAIL;
sz = (max_cpus + 7) / 8;
- cpumap->map = calloc(sz, sizeof(*cpumap->map));
- if (!cpumap->map)
- return ERROR_NOMEM;
+ cpumap->map = libxl__calloc(NULL, sizeof(*cpumap->map), sz);
cpumap->size = sz;
return 0;
}
diff -r c6c9d20963d7 -r 079fce9e5557 tools/libxl/libxl_utils.h
--- a/tools/libxl/libxl_utils.h Tue Jun 26 17:00:20 2012 +0100
+++ b/tools/libxl/libxl_utils.h Wed Jun 27 10:38:16 2012 +0800
@@ -63,7 +63,7 @@ int libxl_devid_to_device_nic(libxl_ctx
int libxl_vdev_to_device_disk(libxl_ctx *ctx, uint32_t domid, const char *vdev,
libxl_device_disk *disk);
-int libxl_cpumap_alloc(libxl_ctx *ctx, libxl_cpumap *cpumap);
+int libxl_cpumap_alloc(libxl_ctx *ctx, libxl_cpumap *cpumap, int max_cpus);
int libxl_cpumap_test(libxl_cpumap *cpumap, int cpu);
void libxl_cpumap_set(libxl_cpumap *cpumap, int cpu);
void libxl_cpumap_reset(libxl_cpumap *cpumap, int cpu);
diff -r c6c9d20963d7 -r 079fce9e5557 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Tue Jun 26 17:00:20 2012 +0100
+++ b/tools/libxl/xl_cmdimpl.c Wed Jun 27 10:38:16 2012 +0800
@@ -503,7 +503,7 @@ static int vcpupin_parse(char *cpu, libx
return 0;
}
- if (libxl_cpumap_alloc(ctx, &exclude_cpumap)) {
+ if (libxl_cpumap_alloc(ctx, &exclude_cpumap, 0)) {
fprintf(stderr, "Error: Failed to allocate cpumap.\n");
return ENOMEM;
}
@@ -656,7 +656,7 @@ static void parse_config_data(const char
if (!xlu_cfg_get_list (config, "cpus", &cpus, 0, 1)) {
int i, n_cpus = 0;
- if (libxl_cpumap_alloc(ctx, &b_info->cpumap)) {
+ if (libxl_cpumap_alloc(ctx, &b_info->cpumap, 0)) {
fprintf(stderr, "Unable to allocate cpumap\n");
exit(1);
}
@@ -692,7 +692,7 @@ static void parse_config_data(const char
else if (!xlu_cfg_get_string (config, "cpus", &buf, 0)) {
char *buf2 = strdup(buf);
- if (libxl_cpumap_alloc(ctx, &b_info->cpumap)) {
+ if (libxl_cpumap_alloc(ctx, &b_info->cpumap, 0)) {
fprintf(stderr, "Unable to allocate cpumap\n");
exit(1);
}
@@ -1779,7 +1779,9 @@ start:
if (vcpu_to_pcpu) {
libxl_cpumap vcpu_cpumap;
- libxl_cpumap_alloc(ctx, &vcpu_cpumap);
+ ret = libxl_cpumap_alloc(ctx, &vcpu_cpumap, 0);
+ if (ret)
+ goto error_out;
for (i = 0; i < d_config.b_info.max_vcpus; i++) {
if (vcpu_to_pcpu[i] != -1) {
@@ -4051,7 +4053,7 @@ static void vcpupin(const char *d, const
find_domain(d);
- if (libxl_cpumap_alloc(ctx, &cpumap)) {
+ if (libxl_cpumap_alloc(ctx, &cpumap, 0)) {
goto vcpupin_out;
}
@@ -4108,7 +4110,7 @@ static void vcpuset(const char *d, const
find_domain(d);
- if (libxl_cpumap_alloc(ctx, &cpumap)) {
+ if (libxl_cpumap_alloc(ctx, &cpumap, 0)) {
fprintf(stderr, "libxl_cpumap_alloc failed\n");
return;
}
@@ -5921,7 +5923,7 @@ int main_cpupoolcreate(int argc, char **
fprintf(stderr, "libxl_get_freecpus failed\n");
goto out_cfg;
}
- if (libxl_cpumap_alloc(ctx, &cpumap)) {
+ if (libxl_cpumap_alloc(ctx, &cpumap, 0)) {
fprintf(stderr, "Failed to allocate cpumap\n");
goto out_cfg;
}
@@ -6289,7 +6291,7 @@ int main_cpupoolnumasplit(int argc, char
return -ERROR_FAIL;
}
- if (libxl_cpumap_alloc(ctx, &cpumap)) {
+ if (libxl_cpumap_alloc(ctx, &cpumap, 0)) {
fprintf(stderr, "Failed to allocate cpumap\n");
libxl_cputopology_list_free(topology, n_cpus);
return -ERROR_FAIL;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 ]libxl: allow to allocate cpumap with specific size
2012-06-28 2:38 [PATCH v3 ]libxl: allow to allocate cpumap with specific size Zhang, Yang Z
@ 2012-06-28 14:54 ` Ian Jackson
2012-06-28 14:58 ` Ian Campbell
2012-06-28 16:52 ` Ian Jackson
1 sibling, 1 reply; 7+ messages in thread
From: Ian Jackson @ 2012-06-28 14:54 UTC (permalink / raw)
To: Zhang, Yang Z; +Cc: xen-devel, Dario Faggioli, Ian Campbell
Zhang, Yang Z writes ("[Xen-devel] [PATCH v3 ]libxl: allow to allocate cpumap with specific size"):
> Change from v2:
> Rebase on top of latest head.
>
> Currently, libxl_cpumap_alloc()allocate the cpumap with size of
> number of physical cpus. In some place, we may want to allocate
> specific size of cpumap. This patch allow to pass a argument to
> specific the size that you want to allocate. If pass 0, it means the
> size is equal to number of physical cpus.
Isn't this same objective achieved in a more general way by Dario's
[PATCH 05 of 10 v2] libxl: rename libxl_cpumap to libxl_bitmap
?
Ian.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 ]libxl: allow to allocate cpumap with specific size
2012-06-28 14:54 ` Ian Jackson
@ 2012-06-28 14:58 ` Ian Campbell
2012-06-28 15:22 ` Dario Faggioli
0 siblings, 1 reply; 7+ messages in thread
From: Ian Campbell @ 2012-06-28 14:58 UTC (permalink / raw)
To: Ian Jackson; +Cc: Zhang, Yang Z, xen-devel, Dario Faggioli
On Thu, 2012-06-28 at 15:54 +0100, Ian Jackson wrote:
> Zhang, Yang Z writes ("[Xen-devel] [PATCH v3 ]libxl: allow to allocate cpumap with specific size"):
> > Change from v2:
> > Rebase on top of latest head.
> >
> > Currently, libxl_cpumap_alloc()allocate the cpumap with size of
> > number of physical cpus. In some place, we may want to allocate
> > specific size of cpumap. This patch allow to pass a argument to
> > specific the size that you want to allocate. If pass 0, it means the
> > size is equal to number of physical cpus.
>
> Isn't this same objective achieved in a more general way by Dario's
> [PATCH 05 of 10 v2] libxl: rename libxl_cpumap to libxl_bitmap
Didn't Dario's patch build on this one, or perhaps incorporate it?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 ]libxl: allow to allocate cpumap with specific size
2012-06-28 14:58 ` Ian Campbell
@ 2012-06-28 15:22 ` Dario Faggioli
2012-06-28 15:33 ` Ian Campbell
0 siblings, 1 reply; 7+ messages in thread
From: Dario Faggioli @ 2012-06-28 15:22 UTC (permalink / raw)
To: Ian Campbell; +Cc: Zhang, Yang Z, xen-devel, Ian Jackson
[-- Attachment #1.1: Type: text/plain, Size: 1602 bytes --]
On Thu, 2012-06-28 at 15:58 +0100, Ian Campbell wrote:
> On Thu, 2012-06-28 at 15:54 +0100, Ian Jackson wrote:
> > Zhang, Yang Z writes ("[Xen-devel] [PATCH v3 ]libxl: allow to allocate cpumap with specific size"):
> > > Change from v2:
> > > Rebase on top of latest head.
> > >
> > > Currently, libxl_cpumap_alloc()allocate the cpumap with size of
> > > number of physical cpus. In some place, we may want to allocate
> > > specific size of cpumap. This patch allow to pass a argument to
> > > specific the size that you want to allocate. If pass 0, it means the
> > > size is equal to number of physical cpus.
> >
> > Isn't this same objective achieved in a more general way by Dario's
> > [PATCH 05 of 10 v2] libxl: rename libxl_cpumap to libxl_bitmap
>
Well, there's sure is a clash, as I'm changing the name of map data
structure. If you check this in, I'll rebase mine one on top of it.
> Didn't Dario's patch build on this one, or perhaps incorporate it?
>
No, or at least not yet, as this patch is not in yet. Anyway, that's of
course possible, just decide what you prefer. :-)
Merging this patch and my 05/10 won't be that hard, and I can take care
of it, and the same should apply to this "[Xen-devel] [PATCH v4 ]libxl:
allow to set more than 31 vcpus".
Thanks and Regards,
Dario
--
<<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)
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 ]libxl: allow to allocate cpumap with specific size
2012-06-28 15:22 ` Dario Faggioli
@ 2012-06-28 15:33 ` Ian Campbell
2012-06-28 15:40 ` Dario Faggioli
0 siblings, 1 reply; 7+ messages in thread
From: Ian Campbell @ 2012-06-28 15:33 UTC (permalink / raw)
To: Dario Faggioli; +Cc: Zhang, Yang Z, xen-devel, Ian Jackson
On Thu, 2012-06-28 at 16:22 +0100, Dario Faggioli wrote:
> On Thu, 2012-06-28 at 15:58 +0100, Ian Campbell wrote:
> > On Thu, 2012-06-28 at 15:54 +0100, Ian Jackson wrote:
> > > Zhang, Yang Z writes ("[Xen-devel] [PATCH v3 ]libxl: allow to allocate cpumap with specific size"):
> > > > Change from v2:
> > > > Rebase on top of latest head.
> > > >
> > > > Currently, libxl_cpumap_alloc()allocate the cpumap with size of
> > > > number of physical cpus. In some place, we may want to allocate
> > > > specific size of cpumap. This patch allow to pass a argument to
> > > > specific the size that you want to allocate. If pass 0, it means the
> > > > size is equal to number of physical cpus.
> > >
> > > Isn't this same objective achieved in a more general way by Dario's
> > > [PATCH 05 of 10 v2] libxl: rename libxl_cpumap to libxl_bitmap
> >
> Well, there's sure is a clash, as I'm changing the name of map data
> structure. If you check this in, I'll rebase mine one on top of it.
>
>
> > Didn't Dario's patch build on this one, or perhaps incorporate it?
> >
> No, or at least not yet, as this patch is not in yet. Anyway, that's of
> course possible, just decide what you prefer. :-)
>
> Merging this patch and my 05/10 won't be that hard, and I can take care
> of it, and the same should apply to this "[Xen-devel] [PATCH v4 ]libxl:
> allow to set more than 31 vcpus".
If you don't mind I think we should take this and the 31 cpus one
(assuming they are otherwise acked) now and the numa one can be rebased
on it.
Ian.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 ]libxl: allow to allocate cpumap with specific size
2012-06-28 15:33 ` Ian Campbell
@ 2012-06-28 15:40 ` Dario Faggioli
0 siblings, 0 replies; 7+ messages in thread
From: Dario Faggioli @ 2012-06-28 15:40 UTC (permalink / raw)
To: Ian Campbell; +Cc: Zhang, Yang Z, xen-devel, Ian Jackson
[-- Attachment #1.1: Type: text/plain, Size: 841 bytes --]
On Thu, 2012-06-28 at 16:33 +0100, Ian Campbell wrote:
> > Merging this patch and my 05/10 won't be that hard, and I can take care
> > of it, and the same should apply to this "[Xen-devel] [PATCH v4 ]libxl:
> > allow to set more than 31 vcpus".
>
> If you don't mind I think we should take this and the 31 cpus one
> (assuming they are otherwise acked) now and the numa one can be rebased
> on it.
>
As I said, feel free to do whatever you wish, I'll rebase the NUMA
series on top of whatever will be in the repository at the time of
posting! :-P
Dario
--
<<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)
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 ]libxl: allow to allocate cpumap with specific size
2012-06-28 2:38 [PATCH v3 ]libxl: allow to allocate cpumap with specific size Zhang, Yang Z
2012-06-28 14:54 ` Ian Jackson
@ 2012-06-28 16:52 ` Ian Jackson
1 sibling, 0 replies; 7+ messages in thread
From: Ian Jackson @ 2012-06-28 16:52 UTC (permalink / raw)
To: Zhang, Yang Z; +Cc: xen-devel, Ian Campbell
Zhang, Yang Z writes ("[Xen-devel] [PATCH v3 ]libxl: allow to allocate cpumap with specific size"):
> Currently, libxl_cpumap_alloc()allocate the cpumap with size of number of physical cpus. In some place, we may want to allocate specific size of cpumap.
> This patch allow to pass a argument to specific the size that you want to allocate. If pass 0, it means the size is equal to number of physical cpus.
>
> Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Thanks,
Ian.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-06-28 16:52 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-28 2:38 [PATCH v3 ]libxl: allow to allocate cpumap with specific size Zhang, Yang Z
2012-06-28 14:54 ` Ian Jackson
2012-06-28 14:58 ` Ian Campbell
2012-06-28 15:22 ` Dario Faggioli
2012-06-28 15:33 ` Ian Campbell
2012-06-28 15:40 ` Dario Faggioli
2012-06-28 16:52 ` Ian Jackson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.