Skip to content

RFC cgroups: add res_counter_write_u64() API

Dwight Engen cgroups containers 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest9 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9cgroups: add res_counter_write_u64() APIinclude/linux/res_counter.h kernel/res_counter.c+16 -00 replies
2/9cgroups: new resource counter inheritance APIinclude/linux/res_counter.h kernel/res_counter.c+20 -00 replies
3/9cgroups: ability to stop res charge propagation on bounded ancestorDocumentation/cgroups/resource_counter.txt include/linux/res_counter.h kernel/res_counter.c+30 -80 replies
4/9cgroups: add res counter common ancestor searchinginclude/linux/res_counter.h kernel/res_counter.c+38 -00 replies
5/9res_counter: allow charge failure pointer to be nullkernel/res_counter.c+4 -20 replies
6/9cgroups: pull up res counter charge failure interpretation to callerDocumentation/cgroups/resource_counter.txt kernel/res_counter.c+3 -10 replies
7/9fix compile error in cgroup_taskset_for_each() when skip_css is NULLinclude/linux/cgroup.h+1 -10 replies
8/9cgroups: Add task and fork limits to cpuacct subsystemDocumentation/cgroups/cpuacct.txt include/linux/cgroup.h kernel/cgroup.c +3 more+347 -210 replies
9/9selftests: Add a new task counter selftesttools/testing/selftests/Makefile tools/testing/selftests/cpuacct/Makefile tools/testing/selftests/cpuacct/fork.c +4 more+456 -00 replies

Reviews trailers per patch

5 of 9 patches have a Reviewed-by or Acked-by.

PatchPaul MenageKirill A. Shutemov
1/9A-b
2/9A-b
3/9A-b A-b
4/9
5/9A-b
6/9A-b
7/9
8/9
9/9

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH RFC 0/9] cgroups: add res_counter_write_u64() API

Hello,

I've seen that some sort of fork/task limiter has been proposed and discussed several times before. Despite the existance of kmem in memcg, a fork limiter is still often asked for by container users. Perhaps this is due to current granularity in kmem (ie. stack/struct task not split out from other slab allocations) but I believe it is just more natural for users to express a limit in terms of tasks.

So what I've done is updated Frederic Weisbecker's task counter patchset and tried to address the concerns that I saw people had raised. This involved the following changes:

- merged into cpuacct controller, as it seems there is a desire not to add new controllers, this controller is already heirarchical, and I feel limiting number of tasks/forks fits best here
- included a fork_limit similar to the one Max Kellermann posted
(https://lkml.org/lkml/2011/2/17/116) which is a use case not addressable with memcg
- ala memcg kmem, for performance reasons don't account unless limit is set
- ala memcg, allow usage to roll up to root (prevents warnings on uncharge), but still don't allow setting limits in root
- changed the interface at fork()/exit(), adding can_fork()/cancel_can_fork() modeled on can_attach(). cgroup_fork() can now return failure to fork().
- ran Frederics selftests, and added a couple more

I also wrote a small fork micro benchmark to see how this change affected performance. I did 20 runs of 100000 fork/exit/waitpid, and took the average. Times are in seconds, base is without the change, cpuacct1 is with the change but no accounting be done (ie. no limit set), and cpuacct2 is with the test being in a cgroup 1 level deep.

base  cpuacct1  cpuaac2
5.59  5.59      5.64

So I believe this change has minimal performance impact, especially when no limit is set.