From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) (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 2ED2B3446A7 for ; Tue, 23 Jun 2026 18:56:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782240982; cv=none; b=YPEHlyNfx/q/HeD8sLfOVyEShfHPCUONP/0mqBawdNwnyGTaDG72nl3HtfE+tWthl6jzqAhB8mQG7K6nrRfPea3lF7vVrNQxJBzXoSMd7Ly3BkoiCO2jZFIpEvsSdjGh6l+ghc8TSWCcWgcBd7XSpb9e0Hhs2I5x32/5UMemryI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782240982; c=relaxed/simple; bh=f8lp6baf6Q2p8c0zIqoCYZYPwEqpstqLIfWZK2LtHJs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z9/N8syBdOjpWYv1nRfwNmaXeCqE5ajuQnHK9U53JEdeQ/vVrpDM71CceJ8A2IibJBZDCSPFHPxBYmc+0+hIMlb09g1qCjFE2lKzsjTU523mFdmgSLZyO8LVUOTWZxI3n9iLuPehxDB6doHRYAeYeOfZDPeWVEZ00kjUKDrUKCQ= 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=Y2dwX7wq; arc=none smtp.client-ip=209.85.167.182 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="Y2dwX7wq" Received: by mail-oi1-f182.google.com with SMTP id 5614622812f47-485ecc0f2dfso197994b6e.3 for ; Tue, 23 Jun 2026 11:56:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782240980; x=1782845780; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6J+ANK03VaN7rdpDI6tnomDHkaUzerJG7W4wHHMwOJo=; b=Y2dwX7wqdZCD55xSWyO/DJqMoZkLB8/l7gIEWvcfmzrCLYtLYIndRUzxVUw2RwdK0T RBFzRj5ol1Xaqhlr2dz+KYAzUDvhjhV9L7WmChr1Lx3tELhG3TOSSsYQrhWfftzAWju1 YttlBOAtuIE+9mmnS+JG4cgFIKuhNpl2bLDEfm50qesSiOTDoezpI7AoJ2AGhkyDrQjU N4CQkB1DZPy1oljVRUrYhzBDrlfTsyQNl/ZcogmKSmmIaAAXoF7wett2Ed1BKuTIGpqy ZD9rfaPnjIeyJBowuBek8/QwTolFEURoJOgoEwiQXNSroh5k3CZdG+JHLtiRfxZUVmZK JKuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782240980; x=1782845780; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=6J+ANK03VaN7rdpDI6tnomDHkaUzerJG7W4wHHMwOJo=; b=dGxSDd/qGmzbKzFub4kN4vbZ5nawc3to8aKtRtjuvyqVTFYA0gZeQZ3zlpavhsSCg2 eL1pWYUDiyQmGSdq1bkJSTccwlUksZWrCwtCtQA1nxT0+tAonPrkwOC0cCypm9sZfHQ+ Kpkq9zXTu/mSF72ahoWOf9d9DABEXTG4zQrWP7fudk0tW6WbkHtpCqKfkj9FBtkjr3F9 wq2NdTX0fsq5Rs8jGjsNxihRwz1sA+O/xLnpCiDgmXzzsti0/Mm9ZIvQnhm7W1QWgvwi GFnLdfi0xHKhpz1OuGu7jA4ZoErQOmqnf+WWgIL8IJts8i+wH3kudtb87W807pJhY5wR C5ww== X-Forwarded-Encrypted: i=1; AFNElJ/1O2yAZIH7LoMS3zdOqAl/lZPEMnSBSR4m5J2CZqm2MFcasSdJIDvbjQd5esyWXwyjGP/PUxvHOvo5ET4=@vger.kernel.org X-Gm-Message-State: AOJu0YzIWaFJJzrjKlMFEcvxsaT+tNfCh8yU+lxSSEYAHHTIN/tR0kF2 QYmfZE0DrzgKouzZVsLVMi6ooDgRoLsK0I2a81gewh9CfYdBugX4ggn+ X-Gm-Gg: AfdE7ckucbzTWo6y9ywfbcp07FWicdwCBllwWjL1mJVMI4xEEfL5MjyYRKuDjcy/Se7 BLSV8SiaV7E4RTlLI3GJ2PIBYnSCg8NKF9vPrqHvGsAxElNPfYmmw9juLHT0Qjed9OqyNYXGRmp EjgP0E8uV/+D2Zmj95wLziZJpmN7ZM5+sWen37Rw5qxxYv15MntsyG5lf12XuTgCS7wuEKBXToK 7IJtLLqQdh9LCDg60l6dY7mtd3n6SaoFJ3UjK3d5ku0fkBmOYhrYWqJUxsMcs3mXLjDDN1LMskT sSqJgv2PXIxK1EDtTNw3cilG2FFSJeR3D0W4g2tmmwQujpVm7fuBYu+cToEbNwg4Z8ihuXVaJpP 5HlCCtmM+v4wfRyisTdlRSg4M0CQaEP0SP1a0Ka6pWuGPW2VPsidPr6achQHhZuuzqwGflaJDlg JlRjc0IyOHKkr8fjMal3ALgyLXYCfSUGdLmih/XJXw/Q== X-Received: by 2002:a05:6808:7008:b0:487:5613:1f with SMTP id 5614622812f47-4907a57addemr445b6e.27.1782240980141; Tue, 23 Jun 2026 11:56:20 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:e::]) by smtp.gmail.com with ESMTPSA id 5614622812f47-48aec0e5e53sm6944307b6e.8.2026.06.23.11.56.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jun 2026 11:56:19 -0700 (PDT) From: Joshua Hahn To: Yosry Ahmed Cc: Youngjun Park , Shakeel Butt , akpm@linux-foundation.org, chrisl@kernel.org, youngjun.park@lge.com, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kasong@tencent.com, hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, muchun.song@linux.dev, shikemeng@huaweicloud.com, nphamcs@gmail.com, baoquan.he@linux.dev, baohua@kernel.org, gunho.lee@lge.com, taejoon.song@lge.com, hyungjun.cho@lge.com, mkoutny@suse.com, baver.bae@lge.com, matia.kim@lge.com Subject: Re: [PATCH v9 3/6] mm: memcontrol: add interface for swap tier selection Date: Tue, 23 Jun 2026 11:56:17 -0700 Message-ID: <20260623185618.1488231-1-joshua.hahnjy@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Tue, 23 Jun 2026 11:10:32 -0700 Yosry Ahmed wrote: > > To get back to the question of how the auto-tuning should work, the > > main question is to which ratio we scale the swap limits to. > > Do we set the swap limits proportional to how much swap is present > > in the system, or how much swap is available to the cgroup? > > > > So if we have 3 swap tiers A, B, C, with 50G, 30G, and 20G capacity > > respectively, how much should a cgroup with swap.max = 10G have if > > it is limited to tiers A and B? > > > > This is what I was getting at earlier when I said we have to calculate > > different ratios for different cgroups, based on what tiers they have > > access to. > > That's a good question. I think the case that is particularly > interesting is whether or not the limits of other tiers should change > when another tier is disabled/enabled. > > So basically in your example, assuming everything starts as "max", > when swap.max is set to 10G, the autoscaled limits would be: (tier A, > 5G), (tier B, 3G), (tier C, 2G). Now the question becomes, if > userspace sets the limit of tier C to 0, should the limits for tiers A > and B change? > > On one hand, it's simpler to just keep the autoscaled limits unchanged > in this case. However, this means that the effective swap limit is now > 8G, which is not great :/ > > The alternative is to recalculate all the limits when one of them > changes, in which case the limits of A and B would change to 6.25G and > 3.75G. But I don't know if this will work well if we allow custom > limits. What happens if the limit of tier C is written as 1 (or 4096) > instead of 0? It's effectively the same scenario, but the tier is > technically allowed. I think the one problem with this is that it becomes quite easy to accidentally overcommit. As a toy example, if you have 10 workloads and 100G swap (as in the example I gave above), intuitively setting swap.max = 10G for all 10 workloads shouldn't ever cause any contention on capacity. But if you start excluding some tiers from some workloads, you actually get overcommitting on the tiers that can service the most workloads. I am not sure how concerning swap overcommit was, but at least in the memory tiering scenario accidental overcommitting of toptier memory seemed bad enough that I wanted to avoid the problem entirely. > The more I think about it, the more I realize it may be best to drop > the autoscaling thing. I imagine memory tiering might run into similar > issues too :/ And that's why I didn't include opt-in/opt-out for any of the tiers; if you have system-wide ratios, there's no need to change the ratios at all, and as long as the sum of your memory.limit for each workload is under the total capacity, all tiers will also not be overcommitted. Now, all of these complications aside, I think we might be overthinking a bit here : -) The auto-scaling should just provide some sort of "reasonable" default, the users can always override the per-tier limits if they are unhappy with the autoscaled values. In fact, maybe it even makes sense to have sum of swap tier limits > swap.max. (I actually recall having a really similar discussion when I was working on weighted interleave auto-tuning a year ago, on how weights should be set when switching between manually-set limits and relying on auto-scaled defaults [1]. I don't think there's a need to follow this convention, but we should think about what the expected behavior should be if a user manually sets a limit, but later wants to go back to auto-scaling limits). Anyways, I think these are important questions. Youngjun, Nhat, Shakeel, any thoughts from you all? : -) [1] https://lore.kernel.org/all/8734hbiq7j.fsf@DESKTOP-5N7EMDA/