Re: [PATCH mm-new v3] mm/memcontrol: Add memory.stat_refresh for on-demand stats flushing

From: Michal Hocko

Date: Tue Nov 11 2025 - 14:48:07 EST


On Tue 11-11-25 14:10:28, Waiman Long wrote:
[...]
> > +static void memcg_flush_stats(struct mem_cgroup *memcg, bool force)
> > +{
> > + if (mem_cgroup_disabled())
> > + return;
> > +
> > + memcg = memcg ?: root_mem_cgroup;
> > + __mem_cgroup_flush_stats(memcg, force);
> > +}
>
> Shouldn't we impose a limit in term of how frequently this
> memcg_flush_stats() function can be called like at most a few times per

This effectivelly invalidates the primary purpose of the interface to
provide a method to get as-fresh-as-possible value AFAICS.

> second to prevent abuse from user space as stat flushing is expensive? We
> should prevent some kind of user space DoS attack by using this new API if
> we decide to implement it.

What exactly would be an attack vector?
--
Michal Hocko
SUSE Labs