From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F228C282C1 for ; Fri, 28 Feb 2025 03:22:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0CE6D280002; Thu, 27 Feb 2025 22:22:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 07DAD6B0088; Thu, 27 Feb 2025 22:22:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E5FAC280002; Thu, 27 Feb 2025 22:22:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C80E96B0085 for ; Thu, 27 Feb 2025 22:22:33 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 6B51E1421A2 for ; Fri, 28 Feb 2025 03:22:33 +0000 (UTC) X-FDA: 83167905786.12.FECD3EE Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) by imf28.hostedemail.com (Postfix) with ESMTP id 8E5F2C0004 for ; Fri, 28 Feb 2025 03:22:31 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="ZX/Wunct"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.219.45 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740712951; a=rsa-sha256; cv=none; b=KxAzumUWMB/mr+qnGR+v26G1fmnLV3tT7fQT19DyRx0D1NK965oYiR3O4aIFXXShZXwxPR PEiw7xCQGwK3GkxjxvxO32rQPHXXlU/ASiy0RmyFMdYscdBG3jfoNXTuQTEmmf4vEYpxVM vMC00w8DEChwQPGCRhWT4v91StnbuDE= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="ZX/Wunct"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.219.45 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740712951; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EaUqXKAuExzL0QlcVz9XzJqgqFGdCUiD2l1s6G21WGw=; b=Rb9HShfeBazjaikcINSUg7P/l/RHMMxoo6qsY/fx1FbKLuD62NyxVF/TER8HMpiuY2iX/L +l4B/OhSrZKPdIYsnOzo61Hd7tSSx3vn72eJJlcWLHYNVG+BxHq3QoDI1kcXguRnbeWxHI 5GuZGMGceJQHOAIK9aXCutR+kdxh9uk= Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-6e891e447dcso18053546d6.2 for ; Thu, 27 Feb 2025 19:22:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740712950; x=1741317750; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=EaUqXKAuExzL0QlcVz9XzJqgqFGdCUiD2l1s6G21WGw=; b=ZX/WunctyxXHTNDLkFwO8974WxofR9c+8lGzTagwHioVzFT081uIoaRG92jTOsEff9 1kqWY995yvx3FvEiPz2PXqvaIYjwf70HPMVlOogAoo2IRCplEkvwXK23eiKBmfQA0VLd kU8Yu5e27Wp0cHHddfREv5KlEs3D17UticwlfvSXZMeUjtxrBfosH/if/tqxO9Twdv6a 4JD3sXQmccaGw522Mr/YycZvBf95N+hSqhvHs7enwreNR7Mi22KtGYkd4gAi92Z+2EDt KpUPA7YDQkUEHgnPJ5zcG/ba63DO+/65MbzpzBS9RsQZTANYKL1C5xWDjB0S/GYoUs4f FrCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740712950; x=1741317750; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EaUqXKAuExzL0QlcVz9XzJqgqFGdCUiD2l1s6G21WGw=; b=q3bN7cGkU52EqLYHsoLFCPI0fMc7EL+nltFObEyGdmsblbyrfouekuMRkWeTVVCs9r yBDLR8oAR6Irxb6SsAdhzZ10bXRMIPR+0lqtIXM+FlnKhhIFQ97UsDhCZxv2V6DjBPCU nCte5fp3ZNVuAYHE6xgz46TucEnmDG7RxDXuG4/GDq3sPuhycG8KAJ6Q96SgeoPVmRyH L2KZpUtE1i3Pga5URl7LpFHUmnRYa+DGds+YesO6YX4IMVWLjCxgCME8dclHeMifmZQ4 MoigHWDyKYy1gTxfft/1NTqMtzcWQcqIeS9WX7xT/NdD90P/hnCrrOePCzKe8RovkjXd 5POA== X-Forwarded-Encrypted: i=1; AJvYcCWTxGPzAFZOem9Ki6frsWhCcYmAer+WMzVVzD8vxqnaXM64+6a7pGwCDk/0aP9OxrK9pIfJBnYy3Q==@kvack.org X-Gm-Message-State: AOJu0YxEYxWAb6bWi+/HIrUcjzhZRzKrO3HoVv8L0avFKJNi4wKwLV7l Oaub4UkNCq6fNtJlDJNbxyxrwkeMRJGvn4lzb37THepse5DuJ/sUTaz34iSYX5OLGmMzuoUVNbj Tfjq0ZIzEfe0LQMNsg8+j4p5WrMuI1KFKMaAT3g== X-Gm-Gg: ASbGncvwWCEcH0HDvL14aEVctljruYscP33XMPAn7uX7+NmiA8Jm/mC6FK9dpGT435c YWCXqAwPvrjdmiUBtcN162HCgn1rz+SeoQgZUOtcbS+VOp/P0YCzeLzD9ngBlmRJ4jzweItihJC iTk5jJ3zf/ X-Google-Smtp-Source: AGHT+IFpEnuTt48F0MQPr5AYdwDVW0ocvrFn7oJ/BfjCvZpWas4vF+WOCAnlj+D5GOaTECzeYCYh66kuuw5e0fFtud0= X-Received: by 2002:a05:6214:d85:b0:6e6:6520:1913 with SMTP id 6a1803df08f44-6e8a0cc793amr29070046d6.19.1740712950581; Thu, 27 Feb 2025 19:22:30 -0800 (PST) MIME-Version: 1.0 References: <20250227155431.2534325-1-joshua.hahnjy@gmail.com> <20250227161934.GA115948@cmpxchg.org> In-Reply-To: <20250227161934.GA115948@cmpxchg.org> From: Yafang Shao Date: Fri, 28 Feb 2025 11:21:54 +0800 X-Gm-Features: AQ5f1JrcDmVjmueHs_T2zF4C0hUbM0cM7wPje4JT3aHJYmA6yWHwUzz1tlFLNsM Message-ID: Subject: Re: [PATCH] mm/vmscan: when the swappiness is set to 0, memory swapping should be prohibited during the global reclaim process To: Johannes Weiner Cc: Joshua Hahn , ying chen , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 8E5F2C0004 X-Stat-Signature: x56s6y3xdjhyy818bm9unerozy193b1t X-HE-Tag: 1740712951-95787 X-HE-Meta: U2FsdGVkX1/StriYL7g0u+n2Z2f6QOn5k5pE3YSst/abst8aJ+Nf95MtQU+Da0DKtwc1kV0nOnajlSJEh35bGEpxglhiGv1pzB2F9YlBOEhqgncL7utFg0w9KaOPTlgDALnUsLetqXJ0nw9SX0LxmEO6Ec8BXyVFfbyCRudJJe1eCYXpiDe/uxsEJNHyIYBejoTIDaCD7wPmwD9M3zCKJMUDKNC8/Tr732Mikk7tKl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lF9pv01nGTPd4TkplTpa38MWbTK8+5V9F9eZlJva3eBNLizn6zFmtb2CvkC3wvVFXtWShyT8ACv5B3CodJSgW+q4wmJxAk53LPfhSE01vIiT+2uf3NgGvMillKWqtzJ0m0A8MKPnwEK7a+MJVgqozm/Y1kcCRSHR3v7YI7TotD9GM47+yHAx4Eye6HMPCt6yCq1XXp0Q2t6NxnIpLYg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000056, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, Feb 28, 2025 at 12:19=E2=80=AFAM Johannes Weiner wrote: > > Hello, > > On Thu, Feb 27, 2025 at 07:54:27AM -0800, Joshua Hahn wrote: > > On Thu, 27 Feb 2025 22:34:51 +0800 ying chen wrot= e: > > > Previously, when the system is under a lot of memory pressure and is > > facing OOMs, global reclaim can create space for the system and prevent > > going out of memory by swapping, even when swappiness is 0. If this pat= ch > > removes that check, it would mean that global reclaim can no longer > > "bypass" the swappiness =3D=3D 0 condition. > > > > I am also CCing Johannes, who is the original author of this section [1= ], > > who clarified in the patch that swappiness =3D=3D 0 has different meani= ngs for > > global reclaim and memory cgroup reclaim. > > Yes. It's been the behavior for decades that swappiness is merely a > preference, and that the VM *will* swap to avert OOM. You would break > users making this change. Hello Johannes, How about introducing a new value, vm.swappiness=3D-1, to disable swapping for global reclaim? diff --git a/mm/vmscan.c b/mm/vmscan.c index 76378bc257e3..4c22352c331c 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2387,13 +2387,19 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc, } /* - * Global reclaim will swap to prevent OOM even with no - * swappiness, but memcg users want to use this knob to - * disable swapping for individual groups completely when - * using the memory controller's swap limit feature would be - * too expensive. + * swappiness > 0: + * Swapping is enabled for both global reclaim and memcg reclaim. + * + * swappiness =3D 0: + * Swapping is completely disabled for individual groups when usi= ng + * the memory controller's swap limit feature would be too costly= . + * + * swappiness =3D -1: + * Swapping is disabled for both global reclaim and memcg reclaim= . + * This is useful when you want to enable swapping for certain + * memory cgroups while disabling it for others. */ - if (cgroup_reclaim(sc) && !swappiness) { + if ((cgroup_reclaim(sc) && !swappiness) || swappiness =3D=3D -1) scan_balance =3D SCAN_FILE; goto out; } Other parts of the code will also need to be updated to accommodate this new swappiness value. > > If you want to hard-exempt cgroups, set memory.swap.max=3D0. This does not apply to the root memcg. > > [ Yes, it's inconsistent. But it's really cgroup_reclaim() that is the > oddball in this. Also for historical reasons... ] > > > > when the vm.swappiness is set to 0, global reclaim should also refrai= n > > > from memory swapping, just like these cgroups. > > > > > > Signed-off-by: yc1082463 > > Nacked-by: Johannes Weiner > --=20 Regards Yafang