From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.176 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796356153; b=a6XOOW90/ZkeGBWfNL7SUTEoYCAV0UOsXv3Fvl6vIIqUp+MgrP3V+iLAN9C+xg/iN2L2 MJ1+jg6XGZtktNHRKAC7f6Qb9fyMU7DcCbqXO3MTzM+xWqfvQks8TXDhsabE57nxloCjE Xgm5Epp/sQ4kKWoYxfupaxI017GmhY0UnpMd3U76X7Lw/o+8ZLoL3j0Ls9AEt2Zfr9CXd GAQyzRl0lS89O+N/ECdFiA+mXRgEkDuHTNNzmi8/iwIceZUYFa6LDRiXafFTZ7yGKiruk QGVQ6VB7BHqB7/pNbbCDnbo0lLp2mickg6zgqTVU/YCx+HJnAw8AkT09YYu3Tuqiz3Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796356153; 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=K62Whgpi51LYmf5zKD/VcS1swZB/JClrE1WqLYM63h4=; b=Wwe87OGhaIXoDTzhg+ddThlfXLz/6EaiGngb/MZgTkYlXLZT2Vw1i7UuYHFm9d9oakkR vR5K1z0n5PKGqYFb75gA+mPKWkdkyYnltZHGLz2RtZWei5vUSTRtAXVZUJ0a7Ex102hoy lVBCmf5gtSfaap1XsgfGRWR8E8J1CEQQ565Xfd8lx9ya68or3UIOKj6za8r/YjYD5nwfT M2nGYz2MHtbfK4wxhHXYd1scKalnhCQ7KQ2vKBMBFB4uhI9gWt0nXntaM89Z3T0Grc5sD IrZ8fkn8r3hy/gzYI+2pDDSZh8iWMVcgV6TZ1TQL8mLqVpKToD8MA/2vH+pn5GogClA== 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=Sy0saxu5; arc=none smtp.remote-ip=74.125.82.176 Received: from mail-dy1-f176.google.com (mail-dy1-f176.google.com [74.125.82.176]) (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 7EAC2606A333 for ; Fri, 4 Dec 2026 03:49:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7EAC2606A333 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=Sy0saxu5 Received: by mail-dy1-f176.google.com with SMTP id 5a478bee46e88-385d8a00598so681463eec.1 for ; Thu, 03 Dec 2026 19:49:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1796356153; x=1796960953; 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=K62Whgpi51LYmf5zKD/VcS1swZB/JClrE1WqLYM63h4=; b=Sy0saxu5sqt/ioNw+AQpuDibsRUkGO6h/dPdWJFIDw4IKlns6mUOCjkisOSpltV66p IxmbN6o2XCo7zirPdAVOYCDQrX1xK7z5BfVkEm5lGi0urJLjNkI78ygHnK1DQdX/u43Z q9H08UEuCp8RnUkWekFdKkhp3Dgy02AYVFpmw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796356153; x=1796960953; 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=K62Whgpi51LYmf5zKD/VcS1swZB/JClrE1WqLYM63h4=; b=iG5ZhTELpPdaIzt6mxOPk7lz+9FWufLOUztMWnZ/L6TtiDfncG/m35YYd6PCRq55Yp ftUbm3Hj/PwVZfjdCTS2jvMxUJ2NqB47jqi2nExtzwfEVc15dAPiaU/f2LlSrDXj+Q21 OZs1EI4r1NBCD5ruRTQOPvU2HJ1v4A3YTFmct8JVa2EiH1cW3xQHxiZHUHrH15nYzI4g RhSonBouyTW+8OjAhpg8rx4pQDqknWvh0xl6MGnpX3V7yPxxO69IY6IBhBRXr5jwNKe8 UlVkAvgNVbj5LwjY6buuoOg+djnbhqQZUcEslNCsxBqdD+L+9ZhMm7OYJWm/d0rmQxBo 8qqQ== X-Forwarded-Encrypted: i=1; AL+hErGriES/T299s36lQSuZBVUnpP75VWDG260sXZvJAY1/F8Pn01PPScgXhBPZqUp4zQE4Pbbb7nY003pxTJ8=@vger.kernel.org X-Gm-Message-State: APuU4Z92uWJ7jEzPvBDRqXr+XEth/lm2P6NYDvHvhw4rx1j5W1Pdv68O ELk5f1wSGz5EKMrRG4rtUmifTpAgyWBrktQRT2yPM91BIcTO2alzXJbU/ZrjNNiqFw== X-Gm-Gg: AZFdTZf2d59NECkPYASxGUpBXtm8dtlYjgy4aBOlFHnaBDeZsAacqr/hoGw8Dq8pC8N /Q1qnwHdoS0fzEcK7BWjRhLPtGxQx6oIhwz1uLcvFnHVbVzpjVJ7N5QtP5HF/OPigwXnlSsyLAy F0auNhALxVNbkdA6QtGRs41Bm/TQtBm9wOmYWxmsl8aHEP1x1F7wtBaFEboCJmPHuZlO0aG+nGu a2j9WzTuk/4Ggrzv9To0pstrb1n8jCwq/qShwHXUxbsBKJHCXaNywykjNf5irsGQE5s8xZ2Xdgy WRG18tEpSIpeLsNr79T9YR/WFvK+rb/n+nXprBPk0IL83WDo9vAnJh0VyGGceR463I4ENsRHuLJ ucTipYmsG7+9vo8n50QsuWb1NIYzxi+l1343sj4EH2l01U9ye58C/iHaWplB6/lPqTJYSCTRX1l M3TnQLTJ1Rm5UIlDEfQORIg7xQqTvWxg5ZzEln20nwsVB06IzkeoyDVLredQDbKwwJ3LIxn+qP9 krIVfRUHfKRqEc+L3MdflnHLJ3AdIbLqwu7S6TXuYgMnn4HzC5/F6zUpnIaSHpRdBUFMCufl/gY haDYmKsljVZU+P5Vegx1osYdD6/wOPO/JgHNdt8/EDBBkXaGtFZXBMm0oHbOrgMHZLAE X-Received: by 2002:a05:693c:69d8:b0:376:6aea:ab with SMTP id 5a478bee46e88-38751fca9b8mr878650eec.3.1796356152417; Thu, 03 Dec 2026 19:49:12 -0800 (PST) Received: from google.com ([2a00:79e0:2031:6:b1d8:8dc2:95bf:66b9]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3875224895asm2487221eec.27.2026.12.03.19.49.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 19:49:11 -0800 (PST) Date: Fri, 4 Dec 2026 12:49:07 +0900 From: Sergey Senozhatsky To: Xueyuan Chen Cc: Sergey Senozhatsky , 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 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: <179635291992.1911544.5833379956441668587.b4-reply@b4> 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.