From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EDDBD606A334 for ; Fri, 4 Dec 2026 10:14:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JLzYzWcV Received: by kanga.kvack.org (Postfix) id 421BC6B05B7; Fri, 4 Dec 2026 05:14:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D28E6B05B6; Fri, 4 Dec 2026 05:14:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30FAA6B05B7; Fri, 4 Dec 2026 05:14:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id B410F6B05B1 for ; Fri, 4 Dec 2026 05:14:41 -0500 (EST) Received: from smtpin16.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5346CC029D for ; Fri, 4 Dec 2026 10:14:41 +0000 (UTC) X-FDA: 85505891562.16.3CEDDB2 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf07.hostedemail.com (Postfix) with ESMTP id B403A40007 for ; Fri, 4 Dec 2026 10:14:39 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=JLzYzWcV; spf=pass (imf07.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796379279; b=bn8cZaX0xkJBkTPWm1AP0bla/bwWVzaTqdCcgFPBJcQ4SQoUj7kZ3lkwqveeYKPeErlb+v FLgHWmzDrw1V3DFciuhz61i7v1vJeaGBX5gTOFb6V1EiGFwQw72vlqW7+WiuNTEbyRJwGQ heE2G+cysiGreF2n7luEG3KP0xQJWT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796379279; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+XYdNxd4Q5Tz077dD4US57WMEdMSX151LqYjHvQ0H1s=; b=sp001IVb4hgp9Cc4R0CUNPPP9S3L0E5uk7mz+MOb3q/OMFzHHh2qCKJNMbHvM8N+8GWU8/ JTgnZy/6TTEt/DHDTKJiVfCleFl3w4g/OEp4qO91LMH5aEi/KmYjtyKHs7PIhT8d/jy0Ho qHoSYcSeYcEFUEkqN5QguJCsx5g57Oo= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=JLzYzWcV; spf=pass (imf07.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id E7E8F62363; Fri, 4 Dec 2026 10:14:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 140201F000C2; Fri, 4 Dec 2026 10:14:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796379278; bh=+XYdNxd4Q5Tz077dD4US57WMEdMSX151LqYjHvQ0H1s=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=JLzYzWcVNg5X9+3KnLr77k8v5tDOJXmD50tMm4l6Jdvw/dRdwBfBJUae+h2ZDfCfT K3JlV1q1CB4w4vwD2Zjs97iUL0283KtLMqNOwALqRc4kKoXODSLLQ9Nd9U6P8wnTNh +ENm9FrjkKczYrv1jrTCI0pcDwW5j0iIwweF7jos/I7R3IV2GufJkO+HR7/sd6JifR Uzmv6Lpp2mkjtW9vcFgj/vFI1GJKeMq5+DygbMdrpT83R8bacebR/6likIT30p2YiI kuIfH8UZR65RLAxWcwLIgDXOLMLdlz506NXkC0QJsgGwAvIGT9Y07Im/NATj7hraaR 7ZzrvWaJJsC1g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH 3/4] zsmalloc: add deferred threshold compaction Reply-To: sashiko-reviews@lists.linux.dev To: "Sergey Senozhatsky" , "Andrew Morton" , "Yosry Ahmed" , "Nhat Pham" , "Barry Song" Cc: "Brian Geffon" , "Minchan Kim" , "Richard Chang" , "Johannes Weiner" , "Chengming Zhou" , "Xueyuan Chen" , "Xueyuan Chen" , "Nanzhe Zhao" , linux-mm@kvack.org In-Reply-To: <20261203101411.3609533-4-senozhatsky@chromium.org> References: <20261203101411.3609533-1-senozhatsky@chromium.org> <20261203101411.3609533-4-senozhatsky@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 10:14:37 +0000 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: B403A40007 X-Rspam-User: X-Stat-Signature: qpd8ynojq9okohgszyic4ymywzgenm7w X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-HE-Tag: 1796379279-170255 X-HE-Meta: U2FsdGVkX1+pgNKvgJiCNCuGje7a1otZbDfN2UlznaeQTkUUNbh+03ZbxybcdoUDJ7FPtn6Ug4/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ub6iWcFIodZScXiGypo3oEkJfxhOr0MEREJWsV2sOdEYQp3nrypUVue7SBmH055AQB6yBCsNADESGODxeFPEvcRMUtDv3KUobPByKQwZwwekY1NyQsEUdQ/aDO4UvjchfS5bRrHIsOgNrwL2AC/7x0x3k3vFm5A5eNPJ1C09VqbwLL0aXmI8dj/Qxy8VcvPd4cEJo6aD8d7+8COJUHwW3yBRjt1Cn5izpQl3XofA8e6MYOWHwvo1QN+iOaoJz9cBc4ClQ9wNCpmuRRfakQKd9ebOZ0fOemzst91HA3VlDnWyBw5UBgnb5lk8ROQ06XkZ1AS8+iQTxCPTI29J1T/HrC+Dv3wg45j1Tki73aXMXaZs2SzZOQl3SF7t6iQRHs4Kv+jb+ESJknmJx3sn8lqR0klyYhuahLGAuouyNMU9/VuGLCWLh0gb7d283t2rHbkapvIhGRqpnqnbaw+Tquj4XnuC6b6mVg8/lwwacqySalJWhND0fKUReQNfD6OpdbvrufOo6o+yfDqkFz8Gky3LmgtFr+HM7AgaDNkStSGSu5FlW+C6eQDFCY4tcIEuleGCpbH9pGDmJ2aze1cpAx0pRBinvRzHp8pA5siGbaW++WOhfP9lw8mY2HbSGw6un2EvFx4porUiLtwooKfd1/sG+CR8MF1he/6KGD+0rwzErCzKavGWih4RjSKa9c8fW/2tnmj58RJ9RaxT2QAQSG4smanBcV87A2PG31xXLMbByL0wQQ1hPrCiKj9BXaG1ejgRfK+h0PjcHDMt4/dSQWV0U7LC2HhZ/w== Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [Medium] zsmalloc: zs_set_compact_threshold() never schedules compaction on idle pool - [Medium] zsmalloc: freeing whole zspages shrinks total_pages without scheduling compact - [Medium] zsmalloc: false sharing between pages_allocated and compact_threshold/work - [Low] zsmalloc: zs_set_compact_threshold() lacks kernel-doc and changelog coverage -- commit 6c8a6f9143072a471636aef6ee685db38822eec1 Author: Sergey Senozhatsky zsmalloc: add deferred threshold compaction This commit adds per-pool delayed compaction work queued after partial zs_free() calls to compact pools whose reclaimable pages exceed a configurable percentage threshold. It also exports zs_set_compact_threshold() to adjust or disable the threshold at runtime. Link: https://lore.kernel.org/linux-kernel/CAGsJ_4yoogQHpxGigawTfMPEKL_A6Ok= fEfsmJHzDHLPS3FCUQg@mail.gmail.com [1] > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c > index c0bad8214853f..6c9211d1fae09 100644 > --- a/mm/zsmalloc.c > +++ b/mm/zsmalloc.c [ ... ] > @@ -276,6 +278,8 @@ struct zs_pool { > struct zs_pool_stats stats; > =20 > struct dentry *stat_dentry; > + unsigned int compact_threshold; > + struct delayed_work compact_work; > #ifdef CONFIG_COMPACTION > struct work_struct free_work; > #endif [Severity: Medium] Can placing compact_threshold and compact_work here cause cacheline false sharing with pages_allocated on 64-bit 8K, 16K, and 64K page kernels? On those configurations ZS_SIZE_CLASSES is 256 (8K) or 257 (16K/64K), putting pages_allocated, compact_threshold, and compact_work.work.data in the same 64-byte cacheline (offsets 2048..2111). Every partial zs_free() now reads compact_threshold and compact_work.work.data via maybe_schedule_compact(), bouncing that cacheline against concurrent atomic updates to pages_allocated in zs_store() and full-zspage zs_free() even when compact_threshold is 0. Aligning compact_threshold and compact_work (or pages_allocated) to a separate cacheline would avoid the contention. [ ... ] > @@ -1498,6 +1505,10 @@ void zs_free(struct zs_pool *pool, struct zs_handl= e *handle) > __free_zspage_lockless(zspage_to_free); > atomic_long_sub(class->pages_per_zspage, &pool->pages_allocated); > } > + > + /* Created a hole in a partial zspage, check if compaction is needed */ > + if (fullness !=3D ZS_INUSE_RATIO_0) > + maybe_schedule_compact(pool, class); > } [Severity: Medium] Can skipping maybe_schedule_compact() when fullness =3D=3D ZS_INUSE_RATIO_0 leave pool fragmentation above compact_threshold indefinitely? async_compact_pool() checks the pool-wide ratio pages_to_free * 100 >=3D total_pages * threshold, so freeing whole zspages shrinks total_pages and can push existing waste in other classes above the threshold. If fragmented non-huge classes sit below 5% alongside many huge-class objects (objs_per_zspage =3D=3D 1), freeing the huge objects always hits ZS_INUSE_RATIO_0 and never queues compact_work; maybe_schedule_compact() only checks the freed class anyway, stranding pages until a partial free. [ ... ] > +int zs_set_compact_threshold(struct zs_pool *pool, unsigned int threshol= d) > +{ > + if (WARN_ON_ONCE(threshold >=3D 100)) > + return -EINVAL; > + > + WRITE_ONCE(pool->compact_threshold, threshold); > + if (!threshold) > + cancel_delayed_work_sync(&pool->compact_work); > + return 0; > +} [Severity: Medium] Should zs_set_compact_threshold() schedule compact_work when enabling or lowering threshold on an already-fragmented pool? Because maybe_schedule_compact() is only called from partial zs_free(), enabling deferred compaction (0 to non-zero) or tightening the threshold on an idle pool leaves existing fragmentation above the new threshold indefinitely until a future partial free happens. > +EXPORT_SYMBOL_GPL(zs_set_compact_threshold); [Severity: Low] Should zs_set_compact_threshold() have a kernel-doc comment documenting its parameter semantics (0 disables, 1..99 is the pool-wide percentage, >=3D 100 returns -EINVAL) and its sleeping contract? When threshold is 0, cancel_delayed_work_sync() sleeps and cannot be called from atomic context or while holding locks taken by async_compact_pool(). The commit message also omits the new zs_set_compact_threshold() API and ZS_DEFAULT_COMPACT_THRESHOLD constant. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203101411.3609= 533-1-senozhatsky@chromium.org?part=3D3