Skip to contentSkip to conversation

mm/vmscan.c: drop all inode/dentry cache from LRU

PATCH In review Sahitya Tummala 3 participants 3 messages May 24, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/vmscan.c: drop all inode/dentry cache from LRU

This is important for the scenario where FBE (file based encryption) is enabled. With FBE, the encryption context needed to en/decrypt a file will be stored in inode and any inode that is left in the cache after drop_caches is done will be a problem. For ex, in Android, drop_caches will be used when switching work profiles.

---
 mm/vmscan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/vmscan.c +1 -1
index d96c547..b48926f 100644
@@ -730,7 +730,7 @@ void drop_slab_node(int nid)
 		do {
 			freed += shrink_slab(GFP_KERNEL, nid, memcg, 0);
 		} while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL);
-	} while (freed > 10);
+	} while (freed != 0);
 }
 
 void drop_slab(void)
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
#1 lore raw
Quoted 17 lines · Sahitya Tummala

This is important for the scenario where FBE (file based encryption) is enabled. With FBE, the encryption context needed to en/decrypt a file will be stored in inode and any inode that is left in the cache after drop_caches is done will be a problem. For ex, in Android, drop_caches will be used when switching work profiles.

---
 mm/vmscan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/vmscan.c +0 -0
index d96c547..b48926f 100644

mm/vmscan.c void drop_slab_node(int nid) · line 734

Quoted 6 lines
mm/vmscan.c +1 -1
@@ -730,7 +730,7 @@ void drop_slab_node(int nid)
                do {
                        freed += shrink_slab(GFP_KERNEL, nid, memcg, 0);
                } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL);
-       } while (freed > 10);
+       } while (freed != 0);
 }

Perhaps that is not enough, because the shrink may stop when scan count is less than SHRINK_BATCH.
Pls. see do_shrink_slab.

What about set shrinker->batch to 1 in this case ?

Thanks
Yafang

maintainer
#2 lore raw
In reply to Sahitya Tummala
Quoted 7 lines · Sahitya Tummala

This is important for the scenario where FBE (file based encryption) is enabled. With FBE, the encryption context needed to en/decrypt a file will be stored in inode and any inode that is left in the cache after drop_caches is done will be a problem. For ex, in Android, drop_caches will be used when switching work profiles.

Instead of making a change to vmscan.c, it's probably better to migrate to the new fscrypt key-management framework, which solves this problem with an explicit FS_IOC_REMOVE_ENCRYPTION_KEY ioctl. This allows the system to remove all inodes that were made available via a single key without having nuking all other inodes --- this would make it much faster after a user logs out of ChromeOS, for example:

See:

	https://patchwork.kernel.org/patch/10952019/

							- Ted