From nobody Mon Feb 9 07:26:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1660298684; cv=none; d=zohomail.com; s=zohoarc; b=X16WTxRdTpwpOwZWxH6aChAOJHaFraGq7gJBHehOjbqwiTH1lMO96zZ9WgkFtLfGJM6Uur2iClKAkU8Yo7oLb7tWi/zAXPUA52ngRfXsuWLkPzsuDow/2TsQBNXNnGIcc+GnRRLG0ST8eSXTYq4CIsWB+L4m56w4bCu3wu+Mmn4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660298684; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LxJ9F/RkVvnrCzId8wBCRi2MZIK5StOPN5N39LKVHb8=; b=YindfAj/AO3qwhvS7DT9gigkhXJx2APJ/zqj3lASVMusYm1ZjviM5QiGMaplx9KsH+JWuDw/Yp04z9IJ3FoQ5+Q/WqXoG5lI3jMsHZ3R+nSdUhmCSMaAXxOTz+JipUi4ZJbWpblN1f6mRxlYY1Sa6WfP4+io4+rnFSAaZQ2pzL0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 16602986849550.4587655298763593; Fri, 12 Aug 2022 03:04:44 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-612-ZJ94WFA7OIGMJCcmF6cDIA-1; Fri, 12 Aug 2022 06:04:39 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5F5C38039A2; Fri, 12 Aug 2022 10:04:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E7DB492C3B; Fri, 12 Aug 2022 10:04:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1991E1946A42; Fri, 12 Aug 2022 10:04:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4E02A1946A41 for ; Fri, 12 Aug 2022 10:04:35 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2ABFDC15BA8; Fri, 12 Aug 2022 10:04:35 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4237C15BA6 for ; Fri, 12 Aug 2022 10:04:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660298683; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=LxJ9F/RkVvnrCzId8wBCRi2MZIK5StOPN5N39LKVHb8=; b=UAHLJzbNItgjfrO84b9xYjXiQUTmyuLhvFRNcYae8UGnivhwzyMsLGLWxz2Z5sO6b+l9NA n4ORBTSDiWzFrsB5pO1Wsg8Hu4Xeaef3GLf7S6VdkKXdPWeeNJWelgZkZELPq9mwZYYwHH ehJmaZnlHPae25r/i5Spv5CDllJ3ayA= X-MC-Unique: ZJ94WFA7OIGMJCcmF6cDIA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v3 7/8] qemu: Enable SCHED_CORE for vCPUs Date: Fri, 12 Aug 2022 12:04:22 +0200 Message-Id: <4955f274c0d26aa41791585c1a8271b96d962674.1660298204.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1660298685521100009 Content-Type: text/plain; charset="utf-8"; x-default="true" For QEMU_SCHED_CORE_VCPUS case, the vCPU threads should be placed all into one scheduling group, but not the emulator or any of its threads. Therefore, as soon as vCPU TIDs are detected, fork off a child which then creates a separate scheduling group and adds all vCPU threads into it. Please note, this commit only handles the cold boot case. Hotplug is going to be implemented in the next commit. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_process.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index a8f8a7cb47..f9c4f72496 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5874,9 +5874,44 @@ qemuProcessSetupVcpu(virDomainObj *vm, } =20 =20 +static int +qemuProcessSetupAllVcpusSchedCoreHelper(pid_t ppid G_GNUC_UNUSED, + void *opaque) +{ + virDomainObj *vm =3D opaque; + size_t i; + + /* Since we are setting all vCPU threads at once and from a forked off + * child, we don't need the dummy schedCoreChildPID and can create one= on + * our own. */ + if (virProcessSchedCoreCreate() < 0) { + virReportSystemError(errno, "%s", + _("Unable to set SCHED_CORE")); + + return -1; + } + + for (i =3D 0; i < virDomainDefGetVcpusMax(vm->def); i++) { + pid_t vcpupid =3D qemuDomainGetVcpuPid(vm, i); + + if (vcpupid > 0 && + virProcessSchedCoreShareTo(vcpupid) < 0) { + virReportSystemError(errno, + _("unable to share scheduling cookie to %= lld"), + (long long) vcpupid); + return -1; + } + } + + return 0; +} + + static int qemuProcessSetupVcpus(virDomainObj *vm) { + qemuDomainObjPrivate *priv =3D vm->privateData; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(priv->dr= iver); virDomainVcpuDef *vcpu; unsigned int maxvcpus =3D virDomainDefGetVcpusMax(vm->def); size_t i; @@ -5919,6 +5954,10 @@ qemuProcessSetupVcpus(virDomainObj *vm) return -1; } =20 + if (cfg->schedCore =3D=3D QEMU_SCHED_CORE_VCPUS && + virProcessRunInFork(qemuProcessSetupAllVcpusSchedCoreHelper, vm) <= 0) + return -1; + return 0; } =20 --=20 2.35.1