From nobody Sat May 4 11:08:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1563800848; cv=none; d=zoho.com; s=zohoarc; b=OTtjhAiZkeOdU6e7zTb0Zkr27nizitZakZm+QTHMRW8Dl2JVoy8tg/jM+kHDgGOZLu86ud7pd/Z9rDgZcgwWqSvhAMiI6KaxjbnDyyJXK02/MZpBLwb+6b90fvYoXWIUY3sDCt+QEKrkBcO//iibCYrgR5fXdtSGmhCw6avEtlo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563800848; 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:ARC-Authentication-Results; bh=rYQhy6tEYz25vf1oqLUyXLHhJBYPmOOF2lRjfunSwS0=; b=WE/aJmz9Vfd6PpEQRv9jmWUy6gkFU/rPA4tWYTh84UpQR1jV+ZPdRi4Qe7LX60Xt5WRaTHORVfXXjPMHrFx4RLRjAXjjb2NQdDCmCHgHkYPPFKAV3z/CKJ+gSAmWY5PxsnpK4KgqGxOFXF5X/v3IBmDgiTTPF6dxz5eJmVQOBAo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1563800848172408.3226180785267; Mon, 22 Jul 2019 06:07:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C0268308222F; Mon, 22 Jul 2019 13:07:26 +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 817AE17168; Mon, 22 Jul 2019 13:07:26 +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 173EA1800207; Mon, 22 Jul 2019 13:07:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6MD7O7h001393 for ; Mon, 22 Jul 2019 09:07:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 69303BA90; Mon, 22 Jul 2019 13:07:24 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id E800660C64 for ; Mon, 22 Jul 2019 13:07:15 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 22 Jul 2019 15:07:04 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/3] vircgroup: fix cgroups v2 controllers detection 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 22 Jul 2019 13:07:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" When creating new group for cgroups v2 the we cannot check cgroups.controllers for that cgroup because the directory is created later. In that case we should check cgroups.subtree_control of parent group to get list of controllers enabled for child cgroups. In order to achieve that we will prefer the parent group if it exists, the current group will be used only for root group. Signed-off-by: Pavel Hrdina --- src/util/vircgroup.c | 2 +- src/util/vircgroupbackend.h | 3 ++- src/util/vircgroupv1.c | 3 ++- src/util/vircgroupv2.c | 23 ++++++++++++++++------- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index f7afc2964d..cc21758323 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -407,7 +407,7 @@ virCgroupDetect(virCgroupPtr group, =20 for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { if (group->backends[i]) { - int rc =3D group->backends[i]->detectControllers(group, contro= llers); + int rc =3D group->backends[i]->detectControllers(group, contro= llers, parent); if (rc < 0) return -1; controllersAvailable |=3D rc; diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h index a91719f89d..77451b0cb6 100644 --- a/src/util/vircgroupbackend.h +++ b/src/util/vircgroupbackend.h @@ -98,7 +98,8 @@ typedef char * =20 typedef int (*virCgroupDetectControllersCB)(virCgroupPtr group, - int controllers); + int controllers, + virCgroupPtr parent); =20 typedef bool (*virCgroupHasControllerCB)(virCgroupPtr cgroup, diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index 7968ab3cf0..4231d8d6fa 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -420,7 +420,8 @@ virCgroupV1StealPlacement(virCgroupPtr group) =20 static int virCgroupV1DetectControllers(virCgroupPtr group, - int controllers) + int controllers, + virCgroupPtr parent ATTRIBUTE_UNUSED) { size_t i; size_t j; diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 9d8a38925a..9c44b3473e 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -242,7 +242,8 @@ virCgroupV2StealPlacement(virCgroupPtr group) =20 =20 static int -virCgroupV2ParseControllersFile(virCgroupPtr group) +virCgroupV2ParseControllersFile(virCgroupPtr group, + virCgroupPtr parent) { int rc; VIR_AUTOFREE(char *) contStr =3D NULL; @@ -250,10 +251,17 @@ virCgroupV2ParseControllersFile(virCgroupPtr group) char **contList =3D NULL; char **tmp; =20 - if (virAsprintf(&contFile, "%s%s/cgroup.controllers", - group->unified.mountPoint, - NULLSTR_EMPTY(group->unified.placement)) < 0) - return -1; + if (parent) { + if (virAsprintf(&contFile, "%s%s/cgroup.subtree_control", + parent->unified.mountPoint, + NULLSTR_EMPTY(parent->unified.placement)) < 0) + return -1; + } else { + if (virAsprintf(&contFile, "%s%s/cgroup.controllers", + group->unified.mountPoint, + NULLSTR_EMPTY(group->unified.placement)) < 0) + return -1; + } =20 rc =3D virFileReadAll(contFile, 1024 * 1024, &contStr); if (rc < 0) { @@ -286,11 +294,12 @@ virCgroupV2ParseControllersFile(virCgroupPtr group) =20 static int virCgroupV2DetectControllers(virCgroupPtr group, - int controllers) + int controllers, + virCgroupPtr parent) { size_t i; =20 - if (virCgroupV2ParseControllersFile(group) < 0) + if (virCgroupV2ParseControllersFile(group, parent) < 0) return -1; =20 /* In cgroup v2 there is no cpuacct controller, the cpu.stat file alwa= ys --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 11:08:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1563800857; cv=none; d=zoho.com; s=zohoarc; b=Qr3xOiyveNp/a9QkPwzM0ElVQKsnSjSngy7DxrwQ8mVkKVdrYK0Q2/6is+FpC6u0ppserYls+X1cW2lh8BbLzo5tZrGPhoqUEd3v6cTztfqiDH24lA2yor5cAxpYEIR9Lp33ZYFIQejbZMjDQ1k80NLqNEdiZ66YgNh39H47H4A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563800857; 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:ARC-Authentication-Results; bh=A9Dz8Qk/AYCO09SXMjKJwW+86YNH3eLsnnYEsjwlfh4=; b=YMSeUSpHrQEJZoqwZOqeIBCtQL6pJ9raGkFB8/trSHkPo0+AH57A8bjeTdNtZSJXyWOxPBKRoWfOmwvGfYS1eaqXFeUUi+I7gPYradI3GWnn4Wq6OaDPfC2i9ixmGMom8Dp8JUGQOBC+tlGyzJ4oKRMzSRXsG8BKiTjPQm8ka+A= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1563800857902596.322437641626; Mon, 22 Jul 2019 06:07:37 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 1B48930C01B6; Mon, 22 Jul 2019 13:07:36 +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 E8FDB5D967; Mon, 22 Jul 2019 13:07:35 +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 A4881180020A; Mon, 22 Jul 2019 13:07:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6MD7QoC001404 for ; Mon, 22 Jul 2019 09:07:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id EA9F660C64; Mon, 22 Jul 2019 13:07:26 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7567C619C6 for ; Mon, 22 Jul 2019 13:07:24 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 22 Jul 2019 15:07:05 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/3] vircgroupv2: store enabled controllers 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 22 Jul 2019 13:07:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" In cgroups v2 when a new group is created by default no controller is enabled so the detection code will not detect any controllers. When enabling the controllers we should also store them for the group. Signed-off-by: Pavel Hrdina --- src/util/vircgroupv2.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 9c44b3473e..af3192c99c 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -365,7 +365,8 @@ virCgroupV2PathOfController(virCgroupPtr group, * 0 on success */ static int -virCgroupV2EnableController(virCgroupPtr parent, +virCgroupV2EnableController(virCgroupPtr group, + virCgroupPtr parent, int controller, bool report) { @@ -391,6 +392,8 @@ virCgroupV2EnableController(virCgroupPtr parent, return -2; } =20 + group->unified.controllers |=3D 1 << controller; + return 0; } =20 @@ -432,14 +435,14 @@ virCgroupV2MakeGroup(virCgroupPtr parent ATTRIBUTE_UN= USED, } =20 if (virCgroupV2HasController(parent, VIR_CGROUP_CONTROLLER_CPU= ) && - virCgroupV2EnableController(parent, + virCgroupV2EnableController(group, parent, VIR_CGROUP_CONTROLLER_CPU, true) < 0) { return -1; } =20 if (virCgroupV2HasController(parent, VIR_CGROUP_CONTROLLER_CPU= SET) && - virCgroupV2EnableController(parent, + virCgroupV2EnableController(group, parent, VIR_CGROUP_CONTROLLER_CPUSET, true) < 0) { return -1; @@ -456,7 +459,7 @@ virCgroupV2MakeGroup(virCgroupPtr parent ATTRIBUTE_UNUS= ED, if (i =3D=3D VIR_CGROUP_CONTROLLER_CPUACCT) continue; =20 - rc =3D virCgroupV2EnableController(parent, i, false); + rc =3D virCgroupV2EnableController(group, parent, i, false= ); if (rc < 0) { if (rc =3D=3D -2) { virResetLastError(); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 11:08:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1563800857; cv=none; d=zoho.com; s=zohoarc; b=O7ZR24odIcPXPcmO1eKy9CBq/GVJgdoZ0uiEvDOpiDjrrIqnDTTDlyHfR4gqOu4rm+OHI/MYwuUlNq10fLBmdOiiaxAd9TbiTKSawsR0cOj25whEn9efwxpD2C73kZtvPgzk9BnC8R60WDPYdDT6Qr0gDb78qyumGq9a5f22I18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563800857; 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:ARC-Authentication-Results; bh=9tyuDsZsYWT91JGxxOMiWCkHSSm1J0ubN/o7Nf7sOZw=; b=S0aKvWaNuQBCl9v6mCsqHoV365EgjqBTfPuXecQnQUlZx0iNtwSxaA5zy0jrZkGle9yTstjnMKvUDDj7AbuXr48WBruQ8PLttGgaQwPJtLKW9NkSDbS+ywKTjpPNzzbAQ5Q+dIgFGM0z8Lazsf66eX5rgPjTqiIWH12pzbU2zS0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1563800857279476.7013011113903; Mon, 22 Jul 2019 06:07:37 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EF99030C01C5; Mon, 22 Jul 2019 13:07:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C807419D7B; Mon, 22 Jul 2019 13:07:35 +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 7F35A4EA2F; Mon, 22 Jul 2019 13:07:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6MD7TQb001414 for ; Mon, 22 Jul 2019 09:07:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id BD42A60C64; Mon, 22 Jul 2019 13:07:29 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 468F1BA9C for ; Mon, 22 Jul 2019 13:07:27 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 22 Jul 2019 15:07:06 +0200 Message-Id: <6b8a862ebf5c9513f0274170b0e843d46c2e3f0f.1563800741.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/3] vircgroupv2: remove ATTRIBUTE_UNUSED for used attribute 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 22 Jul 2019 13:07:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/util/vircgroupv2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index af3192c99c..e36c36685b 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -399,7 +399,7 @@ virCgroupV2EnableController(virCgroupPtr group, =20 =20 static int -virCgroupV2MakeGroup(virCgroupPtr parent ATTRIBUTE_UNUSED, +virCgroupV2MakeGroup(virCgroupPtr parent, virCgroupPtr group, bool create, unsigned int flags) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list