From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.177 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796539082; b=dBFKsBBQ63czY/5+yf96FKYQb54zrGX3kSCGBmVGwjvsbVU5KWWMcUB+tW2YtY48zSlA WTfanZi32r4N3auJlLVH582axmn7UjDCEO7KRWeI8O8XtXeCwavJtydUVyGGxql0PM1yV fBVMCtjFLh7YYrcQrsGgC7mo7ZVKclf15nU91M+Jq4yP5fgrDIReb8zi7RatHorYy7svr PtdVr0/Xz19yJnMgQBqQF53FDc54ULrlAIcJjbOM6oAsW1V3bZ5AXAeHcXWsZNp9pn2Jx +kEZkrecGlD2D8C5Fh7RkCbI0Zl7yX2k3uFLYeaKIdkT9mMrCYRNLYkIvMsZKoCc7Ng== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796539082; 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=1izhOUuOw8FdJdHtEMqPplqANppzUfFNIwVeSk1EEx2Jrc0dawmkp8jk7er9CJMvyWdT 6alLsMu3Xq2R3ghkJ2qK7FfE+ksPJVhMHbc62YF0L9p8UqEvuWO+7IKd0ZJwZPLRsJyCg zP1xdWg4eyrslUhaJ9IZpx7ZTdnHPXCgvRhYFXvVNRW8IleyNMmtFTM0ajBQG0K8hR91t CnWLqruElrBduvFddSJmzXENggzso7UJ7HSvCxP4VQ4DwLIQqSsCWPa42OOD5xqtxVWC1 A2F9OiiTQ2VV7XazdA8AGuUXwqJFnwbNwQqcDRCC60Vvymo7i4hPeJ1A8x/xmd7SpOw== 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.177 Received: from mail-dy1-f177.google.com (mail-dy1-f177.google.com [74.125.82.177]) (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 2FD50606A321 for ; Sun, 6 Dec 2026 06:38:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2FD50606A321 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-dy1-f177.google.com with SMTP id 5a478bee46e88-386ab9ab619so3747993eec.1 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=W8f9t0hwSQys+ogS631v2dvQY3uzh6fHTvJaoCFAgrFwr+caJ2HdosrPSTCNm/0KWm jxAN4yyhKOOLDIvYi9AV06L4tPeToeAHqyYpaijWw2O/9JXS+gaeHdJnTYbgcysRR3zu UCStm6oLrtNtf1uLa9uHPj02fE9LBjDWx8W/KL9PQjfJbIVNuJ9JkoMmv5TZL62KDQE7 nRZv9ONry4o+XIGgUh7yvAC276y+zZt7/1R4GD7oDeJYFPKTQdDIMGKxzCUXBuj20UWV qcL7hIasPonoV2liRA7JeHOY+KbOvseglL/4j5NbR11Pygqt4W1/RKXB9kjgE3+xgMvu wkdw== X-Forwarded-Encrypted: i=1; AL+hErEM6XIteodqE9PK+ePA96RMQfCev2yTRU+IXDprJReYu8fdj2gIu5x0+UWX0TXcYf+59lb8/vWttzM+7w==@vger.kernel.org X-Gm-Message-State: AB4q+uETIXdY76Ap5aharxQI1v2WvkIBpiz8/6lUyuteLIGQk+IM3Csu SixZfRbIfoiloe8JIutISxoR6o+26xIqY5rXSNvp1LUeD0jkDbQmruuMjNO3a92MWQ== X-Gm-Gg: AZFdTZf7XEpXhTgd9+VMDT6Vq1jENndY8Kn5jIEmFHxy7raiYQWu7YKJj4jm3vCcjfY kekpyJzG+ck7yhC2uPD3aWwPdfl8s9mEGAiLDvFMkUYVf2HfGHua32BBjAKkN5wcojxSe9CVI+Y n4z3DYvJQnopEV2UkQpG9RR8Z6Zc1W3k7mVTw0rgfw2CrWJSwaHXYnRG8StHB6KS35KOvja75hp w912xw/NAP0+4LbGFUWEdhsPhlLcu7AZDMG19d+i08pzVRAbvObwL8mnRmC1sI9OSaPzHsjO6YQ dnruTja+qR8H6Tyb86I35YKBI0CgbHHdjPIQDJLiFH+b1IKCJxurkyG6sb+wwh1rUGrB/R6zQEZ k0skd5vWQy7yQFHrt6B9LNppW31SPVwXM3UZtJ8g06leh7iSeJ/I7Py+cqCMsy80APMO4eIj7ld vBj4gL4n+jx0luuwhdkeDiUj2FeRCPh/RTte5gJYfk1uAcYp5X1djrWTgy84u54onI12qGVRWMe nHpGV4Hw82zupHXbqlv8FNsCq7BNUclsAghvmKvH6HLoOx3gphn5oB9H+0GuTHd9E9fXN8pol5g Rn6HR5sqDmf9SDeuvihbOLkdWuTGaSANGNNliNg6l/KfY3TnAM7A1rNCNhpjwhfSOSvJ 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-block@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.