From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796273281; b=0K1MYRO6uWWYt+q53UMZNIZRS1vowg9G/FYqPGWxR4inqcWDONdYhHFHC8br/ghbXEWJ vd7xcjFLGo0DPn8/m9Gq3jleKPPZ3/lNN8zCVtJE/jq44v7BmZ/dWE5MOIAAuwBrttQwG m9v6dNNOflcCnASM2I2RraIU0rRnPyovwj/Qk3X47E0panY2qWM3kn99CoPNnvsNvYayz Aep6A+lvk2Hc66VOYihhEEooXDDlhdwd4AjmZ9ssuaEvv8qXUeZJgp6ey7NkD1diRw++V Vf/49b8iIa1DHFpjrd6Pdje/UasDbBHKY4HTKt3bVGU3x/zOu7MR/iOonqIWHl28zJg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796273281; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=k4pXk4xnUEbkWqUie4wqAIx4ZsfU7/5C43dfdRWyYpQ=; b=BrNsWhMVM1eyitF4nmd/VstaIBwKVW8phUgrRxVnAldDbz4UgJWzQPPqXyKzarJAj/AJ 2oawWzbUFDvT5lMW4uAGVBczOEdR8wLlmVmMPVMZIxgecvJRmsU9E+HhslBmAidYV8DJr na7bwoEu6svJbzvt9vSlm/xIhu7GUaQYt1wk7jt76dujELgzGCzL554yNXhyTr0MuhMg9 UsM0jtolT+vSTopchRQeD3Ohf3JUfhp4hIHzz5UDfThJvmLSBI/iVKtP5h1gMPpqB9d6g UI3pVgGfshvngxTPAZaxWm7A6+XP/xzVE6JQTfj9904rkobc7i+sAVBFUYtBNHjUwlw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=hPYECzWt; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12B55606A322 for ; Thu, 3 Dec 2026 04:48:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=hPYECzWt Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D6B61F000C1; Thu, 3 Dec 2026 04:48:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796273280; bh=k4pXk4xnUEbkWqUie4wqAIx4ZsfU7/5C43dfdRWyYpQ=; h=Date:To:From:In-Reply-To:References:Subject; b=hPYECzWtsrnfZ+ga40T0a+Q/7h9kwj9ABCO77AoEjUJs4GltT7vcELWw4Ke7tKL7J DhBpSQtoaAiFwEC6JWxkoZo7+GyXcVGCWpzpI0aH4h3lRB/PC0s9xt255CRlMiYgGV iod1RXyy9E2YkuclABW6+9mP0OUfpC6ndNVsi0IQ= Date: Wed, 02 Dec 2026 20:47:59 -0800 To: mm-commits@vger.kernel.org,yosry@kernel.org,xueyuan.chen@vivo.com, xueyuan.chen21@gmail.com,senozhatsky@chromium.org,nphamcs@gmail.com, minchan@kernel.org,hannes@cmpxchg.org,chengming.zhou@linux.dev, bgeffon@google.com,baohua@kernel.org,chriswiseman@google.com, akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <18ed2967f99a2eff.3137322e32332e3235332e313736.2c2157.0000sendgmr@google.com> References: <18ed2967f99a2eff.3137322e32332e3235332e313736.2c2157.0000sendgmr@google.com> Subject: [to-be-updated] mm-zsmalloc-remove-shrinker.patch removed from -mm tree Message-Id: <20261203044800.9D6B61F000C1@smtp.kernel.org> X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The quilt patch titled Subject: mm/zsmalloc: remove shrinker has been removed from the -mm tree. Its filename was mm-zsmalloc-remove-shrinker.patch This patch was dropped because an updated version will be issued ------------------------------------------------------ From: Chris Wiseman Subject: mm/zsmalloc: remove shrinker Date: Tue, 01 Dec 2026 15:02:30 +0000 zsmalloc registers a shrinker to run automatic pool compaction under memory pressure. Because zs_shrinker_scan() calls zs_compact(), it ignores sc->nr_to_scan and compacts every size class, taking write_lock(&pool->lock) and per-class locks (dropping them only when a destination zspage fills or pool->lock is contended). During active memory pressure, swap-out allocates concurrently from the same size classes, so physical pages freed by mid-swap compaction are immediately reallocated. Incoming swap-out refills free slots on its own, while shrinker compaction contends with page faults and swap-out. In the RFC discussion, Xueyuan Chen reported compaction stalls up to 269.68 ms (p95 38.86 ms) on a 12 GB Android device. Testing on ARM64 QEMU shows that removing the shrinker eliminates mid-swap compaction churn without increasing active pool memory usage for either zram or zswap, and cuts zswap page-fault latency under active swap-out: ARM64 QEMU (Linux 7.3.0+, zram0, 16 boots per config, ~240 MB swap-out): Before After Pages compacted mid-swap 2,218 0 zram mem_used_total (mid-swap) 121.0 MB 120.9 MB zram mem_used_total (post-compact) 111.2 MB 110.9 MB ARM64 QEMU (Linux 7.3.0+, 4 vCPUs, zswap lz4): Before After Active swap-out pool size 95.9 MB 95.1 MB Active swap-out p50 fault 3,262 us 2,414 us (-26%) After swap-out stops (holes held) 44.2 MB 65.1 MB (+20.9 MB) For zram, userspace can still trigger compaction explicitly via /sys/block/zram/compact (zs_compact()), and mm_stat's pages_compacted now reflects manual compaction only. For zswap, the shrinker only reduced pool size after new swap-outs stopped; as discussed on the RFC thread, reclaim-time compaction hurts active fault latency without reducing active pool size, and any proactive compaction interface for zswap can be evaluated separately. Remove the zsmalloc shrinker callbacks, registration, and header include. Because zs_register_shrinker() was the only remaining reader of pool->name (zs_pool_stat_create() passes the name parameter directly to debugfs), also remove pool->name and its kstrdup()/kfree() allocation. On arm64 defconfig (4K pages, Clang), this shrinks struct zs_pool from 2128 bytes (34 cachelines) to 2112 bytes (33 cachelines) via pahole and reduces mm/zsmalloc.o object size (scripts/bloat-o-meter): arm64 defconfig (Clang): 30684 -> 30127 bytes (-557 bytes, -1.82%) x86_64 minimal (GCC): 12584 -> 12169 bytes (-415 bytes, -3.30%) Link: https://patch.msgid.link/18ed2967f99a2eff.3137322e32332e3235332e313736.2c2157.0000sendgmr@google.com Link: https://lore.kernel.org/cover.1786003779.git.xueyuan.chen@vivo.com Signed-off-by: Chris Wiseman Signed-off-by: Andrew Morton Suggested-by: Sergey Senozhatsky Suggested-by: Yosry Ahmed Acked-by: Sergey Senozhatsky Reviewed-by: Xueyuan Chen Reviewed-by: Nhat Pham Acked-by: Yosry Ahmed Cc: Minchan Kim Cc: Johannes Weiner Cc: Chengming Zhou Cc: Xueyuan Chen Cc: Barry Song Cc: Brian Geffon mm/zsmalloc.c | 76 ------------------------------------------------ 1 file changed, 76 deletions(-) --- a/mm/zsmalloc.c~mm-zsmalloc-remove-shrinker +++ a/mm/zsmalloc.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -270,17 +269,12 @@ struct link_free { static struct kmem_cache *zspage_cachep; struct zs_pool { - const char *name; - struct size_class *size_class[ZS_SIZE_CLASSES]; atomic_long_t pages_allocated; struct zs_pool_stats stats; - /* Compact classes */ - struct shrinker *shrinker; - struct dentry *stat_dentry; #ifdef CONFIG_COMPACTION struct work_struct free_work; @@ -2115,62 +2109,6 @@ void zs_pool_stats(struct zs_pool *pool, } EXPORT_SYMBOL_GPL(zs_pool_stats); -static unsigned long zs_shrinker_scan(struct shrinker *shrinker, - struct shrink_control *sc) -{ - unsigned long pages_freed; - struct zs_pool *pool = shrinker->private_data; - - /* - * Compact classes and calculate compaction delta. - * Can run concurrently with a manually triggered - * (by user) compaction. - */ - pages_freed = zs_compact(pool); - - return pages_freed ? pages_freed : SHRINK_STOP; -} - -static unsigned long zs_shrinker_count(struct shrinker *shrinker, - struct shrink_control *sc) -{ - int i; - struct size_class *class; - unsigned long pages_to_free = 0; - struct zs_pool *pool = shrinker->private_data; - - for (i = ZS_SIZE_CLASSES - 1; i >= 0; i--) { - class = pool->size_class[i]; - if (class->index != i) - continue; - - pages_to_free += zs_can_compact(class); - } - - return pages_to_free; -} - -static void zs_unregister_shrinker(struct zs_pool *pool) -{ - shrinker_free(pool->shrinker); -} - -static int zs_register_shrinker(struct zs_pool *pool) -{ - pool->shrinker = shrinker_alloc(0, "mm-zspool:%s", pool->name); - if (!pool->shrinker) - return -ENOMEM; - - pool->shrinker->scan_objects = zs_shrinker_scan; - pool->shrinker->count_objects = zs_shrinker_count; - pool->shrinker->batch = 0; - pool->shrinker->private_data = pool; - - shrinker_register(pool->shrinker); - - return 0; -} - static int calculate_zspage_chain_size(int class_size) { int i, min_waste = INT_MAX; @@ -2216,10 +2154,6 @@ struct zs_pool *zs_create_pool(const cha rwlock_init(&pool->lock); atomic_set(&pool->compaction_in_progress, 0); - pool->name = kstrdup(name, GFP_KERNEL); - if (!pool->name) - goto err; - /* * Iterate reversely, because, size of size_class that we want to use * for merging should be larger or equal to current size. @@ -2297,14 +2231,6 @@ struct zs_pool *zs_create_pool(const cha /* debug only, don't abort if it fails */ zs_pool_stat_create(pool, name); - /* - * Not critical since shrinker is only used to trigger internal - * defragmentation of the pool which is pretty optional thing. If - * registration fails we still can use the pool normally and user can - * trigger compaction manually. Thus, ignore return code. - */ - zs_register_shrinker(pool); - return pool; err: @@ -2317,7 +2243,6 @@ void zs_destroy_pool(struct zs_pool *poo { int i; - zs_unregister_shrinker(pool); zs_flush_migration(pool); zs_pool_stat_destroy(pool); @@ -2341,7 +2266,6 @@ void zs_destroy_pool(struct zs_pool *poo kfree(class); } - kfree(pool->name); kfree(pool); } EXPORT_SYMBOL_GPL(zs_destroy_pool); _ Patches currently in -mm which might be from chriswiseman@google.com are percpu-skip-sidelined-slot-in-pcpu_balance_populated.patch