Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1436144

Re: [PATCH 5/8] mm/zsmalloc: avoid calculate max objects of zspage twice

From Ganesh Mahendran <opensource.ganesh@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH 5/8] mm/zsmalloc: avoid calculate max objects of zspage twice
Date 2016-07-04 05:30 +0200
Message-ID <rR2K5-q2-1@gated-at.bofh.it> (permalink)
References <rQ0qZ-3gE-3@gated-at.bofh.it> <rQ0r0-3gE-37@gated-at.bofh.it> <rQZCx-6Z7-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Jul 04, 2016 at 09:03:18AM +0900, Minchan Kim wrote:
> On Fri, Jul 01, 2016 at 02:41:03PM +0800, Ganesh Mahendran wrote:
> > Currently, if a class can not be merged, the max objects of zspage
> > in that class may be calculated twice.
> > 
> > This patch calculate max objects of zspage at the begin, and pass
> > the value to can_merge() to decide whether the class can be merged.
> > 
> > Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
> > ---
> >  mm/zsmalloc.c | 21 ++++++++++-----------
> >  1 file changed, 10 insertions(+), 11 deletions(-)
> > 
> > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> > index 50283b1..2690914 100644
> > --- a/mm/zsmalloc.c
> > +++ b/mm/zsmalloc.c
> > @@ -1362,16 +1362,14 @@ static void init_zs_size_classes(void)
> >  	zs_size_classes = nr;
> >  }
> >  
> > -static bool can_merge(struct size_class *prev, int size, int pages_per_zspage)
> > +static bool can_merge(struct size_class *prev, int pages_per_zspage,
> > +					int objs_per_zspage)
> >  {
> > -	if (prev->pages_per_zspage != pages_per_zspage)
> > -		return false;
> > -
> > -	if (prev->objs_per_zspage
> > -		!= get_maxobj_per_zspage(size, pages_per_zspage))
> > -		return false;
> > +	if (prev->pages_per_zspage == pages_per_zspage &&
> > +		prev->objs_per_zspage == objs_per_zspage)
> > +		return true;
> >  
> > -	return true;
> > +	return false;
> >  }
> >  
> >  static bool zspage_full(struct size_class *class, struct zspage *zspage)
> > @@ -2460,6 +2458,7 @@ struct zs_pool *zs_create_pool(const char *name)
> >  	for (i = zs_size_classes - 1; i >= 0; i--) {
> >  		int size;
> >  		int pages_per_zspage;
> > +		int objs_per_zspage;
> >  		struct size_class *class;
> >  		int fullness = 0;
> >  
> > @@ -2467,6 +2466,7 @@ struct zs_pool *zs_create_pool(const char *name)
> >  		if (size > ZS_MAX_ALLOC_SIZE)
> >  			size = ZS_MAX_ALLOC_SIZE;
> >  		pages_per_zspage = get_pages_per_zspage(size);
> > +		objs_per_zspage = get_maxobj_per_zspage(size, pages_per_zspage);
> 
> So, user of get_maxobj_per_zspage is only here? If so, let's remove
> get_maxobj_per_zspage to prevent misuse in future. Instead, use open code
> here.

Yes, get_maxobj_per_zspage is only called here. 
I will remove it in V2.

Thanks.

> 
> 
> >  
> >  		/*
> >  		 * size_class is used for normal zsmalloc operation such
> > @@ -2478,7 +2478,7 @@ struct zs_pool *zs_create_pool(const char *name)
> >  		 * previous size_class if possible.
> >  		 */
> >  		if (prev_class) {
> > -			if (can_merge(prev_class, size, pages_per_zspage)) {
> > +			if (can_merge(prev_class, pages_per_zspage, objs_per_zspage)) {
> >  				pool->size_class[i] = prev_class;
> >  				continue;
> >  			}
> > @@ -2491,8 +2491,7 @@ struct zs_pool *zs_create_pool(const char *name)
> >  		class->size = size;
> >  		class->index = i;
> >  		class->pages_per_zspage = pages_per_zspage;
> > -		class->objs_per_zspage = get_maxobj_per_zspage(class->size,
> > -							class->pages_per_zspage);
> > +		class->objs_per_zspage = objs_per_zspage;
> >  		spin_lock_init(&class->lock);
> >  		pool->size_class[i] = class;
> >  		for (fullness = ZS_EMPTY; fullness < NR_ZS_FULLNESS;
> > -- 
> > 1.9.1
> > 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/8] mm/zsmalloc: modify zs compact trace interface Ganesh Mahendran <opensource.ganesh@gmail.com> - 2016-07-01 08:50 +0200
  [PATCH 4/8] mm/zsmalloc: use class->objs_per_zspage to get num of max objects Ganesh Mahendran <opensource.ganesh@gmail.com> - 2016-07-01 08:50 +0200
    Re: [PATCH 4/8] mm/zsmalloc: use class->objs_per_zspage to get num  of max objects Minchan Kim <minchan@kernel.org> - 2016-07-04 02:00 +0200
  [PATCH 5/8] mm/zsmalloc: avoid calculate max objects of zspage twice Ganesh Mahendran <opensource.ganesh@gmail.com> - 2016-07-01 08:50 +0200
    Re: [PATCH 5/8] mm/zsmalloc: avoid calculate max objects of zspage  twice Minchan Kim <minchan@kernel.org> - 2016-07-04 02:10 +0200
      Re: [PATCH 5/8] mm/zsmalloc: avoid calculate max objects of zspage  twice Ganesh Mahendran <opensource.ganesh@gmail.com> - 2016-07-04 05:30 +0200
  [PATCH 2/8] mm/zsmalloc: add per class compact trace event Ganesh Mahendran <opensource.ganesh@gmail.com> - 2016-07-01 08:50 +0200
    Re: [PATCH 2/8] mm/zsmalloc: add per class compact trace event Minchan Kim <minchan@kernel.org> - 2016-07-04 01:50 +0200
      Re: [PATCH 2/8] mm/zsmalloc: add per class compact trace event Ganesh Mahendran <opensource.ganesh@gmail.com> - 2016-07-04 05:20 +0200

csiph-web