mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Nhat Pham <nphamcs@gmail.com>,
	Xueyuan Chen <xueyuan.chen@vivo.com>,
	 Barry Song <baohua@kernel.org>,
	Yosry Ahmed <yosry.ahmed@linux.dev>,
	 Chris Wiseman <chriswiseman@google.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	 Brian Geffon <bgeffon@google.com>,
	Minchan Kim <minchan@kernel.org>,
	 Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	 xueyuan.chen21@gmail.com
Subject: Re: [RFC PATCH 0/2] mm: zsmalloc: make shrinker compaction budget-aware
Date: Mon, 2 Nov 2026 08:47:17 +0900	[thread overview]
Message-ID: <aufPMirl4cD7tz0X@google.com> (raw)
In-Reply-To: <auKqt6b4AxCLziIH@google.com>

Adding Chris for visibility

On (26/10/29 11:26), Sergey Senozhatsky wrote:
> On (26/08/07 09:25), Nhat Pham wrote:
> > Hmm we'd need to collect more data in our workloads to determine, but
> > if we can compute compactable ratio (freeable_pages / total_pages) on
> > a per size class basis, can we just skip the size class whose ratio is
> > too bad? Would that at least cut down on the vast majority of
> > fruitless memcpys and lock acquisitions etc?

[..]

> ---
> 
> diff --git a/mm/Kconfig b/mm/Kconfig
> index afff1b25b543..72542946bc53 100644
> --- a/mm/Kconfig
> +++ b/mm/Kconfig
> @@ -157,6 +157,17 @@ config ZSMALLOC_CHAIN_SIZE
>  
>  	  For more information, see zsmalloc documentation.
>  
> +config ZSMALLOC_SHRINKER
> +	bool "Enable zsmalloc pool shrinker"
> +	default y
> +	help
> +	  This option enables the zsmalloc pool shrinker, which allows
> +	  the zsmalloc pool to be shrunk when the system is under memory
> +	  pressure. The shrinker will attempt to free up memory by
> +	  compacting zspages and releasing empty zspages back to the system.
> +
> +	  If unsure, say N.
> +
>  endmenu
>  
>  menu "Slab allocator options"
> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> index 7ef80e0da626..e0d7ab9142bb 100644
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@ -276,8 +276,10 @@ struct zs_pool {
>  
>  	struct zs_pool_stats stats;
>  
> +#ifdef CONFIG_ZSMALLOC_SHRINKER
>  	/* Compact classes */
>  	struct shrinker *shrinker;
> +#endif
>  
>  #ifdef CONFIG_ZSMALLOC_STAT
>  	struct dentry *stat_dentry;
> @@ -2050,8 +2052,9 @@ void zs_pool_stats(struct zs_pool *pool, struct zs_pool_stats *stats)
>  }
>  EXPORT_SYMBOL_GPL(zs_pool_stats);
>  
> +#ifdef CONFIG_ZSMALLOC_SHRINKER
>  static unsigned long zs_shrinker_scan(struct shrinker *shrinker,
> -		struct shrink_control *sc)
> +				      struct shrink_control *sc)
>  {
>  	unsigned long pages_freed;
>  	struct zs_pool *pool = shrinker->private_data;
> @@ -2067,7 +2070,7 @@ static unsigned long zs_shrinker_scan(struct shrinker *shrinker,
>  }
>  
>  static unsigned long zs_shrinker_count(struct shrinker *shrinker,
> -		struct shrink_control *sc)
> +				       struct shrink_control *sc)
>  {
>  	int i;
>  	struct size_class *class;
> @@ -2105,6 +2108,10 @@ static int zs_register_shrinker(struct zs_pool *pool)
>  
>  	return 0;
>  }
> +#else
> +static void zs_unregister_shrinker(struct zs_pool *pool) { }
> +static int zs_register_shrinker(struct zs_pool *pool) { return 0; }
> +#endif
>  
>  static int calculate_zspage_chain_size(int class_size)
>  {

      reply	other threads:[~2026-11-01 23:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1786003779.git.xueyuan.chen@vivo.com>
2026-08-07  3:56 ` Sergey Senozhatsky
2026-08-07 10:57   ` Xueyuan Chen
2026-08-07 12:12     ` Sergey Senozhatsky
2026-08-07 16:25       ` Nhat Pham
2026-08-11  9:03         ` Xueyuan Chen
2026-08-11 16:25           ` Nhat Pham
2026-08-14 16:50             ` Xueyuan Chen
2026-08-18 12:11             ` Xueyuan Chen
2026-10-29  1:43         ` Sergey Senozhatsky
2026-10-29  1:48           ` Sergey Senozhatsky
2026-11-02  2:58             ` Xueyuan Chen
2026-10-30  2:05           ` Xueyuan Chen
2026-10-29  2:26         ` Sergey Senozhatsky
2026-11-01 23:47           ` Sergey Senozhatsky [this message]

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=aufPMirl4cD7tz0X@google.com \
    --to=senozhatsky@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=bgeffon@google.com \
    --cc=chriswiseman@google.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=nphamcs@gmail.com \
    --cc=xueyuan.chen21@gmail.com \
    --cc=xueyuan.chen@vivo.com \
    --cc=yosry.ahmed@linux.dev \
    /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

all inboxes | Powered by JetHome®