From: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
To: igt-dev@lists.freedesktop.org
Cc: siqueira@igalia.com,
"Thadeu Lima de Souza Cascardo" <cascardo@igalia.com>,
dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
intel-xe@lists.freedesktop.org,
"Christian Koenig" <christian.koenig@amd.com>,
maarten.lankhorst@linux.intel.com,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Kamil Konieczny" <kamil.konieczny@linux.intel.com>,
"Janusz Krzysztofik" <janusz.krzysztofik@linux.intel.com>,
"Vitaly Prosyak" <vitaly.prosyak@amd.com>,
"Natalie Vock" <natalie.vock@gmx.de>,
"Tvrtko Ursulin" <tvrtko.ursulin@igalia.com>,
kernel-dev@igalia.com
Subject: [PATCH i-g-t v7 8/9] tests/cgroup_dmem: add write_eviction_nonblock subtest
Date: Wed, 23 Sep 2026 17:44:43 -0300 [thread overview]
Message-ID: <20260923-dmem_max-v7-8-194ea47bbb4d@igalia.com> (raw)
In-Reply-To: <20260923-dmem_max-v7-0-194ea47bbb4d@igalia.com>
From: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Add write_eviction_nonblock to exercise the O_NONBLOCK path of the dmem
cgroup max interface. After filling VRAM to the cgroup limit, each
limit-lowering step writes dmem.max with O_NONBLOCK so that synchronous
eviction is skipped. The test then verifies that usage has not yet
dropped below the new limit, allocates a small BO to trigger eviction
explicitly, and finally confirms that usage falls within bounds.
Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
---
tests/cgroup_dmem.c | 37 ++++++++++++++++++++++++++++++++++---
1 file changed, 34 insertions(+), 3 deletions(-)
diff --git a/tests/cgroup_dmem.c b/tests/cgroup_dmem.c
index 5cdb2f8830c8..7f3cfe22db2c 100644
--- a/tests/cgroup_dmem.c
+++ b/tests/cgroup_dmem.c
@@ -38,6 +38,7 @@
#define EVICT_STEP SZ_128M
#define TEST_INTERRUPTIBLE (1 << 0)
+#define TEST_NONBLOCK (1 << 1)
/**
* SUBTEST: simple
@@ -73,6 +74,18 @@
* This subtest requires GPU device with at least one VRAM region.
*/
+/**
+ * SUBTEST: write_eviction_nonblock
+ * DESCRIPTION:
+ * Same fill phase as write_eviction. In the limit-lowering phase dmem.max
+ * is written with O_NONBLOCK, which causes the kernel to skip synchronous
+ * eviction. After each nonblock write the test verifies that usage has not
+ * yet dropped below the new limit, then triggers eviction explicitly by
+ * allocating a small BO. Finally verifies that usage falls within bounds
+ * after the forced eviction.
+ * This subtest requires GPU device with at least one VRAM region.
+ */
+
static atomic_int signal_count;
static struct sigaction sigcont_oldact;
@@ -129,7 +142,7 @@ static void test_write_eviction(int fd, char *cg_region, unsigned int flags, con
struct igt_cgroup *cg;
void **handles;
int max_bo;
- uint64_t current, capacity, cg_max, limit, after;
+ uint64_t current, capacity, cg_max, limit, after, before;
int err;
igt_cgroup_dmem_get_capacity(cg_region, &capacity);
@@ -174,14 +187,31 @@ static void test_write_eviction(int fd, char *cg_region, unsigned int flags, con
while (limit >= EVICT_STEP) {
limit -= EVICT_STEP;
- igt_cgroup_dmem_set_max(cg, cg_region, limit, false);
+
+ if (flags & TEST_NONBLOCK)
+ igt_cgroup_dmem_get_current(cg, cg_region, &before);
+
+ igt_cgroup_dmem_set_max(cg, cg_region, limit,
+ !!(flags & TEST_NONBLOCK));
igt_cgroup_dmem_get_current(cg, cg_region, &after);
igt_debug("Lowered max to %"PRIu64" MiB: usage = %"PRIu64" MiB\n",
limit / SZ_1M, after / SZ_1M);
+ if (flags & TEST_NONBLOCK) {
+ /*
+ * O_NONBLOCK skips eviction: verify usage has not
+ * dropped below the new limit yet.
+ */
+ igt_assert_f(after == before,
+ "Expected no eviction with O_NONBLOCK, but "
+ "usage dropped from %"PRIu64" MiB to %"PRIu64" MiB "
+ "(limit %"PRIu64" MiB)\n",
+ before / SZ_1M, after / SZ_1M, limit / SZ_1M);
+ }
+
if (limit > EVICT_STEP) {
- if ((flags & TEST_INTERRUPTIBLE) && after > limit) {
+ if ((flags & (TEST_INTERRUPTIBLE | TEST_NONBLOCK)) && after > limit) {
/* Let a new bo creation trigger eviction. */
void *handle;
err = drv->allocate_vram(ctx, BO_SIZE / 8, &handle);
@@ -218,6 +248,7 @@ static const struct {
} subtests[] = {
{ "write_eviction", test_write_eviction, 0 },
{ "write_eviction_interruptible", test_write_eviction, TEST_INTERRUPTIBLE },
+ { "write_eviction_nonblock", test_write_eviction, TEST_NONBLOCK },
{ }
};
--
2.47.3
next prev parent reply other threads:[~2026-09-23 20:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 20:44 [PATCH i-g-t v7 0/9] add cgroup_dmem test Thadeu Lima de Souza Cascardo
2026-09-23 20:44 ` [PATCH i-g-t v7 1/9] lib/igt_cgroup: add cgroup v2 and dmem controller helpers Thadeu Lima de Souza Cascardo
2026-09-23 20:44 ` [PATCH i-g-t v7 2/9] tests/cgroup_dmem: add dmem cgroup controller test Thadeu Lima de Souza Cascardo
2026-09-23 20:44 ` [PATCH i-g-t v7 3/9] lib/xe: add xe_cgroup_region_name() helper Thadeu Lima de Souza Cascardo
2026-09-23 20:44 ` [PATCH i-g-t v7 4/9] lib/xe: Introduce dmem driver and implement Xe support Thadeu Lima de Souza Cascardo
2026-09-23 20:44 ` [PATCH i-g-t v7 5/9] lib/amdgpu: add amdgpu_cgroup_region_name Thadeu Lima de Souza Cascardo
2026-09-23 20:44 ` [PATCH i-g-t v7 6/9] lib/amdgpu: add amdgpu support to igt_dmem_driver Thadeu Lima de Souza Cascardo
2026-09-23 20:44 ` [PATCH i-g-t v7 7/9] tests/cgroup_dmem: add dmem cgroup eviction test Thadeu Lima de Souza Cascardo
2026-09-23 20:44 ` Thadeu Lima de Souza Cascardo [this message]
2026-09-23 20:44 ` [PATCH i-g-t v7 9/9] tests/cgroup_dmem: add test for dmem.current Thadeu Lima de Souza Cascardo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260923-dmem_max-v7-8-194ea47bbb4d@igalia.com \
--to=cascardo@igalia.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=igt-dev@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=janusz.krzysztofik@linux.intel.com \
--cc=kamil.konieczny@linux.intel.com \
--cc=kernel-dev@igalia.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=natalie.vock@gmx.de \
--cc=siqueira@igalia.com \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tvrtko.ursulin@igalia.com \
--cc=vitaly.prosyak@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox