Hello, On Wed, Aug 24, 2022 at 12:02:04PM -0700, Mina Almasry wrote: > > If we can express all the resource contraints and structures in the cgroup > > side and configured by the management agent, the application can simply e.g. > > madvise whatever memory region or flag bpf maps as "these are persistent" > > and the rest can be handled by the system. If the agent set up the > > environment for that, it gets accounted accordingly; otherwise, it'd behave > > as if those tagging didn't exist. Asking the application to set up all its > > resources in separate steps, that might require significant restructuring > > and knowledge of how the hierarchy is setup in many cases. > > I don't know if this level of granularity is needed with a madvise() > or such. The kernel knows whether resources are persistent due to the > nature of the resource. For example a shared tmpfs file is a resource > that is persistent and not cleaned up after the process using it dies, > but private memory is. madvise(PERSISTENT) on private memory would not > make sense, and I don't think madvise(NOT_PERSISTENT) on tmpfs-backed > memory region would make sense. Also, this requires adding madvise() > hints in userspace code to leverage this. I haven't thought hard about what the hinting interface should be like. The default assumptions would be that page cache belongs to the persistent domain and anon belongs to the instance (mm folks, please correct me if I'm off the rails here), but I can imagine situations where that doesn't necessarily hold - like temp files which get unlinked on instance shutdown. In terms of hint granularity, more coarse grained (e.g. file, mount whatever) seems to make sense but again I haven't thought too hard on it. That said, as long as the default behavior is reasonable, I think adding some hinting calls in the application is acceptable. It doesn't require any structrual changes and the additions would be for its own benefit of more accurate accounting and control. That makes sense to me. One unfortunate effect this will have is that we'll be actively putting resources into intermediate cgroups. This already happens today but if we support persistent domains, it's gonna be a lot more prevalent and we'll need to update e.g. iocost to support IOs coming out of intermediate cgroups. This kinda sucks because we don't even have knobs to control self vs. children distributions. Oh well... Thanks. -- tejun