Re: [PATCH 6/7] Implement qemuSetupGlobalCpuCgroup

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

 



On Thu, 2016-01-14 at 14:28 +0300, Dmitry Guryanov wrote:
> On Tue, 2016-01-12 at 19:42 +0300, Alexander Burluka wrote:
> > This functions setups per-domain cpu bandwidth parameters
> > 
> > Signed-off-by: Alexander Burluka <aburluka@xxxxxxxxxxxxx>
> > ---
> >  src/qemu/qemu_cgroup.c  | 64 +++++++++++++++++++++++++++++++++++++++++++++++++
> >  src/qemu/qemu_cgroup.h  |  1 +
> >  src/qemu/qemu_process.c |  4 ++++
> >  3 files changed, 69 insertions(+)
> > 
> > diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
> > index e835ac4..53002b7 100644
> > --- a/src/qemu/qemu_cgroup.c
> > +++ b/src/qemu/qemu_cgroup.c
> > @@ -1002,6 +1002,70 @@ qemuSetupCgroupCpusetCpus(virCgroupPtr cgroup,
> >  }
> >  
> >  int
> > +qemuSetupGlobalCpuCgroup(virDomainObjPtr vm)
> > +{
> > +    virCgroupPtr cgroup_vcpu = NULL;
> > +    qemuDomainObjPrivatePtr priv = vm->privateData;
> > +    unsigned long long period = vm->def->cputune.global_period;
> > +    long long quota = vm->def->cputune.global_quota;
> > +    char *mem_mask = NULL;
> > +    virDomainNumatuneMemMode mem_mode;
> > +
> > +    if ((period || quota) &&
> > +        !virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU)) {
> > +        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> > +                       _("cgroup cpu is required for scheduler tuning"));
> > +        return -1;
> > +    }
> > +
> > +    /*
> > +     * If CPU cgroup controller is not initialized here, then we need
> > +     * neither period nor quota settings.  And if CPUSET controller is
> > +     * not initialized either, then there's nothing to do anyway.
> > +     */
> > +    if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU) &&
> > +        !virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET))
> > +        return 0;
> > +
> > +    /* We are trying to setup cgroups for CPU pinning, which can also be done
> > +     * with virProcessSetAffinity, thus the lack of cgroups is not fatal here.
> > +     */
> > +    if (priv->cgroup == NULL)
> > +        return 0;
> > +
> > +    if (virDomainNumatuneGetMode(vm->def->numa, -1, &mem_mode) == 0 &&
> > +        mem_mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT &&
> > +        virDomainNumatuneMaybeFormatNodeset(vm->def->numa,
> > +                                            priv->autoNodeset,
> > +                                            &mem_mask, -1) < 0)
> > +        goto cleanup;
> > +
> > +    if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_GLOBAL, 0,
> > +                           true, &cgroup_vcpu) < 0)
> > +        goto cleanup;
> > +
> > +    if (period || quota) {
> > +        if (qemuSetupBandwidthCgroup(cgroup_vcpu, period, quota) < 0)
> > +            goto cleanup;
> > +    }
> 
> I think you could just use priv->cgroup and don't call virCgroupNewThread, so the
> previous patch is not needed.

Sorry, not previous, 4th.

> 
> > +
> > +    virCgroupFree(&cgroup_vcpu);
> > +    VIR_FREE(mem_mask);
> > +
> > +    return 0;
> > +
> > + cleanup:
> > +    if (cgroup_vcpu) {
> > +        virCgroupRemove(cgroup_vcpu);
> > +        virCgroupFree(&cgroup_vcpu);
> > +    }
> > +    VIR_FREE(mem_mask);
> > +
> > +    return -1;
> > +}
> > +
> > +
> > +int
> >  qemuSetupCgroupForVcpu(virDomainObjPtr vm)
> >  {
> >      virCgroupPtr cgroup_vcpu = NULL;
> > diff --git a/src/qemu/qemu_cgroup.h b/src/qemu/qemu_cgroup.h
> > index 17da920..75f9eb7 100644
> > --- a/src/qemu/qemu_cgroup.h
> > +++ b/src/qemu/qemu_cgroup.h
> > @@ -54,6 +54,7 @@ int qemuSetupBandwidthCgroup(virCgroupPtr cgroup,
> >                               long long quota);
> >  int qemuSetupCgroupCpusetCpus(virCgroupPtr cgroup, virBitmapPtr cpumask);
> >  int qemuSetupCgroupForVcpu(virDomainObjPtr vm);
> > +int qemuSetupGlobalCpuCgroup(virDomainObjPtr vm);
> >  int qemuSetupCgroupForIOThreads(virDomainObjPtr vm);
> >  int qemuSetupCgroupForEmulator(virDomainObjPtr vm);
> >  int qemuRemoveCgroup(virQEMUDriverPtr driver, virDomainObjPtr vm);
> > diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
> > index 3d9e0e5..7a90457 100644
> > --- a/src/qemu/qemu_process.c
> > +++ b/src/qemu/qemu_process.c
> > @@ -4981,6 +4981,10 @@ qemuProcessLaunch(virConnectPtr conn,
> >      if (qemuProcessDetectIOThreadPIDs(driver, vm, asyncJob) < 0)
> >          goto cleanup;
> >  
> > +    VIR_DEBUG("Setting global CPU cgroup (if required)");
> > +    if (qemuSetupGlobalCpuCgroup(vm) < 0)
> > +        goto cleanup;
> > +
> >      VIR_DEBUG("Setting cgroup for each VCPU (if required)");
> >      if (qemuSetupCgroupForVcpu(vm) < 0)
> >          goto cleanup;
> 
> --
> libvir-list mailing list
> libvir-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/libvir-list

--
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]