From nobody Sat Feb 7 07:24:58 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1635149551120758.7516657818483; Mon, 25 Oct 2021 01:12:31 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-361-FoTRtIW9OB6YxuGksBuk6g-1; Mon, 25 Oct 2021 04:12:26 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B5DA10A8E06; Mon, 25 Oct 2021 08:12:21 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3A87CADC8; Mon, 25 Oct 2021 08:12:21 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 061551832DF0; Mon, 25 Oct 2021 08:12:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19LHj9q4014445 for ; Thu, 21 Oct 2021 13:45:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id B3BFC2026D11; Thu, 21 Oct 2021 17:45:09 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AE5B92026D64 for ; Thu, 21 Oct 2021 17:45:06 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C21BE811E7F for ; Thu, 21 Oct 2021 17:45:06 +0000 (UTC) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by relay.mimecast.com with ESMTP id us-mta-425-PnNKbtDjPwKwxtEJB5Pt1w-1; Thu, 21 Oct 2021 13:45:04 -0400 Received: from prapal-ch2.oiwy50ateaxezb1sqsoezlib2f.xx.internal.cloudapp.net (unknown [20.80.162.67]) by linux.microsoft.com (Postfix) with ESMTPSA id AD61320B6C5F; Thu, 21 Oct 2021 10:38:22 -0700 (PDT) X-MC-Unique: FoTRtIW9OB6YxuGksBuk6g-1 X-MC-Unique: PnNKbtDjPwKwxtEJB5Pt1w-1 DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com AD61320B6C5F From: Vineeth Pillai To: libvir-list@redhat.com Subject: [libvirt PATCH 12/13] ch_process: Setup emulator and iothread settings Date: Thu, 21 Oct 2021 17:38:04 +0000 Message-Id: <20211021173805.3118611-13-viremana@linux.microsoft.com> In-Reply-To: <20211021173805.3118611-1-viremana@linux.microsoft.com> References: <20211021173805.3118611-1-viremana@linux.microsoft.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 19LHj9q4014445 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Mon, 25 Oct 2021 04:11:53 -0400 Cc: william.douglas@intel.com, viremana@linux.microsoft.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1635149553161100001 Content-Type: text/plain; charset="utf-8" From: Praveen K Paladugu using virCHProcessSetupPid Signed-off-by: Praveen K Paladugu Signed-off-by: Vineeth Pillai --- src/ch/ch_monitor.c | 60 ++++++++++++++++++++++++++++++++++ src/ch/ch_monitor.h | 2 ++ src/ch/ch_process.c | 78 +++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 138 insertions(+), 2 deletions(-) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 095779cb3f..924d510a2f 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -920,3 +920,63 @@ virCHMonitorResumeVM(virCHMonitor *mon) { return virCHMonitorPutNoContent(mon, URL_VM_RESUME); } + +/** + * virCHMonitorGetIOThreads: + * @mon: Pointer to the monitor + * @iothreads: Location to return array of IOThreadInfo data + * + * Retrieve the list of iothreads defined/running for the machine + * + * Returns count of IOThreadInfo structures on success + * -1 on error. + */ +int virCHMonitorGetIOThreads(virCHMonitor *mon, + virDomainIOThreadInfo ***iothreads) +{ + size_t nthreads =3D 0, niothreads =3D 0; + int thd_index; + virDomainIOThreadInfo **iothreadinfolist =3D NULL, *iothreadinfo =3D N= ULL; + + *iothreads =3D NULL; + nthreads =3D virCHMonitorRefreshThreadInfo(mon); + + iothreadinfolist =3D g_new0(virDomainIOThreadInfo*, nthreads); + + for (thd_index =3D 0; thd_index < nthreads; thd_index++) { + virBitmap *map =3D NULL; + if (mon->threads[thd_index].type =3D=3D virCHThreadTypeIO) { + iothreadinfo =3D g_new0(virDomainIOThreadInfo, 1); + + iothreadinfo->iothread_id =3D mon->threads[thd_index].ioInfo.t= id; + + if (!(map =3D virProcessGetAffinity(iothreadinfo->iothread_id)= )) + goto cleanup; + + if (virBitmapToData(map, &(iothreadinfo->cpumap), + &(iothreadinfo->cpumaplen)) < 0) { + virBitmapFree(map); + goto cleanup; + } + virBitmapFree(map); + //Append to iothreadinfolist + iothreadinfolist[niothreads] =3D iothreadinfo; + niothreads++; + } + } + VIR_DELETE_ELEMENT_INPLACE(iothreadinfolist, + niothreads, nthreads); + *iothreads =3D iothreadinfolist; + VIR_DEBUG("niothreads =3D %ld", niothreads); + return niothreads; + + cleanup: + if (iothreadinfolist) { + for (thd_index =3D 0; thd_index < niothreads; thd_index++) + VIR_FREE(iothreadinfolist[thd_index]); + VIR_FREE(iothreadinfolist); + } + if (iothreadinfo) + VIR_FREE(iothreadinfo); + return -1; +} diff --git a/src/ch/ch_monitor.h b/src/ch/ch_monitor.h index f8c3fa75e8..98edb0faf9 100644 --- a/src/ch/ch_monitor.h +++ b/src/ch/ch_monitor.h @@ -118,3 +118,5 @@ int virCHMonitorGetCPUInfo(virCHMonitor *mon, size_t maxvcpus); size_t virCHMonitorGetThreadInfo(virCHMonitor *mon, bool refresh, virCHMonitorThreadInfo **threads); +int virCHMonitorGetIOThreads(virCHMonitor *mon, + virDomainIOThreadInfo ***iothreads); diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 8dce737adb..25c2910f9c 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -41,7 +41,6 @@ VIR_LOG_INIT("ch.ch_process"); #define START_VM_POSTFIX ": starting up vm\n" =20 =20 - static virCHMonitor * virCHProcessConnectMonitor(virCHDriver *driver, virDomainObj *vm) @@ -131,7 +130,6 @@ virCHProcessUpdateInfo(virDomainObj *vm) virCHProcessUpdateConsole(vm, info); =20 virJSONValueFree(info); - return 0; } =20 @@ -313,6 +311,74 @@ virCHProcessSetupPid(virDomainObj *vm, return ret; } =20 +static int +virCHProcessSetupIOThread(virDomainObj *vm, + virDomainIOThreadInfo *iothread) +{ + virCHDomainObjPrivate *priv =3D vm->privateData; + return virCHProcessSetupPid(vm, iothread->iothread_id, + VIR_CGROUP_THREAD_IOTHREAD, + iothread->iothread_id, + priv->autoCpuset, // This should be updated= when CLH supports accepting + // iothread settings from input domai= n definition + vm->def->cputune.iothread_period, + vm->def->cputune.iothread_quota, + NULL); // CLH doesn't allow choosing a sche= duler for iothreads. +} + +static int +virCHProcessSetupIOThreads(virDomainObj *vm) +{ + virCHDomainObjPrivate *priv =3D vm->privateData; + virDomainIOThreadInfo **iothreads =3D NULL; + size_t i; + size_t niothreads; + + niothreads =3D virCHMonitorGetIOThreads(priv->monitor, &iothreads); + for (i =3D 0; i < niothreads; i++) { + VIR_DEBUG("IOThread index =3D %ld , tid =3D %d", i, iothreads[i]->= iothread_id); + if (virCHProcessSetupIOThread(vm, iothreads[i]) < 0) + return -1; + } + return 0; +} + + +static int +virCHProcessSetupEmulatorThread(virDomainObj *vm, + virCHMonitorEmuThreadInfo emuthread) +{ + return virCHProcessSetupPid(vm, emuthread.tid, VIR_CGROUP_THREAD_EMULA= TOR, + 0, vm->def->cputune.emulatorpin, + vm->def->cputune.emulator_period, + vm->def->cputune.emulator_quota, + vm->def->cputune.emulatorsched); +} + +static int +virCHProcessSetupEmulatorThreads(virDomainObj *vm) +{ + int thd_index =3D 0; + virCHDomainObjPrivate *priv =3D vm->privateData; + /* + Cloud-hypervisor start 4 Emulator threads by default: + vmm + cloud-hypervisor + http-server + signal_handler + */ + for (thd_index =3D 0; thd_index < priv->monitor->nthreads; thd_index++= ) { + if (priv->monitor->threads[thd_index].type =3D=3D virCHThreadTypeE= mulator) { + VIR_DEBUG("Setup tid =3D %d (%s) Emulator thread", priv->monit= or->threads[thd_index].emuInfo.tid, + priv->monitor->threads[thd_index].emuInfo.thrName); + + if (virCHProcessSetupEmulatorThread(vm, priv->monitor->threads= [thd_index].emuInfo) < 0) + return -1; + } + } + return 0; +} + /** * virCHProcessSetupVcpu: * @vm: domain object @@ -439,6 +505,14 @@ int virCHProcessStart(virCHDriver *driver, =20 virCHDomainRefreshThreadInfo(vm); =20 + VIR_DEBUG("Setting emulator tuning/settings"); + if (virCHProcessSetupEmulatorThreads(vm) < 0) + goto cleanup; + + VIR_DEBUG("Setting iothread tuning/settings"); + if (virCHProcessSetupIOThreads(vm) < 0) + goto cleanup; + VIR_DEBUG("Setting global CPU cgroup (if required)"); if (chSetupGlobalCpuCgroup(vm) < 0) goto cleanup; --=20 2.27.0