On Thu, Feb 17, 2022 at 02:26:15PM +0000, Aaron Tomlin wrote: > On Thu 2022-02-17 13:47 +0100, Frederic Weisbecker wrote: > > So, to make sure I understand, the issue is that with nohz_full, we may > > well enter into the idle loop with the tick already stopped. We may also > > exit from idle without restarting the tick (again only with nohz_full). And > > so this can cause the vmstat to not be flushed upon idle entry. Right? > > Hi Frederic, > > Yes - this is exactly it. > > > > A customer provided some evidence which indicates that the idle tick was > > > stopped; albeit, CPU-specific vmstat counters still remained populated. > > > Thus one can only assume quiet_vmstat() was not invoked on return to the > > > idle loop. > > > > > > Unfortunately, I suspect this divergence might erroneously prevent a > > > reclaim attempt by kswapd. If the number of zone specific free pages are > > > below their per-cpu drift value then zone_page_state_snapshot() is used to > > > compute a more accurate view of the aforementioned statistic. > > > Thus any task blocked on the NUMA node specific pfmemalloc_wait queue will > > > be unable to make significant progress via direct reclaim unless it is > > > killed after being woken up by kswapd (see throttle_direct_reclaim()). > > > That being said, eventually reclaim should give up if the conditions are > > > correct, no? > > > Now if quiet_vmstat() isn't called, the vmstat_work should fix this later, > > right? Or does that happen too late perhaps? > > If I understand correctly, in the context of nohz_full, since such work is > deferred, it will only be handled in a scenario when the periodic/or > scheduling-clock tick is enabled i.e. the timer was reprogrammed on exit > from idle. Oh I see, it's a deferrable delayed work... Then I can see two other issues: 1) Can an interrupt in idle modify the vmstat and thus trigger the need to flush it? I believe it's the case and then the problem goes beyond nohz_full because if the idle interrupt fired while the tick is stopped and didn't set TIF_RESCHED, we go back to sleep without calling quiet_vmstat(). 2) What if we are running task A in kernel mode while the tick is stopped (nohz_full). Task A modifies the vmstat and goes to userspace for a long while. Your patch fixes case 1) but not case 2). The problem is that TIMER_DEFERRABLE should really be about dynticks-idle only and not dynticks-full. I've always been afraid about enforcing that rule though because that would break old noise-free setups. But perhaps I should...