From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Minchan Kim <minchan@kernel.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Yosry Ahmed <yosryahmed@google.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCHv2 4/6] zsmalloc: rework compaction algorithm
Date: Wed, 1 Mar 2023 12:47:03 +0900	[thread overview]
Message-ID: <Y/7KtwtAyAfuyJ0d@google.com> (raw)
In-Reply-To: <Y/6K5+pC+nXvDsjq@google.com>
On (23/02/28 15:14), Minchan Kim wrote:
> So, how about this on top of your patch?
> 
Looks good. Let me pick it up.
> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> index eacf9e32da5c..4dfc910f5d89 100644
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@ -2223,40 +2223,33 @@ static unsigned long __zs_compact(struct zs_pool *pool,
>  	 * as well as zpage allocation/free
>  	 */
>  	spin_lock(&pool->lock);
> -	while (1) {
> +	while (zs_can_compact(class)) {
> +		int ret;
> +
>  		if (!dst_zspage) {
>  			dst_zspage = isolate_dst_zspage(class);
>  			if (!dst_zspage)
> -				goto out;
> +				break;
>  			migrate_write_lock(dst_zspage);
>  			cc.d_page = get_first_page(dst_zspage);
>  		}
>  
> -		if (!zs_can_compact(class)) {
> -			putback_zspage(class, dst_zspage);
> -			migrate_write_unlock(dst_zspage);
> -			goto out;
> -		}
> -
>  		src_zspage = isolate_src_zspage(class);
> -		if (!src_zspage) {
> -			putback_zspage(class, dst_zspage);
> -			migrate_write_unlock(dst_zspage);
> -			goto out;
> -		}
> +		if (!src_zspage)
> +			break;
>  
>  		migrate_write_lock_nested(src_zspage);
> -
>  		cc.obj_idx = 0;
>  		cc.s_page = get_first_page(src_zspage);
> +
>  		migrate_zspage(pool, class, &cc);
> +		ret = putback_zspage(class, src_zspage);
> +		migrate_write_unlock(src_zspage);
>  
> -		if (putback_zspage(class, src_zspage) == ZS_INUSE_RATIO_0) {
> -			migrate_write_unlock(src_zspage);
> +		if (ret == ZS_INUSE_RATIO_0) {
>  			free_zspage(pool, class, src_zspage);
>  			pages_freed += class->pages_per_zspage;
> -		} else {
> -			migrate_write_unlock(src_zspage);
> +			src_zspage = NULL;
>  		}
>  
>  		if (get_fullness_group(class, dst_zspage) == ZS_INUSE_RATIO_100
> @@ -2264,14 +2257,22 @@ static unsigned long __zs_compact(struct zs_pool *pool,
>  			putback_zspage(class, dst_zspage);
>  			migrate_write_unlock(dst_zspage);
>  			dst_zspage = NULL;
> -		}
>  
> -		if (!dst_zspage) {
>  			spin_unlock(&pool->lock);
>  			cond_resched();
>  			spin_lock(&pool->lock);
>  		}
>  	}
> +
> +	if (src_zspage) {
> +		putback_zspage(class, src_zspage);
> +		migrate_write_unlock(src_zspage);
> +	}
> +
> +	if (dst_zspage) {
> +		putback_zspage(class, dst_zspage);
> +		migrate_write_unlock(dst_zspage);
> +	}
>  out:
>  	spin_unlock(&pool->lock);
>  
next prev parent reply	other threads:[~2023-03-01  3:47 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-23  3:04 [PATCHv2 0/6] zsmalloc: fine-grained fullness and new compaction algorithm Sergey Senozhatsky
2023-02-23  3:04 ` [PATCHv2 1/6] zsmalloc: remove insert_zspage() ->inuse optimization Sergey Senozhatsky
2023-02-23 23:09   ` Minchan Kim
2023-02-26  4:40     ` Sergey Senozhatsky
2023-02-23  3:04 ` [PATCHv2 2/6] zsmalloc: remove stat and fullness enums Sergey Senozhatsky
2023-02-23 23:11   ` Minchan Kim
2023-02-23 23:32     ` Yosry Ahmed
2023-02-26  4:39     ` Sergey Senozhatsky
2023-02-23  3:04 ` [PATCHv2 3/6] zsmalloc: fine-grained inuse ratio based fullness grouping Sergey Senozhatsky
2023-02-23 23:27   ` Minchan Kim
2023-02-26  4:38     ` Sergey Senozhatsky
2023-02-28 22:53       ` Minchan Kim
2023-03-01  4:05         ` Sergey Senozhatsky
2023-03-02  0:13           ` Minchan Kim
2023-03-01  8:55         ` Sergey Senozhatsky
2023-03-02  0:28           ` Minchan Kim
2023-03-02  0:53             ` Sergey Senozhatsky
2023-03-03  0:20               ` Minchan Kim
2023-03-03  1:06                 ` Sergey Senozhatsky
2023-03-03  1:38                   ` Minchan Kim
2023-03-03  1:43                     ` Sergey Senozhatsky
2023-02-23  3:04 ` [PATCHv2 4/6] zsmalloc: rework compaction algorithm Sergey Senozhatsky
2023-02-23 23:46   ` Minchan Kim
2023-02-26  4:09     ` Sergey Senozhatsky
2023-02-28 23:14   ` Minchan Kim
2023-03-01  3:47     ` Sergey Senozhatsky [this message]
2023-02-23  3:04 ` [PATCHv2 5/6] zsmalloc: extend compaction statistics Sergey Senozhatsky
2023-02-23 23:51   ` Minchan Kim
2023-02-26  3:55     ` Sergey Senozhatsky
2023-02-28 22:20       ` Minchan Kim
2023-03-01  3:54         ` Sergey Senozhatsky
2023-03-01 23:48           ` Minchan Kim
2023-03-03  1:57             ` Sergey Senozhatsky
2023-02-23  3:04 ` [PATCHv2 6/6] zram: show zsmalloc objs_moved stat in mm_stat Sergey Senozhatsky
2023-02-23 23:53 ` [PATCHv2 0/6] zsmalloc: fine-grained fullness and new compaction algorithm Minchan Kim
2023-02-26  3:50   ` Sergey Senozhatsky
2023-02-28 22:17     ` Minchan Kim
2023-03-01  3:57       ` Sergey Senozhatsky
2023-03-01 23:48         ` Minchan Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox
  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):
  git send-email \
    --in-reply-to=Y/7KtwtAyAfuyJ0d@google.com \
    --to=senozhatsky@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=yosryahmed@google.com \
    /path/to/YOUR_REPLY
  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
  Be sure your reply has a Subject: header at the top and a blank line
  before the message body.
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).