Skip to contentSkip to conversation

memcg: accounting for mnt_cache entries

PATCH In review Vasily Averin 1 participant 1 message Mar 9, 2021

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

PATCH 7/9 memcg: accounting for mnt_cache entries

Objects can be created from memcg-limited tasks
but its misuse may lead to host OOM.

---
 fs/namespace.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/namespace.c +3 -2
index 56bb5a5..d550c2a 100644
@@ -203,7 +203,8 @@ static struct mount *alloc_vfsmnt(const char *name)
 			goto out_free_cache;
 
 		if (name) {
-			mnt->mnt_devname = kstrdup_const(name, GFP_KERNEL);
+			mnt->mnt_devname = kstrdup_const(name,
+							 GFP_KERNEL_ACCOUNT);
 			if (!mnt->mnt_devname)
 				goto out_free_id;
 		}
@@ -4213,7 +4214,7 @@ void __init mnt_init(void)
 	int err;
 
 	mnt_cache = kmem_cache_create("mnt_cache", sizeof(struct mount),
-			0, SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL);
+			0, SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_ACCOUNT, NULL);
 
 	mount_hashtable = alloc_large_system_hash("Mount-cache",
 				sizeof(struct hlist_head),
Signature · 1 line
1.8.3.1