Skip to contentSkip to conversation

controllers/memcg: Add testcase for kmem_limit_in_bytes of memory cgroup

PATCH Superseded zhaogongyi 3 participants 3 messages Apr 14, 2021

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

zhaogongyi

author
#0 lore raw

PATCH v2 1/1 controllers/memcg: Add testcase for kmem_limit_in_bytes of memory cgroup

Hi Richard,

That's right. I have a Misunderstanding of cgroup.procs. Actrually, we can write pid or tgid to cgroup.procs instead of pgid.

I'll update the code as:

	SAFE_FILE_PRINTF(CGROUP_PROCS, "%d", getpid());

BTW I find that the testcase run passed on my local system, it seems that tst_* will not trig memory allocation:

tst_test.c:1291: TINFO: Timeout per run is 0h 05m 00s memcg_kmem_limit_in_bytes.c:58: TPASS: fork fail as expected memcg_kmem_limit_in_bytes.c:73: TPASS: kmem alloc is controled by memory.kmem.limit_in_bytes

Summary:

passed   2
failed   0
broken   0
skipped  0

warnings 0

Thanks very much!

Best Regards,
Gongyi

Quoted 18 lines

Hello,

Quoted 3 lines · zhaogongyi

Hi Richard,

Calling setpgid in this testcase is aim to make the task group be

controlled by memory.kmem.limit_in_bytes since we have set the pgid to cgroup.procs.

Quoted 1 line

Please see cgroup_procs_write_start in cgroup/cgroup.c. It calls find_task_by_vpid which interprets pid as PIDTYPE_PID not PIDTYPE_PGID.

--
Thank you,
Richard.

#1 lore raw

PATCH v2 1/1 controllers/memcg: Add testcase for kmem_limit_in_bytes of memory cgroup

Hello,

Quoted 10 lines · zhaogongyi

Hi Richard,

That's right. I have a Misunderstanding of cgroup.procs. Actrually, we can write pid or tgid to cgroup.procs instead of pgid.

I'll update the code as:

	SAFE_FILE_PRINTF(CGROUP_PROCS, "%d", getpid());

BTW I find that the testcase run passed on my local system, it seems that tst_* will not trig memory allocation:

After a short search I found do_tty_write can return ENOMEM due to a call to kmalloc with GFP_KERNEL.

As I said previously stderr can point to many things with different write implementations. Some of these are likely to trigger memory allocation. Please see my previous reply and suggestion.

Also please note the warning message in the kernel log when using memory.kmem.limit_in_bytes.

Quoted 37 lines

tst_test.c:1291: TINFO: Timeout per run is 0h 05m 00s memcg_kmem_limit_in_bytes.c:58: TPASS: fork fail as expected memcg_kmem_limit_in_bytes.c:73: TPASS: kmem alloc is controled by memory.kmem.limit_in_bytes

Summary:

passed   2
failed   0
broken   0
skipped  0

warnings 0

Thanks very much!

Best Regards,
Gongyi

Quoted 18 lines

Hello,

Quoted 3 lines · zhaogongyi

Hi Richard,

Calling setpgid in this testcase is aim to make the task group be

controlled by memory.kmem.limit_in_bytes since we have set the pgid to cgroup.procs.

Quoted 1 line

Please see cgroup_procs_write_start in cgroup/cgroup.c. It calls find_task_by_vpid which interprets pid as PIDTYPE_PID not PIDTYPE_PGID.

--
Thank you,
Richard.

Signature · 2 lines
Thank you,
Richard.
#2 lore raw

PATCH v2 1/1 controllers/memcg: Add testcase for kmem_limit_in_bytes of memory cgroup

In reply to zhaogongyi

Hi!

Quoted 2 lines

BTW I find that the testcase run passed on my local system, it seems that tst_* will not trig memory allocation:

This is not, by any means, a proof that the test is correct.

"Passed on my machine" is nothing but poor excuse.

I can easily write utterly broken code that will work fine on a single machine and fail on anything else. Correctly written test depends on valid assumptions we can make about the operation system the test is supposed to run on.

Signature · 2 lines
Cyril Hrubis
[email protected]