From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796352929; b=ecNYvsXm1wBXexgNiEEWlVdWhF7smfItuMHNtC9XZq96DLNpdVakJAALkwA/nynSapoB UpfbsiHQwOT4dxypqen3qevQaPcWmyl4zUHWgv2od/HWssb2U7uIT0rpWIKKnSxtzyW2l JfL+6XjTT4Z9ZR6K9Cd4DUaZmqq2J8du65scIJSPxQTXKqPkJgxJUCMvMKDLPtlrA7T8R A5A3xkcUPVKK5QMEnW/0s7Pgn49Yzf7So4sQfSyBN5MGpYFWDvLEFkcoAG+N1Oy4zPR74 YuzpuvMUGV79E3ROJN/jbGmEY3XNQnzjVABUSHLNlYcHGFZyoTUserOiY1J8ycn1yVA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796352929; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: MIME-Version:Content-Type:Content-Transfer-Encoding:Subject:From:To: Cc:In-Reply-To:References:Date:Message-Id:X-Mailer; bh=qoA3pPf3YTtwZE3KVatgGXhrhwP2vbzOeHkZ7Y655qE=; b=evXWpBpzzV9Qw/jWNWl7JF9VynU2r9YulHOc4tl3jl2lpOM+MMkchW183Jkf8YqrN+UR Hi+PjfDibFBxm5UMZX4XA+o75aneLfATJSC01N2mSzF8BbtDRw8Eg0Adg5DOep4XCmkvA Ek9aCuanAO+AhFlyetrE1hk4hCcTtaaXsqPr8Q8uz5VvTqC3DPr1YlcH6VJwz0vVADkZ3 qEqRrTYAwx6vjFIHK8iv1rI2C2lQ37j74RAlP/9KwKRuahmnnCRbJrC8gbN+/bX2Xwhc2 XjFdk9OLIAMApO1KxE/jc0ysxxiNF4ch7WstI2qV2qZp6JQuicmv5ktPre6qPRccgGQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="gCFtUC/X"; arc=none smtp.remote-ip=74.125.82.51 Received: from mail-dl1-f51.google.com (mail-dl1-f51.google.com [74.125.82.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0ADFB606A322 for ; Fri, 4 Dec 2026 02:55:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0ADFB606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=gCFtUC/X Received: by mail-dl1-f51.google.com with SMTP id a92af1059eb24-1397a4855beso15052c88.2 for ; Thu, 03 Dec 2026 18:55:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796352928; x=1796957728; darn=vger.kernel.org; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:content-type:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=qoA3pPf3YTtwZE3KVatgGXhrhwP2vbzOeHkZ7Y655qE=; b=gCFtUC/XJON43WNf2mC2IPP9kOIC1hGgoaSLKalbJiDAMCppDCuwb5JlQtfRWgrUQW IzF+C0xQ1Kf3ew76YHmzKptgq64eAfAKJc9TzNw60FOntVSKyo9ZfhEyjWZylM18dIGU hEOlmC+ak9oYBm46sO9k1jlmrIQRz5c6txisR+CoELehuvJlZZTpeb12gXLWgO34u7C9 ILabShDoOIoOsnJTkOyhgUOvuiNYxp+v2dX/s1v1SQtYUCSAz0O5cpqxbsm/BiSAyOkZ ACNgOi1iwkNjiHnBRdi3VdMwbbe1hLkxdC2HTmMReOSRBmmTw8o5OmtERwdM3S445sXK 6DlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796352928; x=1796957728; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:content-type:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=qoA3pPf3YTtwZE3KVatgGXhrhwP2vbzOeHkZ7Y655qE=; b=oHf51YEr1r20fNSTfUoXZ4m/fjpXeRAcmZ84gtu2xIGy6rGokBYL3Mgb9BIT0EAWa5 u3Kca79tuFP/YRROK1+wVdk10dyNNUhVhCivw36k853NQqyB1p3UWzWVu5ac79vYWbt9 Rdl4G6b6Ot48hAWT8sT2mBFmXfYOBAIRFTfYzHw6ftMQfZwEdyhEXWw6ohfL+i5g+EI3 vbSdoTp2LHAC8INx18r95wb78GGF/6blw5rwF4eqapQW6hdS34sMLj7CuMx1wyXVGNac ormKT4O16y3Fjj9cb8W37Y0VVu5FtXFgvi3Sv9ksQEnmnaZVjQuaHl47of35fB58oDY8 kJEA== X-Forwarded-Encrypted: i=1; AL+hErFbj1nvOwYFENQzJjan1wWk2xrgr5DqPXXcdUChOF4G7KYwY3gAUpuVSWIDBshBwF8iBVKvnWozUxKWNXE=@vger.kernel.org X-Gm-Message-State: APuU4Z+zweQJ5UWoSrUs9HKwiiKOinPio05Cc9V7zBVW7FBmrlVVK2yP zoJNbpp1wJq1l2rOo14EAl9L0oAEVk5hDb7H+3WUGiEqJopHMReHi7zt X-Gm-Gg: AZFdTZeYytFw6yUAu0XqrdqFSfaXtQSt8tjD0ApJxNheGlSHhvha/8141DJ4aMX4Zd4 2eFb3vw9uS6/tMBQqJmvwknLNsjFTLNdy1lkN24/2a8KUypfv8vcAwMtsHPAX6YK3NTmJ7bJC5h HdtasGINyc3nTk4FGkGvIVwJARL9zbMK2qg42fC4cbt2VymFh+qsUqaHH0CyMmonXyJdSreffpG J8NDfHsk1oBoJaVodpUWkfxpdcLVt432poIqGtZcX+KoRlV5wd6zxNvI7q1up4A+qvD5DdwNPgO LPy5c0rHNLybvRL2IT3Z9r4EBdQd0aSsBsSA7SKBkM+aMxkOEoZXCbJsqQWHPKt+Cb4HhfVn/th U63f20mg8jL2t17iwmWJWPC4q40AK3a7Q4As0PDzmBAAP15/E7v6u0ze8xKE2G06kuE5CpzFblr 5XK0VFXZTQLK6F/SwLFODVeAeZor/jfYpQdJ/Umts/jkavsMTL5kqSzg25iOeoSrZRufoh3nN62 GGvSnk/cslEz/Uphr1X4srgal8AbhuOsK4Isqf5kZieGdXaHYX+iQkd3wEOAZ6CPGhMJVgZt2qc TcJEJDw32gE0xsUqUpxYNgV6RBugvWPuqSGkkjhWRuf1MPrQNDS/VQVhnC8ha+Ms90A= X-Received: by 2002:a05:7022:b1c4:20b0:1b5:d170:5f55 with SMTP id a92af1059eb24-1b5d70a48dcmr1123916c88.1.1796352927192; Thu, 03 Dec 2026 18:55:27 -0800 (PST) Received: from o6.lan ([2602:fce1:44f:115e::]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b5d642e254sm2845218c88.4.2026.12.03.18.55.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 18:55:26 -0800 (PST) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: Re: [RFC PATCH 0/4] zsmalloc: replace shrinker with deferred compaction From: Xueyuan Chen To: Sergey Senozhatsky Cc: Andrew Morton , Yosry Ahmed , Nhat Pham , Barry Song , Brian Geffon , Minchan Kim , Richard Chang , Johannes Weiner , Chengming Zhou , Xueyuan Chen , Xueyuan Chen , Nanzhe Zhao , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-mm@kvack.org In-Reply-To: <20261203101411.3609533-1-senozhatsky@chromium.org> References: <20261203101411.3609533-1-senozhatsky@chromium.org> Date: Fri, 04 Dec 2026 10:55:19 +0800 Message-Id: <179635291992.1911544.5833379956441668587.b4-reply@b4> X-Mailer: b4 0.16.0 On 2026-12-03 19:13 +0900, Sergey Senozhatsky wrote: > This is a follow-up to Chris's shrinker removal patch [1] and Barry's > Pixel 6 fragmentation numbers [2]. > > Removing the shrinker avoids mid-swap compaction stalls, but without > any automatic compaction we risk regressing memory footprint on systems > that do not run a userspace compaction daemon, and on systems that do > proactive swap-out without hitting memory pressure (no shrinker > triggers). > > Replace shrinker callbacks (now removed) with deferred threshold-based > compaction in zsmalloc (plus a runtime-tunable zram sysfs knob to > configure or disable it). Hi Sergey, I wonder if we could also consider cross-class reuse to reduce the need for compaction. In my Pixel 6 Pro workload, I observed that the 2048-byte class grew by 3.5 MiB within a 2-second window while other size classes had about 125 MiB of compactable memory. When a class runs out of free objects, could we try allocating from an existing zspage in a slightly larger class before allocating a new zspage? This would introduce some internal fragmentation, but might reduce physical page allocations and object migration during compaction, without changing the existing zspage layout or the allocation fast path. What do you think about this trade-off? > > Link: https://lore.kernel.org/linux-kernel/18ed2967f99a2eff.3137322e32332e3235332e313736.2c2157.0000sendgmr@google.com [1] > Link: https://lore.kernel.org/linux-kernel/CAGsJ_4yoogQHpxGigawTfMPEKL_A6OkfEfsmJHzDHLPS3FCUQg@mail.gmail.com [2] > > Chris Wiseman (1): > mm/zsmalloc: remove shrinker > > Sergey Senozhatsky (3): > zsmalloc: introduce lockless zs_class_can_compact() > zsmalloc: add deferred threshold compaction > zram: add compact_threshold sysfs attribute > > Documentation/ABI/testing/sysfs-block-zram | 9 ++ > Documentation/admin-guide/blockdev/zram.rst | 2 + > drivers/block/zram/zram_drv.c | 45 +++++++ > drivers/block/zram/zram_drv.h | 1 + > include/linux/zsmalloc.h | 3 + > mm/zsmalloc.c | 136 ++++++++++++-------- > 6 files changed, 142 insertions(+), 54 deletions(-) > > -- > 2.56.1.987.g2ec0ab4260-goog > >