Re: [PATCH v1 4/8] use virBitmap to store numa nodemask info.

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

 



On 08/30/2012 02:55 AM, Hu Tao wrote:

> +++ b/src/lxc/lxc_controller.c
> @@ -402,6 +402,7 @@ static int virLXCControllerSetupNUMAPolicy(virLXCControllerPtr ctrl)
>      int i = 0;
>      int maxnode = 0;
>      bool warned = false;
> +    bool nodePresent = false;
>  
>      if (!ctrl->def->numatune.memory.nodemask)
>          return 0;
> @@ -418,8 +419,10 @@ static int virLXCControllerSetupNUMAPolicy(virLXCControllerPtr ctrl)
>  
>      /* Convert nodemask to NUMA bitmask. */
>      nodemask_zero(&mask);
> -    for (i = 0; i < VIR_DOMAIN_CPUMASK_LEN; i++) {
> -        if (ctrl->def->numatune.memory.nodemask[i]) {
> +    for (i = 0; i < virBitmapSize(ctrl->def->numatune.memory.nodemask); i++) {
> +        if (virBitmapGetBit(ctrl->def->numatune.memory.nodemask, i, &nodePresent) < 0)
> +            return -1;
> +        if (nodePresent) {

If the bitmap is sparse, this argues that we might want a new helper
function:

/* If bit is -1, find the first set bit (if any); otherwise, find the
next set bit after the given position.  Return -1 if there are no
further set bits.  */
int virBitmapNextAfter(virBitmapPtr map, int bit);

The loop would then be:

int i = virBitmapNextAfter(ctrl->def->numatune.memory.nodemask, -1);
while (i >= 0) {
    /* do stuff for bit i */
    i = virBitmapNextAfter(ctrl->def->numatune.memory.nodemask, i);
}


> +++ b/src/parallels/parallels_driver.c
> @@ -1428,7 +1428,7 @@ parallelsApplyChanges(virDomainObjPtr dom, virDomainDefPtr new)
>  
>      if (old->numatune.memory.mode != new->numatune.memory.mode ||
>          old->numatune.memory.placement_mode != new->numatune.memory.placement_mode ||
> -        !STREQ_NULLABLE(old->numatune.memory.nodemask, new->numatune.memory.nodemask)) {
> +        !virBitmapCmp(old->numatune.memory.nodemask, new->numatune.memory.nodemask)) {

Hmm, this usage says we named the function incorrectly.  'cmp' implies
<0, 0, >0 for use in qsort; whereas you give only a bool, so I would
name it virBitmapEqual().

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]