Re: memcg stats flushing (WAS "Re: [PATCH] fuse: disable default bdi strictlimiting")
Yosry Ahmed <[email protected]>
| Newsgroups | dev.linux.lists.fuse-devel,org.kernel.vger.cgroups,org.kernel.vger.linux-fsdevel,org.kvack.linux-mm |
|---|---|
| Message-ID | <CAO9r8zNJ=Fpc0pZExrttVTDCM3yzSmLPCAU=+RS0k5Pm+hY96w@mail.gmail.com> |
On Thu, Aug 20, 2026 at 4:39 PM Joanne Koong <[email protected]> wrote: > > On Tue, Aug 18, 2026 at 11:40 AM Yosry Ahmed <[email protected]> wrote: > > > > On Wed, Aug 12, 2026 at 1:59 PM Joanne Koong <[email protected]> wrote: > > > > > > d) vmscan (prepare_scan_control()): for determining whether reclaim > > > can deactivate, there's this logic > > > > > > /* > > > * When refaults are being observed, it means a new > > > * workingset is being established. Deactivate to get > > > * rid of any stale active pages quickly. > > > */ > > > refaults = lruvec_page_state(target_lruvec, > > > WORKINGSET_ACTIVATE_ANON); > > > if (refaults != target_lruvec->refaults[WORKINGSET_ANON] || > > > inactive_is_low(target_lruvec, LRU_INACTIVE_ANON)) > > > sc->may_deactivate |= DEACTIVATE_ANON; > > > else > > > sc->may_deactivate &= ~DEACTIVATE_ANON; > > > > > > (and same for DEACTIVATE_FILE for file-backed folios) > > > > > > target_lruvec->refaults[] gets set at the end of the reclaim pass. It > > > stores the same lruvec_page_state() value that prepare_scan_control() > > > will read at the start of the next reclaim pass, which means if > > > reclaim passes happen more frequently than the 2s flushes (eg under > > > sustained/heavy memory pressure), this logic will incorrectly assume > > > no refaults occurred and deactivation is disabled, which afaict means > > > folios won't be moved from the active -> inactive list, and reclaim > > > will start evicting pages from the inactive list that are hot (eg more > > > refaults). > > > > > > This is from reading the code rather than a reproducer though, so I > > > don't know how much this matters in practice. Unlike for the writeback > > > case, I don't think flushign more frequently solves the problem. It > > > would shrink the staleness window but not eliminate it. Maybe one > > > solution is to keep the deactivation state for a period of time if > > > refaults were observed. > > > > We do have an internal test that runs a VM under memory pressure and > > we started observing OOM kills after the ratelimited flush was added > > in vmscan, so I think it's more problematic than just reclaiming hot > > memory, but I didn't look too closely. > > > > Would you be able to share the test you're using? I've been trying to > repro it locally without much luck. The exact test uses some internal testing libraries, we're looking into whether we can translate it to a standalone C repro. From a high-level, the test: - Creates a VM with 260 MB (256 MB for testing + 4 MB margin) in a cgroup, backed by shmem THPs. The VM is not a fully fledged VM, just a KVM VM running bare metal code (so 4 MB is enough margin). - Enables zswap in the cgroup. - Tells the VM to write to 256 MB of its memory. - Checks the cgroup shmem usage and that no swap occurred (no limit). - Sets the cgroup limit to half the VM memory. - Checks the cgroup shmem usage and swap again, usage should be ~half and so is swap. - Tells the VM to read the 256 MB of memory again. This should cause a lot of thrashing and reclaim, but no OOM kills as all guest memory is reclaimable. With the ratelimited flushing, the test started flaking 5-10% of the time due to OOM kills.