From nobody Sun Feb 8 23:37:02 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=1661331337; cv=none; d=zohomail.com; s=zohoarc; b=KpTjM4v/k5IBkpplBTwg4sOMgySO2pKN5f3mgutXUQKnIpwar93549kDXxlQRfPx8cbZdJ+r+GcYUw8cCCbtSsFWiGKVkSGHBOCCZx2f1SCbS9hWBKFh4LWLdravqs7pcsXb1zEZleAP4Mevr9BAGf/w3yEzQGH3S/JzUkYxVG0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661331337; 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=bkE7qYGfk61TkobCd6o+d/0lh39YCCYH7gqXK3TiUFQ=; b=m7VKPl7LM8GsjXH1zCMdnfbH6SFBnCztCMpkTQi1DgkWEYgvRQDT2BL4kULgfxVifdPV+oBk9fL6faDy7Elmnhorw4oDXYZhSebvx1k/zkV1gkjgR5lKrI5CYEA4SIYjBEhkSKBHQzQvK6D9rGvPx1m5OiPGy9FG3PNCM9zqJ/c= 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 1661331337029292.6513833426736; Wed, 24 Aug 2022 01:55:37 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-82-fAFOyjFwMwOO6rN2g1cWsw-1; Wed, 24 Aug 2022 04:55:32 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8AF871C14D31; Wed, 24 Aug 2022 08:55:30 +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 79A641415125; Wed, 24 Aug 2022 08:55:30 +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 6E5B51946A42; Wed, 24 Aug 2022 08:55:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0D9461946A40 for ; Wed, 24 Aug 2022 08:55:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E62C92024CC2; Wed, 24 Aug 2022 08:55:28 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 915BE2024CBC for ; Wed, 24 Aug 2022 08:55:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661331336; 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=bkE7qYGfk61TkobCd6o+d/0lh39YCCYH7gqXK3TiUFQ=; b=Py+HjtBaYfUUXyk8mamGcbwDYnG3QLMSFiIgVZTqccalmJYgXD5Z6HgPtUTaqLLhZoqqZ4 EOu5fYJkCSfOfl2oV+jsGaxsS7Bw/RwPrX+eklZ9H+PKA6LBD+7knQsZjx79RykzmVTT+v Tf/kIuWvIebDXLlvBPGx+QJM9k0U11Q= X-MC-Unique: fAFOyjFwMwOO6rN2g1cWsw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v4 7/8] qemu: Enable SCHED_CORE for vCPUs Date: Wed, 24 Aug 2022 10:55:12 +0200 Message-Id: <61a7ad476e55c42bd3a5bd70ddbd12306010e09a.1661331156.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 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.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661331338717100005 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 dbd4408a8a..83fcb5518a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5875,9 +5875,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; @@ -5920,6 +5955,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