0

I want to limit the memory usage of a process using cgroup but failed with error

sh: echo: I/O error

After creating a test dir in /sys/fs/cgroup/memory. I opened two shell, one run sudo sh -c "echo $$ >> cgroup.procs" to set the process, the other is to set memory limit.

It seems it's ok to set large memory: sudo sh -c "echo 25M > memory.limit_in_bytes" while will fail to set low memmory: sudo sh -c "echo 2M > memory.limit_in_bytes".

OS: Ubuntu 18.04.2 LTS

  • There is only one case when cgroupfs returns `EIO` (I/O error) - not in-place renaming of the control group ([source](https://github.com/torvalds/linux/blob/d8a5b80568a9cb66810e75b182018e9edb68e8ff/kernel/cgroup/cgroup-v1.c#L866)), and it's pretty unlikely that `echo` does this. Are you sure that steps you described are the only things you do? – Danila Kiver Jul 26 '19 at 12:01
  • Btw, how this question is related to Docker? The [docker] tag seems useless here. – Danila Kiver Jul 26 '19 at 12:02

0 Answers0