[LTP] [PATCH] memcg_control_test: Disable swapping in test cgroup

T.J. Mercier tjmercier@google.com
Thu Mar 27 20:37:41 CET 2025


On Thu, Mar 27, 2025 at 6:36 AM Michal Koutný <mkoutny@suse.com> wrote:
>
> Hello.
>
> On Wed, Mar 26, 2025 at 10:35:32PM +0000, "T.J. Mercier" <tjmercier@google.com> wrote:
> > memcg_control_test_1 sets both a memory limit and a memsw/swap limit to
> > a single page, and then asks mem_process to allocate 2 pages in an
> > attempt to cause a memcg OOM kill. However, if swapping is enabled the
> > first page can be swapped before the second is allocated causing neither
> > limit to be exceeded, and no OOM kill to occur which results in a test
> > failure. Fix this by disabling swap in the test cgroup if it is enabled,
> > causing both pages to always be accounted under the same counter such
> > that memory.max (v2) / memory.limit_in_bytes (v1) causes an OOM kill.
>
> I see how this fixes the test for v2 but for v1 the write would fail
> with -EINVAL because memory.memsw.limit_in_bytes < memory.limit_in_bytes
> and swapout would still be possible (which it wasn't _on v1_ before this
> patch IIUC).
>
> IOW the testcase should not treat memory.swap.max (v2) and
> memory.memsw.limit_in_bytes (v1) as equivalent quantities.

Thanks Michal. I'm about to send a v2 where swap is disabled only in
memcg v2 but the memsw limit is still applied in memcg v1. Tested on
both versions of memcg this time.


More information about the ltp mailing list