From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8EAFAC9830D for ; Wed, 23 Sep 2026 20:45:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0262A10F1A2; Wed, 23 Sep 2026 20:45:08 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=igalia.com header.i=@igalia.com header.b="nY/JaYBc"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id CBB1810F1B1; Wed, 23 Sep 2026 20:45:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:Message-Id:Content-Transfer-Encoding:Content-Type: MIME-Version:Subject:Date:From:From:Reply-To; bh=rjsfF1fEBJ1GVJyZ8uFAH8nL4bHJqwnmPL1J2vr0sxw=; b=nY/JaYBcZhdiU8rvVG7xT7knDv saKW8Z7wKvVAkUxhg/sqtIKBEfZAcF5cLSgzl5PAKpW9OoVU2HX8VM0ZJPOFAJs794rX77ou17ub0 5gE6IVA2OTQa+i8xZFR/LcJLKluGJ8PH5zt/eEpweEHub9xTa5+GRAq6nuFaaUmDXoU9wllPjdLnY JYUioOI1Tf5RTQEspcVDGtMkDFiR0mjvkSfKn7E1nRWa6YJDgT9InkpWd7jcsKJTcU0iaQSG7gsZa GP87Pyvz87vg3oj51ZXgGLJvPRPtD6f5kT541H3nuBI+kfG6fe8C1zcwk14gVRbTe83xng4T7LjTr ArrFIBFw==; Received: from 179-125-72-1-dinamico.pombonet.net.br ([179.125.72.1] helo=[127.0.0.1]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1x9Tpr-006KVk-Fu; Wed, 23 Sep 2026 22:44:59 +0200 From: Thadeu Lima de Souza Cascardo Date: Wed, 23 Sep 2026 17:44:37 -0300 Subject: [PATCH i-g-t v7 2/9] tests/cgroup_dmem: add dmem cgroup controller test MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20260923-dmem_max-v7-2-194ea47bbb4d@igalia.com> References: <20260923-dmem_max-v7-0-194ea47bbb4d@igalia.com> In-Reply-To: <20260923-dmem_max-v7-0-194ea47bbb4d@igalia.com> To: igt-dev@lists.freedesktop.org Cc: siqueira@igalia.com, Thadeu Lima de Souza Cascardo , dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, Christian Koenig , maarten.lankhorst@linux.intel.com, =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Kamil Konieczny , Janusz Krzysztofik , Vitaly Prosyak , Natalie Vock , Tvrtko Ursulin , kernel-dev@igalia.com X-Mailer: b4 0.16-dev-62088 X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" From: Thomas Hellström Add a test that exercises the cgroup v2 dmem controller interface using the new igt_cgroup library. The test uses igt_simple_main and: - Skips if no dmem regions are registered (no cgroup v2 or no dmem-capable device). - Creates a sub-cgroup and moves the test process into it. - Enumerates all registered device memory regions and prints their capacity, system-wide current usage, per-cgroup current usage, and configured min, low and max limits. Assisted-by: GitHub Copilot:claude-sonnet-4.6 Signed-off-by: Thomas Hellström Signed-off-by: Thadeu Lima de Souza Cascardo --- tests/cgroup_dmem.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/meson.build | 1 + 2 files changed, 92 insertions(+) diff --git a/tests/cgroup_dmem.c b/tests/cgroup_dmem.c new file mode 100644 index 000000000000..2ccd8bdb00ae --- /dev/null +++ b/tests/cgroup_dmem.c @@ -0,0 +1,91 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright © 2025 Intel Corporation + */ + +/** + * TEST: cgroup dmem + * Description: Exercises the cgroup v2 dmem controller interface. Creates a + * cgroup, moves the process into it, enumerates all dmem regions, + * prints their capacity, system-wide current usage, per-cgroup + * current usage and configured limits, then destroys the cgroup. + * Category: Core + * Mega feature: General Core features + * Sub-category: uapi + * Functionality: cgroup + * Feature: dmem + * Test category: uapi + */ + +#include + +#include "igt.h" +#include "igt_cgroup.h" + +IGT_TEST_DESCRIPTION("Exercises the cgroup v2 dmem controller interface."); + +static void fmt_bytes(uint64_t v, char *buf, size_t len) +{ + if (v == IGT_CGROUP_DMEM_MAX) + snprintf(buf, len, "max"); + else + snprintf(buf, len, "%" PRIu64, v); +} + +int igt_simple_main() +{ + struct igt_cgroup *cg; + const char *region; + char **regions; + uint64_t capacity, sys_current, cg_current, min, low, max; + char cap_s[32], sys_s[32], cg_s[32]; + char min_s[32], low_s[32], max_s[32]; + int i; + + igt_require_f(igt_cgroup_dmem_available(), + "No dmem regions found; is cgroup v2 with the " + "dmem controller available?\n"); + + cg = igt_cgroup_new("igt-cgroup-dmem-test"); + igt_assert_f(cg, "Failed to create cgroup\n"); + + igt_cgroup_move_current(cg); + + regions = igt_cgroup_dmem_regions(); + igt_assert_f(regions, "Failed to enumerate dmem regions\n"); + + igt_info("%-40s %16s %16s %16s %16s %16s %16s\n", + "region", "capacity", "system-current", + "cgroup-current", "min", "low", "max"); + igt_info("%-40s %16s %16s %16s %16s %16s %16s\n", + "------", "--------", "--------------", + "--------------", "---", "---", "---"); + + for (i = 0; regions[i]; i++) { + region = regions[i]; + + igt_cgroup_dmem_get_capacity(region, &capacity); + fmt_bytes(capacity, cap_s, sizeof(cap_s)); + + igt_cgroup_dmem_get_system_current(region, &sys_current); + fmt_bytes(sys_current, sys_s, sizeof(sys_s)); + + igt_cgroup_dmem_get_current(cg, region, &cg_current); + fmt_bytes(cg_current, cg_s, sizeof(cg_s)); + + igt_cgroup_dmem_get_min(cg, region, &min); + fmt_bytes(min, min_s, sizeof(min_s)); + + igt_cgroup_dmem_get_low(cg, region, &low); + fmt_bytes(low, low_s, sizeof(low_s)); + + igt_cgroup_dmem_get_max(cg, region, &max); + fmt_bytes(max, max_s, sizeof(max_s)); + + igt_info("%-40s %16s %16s %16s %16s %16s %16s\n", + region, cap_s, sys_s, cg_s, + min_s, low_s, max_s); + } + + igt_cgroup_dmem_regions_free(regions); +} diff --git a/tests/meson.build b/tests/meson.build index 4f5c9be7b458..65b9a230f935 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,4 +1,5 @@ test_progs = [ + 'cgroup_dmem', 'core_auth', 'core_debugfs', 'core_getclient', -- 2.47.3