From nobody Sat Nov 23 05:52:20 2024 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=1681980581; cv=none; d=zohomail.com; s=zohoarc; b=SNzyu2HOBhVYls3y5uHkSdIfAp4/ksxigL91CPyXMV9F5xoZ5tXyGeDQOW7WjoPk5skVIwlU52Mr31T6DPuTol6vvimL4NVg5UH21kKleOGisQAqVc0YDGye39JqQvwv2PlFj13f+LG5iwAd73z2yFfcJ6YvftlQQVI+U29JxHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681980581; 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=r137H6Lo0X07pwpjUDrLM10dzX3j9X/d594vQYe8V/E=; b=QklMlLlEcV1g8GhJTFUBtiSK7WzLMf8DTlbNsmXzPQAskvrCmBfuM3bLEEPYhUdMT0KbSECP9X5Qb/OJz9AUepF+4MtVh3K/wH+H6jaNYLJphnXRq+MT1gTn4dOLa5H0TcfOF1sdNCEFhywo0VDTv1O+68O+XydiCaiEclKm598= 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 168198058129969.89452852305067; Thu, 20 Apr 2023 01:49:41 -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-46-2jXga7oeNVC1NEL_M7bjgQ-1; Thu, 20 Apr 2023 04:49:33 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1F4DC3C10696; Thu, 20 Apr 2023 08:49:31 +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 1657A63A5F; Thu, 20 Apr 2023 08:49:28 +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 96E5219465B9; Thu, 20 Apr 2023 08:49:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 543BC19465B5 for ; Thu, 20 Apr 2023 08:49:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4290D40C201F; Thu, 20 Apr 2023 08:49:26 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3B41440C2064 for ; Thu, 20 Apr 2023 08:49:26 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 1DA47185A78B for ; Thu, 20 Apr 2023 08:49:26 +0000 (UTC) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-495-a4Y9_rM-NGC5wEG7AhMl8g-1; Thu, 20 Apr 2023 04:49:24 -0400 Received: by mail-ed1-f71.google.com with SMTP id x5-20020a50d605000000b005066c2aa22aso1184242edi.17 for ; Thu, 20 Apr 2023 01:49:24 -0700 (PDT) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id q14-20020a17090676ce00b00932ba722482sm490377ejn.149.2023.04.20.01.49.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 01:49:22 -0700 (PDT) Received: from wheatley.. (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 89819FB446AF for ; Thu, 20 Apr 2023 10:49:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681980580; 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=r137H6Lo0X07pwpjUDrLM10dzX3j9X/d594vQYe8V/E=; b=Hw7JAamRKI2WzrbP2B296JDJCtMbXgtSz6cQRF+CMRLDOuW6+uhlv7TZUvgnAyc8bFtoB/ BOweb/wr5OWXH7s21fcqsd/kyXtYlVc7iC7EnfuP1fncHeXsWzRMcOJEk73jG4qVA2KP1L jMZp9E/b2MGBOFaCqoX/ky0aUOnPvew= X-MC-Unique: 2jXga7oeNVC1NEL_M7bjgQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: a4Y9_rM-NGC5wEG7AhMl8g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681980563; x=1684572563; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r137H6Lo0X07pwpjUDrLM10dzX3j9X/d594vQYe8V/E=; b=gUtsGsFkCWPE6uY6Si64OXmtDqksJJkGtxvWfDuDNl19DlVWh7dvw2oBmF7Ufrh3xc Hc7nohQdy9UbyK6t2cDk0rvif0R1oVu/9jbgdaoJ+xFfjJKKSy/HmComEwvO+aqTqmxq 6ytX8DBqFJ3dGbYr0jevTsCNBUUu+i/x6oRVmO0X8sYUJVl+jgeUpc7batj2REcYLSB9 KeLHIsUPUqBH5USo1CjDGQ4iuEGkbxPMIpXIX7eicv3aeOxnhkRxXLkxknweySsRrPWm 2dAxchTBY5wg200mntNgAG0ye6woEKUmUFRwsaXUkI8JuDO4/oWcCRBhkr9qpSYT0q4T ddZw== X-Gm-Message-State: AAQBX9cz3F1qOpYcO1OreMRU7k/8qX8nsooWoO6xCCUvzOnlLPJrNmwY w3ethSEY6Vz1925VjeHj93t2aqXYSHVtG32Mh3Zg3+GQBGiMGlQC35+Dh9MXZQKDjbcfck3zz51 wpskwep0ERMN1n4DD2eW46we9JpGr8qrLVoFwS/z/5v98yaXoNiXSZ9Y6iDTFha+qqPBPGKRGBb SIPS2vPQ== X-Received: by 2002:a17:906:8281:b0:953:7e12:838c with SMTP id h1-20020a170906828100b009537e12838cmr842451ejx.40.1681980563770; Thu, 20 Apr 2023 01:49:23 -0700 (PDT) X-Google-Smtp-Source: AKy350Zo/QIE/5aPEc8lFiSVQqHhOc1wg25pjprscW89y33/tJ/AZYWt+OKckryHhA7+KsoG9wRQKg== X-Received: by 2002:a17:906:8281:b0:953:7e12:838c with SMTP id h1-20020a170906828100b009537e12838cmr842434ejx.40.1681980563446; Thu, 20 Apr 2023 01:49:23 -0700 (PDT) From: Martin Kletzander To: libvir-list@redhat.com Subject: [PATCH 1/2] qemu, ch: Move threads to cgroup dir before changing parameters Date: Thu, 20 Apr 2023 10:49:18 +0200 Message-Id: <1fa7acd01844d1e8b0c1efae17704af871f7a483.1681980463.git.mkletzan@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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 3.1 on 10.11.54.5 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: 1681980583094100002 Content-Type: text/plain; charset="utf-8"; x-default="true" With cgroupv2 this has better effect on the resource allocation. An excerpt from Documentation/admin-guide/cgroup-v2.rst explains is this way: Migrating a process across cgroups is a relatively expensive operation and stateful resources such as memory are not moved together with the process. This is an explicit design decision as there often exist inherent trade-offs between migration and various hot paths in terms of synchronization cost. [...] Setting a non-empty value to "cpuset.mems" causes memory of tasks within the cgroup to be migrated to the designated nodes if they are currently using memory outside of the designated nodes. Signed-off-by: Martin Kletzander --- src/ch/ch_process.c | 12 ++++++------ src/qemu/qemu_process.c | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index c145a7849647..44c5b0611ef5 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -262,6 +262,12 @@ virCHProcessSetupPid(virDomainObj *vm, if (virCgroupNewThread(priv->cgroup, nameval, id, true, &cgroup) <= 0) goto cleanup; =20 + /* Move the thread to the sub dir before changing the settings so = that + * all take effect even with cgroupv2. */ + VIR_INFO("Adding pid %d to cgroup", pid); + if (virCgroupAddThread(cgroup, pid) < 0) + goto cleanup; + if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU= SET)) { if (use_cpumask && virDomainCgroupSetupCpusetCpus(cgroup, use_cpumask) < 0) @@ -274,12 +280,6 @@ virCHProcessSetupPid(virDomainObj *vm, =20 if (virDomainCgroupSetupVcpuBW(cgroup, period, quota) < 0) goto cleanup; - - /* Move the thread to the sub dir */ - VIR_INFO("Adding pid %d to cgroup", pid); - if (virCgroupAddThread(cgroup, pid) < 0) - goto cleanup; - } =20 if (!affinity_cpumask) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b9e9a7d320c4..8baa88287567 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2630,6 +2630,11 @@ qemuProcessSetupPid(virDomainObj *vm, if (virCgroupNewThread(priv->cgroup, nameval, id, true, &cgroup) <= 0) goto cleanup; =20 + /* Move the thread to the sub dir before changing the settings so = that + * all take effect even with cgroupv2. */ + if (virCgroupAddThread(cgroup, pid) < 0) + goto cleanup; + if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU= SET)) { if (use_cpumask && virDomainCgroupSetupCpusetCpus(cgroup, use_cpumask) < 0) @@ -2642,11 +2647,6 @@ qemuProcessSetupPid(virDomainObj *vm, =20 if (virDomainCgroupSetupVcpuBW(cgroup, period, quota) < 0) goto cleanup; - - /* Move the thread to the sub dir */ - if (virCgroupAddThread(cgroup, pid) < 0) - goto cleanup; - } =20 if (!affinity_cpumask) --=20 2.40.0