Skip to contentSkip to conversation

mm: zram: amend SLAB_RECLAIM_ACCOUNT on zspage_cachep

PATCH In review Huangzhaoyang 2 participants 5 messages Jun 8, 2021 – Jun 23, 2021

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

PATCH 1/1 mm: zram: amend SLAB_RECLAIM_ACCOUNT on zspage_cachep

From: Zhaoyang Huang <[email protected]>

Zspage_cachep is found be merged with other kmem cache during test, which is not good for debug things(zs_pool->zspage_cachep present to be another kmem cache in memory dumpfile). It is also neccessary to do so as shrinker has been registered for zspage. Amending this flag can help kernel to calculate SLAB_RECLAIMBLE correctly.

---
 mm/zsmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/zsmalloc.c +1 -1
index 19b563b..0b0addd 100644
@@ -328,7 +328,7 @@ static int create_cache(struct zs_pool *pool)
 		return 1;
 
 	pool->zspage_cachep = kmem_cache_create("zspage", sizeof(struct zspage),
-					0, 0, NULL);
+					0, SLAB_RECLAIM_ACCOUNT, NULL);
 	if (!pool->zspage_cachep) {
 		kmem_cache_destroy(pool->handle_cachep);
 		pool->handle_cachep = NULL;
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 5 lines · Huangzhaoyang

From: Zhaoyang Huang <[email protected]>

Zspage_cachep is found be merged with other kmem cache during test, which is not good for debug things(zs_pool->zspage_cachep present to be another kmem cache in memory dumpfile). It is also neccessary to do so as shrinker has

It's not a only problem of zsmalloc because slab want to minimize fragmentation so try to merge several objects if it's allowed. So I don't think it's particular problem of zsmalloc.
I guess slub has some option maybe "nomerge" if you want it.

Quoted 13 lines

been registered for zspage. Amending this flag can help kernel to calculate SLAB_RECLAIMBLE correctly.

---
 mm/zsmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/zsmalloc.c +0 -0
index 19b563b..0b0addd 100644

mm/zsmalloc.c static int create_cache(struct zs_pool *pool) · line 331

Quoted 5 lines
mm/zsmalloc.c +1 -1
@@ -328,7 +328,7 @@ static int create_cache(struct zs_pool *pool)
 		return 1;
 
 	pool->zspage_cachep = kmem_cache_create("zspage", sizeof(struct zspage),
-					0, 0, NULL);
+					0, SLAB_RECLAIM_ACCOUNT, NULL);

How does zspage become SLAB_RECLAIM_ACCOUNT?

I took the flag as "cacheable" object. IOW, when the shrinker ask to reclaim the object, it should reclaim(e.g., discarding) those objects for reclaming. However, that's not the case in zsmalloc.

#2 lore raw
Quoted 35 lines · Minchan Kim
Quoted 5 lines · Huangzhaoyang

From: Zhaoyang Huang <[email protected]>

Zspage_cachep is found be merged with other kmem cache during test, which is not good for debug things(zs_pool->zspage_cachep present to be another kmem cache in memory dumpfile). It is also neccessary to do so as shrinker has

It's not a only problem of zsmalloc because slab want to minimize fragmentation so try to merge several objects if it's allowed. So I don't think it's particular problem of zsmalloc.
I guess slub has some option maybe "nomerge" if you want it.

Quoted 13 lines

been registered for zspage. Amending this flag can help kernel to calculate SLAB_RECLAIMBLE correctly.

---
 mm/zsmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/zsmalloc.c +0 -0
index 19b563b..0b0addd 100644

mm/zsmalloc.c static int create_cache(struct zs_pool *pool) · line 331

Quoted 5 lines
mm/zsmalloc.c +1 -1
@@ -328,7 +328,7 @@ static int create_cache(struct zs_pool *pool)
              return 1;
 
      pool->zspage_cachep = kmem_cache_create("zspage", sizeof(struct zspage),
-                                     0, 0, NULL);
+                                     0, SLAB_RECLAIM_ACCOUNT, NULL);

How does zspage become SLAB_RECLAIM_ACCOUNT?

Quoted 4 lines

I took the flag as "cacheable" object. IOW, when the shrinker ask to reclaim the object, it should reclaim(e.g., discarding) those objects for reclaming. However, that's not the case in zsmalloc.

alloc_slab will take the allocated object into account as SLAB_RECLAIMABLE when this flag set on the kmem_cache

maintainer
#3 lore raw
Quoted 36 lines · Zhaoyang Huang
Quoted 35 lines · Minchan Kim
Quoted 5 lines · Huangzhaoyang

From: Zhaoyang Huang <[email protected]>

Zspage_cachep is found be merged with other kmem cache during test, which is not good for debug things(zs_pool->zspage_cachep present to be another kmem cache in memory dumpfile). It is also neccessary to do so as shrinker has

It's not a only problem of zsmalloc because slab want to minimize fragmentation so try to merge several objects if it's allowed. So I don't think it's particular problem of zsmalloc.
I guess slub has some option maybe "nomerge" if you want it.

Quoted 13 lines

been registered for zspage. Amending this flag can help kernel to calculate SLAB_RECLAIMBLE correctly.

---
 mm/zsmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/zsmalloc.c +0 -0
index 19b563b..0b0addd 100644

mm/zsmalloc.c static int create_cache(struct zs_pool *pool) · line 331

Quoted 5 lines
mm/zsmalloc.c +1 -1
@@ -328,7 +328,7 @@ static int create_cache(struct zs_pool *pool)
              return 1;
 
      pool->zspage_cachep = kmem_cache_create("zspage", sizeof(struct zspage),
-                                     0, 0, NULL);
+                                     0, SLAB_RECLAIM_ACCOUNT, NULL);

How does zspage become SLAB_RECLAIM_ACCOUNT?

Quoted 6 lines
Quoted 4 lines

I took the flag as "cacheable" object. IOW, when the shrinker ask to reclaim the object, it should reclaim(e.g., discarding) those objects for reclaming. However, that's not the case in zsmalloc.

alloc_slab will take the allocated object into account as SLAB_RECLAIMABLE when this flag set on the kmem_cache

My point is zspage_cachep is not an reclimable slab cache. Please describe why you believe it's reclaimable slab.

#4 lore raw
Quoted 42 lines · Minchan Kim
Quoted 40 lines · Zhaoyang Huang
Quoted 39 lines · Minchan Kim
Quoted 5 lines · Huangzhaoyang

From: Zhaoyang Huang <[email protected]>

Zspage_cachep is found be merged with other kmem cache during test, which is not good for debug things(zs_pool->zspage_cachep present to be another kmem cache in memory dumpfile). It is also neccessary to do so as shrinker has

It's not a only problem of zsmalloc because slab want to minimize fragmentation so try to merge several objects if it's allowed. So I don't think it's particular problem of zsmalloc.
I guess slub has some option maybe "nomerge" if you want it.

Quoted 13 lines

been registered for zspage. Amending this flag can help kernel to calculate SLAB_RECLAIMBLE correctly.

---
 mm/zsmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/zsmalloc.c +0 -0
index 19b563b..0b0addd 100644

mm/zsmalloc.c static int create_cache(struct zs_pool *pool) · line 331

Quoted 5 lines
mm/zsmalloc.c +1 -1
@@ -328,7 +328,7 @@ static int create_cache(struct zs_pool *pool)
              return 1;
 
      pool->zspage_cachep = kmem_cache_create("zspage", sizeof(struct zspage),
-                                     0, 0, NULL);
+                                     0, SLAB_RECLAIM_ACCOUNT, NULL);

How does zspage become SLAB_RECLAIM_ACCOUNT?

I took the flag as "cacheable" object. IOW, when the shrinker ask to reclaim the object, it should reclaim(e.g., discarding) those objects for reclaming. However, that's not the case in zsmalloc.

Quoted 5 lines
Quoted 2 lines

alloc_slab will take the allocated object into account as SLAB_RECLAIMABLE when this flag set on the kmem_cache

My point is zspage_cachep is not an reclimable slab cache. Please describe why you believe it's reclaimable slab.

zspage registered slab shrinker via zs_register_shrinker, in which the zspage be freed to cache