Whamcloud - gitweb
LU-17463 osc: add support for unevictable mlock()ed pages 26/53826/16
authorQian Yingjin <qian@ddn.com>
Fri, 26 Jan 2024 07:49:34 +0000 (02:49 -0500)
committerOleg Drokin <green@whamcloud.com>
Fri, 23 Aug 2024 21:57:16 +0000 (21:57 +0000)
commit2a3ec2fea384355901e7888d1e043e82416518cb
treebd275d64534325e64b644a2177f7ebc0e076bcec
parentb2958c09634d6ef0ed13364f6b2675a843c09817
LU-17463 osc: add support for unevictable mlock()ed pages

The page cache shrinker does not distinguish mlock()ed pages from
normal unused pages in page LRU list and would remove it from
cache wrongly.

In this patch, we use a separate unevictable list to manage the
pages marked with PG_mlocked flag.
As there is no direct notification or interface for page mlock()/
munlock() to the filesystem, we need to scan the whole unevitable
list heavily to check whether there are any freeable pages in the
list to remove them later.

Thus we implement two interfaces to scan and shrink unevictable
pages that no longer marked with PG_mlocked and remove them
from cache manually.
- $LCTL set_param llite.*.unevict_cached_mb=clear
  Scan and clear all pages in unevictable lists that no
  longer marked with PG_mlocked on a Lustre client FS.
  Scan the normal LRU list to move the pages marked with
  PG_mlocked into the unevictable list.
- $LCTL set_param osc.*.osc_unevict_cached_mb=clear
  Scan and clear all pages that no longer marked with PG_mlocked
  in the unevictable list corresponding to this OSC obd device.
  Scan the normal LRU list to move the pages marked with
  PG_mlocked into the unevictable list.

The command "echo 3 > /proc/sys/vm/drop_caches" can also be
used to evict the pages unlocked by munlock() system call which
are no longer marked with PG_mlocked.

In our design, the mlocked pages are not accounted into the LRU.
Thus, the total cached pages in a Lustre client FS may exceed
the maximum LRU limit @max_cached_mb on a Lustre client FS.

Add a tunable parameter to control whether the mlocked pages
functionality is enabled:
llite.*.enable_mlock_pages
This will allow disabling this feature if something goes wrong in
the feild.
It is disabled by default.

Add test case sanity/test_600{a,b,c,d}.

Signed-off-by: Qian Yingjin <qian@ddn.com>
Change-Id: I0713ad254999dfc32ed5063ec0d8e042968793a9
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53826
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Patrick Farrell <patrick.farrell@oracle.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
15 files changed:
lustre.spec.in
lustre/include/cl_object.h
lustre/include/lustre_osc.h
lustre/include/obd.h
lustre/ldlm/ldlm_lib.c
lustre/llite/llite_mmap.c
lustre/llite/lproc_llite.c
lustre/llite/rw.c
lustre/llite/vvp_page.c
lustre/obdclass/cl_page.c
lustre/osc/lproc_osc.c
lustre/osc/osc_internal.h
lustre/osc/osc_page.c
lustre/osc/osc_request.c
lustre/tests/sanity.sh