All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
* [Devel] [PATCH hci-8.1 0/2] selftests: cgroup: fix the flaky and vacuous test_memcg_sock
@ 2026-10-19 19:47 Konstantin Khorenko
  2026-10-19 19:47 ` [Devel] [PATCH hci-8.1 1/2] ms/selftests: cgroup: skip test_memcg_sock under cgroup.memory=nosocket Konstantin Khorenko
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Konstantin Khorenko @ 2026-10-19 19:47 UTC (permalink / raw)
  To: devel, Konstantin Khorenko

test_memcg_sock compares memory.current of its cgroup with the "sock "
entry of memory.stat. memory.current moves at charge time, "sock " only
when the memcg stats are flushed, and nothing in the test makes a flush
happen. So the test either compares 0 with 0 and passes without having
checked anything, or fails at random.

This tree is worse off than mainline was before the fix: the final
check reads "sock " once, right after the connection is closed, with no
wait at all. Mainline polled for 3 seconds there (6360d444ae32), this
tree never got that commit.

It fails here
=============

10.193.16.26 (4 CPUs), test_memcontrol run 100 times before and after
the series, interleaved:

  kernel                                  before      after
  6.12.0-211.52.1.22.8.vz10 (release)     0 failed    0 failed
  6.12.0-211.52.1.22.8.vz10 (debug)       5 failed    0 failed

Every failure on the debug kernel is the final check: the client part
of the test had passed, the single read still saw the socket memory.

The release kernel passes here only because the machine is small. A
memory.stat read flushes once MEMCG_CHARGE_BATCH pages per online CPU
of updates are pending, so on 4 CPUs the test traffic crosses the
threshold by itself. On a 48-CPU host mainline's test failed 8 of 30
runs on a debug kernel, and most of its passes compared 0 with 0.

The patches
===========

Both are in mainline's cgroup tree, cgroup/for-7.4:
https://lore.kernel.org/r/20261012-b4-prep-vstor-149854-let-test_memcg_sock-compare-flushed-sock-stats-v1-0-bc864b1950ad@virtuozzo.com

- 1/2 skips the test under cgroup.memory=nosocket, where no socket
  memory is charged and the test can only pass on 0 == 0.
- 2/2 makes the test cause the flushes it needs instead of waiting for
  them: the client keeps the data in the server's socket and reads until
  enough socket memory has moved through the cgroup that a memory.stat
  read must flush, and the final check allocates and frees anonymous
  memory in the cgroup before it reads "sock ".

The backport differs from mainline only as the Conflict: notes say:

- 1/2 sizes its buffer with PAGE_SIZE, mainline renamed it to BUF_SIZE
- 2/2 replaces the single "sock " read, not mainline's poll

https://virtuozzo.atlassian.net/browse/VSTOR-149854

---
Konstantin Khorenko (2):
      ms/selftests: cgroup: skip test_memcg_sock under cgroup.memory=nosocket
      ms/selftests: cgroup: make test_memcg_sock check flushed sock stats

 .../selftests/cgroup/lib/include/cgroup_util.h     |  3 ++
 tools/testing/selftests/cgroup/test_kmem.c         |  2 +-
 tools/testing/selftests/cgroup/test_memcontrol.c   | 56 ++++++++++++++++++++--
 3 files changed, 55 insertions(+), 6 deletions(-)
---
base-commit: 8026fb5599f945a36a6911f8febad3ab569176da
change-id: 20261019-b4-prep-khorenko-vstor-149854-selftests-test_memcg_sock-6c864da317a3

Best regards,
--  
Konstantin Khorenko <khorenko@virtuozzo.com>

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-10-19 20:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-19 19:47 [Devel] [PATCH hci-8.1 0/2] selftests: cgroup: fix the flaky and vacuous test_memcg_sock Konstantin Khorenko
2026-10-19 19:47 ` [Devel] [PATCH hci-8.1 1/2] ms/selftests: cgroup: skip test_memcg_sock under cgroup.memory=nosocket Konstantin Khorenko
2026-10-19 19:50   ` no-reply
2026-10-19 19:47 ` [Devel] [PATCH hci-8.1 2/2] ms/selftests: cgroup: make test_memcg_sock check flushed sock stats Konstantin Khorenko
2026-10-19 19:50   ` no-reply
2026-10-19 19:59 ` [Devel] [PATCH hci-8.1 0/2] selftests: cgroup: fix the flaky and vacuous test_memcg_sock Konstantin Khorenko

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.