[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y/7KtwtAyAfuyJ0d@google.com>
Date: Wed, 1 Mar 2023 12:47:03 +0900
From: Sergey Senozhatsky <senozhatsky@...omium.org>
To: Minchan Kim <minchan@...nel.org>
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Yosry Ahmed <yosryahmed@...gle.com>,
linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCHv2 4/6] zsmalloc: rework compaction algorithm
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);
>
Powered by blists - more mailing lists