linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: zram: amend SLAB_RECLAIM_ACCOUNT on zspage_cachep
@ 2021-06-08  7:28 Huangzhaoyang
  2021-06-18 22:02 ` Minchan Kim
  0 siblings, 1 reply; 5+ messages in thread
From: Huangzhaoyang @ 2021-06-08  7:28 UTC (permalink / raw)
  To: Andrew Morton, Minchan Kim, Zhaoyang Huang, linux-mm,
	linux-kernel, Nitin Gupta, Sergey Senozhatsky

From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>

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.

Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
---
 mm/zsmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 19b563b..0b0addd 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -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;
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm: zram: amend SLAB_RECLAIM_ACCOUNT on zspage_cachep
  2021-06-08  7:28 [PATCH] mm: zram: amend SLAB_RECLAIM_ACCOUNT on zspage_cachep Huangzhaoyang
@ 2021-06-18 22:02 ` Minchan Kim
  2021-06-21  2:35   ` Zhaoyang Huang
  0 siblings, 1 reply; 5+ messages in thread
From: Minchan Kim @ 2021-06-18 22:02 UTC (permalink / raw)
  To: Huangzhaoyang
  Cc: Andrew Morton, Zhaoyang Huang, linux-mm, linux-kernel,
	Nitin Gupta, Sergey Senozhatsky

On Tue, Jun 08, 2021 at 03:28:17PM +0800, Huangzhaoyang wrote:
> From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> 
> 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.

> been registered for zspage. Amending this flag can help kernel to calculate
> SLAB_RECLAIMBLE correctly.
> 
> Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> ---
>  mm/zsmalloc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> index 19b563b..0b0addd 100644
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@ -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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm: zram: amend SLAB_RECLAIM_ACCOUNT on zspage_cachep
  2021-06-18 22:02 ` Minchan Kim
@ 2021-06-21  2:35   ` Zhaoyang Huang
  2021-06-22 23:38     ` Minchan Kim
  0 siblings, 1 reply; 5+ messages in thread
From: Zhaoyang Huang @ 2021-06-21  2:35 UTC (permalink / raw)
  To: Minchan Kim
  Cc: Andrew Morton, Zhaoyang Huang, open list:MEMORY MANAGEMENT, LKML,
	Nitin Gupta, Sergey Senozhatsky

On Sat, Jun 19, 2021 at 6:02 AM Minchan Kim <minchan@kernel.org> wrote:
>
> On Tue, Jun 08, 2021 at 03:28:17PM +0800, Huangzhaoyang wrote:
> > From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> >
> > 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.

>
> > been registered for zspage. Amending this flag can help kernel to calculate
> > SLAB_RECLAIMBLE correctly.
> >
> > Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> > ---
> >  mm/zsmalloc.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> > index 19b563b..0b0addd 100644
> > --- a/mm/zsmalloc.c
> > +++ b/mm/zsmalloc.c
> > @@ -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.
alloc_slab will take the allocated object into account as
SLAB_RECLAIMABLE when this flag set on the kmem_cache


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm: zram: amend SLAB_RECLAIM_ACCOUNT on zspage_cachep
  2021-06-21  2:35   ` Zhaoyang Huang
@ 2021-06-22 23:38     ` Minchan Kim
  2021-06-23  5:46       ` Zhaoyang Huang
  0 siblings, 1 reply; 5+ messages in thread
From: Minchan Kim @ 2021-06-22 23:38 UTC (permalink / raw)
  To: Zhaoyang Huang
  Cc: Andrew Morton, Zhaoyang Huang, open list:MEMORY MANAGEMENT, LKML,
	Nitin Gupta, Sergey Senozhatsky

On Mon, Jun 21, 2021 at 10:35:26AM +0800, Zhaoyang Huang wrote:
> On Sat, Jun 19, 2021 at 6:02 AM Minchan Kim <minchan@kernel.org> wrote:
> >
> > On Tue, Jun 08, 2021 at 03:28:17PM +0800, Huangzhaoyang wrote:
> > > From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> > >
> > > 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.
> 
> >
> > > been registered for zspage. Amending this flag can help kernel to calculate
> > > SLAB_RECLAIMBLE correctly.
> > >
> > > Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> > > ---
> > >  mm/zsmalloc.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> > > index 19b563b..0b0addd 100644
> > > --- a/mm/zsmalloc.c
> > > +++ b/mm/zsmalloc.c
> > > @@ -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.
> 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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm: zram: amend SLAB_RECLAIM_ACCOUNT on zspage_cachep
  2021-06-22 23:38     ` Minchan Kim
@ 2021-06-23  5:46       ` Zhaoyang Huang
  0 siblings, 0 replies; 5+ messages in thread
From: Zhaoyang Huang @ 2021-06-23  5:46 UTC (permalink / raw)
  To: Minchan Kim
  Cc: Andrew Morton, Zhaoyang Huang, open list:MEMORY MANAGEMENT, LKML,
	Nitin Gupta, Sergey Senozhatsky

On Wed, Jun 23, 2021 at 7:38 AM Minchan Kim <minchan@kernel.org> wrote:
>
> On Mon, Jun 21, 2021 at 10:35:26AM +0800, Zhaoyang Huang wrote:
> > On Sat, Jun 19, 2021 at 6:02 AM Minchan Kim <minchan@kernel.org> wrote:
> > >
> > > On Tue, Jun 08, 2021 at 03:28:17PM +0800, Huangzhaoyang wrote:
> > > > From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> > > >
> > > > 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.
> >
> > >
> > > > been registered for zspage. Amending this flag can help kernel to calculate
> > > > SLAB_RECLAIMBLE correctly.
> > > >
> > > > Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> > > > ---
> > > >  mm/zsmalloc.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> > > > index 19b563b..0b0addd 100644
> > > > --- a/mm/zsmalloc.c
> > > > +++ b/mm/zsmalloc.c
> > > > @@ -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.
> > 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-06-23  5:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08  7:28 [PATCH] mm: zram: amend SLAB_RECLAIM_ACCOUNT on zspage_cachep Huangzhaoyang
2021-06-18 22:02 ` Minchan Kim
2021-06-21  2:35   ` Zhaoyang Huang
2021-06-22 23:38     ` Minchan Kim
2021-06-23  5:46       ` Zhaoyang Huang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).