Notifying on empty cgroup
I want to write software which needs to receive a signal when the cgroup created by it becomes empty. (After this the empty cgroup should be deleted just not to clutter the memory.)
If the kernel does not support such notifications, it should be improved. This functionality is crucial for some kinds of software.
There is /sys/fs/cgroup/systemd/release_agent but I don't understand how to use it. I don't understand why we would need it at all.
Starting a binary on emptying a cgroup with the purpose to notify an other binary looks like a big overkill. Also my program should work in userspace without the need to use release_agent which can be accessed only by root.
Note that my work is related with sandboxing software (running a program in closed environment, so that it would be unable for example to remove user's files).
See also
http://portonsoft.wordpress.com/2014/01/11/toward-robust-linux-sandbox/
Signature · 1 line
Victor Porton - http://portonvictor.org
[CCing cgroups mailing list]
Quoted 9 lines · Victor Porton
I want to write software which needs to receive a signal when the cgroup created by it becomes empty. (After this the empty cgroup should be deleted just not to clutter the memory.)
If the kernel does not support such notifications, it should be improved. This functionality is crucial for some kinds of software.
There is
/sys/fs/cgroup/systemd/release_agentbut I don't understand how to use it. I don't understand why we would need it at all.
"1.4 What does notify_on_release do ?" in Documentation/cgroups/cgroups.txt the kernel source doesn't help?
Quoted 2 lines
Starting a binary on emptying a cgroup with the purpose to notify an other binary looks like a big overkill.
the binary can do rmdir which is what you want, no?
Quoted 2 lines
Also my program should work in userspace without the need to use
release_agentwhich can be accessed only by root.
The release_agent is global for all groups so the program doesn't have to care.
Quoted 14 lines
Note that my work is related with sandboxing software (running a program in closed environment, so that it would be unable for example to remove user's files).
See also
http://portonsoft.wordpress.com/2014/01/11/toward-robust-linux-sandbox/Signature · 6 lines
Victor Porton - http://portonvictor.org -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Signature · 2 lines
Michal Hocko SUSE Labs
15.01.2014, 15:59, "Michal Hocko" <[email protected]>:
Quoted 7 lines
[CCing cgroups mailing list]
Quoted 4 lines · Victor Porton
šI want to write software which needs to receive a signal when the cgroup šcreated by it becomes empty. (After this the empty cgroup should be deleted šjust not to clutter the memory.)
Quoted 8 lines
Quoted 5 lines
šIf the kernel does not support such notifications, it should be improved. šThis functionality is crucial for some kinds of software.
šThere is
/sys/fs/cgroup/systemd/release_agentbut I don't understand how to šuse it. I don't understand why we would need it at all."1.4 What does
notify_on_releasedo ?" inDocumentation/cgroups/cgroups.txtthe kernel source doesn't help?
I've read it. I understand what it does. I don't understand how to use it in practice nor why it is done this way.
Quoted 4 lines
Quoted 2 lines
šStarting a binary on emptying a cgroup with the purpose to notify an other šbinary looks like a big overkill.
the binary can do rmdir which is what you want, no?
I suppose a base package should do that, not my specific software. Do I understand right?
Quoted 5 lines
Quoted 2 lines
šAlso my program should work in userspace without the need to use šrelease_agent which can be accessed only by root.
The
release_agentis global for all groups so the program doesn't have to care.
Again: What MY program should do?
Quoted 18 lines
Quoted 7 lines
šNote that my work is related with sandboxing software (running a program in šclosed environment, so that it would be unable for example to remove user's šfiles).
šSee also šhttp://portonsoft.wordpress.com/2014/01/11/toward-robust-linux-sandbox/
Quoted 7 lines
š--
šVictor Porton - http://portonvictor.org
š--
šTo unsubscribe from this list: send the line "unsubscribe linux-kernel" in šthe body of a message to [email protected]
šMore majordomo info at šhttp://vger.kernel.org/majordomo-info.html šPlease read the FAQ at šhttp://www.tux.org/lkml/--
Michal Hocko
SUSE Labs
Signature · 1 line
Victor Porton - http://portonvictor.org
Quoted 11 lines · Victor Porton
15.01.2014, 15:59, "Michal Hocko" <[email protected]>:
Quoted 10 lines
[CCing cgroups mailing list]
Quoted 7 lines · Victor Porton
I want to write software which needs to receive a signal when the cgroup created by it becomes empty. (After this the empty cgroup should be deleted just not to clutter the memory.)
If the kernel does not support such notifications, it should be improved. This functionality is crucial for some kinds of software.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
There is
/sys/fs/cgroup/systemd/release_agentbut I don't understand how to use it. I don't understand why we would need it at all."1.4 What does
notify_on_releasedo ?" inDocumentation/cgroups/cgroups.txtthe kernel source doesn't help?I've read it. I understand what it does. I don't understand how to use it in practice nor
You want to clean up your memcg without any tasks so the script might do something like:
---
#!/bin/sh
CGROUP="$1"
CGROUP_MNT=mount | grep cgroup | awk '{print $3}'
rmdir "$CGROUP_MNT/$CGROUP"
---
Quoted 1 line
why it is done this way.
I find the interface rather awkward as well but that is a question for those who have implement it.
The interface will change in the future (sorry I do not have any link to discussion about the change handy).
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Starting a binary on emptying a cgroup with the purpose to notify an other binary looks like a big overkill.
the binary can do rmdir which is what you want, no?
I suppose a base package should do that, not my specific software. Do I understand right?
Yes. The notifier works on the root of the cgroup hierarchy so it is a matter of the admin to set it.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Also my program should work in userspace without the need to use
release_agentwhich can be accessed only by root.The
release_agentis global for all groups so the program doesn't have to care.Again: What MY program should do?
Nothing. (assuming the only thing you are interested in is removing the empty group).
[...]
Signature · 2 lines
Michal Hocko SUSE Labs