[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v5 08/24] libxl: introduce libxl__vnuma_config_check



On Fri, Feb 13, 2015 at 03:40:32PM +0000, Andrew Cooper wrote:
[...]
> > +    return 0;
> > +}
> > +
> > +/* Check if vNUMA configuration is valid:
> > + *  1. all pnodes inside vnode_to_pnode array are valid
> > + *  2. one vcpu belongs to and only belongs to one vnode
> > + *  3. each vmemrange is valid and doesn't overlap with each other
> > + */
> > +int libxl__vnuma_config_check(libxl__gc *gc,
> > +                              const libxl_domain_build_info *b_info,
> > +                              const libxl__domain_build_state *state)
> > +{
> > +    int i, j, rc = ERROR_VNUMA_CONFIG_INVALID, nr_nodes;
> 
> i, j and nr_nodes are all semantically unsigned.
> 

Fixed.

> > +    libxl_numainfo *ninfo = NULL;
> > +    uint64_t total_memkb = 0;
> > +    libxl_bitmap cpumap;
> > +    libxl_vnode_info *p;
> > +
> > +    libxl_bitmap_init(&cpumap);
> > +
> > +    /* Check pnode specified is valid */
> > +    ninfo = libxl_get_numainfo(CTX, &nr_nodes);
> > +    if (!ninfo) {
> > +        LOG(ERROR, "libxl_get_numainfo failed");
> > +        goto out;
> > +    }
> > +
> > +    for (i = 0; i < b_info->num_vnuma_nodes; i++) {
> > +        uint32_t pnode;
> > +
> > +        p = &b_info->vnuma_nodes[i];
> > +        pnode = p->pnode;
> > +
> > +        /* The pnode specified is not valid? */
> > +        if (pnode >= nr_nodes) {
> > +            LOG(ERROR, "Invalid pnode %d specified", pnode);
> 
> pnode is uint32_t, so should be %u
> 

Fixed.

> > +            goto out;
> > +        }
> > +
> > +        total_memkb += p->memkb;
> > +    }
> > +
> > +    if (total_memkb != b_info->max_memkb) {
> > +        LOG(ERROR, "Amount of memory mismatch (0x%"PRIx64" != 
> > 0x%"PRIx64")",
> > +            total_memkb, b_info->max_memkb);
> > +        goto out;
> > +    }
> > +
> > +    /* Check vcpu mapping */
> > +    libxl_cpu_bitmap_alloc(CTX, &cpumap, b_info->max_vcpus);
> > +    libxl_bitmap_set_none(&cpumap);
> 
> Worth using/making libxl_cpu_bitmap_zalloc(), or perhaps making this a
> defined semantic of the alloc() function?  This would seem to be a very
> common pair of operations to perform.
> 

Actually libxl_bitmap_alloc already uses calloc, so the bitmap is always
set to all zeros.

> > +    for (i = 0; i < b_info->num_vnuma_nodes; i++) {
> > +        p = &b_info->vnuma_nodes[i];
> > +        libxl_for_each_set_bit(j, p->vcpus) {
> > +            if (!libxl_bitmap_test(&cpumap, j))
> > +                libxl_bitmap_set(&cpumap, j);
> > +            else {
> > +                LOG(ERROR, "Vcpu %d assigned more than once", j);
> > +                goto out;
> > +            }
> > +        }
> 
> This libxl_for_each_set_bit() loop can be optimised to a
> bitmap_intersects() for the error condition, and bitmap_or() for the
> success case.
> 
> > +    }
> > +
> > +    for (i = 0; i < b_info->max_vcpus; i++) {
> > +        if (!libxl_bitmap_test(&cpumap, i)) {
> > +            LOG(ERROR, "Vcpu %d is not assigned to any vnode", i);
> > +            goto out;
> > +        }
> 
> This loop can be optimised to !bitmap_all_set().
> 

I can introduce a new patch set of bitmap operations and switch to that
later.  Now this series has grown to almost 30 patches and I would like
to keep this series focus mostly on vNUMA related stuffs.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.