lkml.org 
[lkml]   [2015]   [Jan]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] mm/zsmalloc: avoid unnecessary iteration when freeing size_class
From
ping.

2015-01-24 21:50 GMT+08:00 Ganesh Mahendran <opensource.ganesh@gmail.com>:
> The pool->size_class[i] is assigned with the i from (zs_size_classes - 1) to 0.
> So if we failed in zs_create_pool(), we only need to iterate from (zs_size_classes - 1)
> to i, instead of from 0 to (zs_size_classes - 1)

No functionality has been changed. This patch just avoids some
necessary iteration.

Thanks.

>
> Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
> Cc: Nitin Gupta <ngupta@vflare.org>
> Cc: Minchan Kim <minchan@kernel.org>
> ---
> mm/zsmalloc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> index 16617e9..e6fa3da 100644
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@ -1433,12 +1433,12 @@ void zs_destroy_pool(struct zs_pool *pool)
>
> zs_pool_stat_destroy(pool);
>
> - for (i = 0; i < zs_size_classes; i++) {
> + for (i = zs_size_classes - 1; i >= 0; i--) {
> int fg;
> struct size_class *class = pool->size_class[i];
>
> if (!class)
> - continue;
> + break;
>
> if (class->index != i)
> continue;
> --
> 1.7.9.5
>


\
 
 \ /
  Last update: 2015-01-31 10:21    [W:1.322 / U:0.672 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site