Commit Graph
31 Commits
Author SHA1 Message Date
Jing ChenandgVisor bot 6cbd7dbd93 Let devices cgroup add/remove rules via devices.allow and devices.deny.
PiperOrigin-RevId: 563261158
2023-09-06 17:27:02 -07:00
Jing ChenandgVisor bot 606462c738 Add device cgroup's devices.list, which defaults to allow all.
PiperOrigin-RevId: 558534572
2023-08-20 02:20:04 -07:00
Jing ChenandgVisor bot 6e7a49f314 Add missing device cgroups.
PiperOrigin-RevId: 556053561
2023-08-11 12:48:03 -07:00
Nayana BidariandgVisor bot eba9311640 Make changes for CgroupsReadControlFile method to get memory usage per cgroup.
- Adds methods to Enter, Leave and Migrate the tasks for memory controller.
- Update the memory cgroup id when the task enters and leaves the cgroups.

PiperOrigin-RevId: 555568875
2023-08-10 11:09:28 -07:00
Jing ChenandgVisor bot 4e5d1c16a5 Add devices cgroups which is partially implemented. It could export the device cgroups to devices.deny and devices.allow, add/remove device cgroups rules will need to be implemented to fully support device cgroups.
PiperOrigin-RevId: 552673967
2023-07-31 21:22:07 -07:00
Andrei VaginandgVisor bot 833fa1c28e cgroups: allow statfs on cgroup files
PiperOrigin-RevId: 544179511
2023-06-28 15:39:34 -07:00
gVisor bot d034171d9c Merge pull request #8679 from avagin:cpp-warnings
PiperOrigin-RevId: 523157922
2023-04-10 10:59:51 -07:00
Andrei Vagin 3445db339d Fix all c++ compile time warnings 2023-03-09 19:01:00 -08:00
Rahat MahmoodandgVisor bot 5c0b77ff0d cgroupfs: Handle hierachy changes across charge/uncharge.
When charging a pids cgroup during thread creation, it is possible for
the hierachy containing the pids controller to be destroyed and
recreated. If thread creation fails and the charge has to be rolled
back, an intervening hierachy change previously caused a charge
underflow during the rollback.

If the hierachy changes between the charge and uncharge, the uncharge
is uncessary.

Reported-by: [email protected]
PiperOrigin-RevId: 471112484
2022-08-30 16:02:58 -07:00
Rahat MahmoodandgVisor bot 6953027743 cgroupfs: Implement named hierarchies.
PiperOrigin-RevId: 450773348
2022-05-24 14:46:49 -07:00
Rahat MahmoodandgVisor bot ae225faf51 cgroupfs: Per cgroups(7), PID/TID 0 refers to the current task.
PiperOrigin-RevId: 447090229
2022-05-06 16:06:43 -07:00
Rahat MahmoodandgVisor bot efd89c4d35 kernfs/cgroupfs: Fix rename.
Rename was broken for serveral reasons:

- The underlying kernfs.OrderedChildren.Rename had a bug so it could
  never successfully extract OrderedChildren from the dst Inode.

- kernfs.OrderedChildren.Rename didn't check for name collisions on
  the dst.

cgroupfs is the first kernfs-based filesystem to implement rename, so
these code paths weren't exercised.

PiperOrigin-RevId: 444964501
2022-04-27 14:20:25 -07:00
Rahat MahmoodandgVisor bot be6839c8af cgroupfs: Fix test race with task exit.
The PID controller isn't uncharged synchronously with task exit. The
test checks the PID is released after thread join, which races with
the task being reaped.

PiperOrigin-RevId: 444960688
2022-04-27 14:06:51 -07:00
Rahat MahmoodandgVisor bot 4fe790e6f4 cgroupfs: Implement pids controller.
This also introduces the controller charge interface.

PiperOrigin-RevId: 444703063
2022-04-26 16:50:15 -07:00
Rahat MahmoodandgVisor bot c956a0845b cgroupfs: Mkdir should honour file mode.
PiperOrigin-RevId: 440199111
2022-04-07 14:22:40 -07:00
Rahat MahmoodandgVisor bot bbd229dad7 cgroupfs: Directories should support setstat.
PiperOrigin-RevId: 438688088
2022-03-31 16:30:51 -07:00
Rahat MahmoodandgVisor bot 0d9bfe7669 cgroupfs: Return the correct cgroup path for tasks from procfs.
Previously we were returning the path to the control file used to
migrate a task, rather than the path to the cgroup directory.

PiperOrigin-RevId: 438676422
2022-03-31 15:33:04 -07:00
Rahat MahmoodandgVisor bot f4e68fa304 cgroupfs: Implement hierarchical accounting for cpuacct controller.
PiperOrigin-RevId: 438193226
2022-03-29 20:02:09 -07:00
Rahat MahmoodandgVisor bot 098af86c52 cgroupfs: Handle invalid PID/PGID on migration.
Reported-by: [email protected]
PiperOrigin-RevId: 437096386
2022-03-24 15:09:56 -07:00
Rahat MahmoodandgVisor bot cc99b36556 kernfs: Handle duplicate unlink on orphaned directories.
Also don't print kernfs inode internals on panic, when we can't
acquire the necessary locks.

Reported-by: [email protected]
Reported-by: [email protected]
PiperOrigin-RevId: 436869482
2022-03-23 17:26:14 -07:00
Rahat MahmoodandgVisor bot cba44f0e4f cgroupfs: Implement task migration
PiperOrigin-RevId: 430273113
2022-02-22 12:43:54 -08:00
Rahat MahmoodandgVisor bot 206ddcb9db cgroupfs: Push controller state to inodes.
This is necessary for subcontainers since each cgroup needs to carry
independent state.

PiperOrigin-RevId: 429646074
2022-02-18 14:18:21 -08:00
Ayush RanjanandgVisor bot f6263c38df Remove VFS1 special handling in tests.
Also clean up usage of GVISOR_VFS environment variable.
Updates #1624

PiperOrigin-RevId: 429100450
2022-02-16 11:41:51 -08:00
Rahat MahmoodandgVisor bot 52dc9a4d59 Stub cpuset cgroup control files.
PiperOrigin-RevId: 404382475
2021-10-19 15:38:55 -07:00
Rahat MahmoodandgVisor bot 2fa4c9e52d Initial cgroupfs support for subcontainers
Allow creation and management of subcontainers through cgroupfs
directory syscalls. Also add a mechanism to specify a default root
container to start new jobs in.

This implements the filesystem support for subcontainers, but doesn't
implement hierarchical resource accounting or task migration.

PiperOrigin-RevId: 390254870
2021-08-11 17:21:37 -07:00
Rahat MahmoodandgVisor bot 3d871f2b76 Fix cgroupfs mount racing with unmount.
Previously, mount could discover a hierarchy being destroyed
concurrently, which resulted in mount attempting to take a ref on an
already destroyed cgroupfs.

Reported-by: [email protected]
PiperOrigin-RevId: 374959054
2021-05-20 15:09:41 -07:00
Rahat MahmoodandgVisor bot e2e7c1aa33 Fix cgroup hierarchy registration.
Previously, registration was racy because we were publishing
hierarchies in the registry without fully initializing the underlying
filesystem. This led to concurrent mount(2)s discovering the partially
intialized filesystems and dropping the final refs on them which cause
them to be freed prematurely.

Reported-by: [email protected]
Reported-by: [email protected]
PiperOrigin-RevId: 373824552
2021-05-14 11:07:57 -07:00
Rahat MahmoodandgVisor bot 5d7079da00 Also report mount options through /proc/<pid>/mounts.
PiperOrigin-RevId: 369967629
2021-04-22 15:52:24 -07:00
Rahat MahmoodandgVisor bot ece1d0685e Stub the custom "job" controller required by some workloads.
PiperOrigin-RevId: 369724358
2021-04-21 13:36:50 -07:00
Rahat MahmoodandgVisor bot 1ec152491f Report task CPU usage through the cpuacct cgroup controller.
PiperOrigin-RevId: 366923274
2021-04-05 19:46:26 -07:00
Rahat MahmoodandgVisor bot de97621de2 Implement cgroupfs.
A skeleton implementation of cgroupfs. It supports trivial cpu and
memory controllers with no support for hierarchies.

PiperOrigin-RevId: 366561126
2021-04-02 21:10:44 -07:00