Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4220778rdh; Tue, 28 Nov 2023 15:46:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdD60ucKDYS2yL8FxW+MTtIXtzy455u2EEGnV8SOXKkE1U44sGJZMRoDFrNXuOM+zgvcYn X-Received: by 2002:a17:902:db0d:b0:1cf:cc0d:9600 with SMTP id m13-20020a170902db0d00b001cfcc0d9600mr10268242plx.24.1701215188964; Tue, 28 Nov 2023 15:46:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701215188; cv=none; d=google.com; s=arc-20160816; b=VKueWMoczBIcl5EwTOiCEh99MyQraL4+7gzWqov7nkwwu9ucu7yvgs0jUAX2HiLS8K mxygp4VyRCO6iadpORJofjF14KO83WWv10Yrmr+JvBXmxoWWt1tKvuE+M7fwYo+sJya6 /Fngd2G7Q27FoWP2Ts3RTWAdANO07LpydJkSi9K+1zDiLmLnK/ld48S215/HvZfPcRAr fH6LLdglk2L0XMk28jFKbWVfuWy+xgKtv0UwXefYDDG3rAlE/u8mqGwnU2Y+mVi3N0qs qG4dd0SrnKPHbt8LwtxwRYD3h/SWKQ47t+BuqWgXTvpYN/oe+ornESYao9NN8Np/XM4j SenQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=aSZuHyKyUmN5K/cS2AoWZVFd+W/qKh/zStdfOZiTTBc=; fh=XvsHNERV1r5iNggt9j9dBb6Y5/AxnYR+9/yHx6AMoG0=; b=d1ML8bjuVAe5+pWOhCu/mbREX0ctI2DelbScX/F2v7U1AtHOAXIUaFYyThaQVqAcJP GwlYmGYUWHn3MwJNfIvog/7mjG2R/pSEPXQMjIXZeIFpSYHjSKbhlc5NXSAgYb14vk+H ucJvKaTyC5+IMcx9e2aJ+cXqtLgxqMf9Y/qD62DEndjg+hhr2nMa2HkauQSIs+YPYmMT 8o3zOethJ7QoCftIArfGavrUZ80ejSJs/H8oLZiLNHsEkwnpYUIKXodHvBOBlZ4fGE8+ JP0YUVTqo1dLp9Qfpyn3fOkhO5xYl8aCUHxHK4ucmstDWqort53wn+LFHOiIN5vua4/8 1CAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=STWGDOJU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id i1-20020a170902c28100b001cf817b01d2si12282496pld.277.2023.11.28.15.46.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 15:46:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=STWGDOJU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 46623807833E; Tue, 28 Nov 2023 15:45:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229816AbjK1XpS (ORCPT + 99 others); Tue, 28 Nov 2023 18:45:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229543AbjK1XpR (ORCPT ); Tue, 28 Nov 2023 18:45:17 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE0341727 for ; Tue, 28 Nov 2023 15:45:23 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A00EC433C8 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-f42.google.com with SMTP id 98e67ed59e1d1-285be6134ecso2370405a91.2 for ; Tue, 28 Nov 2023 15:45:23 -0800 (PST) X-Gm-Message-State: AOJu0YwWOrTupCFyQ5AzvT+TFC7Xc+rO0GcDM9c1kZ9bkhBBe0na1xfZ TckW8slLcPHR92DZ9t37//XQcnLCMaDMq8i7l4inzg== 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-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 28 Nov 2023 15:45:36 -0800 (PST) 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