[libvirt] [PATCH v3] qemu: Support numad

Eric Blake eblake at redhat.com
Thu Mar 15 22:12:00 UTC 2012


On 03/08/2012 06:36 AM, Osier Yang wrote:
> numad is an user-level daemon that monitors NUMA topology and
> processes resource consumption to facilitate good NUMA resource
> alignment of applications/virtual machines to improve performance
> and minimize cost of remote memory latencies. It provides a
> pre-placement advisory interface, so significant processes can
> be pre-bound to nodes with sufficient available resources.

Better late than never, but here's a few things you might want to tweak:


> +#if defined(NUMAD)
> +static char *
> +qemuGetNumadAdvice(virDomainDefPtr def)
> +{
> +    virCommandPtr cmd = NULL;
> +    char *args = NULL;
> +    char *output = NULL;
> +
> +    if (virAsprintf(&args, "%d:%lu", def->vcpus, def->mem.cur_balloon) < 0) {
> +        virReportOOMError();
> +        goto out;
> +    }

This prints into a temporary,

> +    cmd = virCommandNewArgList(NUMAD, "-w", args, NULL);

only to then copy it to cmd and have to free the temporary.  It's fewer
lines of code, and less malloc pressure, to avoid the temporary by
printing directly into cmd:

cmd = virCommandNewArgList(NUMAD, "-w", NULL);
virCommandAddArgFormat(&cmd, "%d:%llu", def->vcpus, def->mem.cur_balloon);

> +        if (vm->def->cpumask) {
> +            /* XXX why don't we keep 'cpumask' in the libvirt cpumap
> +             * format to start with ?!?! */
> +            for (i = 0 ; i < maxcpu && i < vm->def->cpumasklen ; i++)
> +                if (vm->def->cpumask[i])
> +                    VIR_USE_CPU(cpumap, i);

This comment just verbalizes what has already been bothering me.  It
would be really nice if someone could convert all of our internal uses
of cpumask (with its inefficient one-byte-per-cpu representation) into
virBitmask(), as well as making virBitmask provide convenience functions
for converting to and from our stringized format as well as from the
public api cpumap (8 cpus per byte).

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120315/66734f29/attachment-0001.sig>


More information about the libvir-list mailing list