Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4468679rdh; Wed, 29 Nov 2023 02:18:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyk1Uh1iu2p1N7NIjDy8adGE13VlQhtuL9Wo59C2OMRzrQh5+36Hpmf/InIc/N0qZC+O3z X-Received: by 2002:a17:902:9f87:b0:1cc:4e46:3e45 with SMTP id g7-20020a1709029f8700b001cc4e463e45mr18878935plq.49.1701253093743; Wed, 29 Nov 2023 02:18:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701253093; cv=none; d=google.com; s=arc-20160816; b=KI5B3MXoG9io+Z7qQp1m1FvpdtmIyoxu7s6hX8Cz89nzWhz7J/xnuJWFw/Mhwt0bRs LIfxsUhNd+ryLM8jhLTDS+J/IOA5NBLGsRgchbpCRhouu7mnoKaz5xx/3onn0eknI7Nf 3zWlXLNJD1hhq7N+NGgGruBuRTeVHc4Iy2nGt+cNstd4Mw5AHf34lDC0zK+DcbJ087W6 lMlaMevtt/BSC9g1uh6LfFzDVLtz6bXl1W9pZUu2gVhRLU9MWNSxfUA5MAaTlnXkBARW WPplc0F76KtJe+0tvkK5PCTruY+AWZSrnCxos2MNeQDw5j9oR4xwovPeycmP73mYQzd/ 4NlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=r0ZNSSdiuhPZJjrQJc/XZpJco19dhpkd07gQ54Kh9OI=; fh=SIK4Wv9aEAc1wd6c80VfHzLbpUWayQPivgvg/7T33W8=; b=Fu17pgKBj0cr6sZDZKkq993p58b+Ku6lhOC32gJieVgVC73t7E4JeTAxjKUsMas++Y C4VW/3a8n2f1/nc9qgE/IMgSqTDL0+5dqI+J9E/kYr5yE4VSGBMqb6n4v1PpIHRUgPt0 uyu9XGaFzh12e9ne6IDdXSQu60QWT2599d4w74lqLpczS8LXujHa8+mgs/iztk2z44GK ZRWZH9Zr0hpCyyaLfzRjfEJ/PYWYfkfOdADNlsssO8j45CF4JNNfPkG7lnJtjaCofj6Z reNyduPqLDbMg4BjS91KYZXAo4Ii1p4nh0X/OBOkitdo/bsTTM0rRrvbncXQo+pG6r2k WZPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id iz13-20020a170902ef8d00b001ca96a6eefesi13707117plb.577.2023.11.29.02.18.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 02:18:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 3EE5B80966CF; Wed, 29 Nov 2023 02:18:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232839AbjK2KRj (ORCPT + 99 others); Wed, 29 Nov 2023 05:17:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232895AbjK2KRf (ORCPT ); Wed, 29 Nov 2023 05:17:35 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86B2C1BC6 for ; Wed, 29 Nov 2023 02:17:36 -0800 (PST) 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-Score: 15.00 X-Rspamd-Server: rspamd1 Authentication-Results: smtp-out1.suse.de; dkim=none; spf=fail (smtp-out1.suse.de: domain of mhocko@suse.com does not designate 2a07:de40:b281:104:10:150:64:97 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=suse.com (policy=quarantine) X-Rspamd-Queue-Id: 00A7221999 X-Spamd-Result: default: False [15.00 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_FAIL(1.00)[-all]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MID_RHS_NOT_FQDN(0.50)[]; DMARC_POLICY_QUARANTINE(1.50)[suse.com : No valid SPF, No valid DKIM,quarantine]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_THREE(0.00)[3]; MX_GOOD(-0.01)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[11]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(2.20)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam: Yes X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, 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 howler.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 (howler.vger.email [0.0.0.0]); Wed, 29 Nov 2023 02:18:11 -0800 (PST) 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