From: Albert Esteve <aesteve@redhat.com>
To: "Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Shuah Khan" <shuah@kernel.org>,
"Maarten Lankhorst" <dev@lankhorst.se>,
"Natalie Vock" <nat@pixelcluster.dev>
Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
linux-kselftest@vger.kernel.org,
dri-devel@lists.freedesktop.org,
Albert Esteve <aesteve@redhat.com>,
echanude@redhat.com, mripard@kernel.org,
R Nageswara Sastry <rnsastry@linux.ibm.com>
Subject: [PATCH v7 0/3] cgroup: dmem: add selftest helper and coverage
Date: Tue, 17 Nov 2026 14:27:45 +0100 [thread overview]
Message-ID: <20261117-kunit_cgroups-v7-0-5bcbfe17f323@redhat.com> (raw)
Hi all,
This small series adds practical test coverage for the dmem
cgroup controller.
The motivation came from following the recent dmem API discussion in
thread [1]. That discussion considered changing the dmem API and
adding a new knob. Currently there are no dedicated tests covering
dmem behaviour, which makes such changes riskier.
No reviews were received on the last version. The series is small
and self-contained, and was tested by R Nageswara Sastry, so
reviewing it should be cheap.
Adding selftests has an additional challenge: dmem charging paths
are driver-driven today, so regression testing is harder unless a
suitable driver is present in the test environment.
This series addresses that by adding:
- an out-of-tree dmem_selftest helper with alloc/free module parameters,
- KB() definition next to existing MB()/GB() helpers
- test_dmem for dmem.max enforcement and byte-accurate dmem.current
The goal is to make dmem behavior easier to validate when evolving the API
and implementation, while keeping tests deterministic and driver-independent.
Thanks.
[1] - https://lore.kernel.org/all/aZoHfloupKvF2oSu@fedora/
Signed-off-by: Albert Esteve <aesteve@redhat.com>
---
Changes in v7:
- Rebased onto v7.4-rc3. No functional changes since v6.
- Link to v6: https://lore.kernel.org/r/20260831-kunit_cgroups-v6-0-63b6c7695287@redhat.com
Changes in v6:
- Drop virtme-ng wrappers
- Build the helper out of tree, drop CONFIG_DMEM_SELFTEST
- Rename charge/uncharge to alloc/free
- Add KB() in cgroup_util.h
- Use cg_read_key_long(), ARRAY_SIZE(), and KB()/MB() size literals
- Drop test_dmem_min/low
- Check dmem.current for exact equality
- stat() the helper once in main() instead of per-subtest
- Link to v5: https://lore.kernel.org/r/20260706-kunit_cgroups-v5-0-6c42c8753468@redhat.com
Changes in v5:
- Change parse_first_region() by find_selftest_region to scan
dmem.capacity lines
- Use exact equality for limit readback, not values_close()
- Write VM tempfile to $SCRIPT_DIR
- Fix KTAP by dropping outer framing in test_dmem
- Use array for optional vng args to handle paths with spaces
- Respect O=/KBUILD_OUTPUT= when building, per bpf/vmtest.sh convention
- Link to v4: https://lore.kernel.org/r/20260519-kunit_cgroups-v4-0-f6c2f498fae4@redhat.com
Changes in v4:
- Fix charged_pool leak in dmem_selftest_init()
- Replace ssh-based VM approach in vmtest-dmem.sh with vng --exec
- Add main() wrapper to vmtest-dmem.sh
- Other small fixes suggested by Sashiko
- Link to v3: https://lore.kernel.org/r/20260504-kunit_cgroups-v3-0-4eac90b76f91@redhat.com
Changes in v3:
- Set charged flag on unexpected over-limit charge success.
- Add CONFIG_DMEM_SELFTEST=m to selftest config.
- Simplify -v to a boolean; single -v was a no-op.
- Unquote kernel_opt to avoid empty-string arg to vng.
- Document -b in usage() output.
- Link to v2: https://lore.kernel.org/r/20260421-kunit_cgroups-v2-0-bb6675d8249c@redhat.com
Changes in v2:
- Fix debugfs_create_dir() error check
- Fix module teardown race: call dmem_selftest_remove() before
uncharging so debugfs files are torn down
- Use IS_ERR_OR_NULL() in selftest() sanity check
- Add CONFIG_CGROUP_DMEM=y to the cgroup selftest config
- Replace config-file parsing in check_guest_requirements() with
a direct check of /sys/fs/cgroup/cgroup.controllers
- Add new patch 4 (from Eric Chanudet): vmtest-dmem.sh -b flag
to configure and build a local kernel tree
- Link to v1: https://lore.kernel.org/r/20260327-kunit_cgroups-v1-0-971b3c739a00@redhat.com
---
Albert Esteve (3):
selftests: cgroup: Add dmem_selftest helper module
selftests: cgroup: Add KB() helper
selftests: cgroup: Add dmem selftest coverage
tools/testing/selftests/cgroup/.gitignore | 1 +
tools/testing/selftests/cgroup/Makefile | 3 +
tools/testing/selftests/cgroup/config | 1 +
.../selftests/cgroup/lib/include/cgroup_util.h | 1 +
tools/testing/selftests/cgroup/test_dmem.c | 314 +++++++++++++++++++++
.../testing/selftests/cgroup/test_modules/Makefile | 17 ++
.../selftests/cgroup/test_modules/dmem_selftest.c | 146 ++++++++++
7 files changed, 483 insertions(+)
---
base-commit: 666539eecdf4db623f5e3c3e55cf9f2dfad24aa4
change-id: 20260318-kunit_cgroups-7fb0b9e64017
Best regards,
--
Albert Esteve <aesteve@redhat.com>
next reply other threads:[~2026-11-17 13:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 13:27 Albert Esteve [this message]
2026-11-17 13:27 ` [PATCH v7 1/3] selftests: cgroup: Add dmem_selftest helper module Albert Esteve
2026-11-17 13:46 ` sashiko-bot
2026-11-17 13:27 ` [PATCH v7 2/3] selftests: cgroup: Add KB() helper Albert Esteve
2026-11-17 13:27 ` [PATCH v7 3/3] selftests: cgroup: Add dmem selftest coverage Albert Esteve
2026-11-17 13:33 ` sashiko-bot
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=20261117-kunit_cgroups-v7-0-5bcbfe17f323@redhat.com \
--to=aesteve@redhat.com \
--cc=cgroups@vger.kernel.org \
--cc=dev@lankhorst.se \
--cc=dri-devel@lists.freedesktop.org \
--cc=echanude@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mkoutny@suse.com \
--cc=mripard@kernel.org \
--cc=nat@pixelcluster.dev \
--cc=rnsastry@linux.ibm.com \
--cc=shuah@kernel.org \
--cc=tj@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.