Whamcloud - gitweb
LU-17463 osc: add option to disable page cache shrinker
authorQian Yingjin <qian@ddn.com>
Wed, 24 Jan 2024 02:43:38 +0000 (21:43 -0500)
committerAndreas Dilger <adilger@whamcloud.com>
Sat, 27 Apr 2024 22:32:56 +0000 (22:32 +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.

Lustre-Change: https://review.whamcloud.com/53795
Lustre-Commit: d90ce0aab10ee8856140720cd71935da6877a5ab

Signed-off-by: Qian Yingjin <qian@ddn.com>
Change-Id: I23ebf6d438a71c7917b0cb3375407a64587e15db
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54754
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/osc/lproc_osc.c
lustre/osc/osc_internal.h
lustre/osc/osc_page.c
lustre/osc/osc_request.c

index 479136a..d07001a 100644 (file)
@@ -361,6 +361,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)
@@ -1024,6 +1048,7 @@ static int lprocfs_osc_attach_seqstat(struct obd_device *obd)
 static struct attribute *osc_attrs[] = {
        &lustre_attr_active.attr,
        &lustre_attr_allow_intr.attr,
+       &lustre_attr_enable_page_cache_shrink.attr,
        &lustre_attr_checksums.attr,
        &lustre_attr_checksum_dump.attr,
        &lustre_attr_cur_dirty_bytes.attr,
index b96d02e..baee093 100644 (file)
@@ -176,6 +176,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 435a30a..7ac3849 100644 (file)
@@ -1087,6 +1087,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 000b112..1738717 100644 (file)
@@ -4052,6 +4052,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 ll_shrinker_ops osc_cache_sh_ops = {