Whamcloud - gitweb
LU-17463 osc: add option to disable page cache shrinker 95/53795/8
authorQian Yingjin <qian@ddn.com>
Wed, 24 Jan 2024 02:43:38 +0000 (21:43 -0500)
committerOleg Drokin <green@whamcloud.com>
Sat, 23 Mar 2024 05:54:20 +0000 (05:54 +0000)
The pages mapped into VM_LOCKED [mlocked()ed] VMAs are unevictable
pages. Those pages are marked with PG_mlocked.
However, page cache shrinker in Lustre treats all cached pages
equally even some of them are unevictable. It may evict mlocked
pages by mlock() or mlockall() calls wrongly.

This patch adds an tunable option to enable or disable page cache
shrinker:
- osc.*.enable_page_cache_shrink
It is enabled by default.

Signed-off-by: Qian Yingjin <qian@ddn.com>
Change-Id: I23ebf6d438a71c7917b0cb3375407a64587e15db
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53795
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Vladimir Saveliev <vladimir.saveliev@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/osc/lproc_osc.c
lustre/osc/osc_internal.h
lustre/osc/osc_page.c
lustre/osc/osc_request.c

index 21e27f6..0bce55b 100644 (file)
@@ -363,6 +363,30 @@ static ssize_t grant_shrink_interval_store(struct kobject *kobj,
 }
 LUSTRE_RW_ATTR(grant_shrink_interval);
 
+static ssize_t enable_page_cache_shrink_show(struct kobject *kobj,
+                                            struct attribute *attr,
+                                            char *buf)
+{
+       return scnprintf(buf, PAGE_SIZE, "%d\n", osc_page_cache_shrink_enabled);
+}
+
+static ssize_t enable_page_cache_shrink_store(struct kobject *kobj,
+                                             struct attribute *attr,
+                                             const char *buffer,
+                                             size_t count)
+{
+       bool val;
+       int rc;
+
+       rc = kstrtobool(buffer, &val);
+       if (rc)
+               return rc;
+
+       osc_page_cache_shrink_enabled = val;
+       return count;
+}
+LUSTRE_RW_ATTR(enable_page_cache_shrink);
+
 static ssize_t checksums_show(struct kobject *kobj,
                              struct attribute *attr,
                              char *buf)
@@ -869,6 +893,7 @@ LUSTRE_OBD_UINT_PARAM_ATTR(ldlm_enqueue_min);
 
 static struct attribute *osc_attrs[] = {
        &lustre_attr_active.attr,
+       &lustre_attr_enable_page_cache_shrink.attr,
        &lustre_attr_checksums.attr,
        &lustre_attr_checksum_dump.attr,
        &lustre_attr_cur_dirty_bytes.attr,
index 361f4f7..ee68cf4 100644 (file)
@@ -174,6 +174,9 @@ int osc_object_invalidate(const struct lu_env *env, struct osc_object *osc);
 extern struct list_head osc_shrink_list;
 /** spin lock to protect osc_shrink_list */
 extern spinlock_t osc_shrink_lock;
+/** Whether enable page cache shrinker */
+extern bool osc_page_cache_shrink_enabled;
+
 extern unsigned long osc_cache_shrink_count(struct shrinker *sk,
                                            struct shrink_control *sc);
 extern unsigned long osc_cache_shrink_scan(struct shrinker *sk,
index 0bb3bf3..9729275 100644 (file)
@@ -1067,6 +1067,9 @@ unsigned long osc_cache_shrink_count(struct shrinker *sk,
        struct client_obd *cli;
        unsigned long cached = 0;
 
+       if (!osc_page_cache_shrink_enabled)
+               return 0;
+
        spin_lock(&osc_shrink_lock);
        list_for_each_entry(cli, &osc_shrink_list, cl_shrink_list)
                cached += atomic_long_read(&cli->cl_lru_in_list);
index b48e3bd..6485093 100644 (file)
@@ -3947,6 +3947,7 @@ static const struct obd_ops osc_obd_ops = {
 
 LIST_HEAD(osc_shrink_list);
 DEFINE_SPINLOCK(osc_shrink_lock);
+bool osc_page_cache_shrink_enabled = true;
 
 #ifdef HAVE_SHRINKER_COUNT
 static struct shrinker osc_cache_shrinker = {