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 600A2C07E97 for ; Tue, 28 Nov 2023 23:45:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B465A8D0010; Tue, 28 Nov 2023 18:45:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ACF0F8D0001; Tue, 28 Nov 2023 18:45:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 921818D0010; Tue, 28 Nov 2023 18:45:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7BC578D0001 for ; Tue, 28 Nov 2023 18:45:27 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4EBE11C03CA for ; Tue, 28 Nov 2023 23:45:27 +0000 (UTC) X-FDA: 81508997094.14.2741AD2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id 4AB984000B for ; Tue, 28 Nov 2023 23:45:25 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=STWGDOJU; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of chrisl@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=chrisl@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701215125; 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=aSZuHyKyUmN5K/cS2AoWZVFd+W/qKh/zStdfOZiTTBc=; b=4OLuaiXFO8A2bSdlHGg2EZ+TTQrs0n4Imd9fyvRy0v3H7PqOEccKtYVf6JWwzcnhswcWyf AbHPifIuPr/eB5+7iD1w4OR/++vUhyoa1Ji1oss07q3Yw3oGEVKkWu5poJiGz174EXp5pq W9QcPpHvKhXhZHZp3SUcZnZI+AoOem0= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=STWGDOJU; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of chrisl@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=chrisl@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701215125; a=rsa-sha256; cv=none; b=PcczcO5r0EXHBz3FiCjAyKKScrcJSuLsIu0cDbCIldB1qPHDOx6D6xXcdp5TdO0rk1hIbO BuJhO+Qen+v27N4uClpt/VcWD/wb5LWs+ZXWHlcrr565/w9XfdxIWcOMfFH5+iSgVieCue pjc7t6eEdF0P7gDqnASYyf+4HFsMUTM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 54C2661481 for ; Tue, 28 Nov 2023 23:45:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A331AC43391 for ; Tue, 28 Nov 2023 23:45:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701215123; bh=c5hTYvlFDuS4/yvEogM5PHkabW5ZbLst+WDDOGe66dM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=STWGDOJUdWImIIAGbydMmvu7UrSSvfqbPgqrcwG8dQ3DTs89x2eZ7B6zKI/kKlQm8 kg5VXvo7DPGTMOBrMjEHhNTA/qMlAkEDqnjTMJ4BvuWI5jrR3mbRzizbUmT91w71z5 5+bXkAE13ICYnsOW1oEAvjhNqg7TxhL7LLCLyeDTLv7+fwjk9KOZ8VyZ9U+zp8X1JU le6oU5utYcsvTm7YrnUSXEaePNmAlFVXNxIPHKmZUq03ztL5eR1B++nuW/a59Bs+0r GboszV29DlZi7Kx5FJUtkFhs2d4/ihBDMACP6F0aLYxFrJyE7moMzO2dITnCVeIA38 ryvBiqlUleweg== Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-285abb82925so2697198a91.3 for ; Tue, 28 Nov 2023 15:45:23 -0800 (PST) X-Gm-Message-State: AOJu0Yw0w1NrLMJZoIcanxuuA1l7Zj6AJ/jzPcbcHL8WHCaCpFG5ReoN t9mjZzAqpq77EZaWZpJlEkENc0CG5apuiTiws6K/yQ== X-Google-Smtp-Source: AGHT+IGdFS8Bsul2mdGiC/tCtB+HU6iOQ3kNjL4sxTCJdac4jDtFdDYLq7mNaL4RD3laDYaf1g/6TFKZQKUwwYafFDU= X-Received: by 2002:a17:90b:1e44:b0:285:b019:1505 with SMTP id pi4-20020a17090b1e4400b00285b0191505mr11406711pjb.45.1701215122938; Tue, 28 Nov 2023 15:45:22 -0800 (PST) MIME-Version: 1.0 References: <87msv58068.fsf@yhuang6-desk2.ccr.corp.intel.com> <87h6l77wl5.fsf@yhuang6-desk2.ccr.corp.intel.com> <87bkbf7gz6.fsf@yhuang6-desk2.ccr.corp.intel.com> In-Reply-To: From: Chris Li Date: Tue, 28 Nov 2023 15:45:11 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v10] mm: vmscan: try to reclaim swapcache pages if no swap space To: Yosry Ahmed Cc: Minchan Kim , "Huang, Ying" , Michal Hocko , Liu Shixin , Yu Zhao , Andrew Morton , Sachin Sant , Johannes Weiner , Kefeng Wang , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue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uQtBwTIQSq1typsLNYw neh21bvf SyBey+b7zKWV5pttPYt+Aq/GNpLP9Wj9aIUesYUlef30e/5/3igqxtfGv1MDAmXKjMUu/ctsRwdREd9uG+jsxjwhDzITYwPzZIlPm3+aKmrWYT62LbKj4K6omLeoSZwtAfeB7kROu3oHMgJxE9QGM52ot7KCTGcWguHHVBe/ZxlZEa4hkxr+m0pomDULlVzX/avxD3a06iAgu5q2GDaWbLWdpDtTT5d+pVy55iWbTWnIfujhFIJAYBr+yDw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 Mon, Nov 27, 2023 at 1:57=E2=80=AFPM Yosry Ahmed = wrote: > > > > Exactly. Since swap cache has different life time with page cache, they > > would be usually dropped when pages are unmapped(unless they are shared > > with others but anon is usually exclusive private) so I wonder how much > > memory we can save. > > I think the point of this patch is not saving memory, but rather > avoiding an OOM condition that will happen if we have no swap space > left, but some pages left in the swap cache. Of course, the OOM > avoidance will come at the cost of extra work in reclaim to swap those > pages out. You are discussing how to use the memory that got freed. e.g. using other apps so avoid OOM. I am asking how much memory can be freed by this patch. That number is still useful to understand how effective the patch is. Does it justify the additional complexity? > The only case where I think this might be harmful is if there's plenty > of pages to reclaim on the file LRU, and instead we opt to chase down > the few swap cache pages. So perhaps we can add a check to only set > sc->swapcache_only if the number of pages in the swap cache is more > than the number of pages on the file LRU or similar? Just make sure we > don't chase the swapcache pages down if there's plenty to scan on the > file LRU? One idea is that we need to measure how effective the reclaim was toward the swap cache. If we do a lot of work but are not able to reclaim much from the swap cache, then additional reclaim work on swap cache is not going to be effective. MGLRU has a PID controller to adjust the reclaim ratio between the file and anonymous LRU. That is one way of measuring the effectiveness of the reclaim. Use the feedback to adjust the follow up reclaim work. I kind of wish we could have some feedback machine like this for the swap cache reclaim as well. Not sure how complicated it is to implement one. Chris