From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796539087; b=S6ymaMaZeivpZgjtadHQF6c7NI5R9iRlDURfADIbZFpkroSrenfuHnPBKNJRoDdTks9B bLk6xsqYPfnSnB2Zw969BLMR/rlZO6En2XhUfAUfV3nqKZbxPJ1Y9y1Fdy5mpW51vCqdp 75iEXK+fm8Z5dgi3MtrsFcqrMn/bXzoltRSmKUPjPDoWvK0xlvwIgb/uOzMgUes2wJTAF TnyypNI9on7MUMpYpY99hifmKZUEpTrcEb1xTOThMosIxEXtj9OxsYmhtCnrlsXIMimBj FkY40LPeB1iK1h78zBo9VugzaK4meIttt+n5zEhBcTV2BbT9wRxUGoCJoXUECUH3K3Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796539087; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=DJuH8gs0YdnBgZp5EGUcKq3rW9GZx4YThvG3IKhZjRY=; b=1Er+l0ufc2P6HCElxeeCFfSa7NxCvEzaPUXYNJSs5hxtifMwhqyF2DhTMuvhdmyTxVcg rJ5i9eKCIWyY24tfLH2c2ZuX7xjWeGx/vz8CFLGrgOzZhV+5W34w5kidpVwWaIIv2tvEH ays5PJg+clK4+XI22o/tBdXhp1gLf2OW8bPhKKFmdmddlQsiyLDVWHniL2lrfqYYj5Wjt xjbfa+4bHm11TZIR3F/oGPbQCvKOGUboyR3L4r5jXggkqoggglSjKiRarVVGACGJ3NRdl nDYbWwaDv3FERMIEf36Y8Bt9bhtOwBHE5CAkhnKbMl7Tt3Dneq8+wOm4ZlBQCwCEXwQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=eq0bsrKm; arc=none smtp.remote-ip=74.125.82.49 Received: from mail-dl1-f49.google.com (mail-dl1-f49.google.com [74.125.82.49]) (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 27272606A31F for ; Sun, 6 Dec 2026 06:38:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 27272606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=eq0bsrKm Received: by mail-dl1-f49.google.com with SMTP id a92af1059eb24-1b5d5f3d5b8so2370600c88.0 for ; Sat, 05 Dec 2026 22:38:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1796539081; x=1797143881; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=DJuH8gs0YdnBgZp5EGUcKq3rW9GZx4YThvG3IKhZjRY=; b=eq0bsrKmWx3naamrKvGbjlmYOQF4/Fl3wBFXrlBVdnSkHncFoGFyB79+HQbC3kFKMz fmdA72nDyM5MZ5nlq6X07gV1RR0D39bElA4FPmn6mq3W3vwOa1QoUbTmoZTq74dGpI3c sF3tlZ3hrbff5I/yLl6kscBU9dgdxN2iq6JpQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796539081; x=1797143881; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=DJuH8gs0YdnBgZp5EGUcKq3rW9GZx4YThvG3IKhZjRY=; b=KgQwYuqSpa0/PYDk3S+1WUgLsvvFs0ftvo7fjaQtqc+OmtML0jJP/rKscr2g6HNCXf jtsX4KAtxruwdznpZ5breRUBkjg+iEPmG+/rA2CzrjLKGtrqzAhh9+Rz8YqOqKhNNsqy uV8d4JML143GCrb0SfF+dWNd6nroKv7G2Eq404VtBaawjBOgcDHTzFgW1ZomNpv7i+Od g5qn582SH2FTBy/PNLr+gQBwtyJ9RVh+4uSkMpuIdfl4ebp3EbIs2tynUinBbVP1hmB9 m0L1H4FdzYhZXhBhIbJ8VDrIVUJJqDQmzLliKEQPJB9T2F8wuslyx1b911+FovGTJM/w BVtQ== X-Forwarded-Encrypted: i=1; AL+hErHuA2taO/pextu2Z4BlD3hLjEjfkFJ2uxz03DW+cAuoIzAp2arjLXjXk3VpwSyMsJYOk7rXO+AgWFytKKo=@vger.kernel.org X-Gm-Message-State: AB4q+uEFE8obJ5TIVwH1MIHFEUH7V4hdztITFjRslCU3wLCMhQjvkR6N iSeO8Hbm3U9uTd1jxNiu2StxCeVuOABehf3HzpcSwMDPmTp6VQgo7PDwXt4g8BqmgQ== X-Gm-Gg: AZFdTZcSmb6Y0RMMkCBcEcnaAV1m4bMzMdno10aBeBiF5i15PXJ0J/Cme0dZDYkD8x1 iZdmHgYCB3du9LE7tB+UznQi4piaudMr5qxwglu1puGxzMARCrJATy6y9iX99WApBVevM9c8iIO UrwJ2YwWXtOvcMvPmlugs9ul8qzqexMb1nHKTCKbrhKslCI4lt7FUI4Yhck215bIzWM3Q3+1iNI oHf1uKb6FfFll9STQxf6OemnQdcgzYOeiicxc2TeNKUZPNY/0831GZSpqOwlK327EI7d6iJJ+Wz zX6w9I/uvONuE8UYQJtxb1LUTmkYFIy77o9k7yjfQmcqz8ObdtOCm1O8k3GCSBdbB5cwDQh/NI6 3Bsrcfmodyh2ADZ+9a9VT/dUvpBkhHG0aneZEInOTA2vrfh9hSUbP7bvOsEQJNpKmaeIW6YfS2e M/fMKsGxdJjOpsHG1KA8q5mQ675DsYzqpYPYkSdNB7Wsvee/R1In/wdVSRCz+MPVXvHw0UHLSFq 3mx40zU5pCh8U4gDPZXJ/G5znwB91TYvwYYWaCnqkzRdyjQ9QR6c1QO1QXwUaLAti0djYkoxShZ gIlNmzbq76RsjWgFsQ0tMgBJwtWS0T3ODLYJMWKRPkRJqLw1yNq7Om/nHLAXFdxw22Ro X-Received: by 2002:a05:7301:da85:b0:387:3248:15d4 with SMTP id 5a478bee46e88-38751fc3beamr7663512eec.4.1796539081090; Sat, 05 Dec 2026 22:38:01 -0800 (PST) Received: from google.com ([2a00:79e0:2031:6:b038:d139:bc86:b03e]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3875220c35asm28297778eec.22.2026.12.05.22.37.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 22:38:00 -0800 (PST) Date: Sun, 6 Dec 2026 15:37:53 +0900 From: Sergey Senozhatsky To: Xueyuan Chen Cc: Andrew Morton , Yosry Ahmed , Nhat Pham , Barry Song , Brian Geffon , Minchan Kim , Richard Chang , Johannes Weiner , Chengming Zhou , Xueyuan Chen , Nanzhe Zhao , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: Re: [RFC PATCH 0/4] zsmalloc: replace shrinker with deferred compaction Message-ID: References: <20261203101411.3609533-1-senozhatsky@chromium.org> <179635291992.1911544.5833379956441668587.b4-reply@b4> 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=us-ascii Content-Disposition: inline In-Reply-To: On (26/12/04 12:49), Sergey Senozhatsky wrote: > On (26/12/04 10:55), Xueyuan Chen wrote: > > 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? > > That idea did pop-up sometime in 2015-2017, but we were never sure > about it. Borrowing free space from a higher size class comes with > higher object padding overhead, potentially, so we never explored > it in depth. This kind of changes zsmalloc design, from being slab-like > to managing free spaces. The last sentence in my previous email can be ignored, I don't understand what I was trying to say there :) Now, back to your numbers. I guess with threshold-based compaction we won't be having a problem of wasted 125 MiB in some size classes. So maybe rather than counting on possibility of lower size clasess borrowing free space from upper classes, which they may not do and then we just have wasted memory, we can just free unused memory.