Commit ed8f3f99 authored by Yang Yang's avatar Yang Yang Committed by Andrew Morton

mm: workingset: update description of the source file

The calculation of workingset size is the core logic of handling refault,
it had been updated several times[1][2] after workingset.c was created[3].
But the description hadn't been updated accordingly, this mismatch may
confuse the readers.  So we update the description to make it consistent
to the code.

[1] commit 34e58cac ("mm: workingset: let cache workingset challenge anon")
[2] commit aae466b0 ("mm/swap: implement workingset detection for anonymous LRU")
[3] commit a528910e ("mm: thrash detection-based file cache sizing")

Link: https://lkml.kernel.org/r/202304131634494948454@zte.com.cnSigned-off-by: default avatarYang Yang <yang.yang29@zte.com.cn>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 1f6ab566
...@@ -111,9 +111,20 @@ ...@@ -111,9 +111,20 @@
* *
* NR_inactive + (R - E) <= NR_inactive + NR_active * NR_inactive + (R - E) <= NR_inactive + NR_active
* *
* which can be further simplified to * If we have swap we should consider about NR_inactive_anon and
* NR_active_anon, so for page cache and anonymous respectively:
* *
* (R - E) <= NR_active * NR_inactive_file + (R - E) <= NR_inactive_file + NR_active_file
* + NR_inactive_anon + NR_active_anon
*
* NR_inactive_anon + (R - E) <= NR_inactive_anon + NR_active_anon
* + NR_inactive_file + NR_active_file
*
* Which can be further simplified to:
*
* (R - E) <= NR_active_file + NR_inactive_anon + NR_active_anon
*
* (R - E) <= NR_active_anon + NR_inactive_file + NR_active_file
* *
* Put into words, the refault distance (out-of-cache) can be seen as * Put into words, the refault distance (out-of-cache) can be seen as
* a deficit in inactive list space (in-cache). If the inactive list * a deficit in inactive list space (in-cache). If the inactive list
...@@ -130,14 +141,14 @@ ...@@ -130,14 +141,14 @@
* are no longer in active use. * are no longer in active use.
* *
* So when a refault distance of (R - E) is observed and there are at * So when a refault distance of (R - E) is observed and there are at
* least (R - E) active pages, the refaulting page is activated * least (R - E) pages in the userspace workingset, the refaulting page
* optimistically in the hope that (R - E) active pages are actually * is activated optimistically in the hope that (R - E) pages are actually
* used less frequently than the refaulting page - or even not used at * used less frequently than the refaulting page - or even not used at
* all anymore. * all anymore.
* *
* That means if inactive cache is refaulting with a suitable refault * That means if inactive cache is refaulting with a suitable refault
* distance, we assume the cache workingset is transitioning and put * distance, we assume the cache workingset is transitioning and put
* pressure on the current active list. * pressure on the current workingset.
* *
* If this is wrong and demotion kicks in, the pages which are truly * If this is wrong and demotion kicks in, the pages which are truly
* used more frequently will be reactivated while the less frequently * used more frequently will be reactivated while the less frequently
...@@ -469,7 +480,7 @@ void workingset_refault(struct folio *folio, void *shadow) ...@@ -469,7 +480,7 @@ void workingset_refault(struct folio *folio, void *shadow)
* don't activate pages that couldn't stay resident even if * don't activate pages that couldn't stay resident even if
* all the memory was available to the workingset. Whether * all the memory was available to the workingset. Whether
* workingset competition needs to consider anon or not depends * workingset competition needs to consider anon or not depends
* on having swap. * on having free swap space.
*/ */
workingset_size = lruvec_page_state(eviction_lruvec, NR_ACTIVE_FILE); workingset_size = lruvec_page_state(eviction_lruvec, NR_ACTIVE_FILE);
if (!file) { if (!file) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment