From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pz2-f40.google.com (mail-pz2-f40.google.com [74.125.228.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9D65443C17 for ; Fri, 25 Sep 2026 19:21:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.228.40 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790364105; cv=none; b=j9Qs5yN8XU2kVPV3VbqDbfqZ+YEyTTCrvvcdXNu187IwUbHaKYYHjYs9p6RMRWLG4MDDdl8BoJ8XE0bbXtZqxc6Dgmqqzk3ud6Vvl0d3mi/Fdkrw4yazV0ctI70OL4UF9CtISjNp2KFyTv7via0qzcuujJ5wjrPecFItnFbWr4Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790364105; c=relaxed/simple; bh=AnW3FoapXOivL/XrYzT5pF2wRXd8Iw8zMnVMCQAyolo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AZo2zX9wr+45o8ma+rlhPo2JfK1jv5oLj8s7QAudXxH4EoWAM6xcy+ztUCB6ft0wLsoLLDCggfKkeny21Ik1Y1uetRTuONbWtrLtuVNbSluotm+UOYOzRIGUQFDOfS6+CgBw62cseYZXA3R5/36JUo3LkumsrvAqLQp5xOXm528= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nmcqFz/q; arc=none smtp.client-ip=74.125.228.40 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.b="nmcqFz/q" Received: by mail-pz2-f40.google.com with SMTP id d2e1a72fcca58-880483985aeso536113b3a.0 for ; Fri, 25 Sep 2026 12:21:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790364103; x=1790968903; 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=0Jb6ew+moeljvdv7wET58Ij2hd/p8EP7Hag+x2wkklw=; b=nmcqFz/qyOukKj34wtiHPfe3qgKtVZfvOidqK217MgnoZleXmfwJcyIcKX6jN0szhg z5c9mUsleUxRpujUCS1P6eHIVH3DpQiN/Q7fH2XCLjxBYLqTcyhjL36K3E5EWSuaFTes gso2OgKzumbGFolOS7269W1nOMkh2oLlKbnxdXHf8YWHKVSq/BWuIgs/9NDatJKFZAxD FmlFhqyqgyvM55Pt3nucmo4DMsMQEhNg0uQXYL8STnnPlqtL8nvtt0OLfWP684jdu1LO zAz1ODZEOtDHRoasIQbhNI61Xcf6qDH+rI4sVUzsMChYj+Uw5/Q3Sx9TLVtf0IiKaLd+ //IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790364103; x=1790968903; 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=0Jb6ew+moeljvdv7wET58Ij2hd/p8EP7Hag+x2wkklw=; b=VLOEGd7kML+ggyMfzF0b/NjpUoHvMKRdFM6sauRFa2mVh14Hn/JH/ZQ8jz+c6+xcQF Fmx1ItPvvpq+BrFjp0v3Br7L9oe52tltWr4ZxI0x0RzTYPCMgtbk6fnoFIX/75ubGcOd 3Q/LhBnD6qOUSWC8TVY3TTl1rDmLrX3FSGpX4VZ7KQ51MoYrcLsr7QQcr9Rg0CJVvifL Qpx12xS5NqkoX8m53+Qo3ABW9CUsfsybHevkaqDFxRDDGKe8FpB1L6X8ZqiMSGWwcL+g qbzXiBQncown/iJ9KE7vsBLB0xEmznsNYyONG8OcxJVx3AYR3/8ne/fAfDl4XvJVqqTd Q1Bw== X-Forwarded-Encrypted: i=1; AKwUvBxbNOkjnkqXLpGQ93UQPr1KdUdJoOoCG12y3O8vZcrqQNYNfeMnzZRYczUEWH3bCBqbHZkAGK57L1VwMxk=@vger.kernel.org X-Gm-Message-State: AFuF++k+ihKsO7hFegmZ3Pxy5Hat9Y2GiWDIVqIbKaIkdclR62dDmZ/o hnAEOCdLq9d6/UM2YDgA8enpCD+oN0gcegesxFMBN410mlsLDREiwkz1 X-Gm-Gg: AYBFou2Vswc3HTP9NpcsisElPqbLtwCRMNjUcR4NKHSlZUOLquyBfwtgy37ygwNj1JH pPG5RSeJOchqdFp3FoZCXKfoe6Z6/ZHRMrrIM/9kEmD3WJt2ZE3T1qjLZ/Rut93XiXUOrMzXPif R0mRvrAzE/Qyv+Y6WC+7LRQcqTIU/a88NQOWE3mfTAI0TLqTT1DIU5O0abp2A7oJmTEQjvhIw+F pxaYuFfkZ9df/9hj1/QU19jsuQtXK1rWi4Zr5NpIYn6qPpPHCUOBVSviIjRYDzKeTaak9w9lwrQ zllQHq89hCI5LU+Q9/13RFe7azphQhe21/JzPQFXbAUw17eEkJzK/sRTHPcfzkHJXn3L6W0LsVZ +T7aVLyHGKuVnIRelg0oP3FYe1xWC6V9QtVV8b3aB9vZTpMCUFdwdc5mwse79QOnIV82MqRto8J xs2eGO6LJkzLheGcVB3ipmA0FyB6IVUQB8e9IqNbfte0Z0iz8vhsHxsUluzVSMJlpSeZreVGFFb Q62N6U/1YVGFMV5bRFDnXhLEf8vkQxdE3hpqC4= X-Received: by 2002:a05:6a00:10d2:b0:87c:9094:b72f with SMTP id d2e1a72fcca58-87e98789dbdmr5541733b3a.12.1790364103038; Fri, 25 Sep 2026 12:21:43 -0700 (PDT) Received: from KASONG-MC4 ([1.203.116.237]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-87feaf83e0fsm1597652b3a.37.2026.09.25.12.21.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Sep 2026 12:21:41 -0700 (PDT) Date: Sat, 26 Sep 2026 03:21:30 +0800 From: Kairui Song To: Johannes Weiner , YoungJun Park Cc: Chris Li , Nhat Pham , Rik van Riel , Baoquan He , Shakeel Butt , Kairui Song , Michal Hocko , Roman Gushchin , Yosry Ahmed , David Hildenbrand , Muchun Song , Kemeng Shi , Barry Song , YoungJun Park , Chengming Zhou , "Lorenzo Stoakes (Oracle)" , "Liam R. Howlett" , "Vlastimil Babka (SUSE)" , Mike Rapoport , Suren =?utf-8?B?QmFnaGRhc2FyeWFu77+8?= , Qi Zheng , Axel Rasmussen , Yuanchu Xie , Wei Xu , Gregory Price , Wenchao Hao , Jonathan Corbet , Hugh Dickins , Baolin Wang , Tejun Heo , Michal =?utf-8?Q?Koutn=C3=BD?= , Shuah Khan , Kunwu Chan , Meta kernel team , Linux Memory Management List , Linux Kernel Mailing List , linux-doc@vger.kernel.org, "open list:CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)" , Andrew Morton , Joshua Hahn Subject: Re: Path forward for Virtualized Swap? Message-ID: References: <7ee199ddee81bf8026688def82f78ad9db09be9e.camel@surriel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Sep 25, 2026 at 11:41:31AM +0800, Johannes Weiner wrote: > > Thanks for your thoughtful email, Kairui. Hello Johannes, > > I also want to separate two things that I think got bundled together > > here: not requiring a physical slot behind a compressed entry, and not > > charging the raw size to the swap counter. The first one is great, yeah, > > and it's exactly the part we want, it's what makes compression usable > > without provisioning disk. The second one is a policy change, maybe it's > > not needed for the first stage, charging a cgroup for the > > memories it has offloaded doesn't require any slot to exist behind them. > > If someone wants to run memory compression with no disk at all, > > memory.swap.max defaults to max, so that still works fine, right? > > I think what we found out over the course of this discussion is that > people have been using memory.swap.max in two ways. Regardless of what > we do, we will "break" one side. > > (1) The usecase you're describing. Use memory.swap.max, combined with > memory.max, to set a "total", predictable footprint of in-use > application address space. You can mmap whatever you want, but the > number of unique pages you can touch is limited to this sum. And you > can control residency vs non-residency through the invididual values > of those settings. If compressed entries are not included, this > usecase will break. Right, thanks for the reply! residency vs non-residency is one of the issues here. It's also about how we consider these two kind of resources to balance the scheduling of containers. > (2) The use case we have. Use memory.swap.max to divide a finite space > in storage. We only have so much space on disk, and we need to manage > fair access. Note that this isn't about speed. We have a mix of > containers where some use writeback and others do not. The ones who Same for us, the usage is mixed. > write back to the swapfile need to be able to get their fair share - > not more, not less. Including something that doesn't actually consume Is that writeback compression rate based? I mean for zswap, you have to writeback uncompressable part, and then also do cold writeback through shrinker. The compressable part is hard to predict and control though? > this separate finite resource is also a behavioral change that would > break that usecase. And arguably it's a deviation from how the control > was intended and from the broader cgroup design philosophy. > > I think we need to build tools to support both cases. But somebody > will have to change how they're doing things... :/ > In the long term we might need something like tier or xxx_ext for cgroup for better control of different resources? In either case I think if we could get the building blocks more flexible, and this actually sounds like a tiering issue? I remember Youngjun once mentioned a memcg X tier limit which sound a bit similiar.