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 20311C4167B for ; Wed, 29 Nov 2023 10:17:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 97C456B03BC; Wed, 29 Nov 2023 05:17:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 905906B03BF; Wed, 29 Nov 2023 05:17:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7CE816B03C0; Wed, 29 Nov 2023 05:17:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 69F056B03BC for ; Wed, 29 Nov 2023 05:17:39 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 39876140357 for ; Wed, 29 Nov 2023 10:17:39 +0000 (UTC) X-FDA: 81510590238.15.C1DDFC7 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf22.hostedemail.com (Postfix) with ESMTP id E812CC000A for ; Wed, 29 Nov 2023 10:17:36 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf22.hostedemail.com: domain of mhocko@suse.com designates 195.135.223.130 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701253057; a=rsa-sha256; cv=none; b=LkEzbUOM4kKZnCQV3ShysYwOiy/So7RPY+q8nwYEf7/aR8/c9ma+KxHw5ONjnLOuJsSOXu QmEh6BWIE/Uq3k08OmXSLCYA9+d+jMhPlyuMn4oxk9QGXpgerbgUSgyk3M0BJKu/r6ln4b 4uyvYVOIT35lERvrpQpBeZzybdSSSnE= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf22.hostedemail.com: domain of mhocko@suse.com designates 195.135.223.130 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701253057; 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; bh=r0ZNSSdiuhPZJjrQJc/XZpJco19dhpkd07gQ54Kh9OI=; b=Wm1DS92Ivw8x6LglTiclWjUDUQ7neXOJJ7B/rtMu1aireW6i/7CS8L6LHaad1DcaWHMn8h d7ZYd3Aan8/I6qoF/eIoC7bHzDrI00XE0XsqGt01VxVySbwTtDo79vuVz40K2yr8kiEj6D +MKVncsP4z7jXXI6R+ZtL3rd8oly5T8= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 00A7221999; Wed, 29 Nov 2023 10:17:35 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id C003B1388B; Wed, 29 Nov 2023 10:17:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id G8u2Kr4PZ2UnBgAAD6G6ig (envelope-from ); Wed, 29 Nov 2023 10:17:34 +0000 Date: Wed, 29 Nov 2023 11:17:29 +0100 From: Michal Hocko To: Minchan Kim Cc: Yosry Ahmed , "Huang, Ying" , Liu Shixin , Yu Zhao , Andrew Morton , Sachin Sant , Johannes Weiner , Kefeng Wang , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v10] mm: vmscan: try to reclaim swapcache pages if no swap space Message-ID: References: <87msv58068.fsf@yhuang6-desk2.ccr.corp.intel.com> <87h6l77wl5.fsf@yhuang6-desk2.ccr.corp.intel.com> <87r0ka64v9.fsf@yhuang6-desk2.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spamd-Bar: +++++++++++++++ X-Spam: Yes X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: E812CC000A X-Stat-Signature: 18856efuykzuqf4qcdtda3hynxhrukdn X-Rspam-User: X-HE-Tag: 1701253056-196112 X-HE-Meta: U2FsdGVkX1/kkC5sEYw48w2IA8fNnsiZasHCyX7hflYgcKtCX+BCalj55NFrgCG1faVZGBwdsnC2ttT8QRznTVrNEstVGX9ylMO3kCTXGlUnAapuG+Znzo2stLWsZUH7NnSbkXOMZcxnPN/K+AVYrzgGOpVu7p40/5axNhrrYRuRnG4cE5GnOUq2gRFqiQg6hZXjwduFu6q/i+Lg0+J7FrZe/lH1qNQH1FcK526s4yhgefHns+ZJCTUwrue4pLHt60ZfQkTChnFycvNXLrW3AfI5epKh8p0zEM47hmH2xaX9mNE1VDmDCGXFUzMlyeZuZy/pQe3W473oEtpCx1NO7fROGw5x2Z4tor3CoiPnkzNWgdOhsXqOAxhKnSOWQm3rhY+I6yuaqvknTHwznrsn5cHkchIOUlmeiBlHGrPuySeZUhABnCV1BE5OIVOLbY321DAxTbpqDig8cjvxDCPqYpA6OrVbEnTu1x7uJcfc9ZlXxX05hY9FOaqMMH8S+tLNF8vgDGJ33etgp+BpISzjM0k10l92R/xgrZQiKnP38hcKwkt69Cixb+mVOc5RhowqGa065cGunkRMN3x0PTe7yrkMs2w9uPIP5+cGV5+oSYWHoSjb/f5Gbk7o2MRvhquhnak43BvayDe6ZYsxy9dTHsh67Qb9gHUqedMTzQZjqhhyKnxGp6xwO1GFv1b8gmPI54wuPsAl91Bddxyv0fG5QfoU5cYWSz/y0W3irX38/1R2qNGry/Yr13wh8vV8VNdixd1DZswAt16KDltpBbDfoUOQnaBu9//EI92T/5DnTAfAl3MMc4awav9YSqFZc97OeNJVGQoRtfBBwIyM+zZlHg1+BwpiONGwpG+wkBDLOdzXbPsqK52pLYFMI1q6ZctYKhF/WBAz4VM9vqsSOXix7EIENSamydtTadhtvBSfxrFMuLhxzpGP6XwJGr4zb6fNkvpD3k+mkMeTV+SMuIb VjH0qaAW eIGhVIONBngschkFoEbAn9E/0d9gRbbfHn4pSf5M0DRCxt7IRmvLfyCVtI3UvzKCO56ue6U6vuYWaA/MiYuEEBMIWFeE5b5+Gs7J0HPocxtlLyO0wFmkus5L5yX+gXUw6h1PaFY36BCG2iWDK/z4PjuUWLdjhyKFrFGrDShhvD7BnMs81FGCsYCWGVr5++/SoHBXLIotCWXy5fpFq/T/shGDU4+p3tN/rIwuGrdhLY2UAZX5WYryXAb1OzUs0wfUqCOs4OSooZXYsvNFZrJ1zu2/CldrIR1Lyn7ZY 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 Tue 28-11-23 15:15:08, Minchan Kim wrote: > On Tue, Nov 28, 2023 at 03:05:29PM -0800, Yosry Ahmed wrote: > > On Tue, Nov 28, 2023 at 2:45 PM Minchan Kim wrote: > > > > > > On Tue, Nov 28, 2023 at 11:16:04AM +0100, Michal Hocko wrote: > > > > On Tue 28-11-23 09:31:06, Huang, Ying wrote: > > > > > Michal Hocko writes: > > > > [...] > > > > > > Right. On the other hand we could be more aggressive when dropping the > > > > > > swapcache. Is there any actual reason why we cannot try to folio_free_swap > > > > > > even when mem_cgroup_swap_full == F? > > > > > > > > > > If there are plenty free space in swap device, why not take advantage of > > > > > it? > > > > > > > > Maybe a stupid question but what is the advantage of keeping around in > > > > the swap cache? > > > > > > If the page is shared, we avoids addtional IO to bring them back so > > > swap cache. > > > > I think this case is actually necessary for correctness, not just to > > avoid additional IO. Otherwise subsequent swapins will create new > > copies of the page, right? > > I think if the page was shared by MAP_SHARED, then, yes. In that case deleting from the swap cache would fail because there are still swapped out ptes, no? > I think if the page was shared by MAP_PRIVATE but CoW(e.g., fork), then, no. OK, but we are talking about a memory pressure here and evicting available memory. So what is the actual cost benefit model here? Is it really better to keep swapcache around even under memory pressure if the CoWed page could never be faulted in? -- Michal Hocko SUSE Labs