Re: [PATCH v4] mm: don't be stuck to rmap lock on reclaim path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 10, 2022 at 02:54:23PM -0700, Minchan Kim wrote:
> The rmap locks(i_mmap_rwsem and anon_vma->root->rwsem) could be
> contended under memory pressure if processes keep working on
> their vmas(e.g., fork, mmap, munmap). It makes reclaim path
> stuck. In our real workload traces, we see kswapd is waiting the
> lock for 300ms+(worst case, a sec) and it makes other processes
> entering direct reclaim, which were also stuck on the lock.
> 
> This patch makes lru aging path try_lock mode like shink_page_list
> so the reclaim context will keep working with next lru pages
> without being stuck. if it found the rmap lock contended, it rotates
> the page back to head of lru in both active/inactive lrus to make
> them consistent behavior, which is basic starting point rather than
> adding more heristic.
> 
> Since this patch introduces a new "contended" field as out-param
> along with try_lock in-param in rmap_walk_control, it's not
> immutable any longer if the try_lock is set so remove const
> keywords on rmap related functions. Since rmap walking is already
> expensive operation, I doubt the const would help sizable benefit(
> And we didn't have it until 5.17).
> 
> In a heavy app workload in Android, trace shows following statistics.
> It almost removes rmap lock contention from reclaim path.
> 
> From Martin Liu
> 
> Before:
> 
>    max_dur(ms)  min_dur(ms)  max-min(dur)ms  avg_dur(ms)  sum_dur(ms)  count blocked_function
>          1632            0            1631   151.542173        31672    209  page_lock_anon_vma_read
>           601            0             601   145.544681        28817    198  rmap_walk_file
> 
> After:
> 
>    max_dur(ms)  min_dur(ms)  max-min(dur)ms  avg_dur(ms)  sum_dur(ms)  count blocked_function
>           NaN          NaN              NaN          NaN          NaN    0.0             NaN
>             0            0                0     0.127645            1     12  rmap_walk_file
> 
> Signed-off-by: Minchan Kim <minchan@xxxxxxxxxx>

Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx>




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux