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 5C835C4167B for ; Mon, 27 Nov 2023 21:57:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D9C7E6B029D; Mon, 27 Nov 2023 16:57:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D252E6B02AD; Mon, 27 Nov 2023 16:57:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC58A6B02DB; Mon, 27 Nov 2023 16:57:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A73F06B029D for ; Mon, 27 Nov 2023 16:57:05 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 79535A05F7 for ; Mon, 27 Nov 2023 21:57:05 +0000 (UTC) X-FDA: 81505095210.01.FE15E0C Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) by imf29.hostedemail.com (Postfix) with ESMTP id AAA53120015 for ; Mon, 27 Nov 2023 21:57:03 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=v5vzAMo0; spf=pass (imf29.hostedemail.com: domain of yosryahmed@google.com designates 209.85.208.54 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701122223; 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=m0MzoXczE2pvdHgF1zgI5abaXqlolYZSijKABG1fsdo=; b=F5LJ3dr1ZTjF+Zi6h+fn6HruIyV6HDf+FnQ7QeW8GS4oCcpN7ARKm4RjhI8IAtKoOvVZ3n TitF+LnP3h8n5+eHKltBFo69Ms+9zegIbQnQrO1bKvLJuQCq+AzBTnn6dHerP2vfBmJtDf wHL2KHPA1t/9MZuIlDeCjrgcYcjVWu4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701122223; a=rsa-sha256; cv=none; b=j1aR1/EUM90dFBZOtlv4jTGzQcmJWcNmsqXK6xrzvGQHeBH/2p33Fg8rnsN3GbwniDryAQ F/TEA6ZOvTk9dQ6ntmMXplvG3isjCRjwu6zM9MaT/ipEgRT/UEIxhzL86rJn/skzCon0V7 +yrRWlIHMebouqQmmTFE4znaHtKsupw= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=v5vzAMo0; spf=pass (imf29.hostedemail.com: domain of yosryahmed@google.com designates 209.85.208.54 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-54acdd65c88so4859453a12.2 for ; Mon, 27 Nov 2023 13:57:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701122222; x=1701727022; 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=m0MzoXczE2pvdHgF1zgI5abaXqlolYZSijKABG1fsdo=; b=v5vzAMo0hy2YCBfBJeAip0argysIr3yJUn8571+gf9ihz02lRVjS3hmFgm9xMIz8GI 80ImnUbhLqrHq+ErRjxWTG0LhMZueIo29hL1ao29mfJ0s9j7XDpSRSpNJw4x35JJV2ts qUZ7PYTSNisuuxX6CU3vCJX9EWwY/hpADlCh6wsbD3Yd+ejX9333OKsgSEkpEXJD9HF5 4V4Yaeds4l0kevXmxs8gp1RDWND6hCqrq/Nlo8rDLPmJicFSnTJLWORl3LQQfItTpCRN m5bgT/uN6risOw0nX7A14SqCah32do+OjGpDBofu9iF7Uy1se4qJlF76ConSrD6sbf7S m6Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701122222; x=1701727022; 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=m0MzoXczE2pvdHgF1zgI5abaXqlolYZSijKABG1fsdo=; b=hicq126o8Glaj3pTU2Z4og9cffmhOTNqTzkE7K/2FHWEdzmkcn12eG/t/VPfSvivIn oaWjCRLK25P+LgQVZ7gin/i5nYWHu7R0kkWhXsZAgXBAYTK2FIL36wgOVCfvleZbbnP/ XRvpeZE+jlYOAW/k8h3O41jr1iukwqdE/LMXiMAQIzqBFRy1m2g1jQBv6JWdC+46C3ll +F8ReXC20KPv12Rv6nn3VmgTvbUhXjdjl3pEF7tGRo73UV9VTsg31cJaLSDivr0xJLc0 Xo4X0r/5DmvUTq1METMwC82ud19VtWzCHBGhOi7CoxeyXwjxMEaP27Ku4jAg6/TbZyBC Vc7A== X-Gm-Message-State: AOJu0Yyn2kNaySg/nYmyY2cQLxwxLXtakhZoxwqvBklfKZEqcktyPtLZ OyLmRKi90njDAQOlEri9pL1Ev+/5zV7FW72x64CYLg== X-Google-Smtp-Source: AGHT+IFT8GxbfU4ZjoWoqPk91lBLeABCByto7q81DYaCAPE6XdtZ49BCKB7mSrmDLBE/kVkErqEaO1yWce9SgUqIchQ= X-Received: by 2002:a17:906:1083:b0:a09:e7bf:127a with SMTP id u3-20020a170906108300b00a09e7bf127amr7840196eju.67.1701122222013; Mon, 27 Nov 2023 13:57:02 -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: Yosry Ahmed Date: Mon, 27 Nov 2023 13:56:26 -0800 Message-ID: Subject: Re: [PATCH v10] mm: vmscan: try to reclaim swapcache pages if no swap space To: Minchan Kim Cc: Chris Li , "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-Id: AAA53120015 X-Rspam-User: X-Stat-Signature: fhxmnpqs57ej4ii46f9y5bwtzer4h5jb X-Rspamd-Server: rspam03 X-HE-Tag: 1701122223-74178 X-HE-Meta: U2FsdGVkX1955GRhAKWZKLaDv8cO1gH83m6L3W9FKde/v/HR7K/doNqv356TjRuBQ9PeL3Av4pkaLUl2MT7vK1Iq1G+rRK0getCe/PeCZPFLC/HPCqEjfQVDYOLQhsL+WdKLsYmwdaaihICUg/xt1/sMgup8S3wDxYPt8LiIJtTiLNd/bxkf0LYlW55ot4u43kLVV7f8jJeWqNhC6+p8uHAf0/rSvtV5Oli8RIPJwRSPvXpA8/9FTpimCiG5MlctVnUps35cXeJovuNB/6ovLZ+qC4tUM1f+iNcvGxfN9GICe0HFBWwkQHfIElrr9IZoQP050tcT+74/eSCBb5FTUNfAssTOGUrsA3dIjZ7U78VpVceVl/lwQ7l1P0IKFzrVBjfaDjnbhl9/N+QtDTJ9fTP11izI+dRk75Tf4IQaIy84VDZG8sfxMSr/REsV5GmoB0qwmMynBxm5GD6CdOhe1EUqiFkC8UqUF6lAwlM+P5Kef6SNQaNEzuH94G99wbxWJhZt89BHgeLh2160H9EG3A14JK5FyQamIqvFqFmyn1XkCTI1aaSayNeSvtAaGzE8OjzF8i7DviX6w9A/CSEPGnFiJjmajRVPdsfAeKB6QZc0hSF0oYe+n1T4Lb94MoMJHng4jKlpANxdQFBsV/+bvHYFc3BFiOofnSMdLo8HB8Xk/93itpjeyHHzhFKjAqasyoo7+nRB2Rklj1bqkvX6erVfbmSYDhhbYizMQ3pEwgEAj+bl7m4HQ/nO21hW7+cCBy+EIRSay4oGylkJ42yWyUNTkFcBYhMnVL20nI+GiBO3TI0Od26NIBSTw0GfkA58nMyYO1PFQLbmpMAhXRKSywwOnQ2nDVQZS8ezanDNIsyvIuWWa1VbsaPmqS/WHwLnBKISlHIb4NJ6S49wseoCo1zlkEJeGNxk0xYjs9GQ8U4fw/nDmjqfrCR7AVC0YSQiLBN1z+twasbr0l+t2s5 Ar4AZY2V xp1wDpBuGmXEHDataxmYjmJ0QoOpL1YAlNdV731O3T7AEPWy+O3VM91FJRHf7nnMmdMJbHg3cemBV7OrZZWR93Yz70Mf+On9OXas6870+YkrYyrBje2Z9+RVdIVuDYt3awg7bkagEX+dbqvp4ZrE+RLSOPqQCHnZD3Qsd3zM4M6BA7f35AKBoUXlhElzOgBWzn7Qjb1F9+RaH2baz66OYNzOpE9WL+NgJc6J/KWSvct6FxHv8XR7rY/u5Mc0QDqOo27hOze2yhGXL+0EIZQAIUeRLemMnM7FS2uy6eb34e9WRQt6xR3+tC7KZTw== 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:32=E2=80=AFPM Minchan Kim wr= ote: > > On Mon, Nov 27, 2023 at 12:22:59AM -0800, Chris Li wrote: > > On Mon, Nov 27, 2023 at 12:14=E2=80=AFAM Huang, Ying wrote: > > > > I agree with Ying that anonymous pages typically have different pa= ge > > > > access patterns than file pages, so we might want to treat them > > > > differently to reclaim them effectively. > > > > One random idea: > > > > How about we put the anonymous page in a swap cache in a different = LRU > > > > than the rest of the anonymous pages. Then shrinking against those > > > > pages in the swap cache would be more effective.Instead of having > > > > [anon, file] LRU, now we have [anon not in swap cache, anon in swap > > > > cache, file] LRU > > > > > > I don't think that it is necessary. The patch is only for a special = use > > > case. Where the swap device is used up while some pages are in swap > > > cache. The patch will kill performance, but it is used to avoid OOM > > > only, not to improve performance. Per my understanding, we will not = use > > > up swap device space in most cases. This may be true for ZRAM, but w= ill > > > we keep pages in swap cache for long when we use ZRAM? > > > > I ask the question regarding how many pages can be freed by this patch > > in this email thread as well, but haven't got the answer from the > > author yet. That is one important aspect to evaluate how valuable is > > that patch. > > 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. 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? > > > Regarding running out of swap space. That is a good point, in server > > workload we don't typically run out of swap device space anyway. > > > > Android uses ZRAM, the story might be different. Adding Minchan here. > > Swap is usually almost full in Android since it compacts(i.e., swapout) > background apps aggressively.