Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp360609rdf; Tue, 21 Nov 2023 05:02:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IGKlj2SW5l37WghJ0tKfjQduLNrxuOVUJDs2s5lQIuzXVAvchijenkdObdE2pVnZNAQsGct X-Received: by 2002:a05:6602:d1:b0:7b3:4b1a:e414 with SMTP id z17-20020a05660200d100b007b34b1ae414mr1194985ioe.11.1700571747343; Tue, 21 Nov 2023 05:02:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700571747; cv=none; d=google.com; s=arc-20160816; b=mRp7EF/WUwuuKSND4svmfyoiSYVjIbxyh2OwQSTiAd/IiJsVp+2bHkNoSz4sfDJRfH MMlXiHjkJUr3peOHqQCilIBrhw1q28qrjgzi4DIettzvaj6P9aSfKcxWrpbntrRUGkiL qMnVQVQtNepIZ1AL+FZy22zEc2xPiuM/Xa2KzTU5Enyov/W1dJVumLn+rBKLdFloS5kd shzuVs2YHlsyw6J1Pybe5nwxtorUrkpVVWrBf9i2Tg7BPXPtMqqPr70nGj/3xa8sd7qy AjQY3xvRJvRPVbG5DFiDCGh7P/b16w+ZrbhSkEPMHCGxGFqAFS2ol0X2rUfNLjBppLpf b+sQ== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ENH/10FZxHe1EFz0Z49wUOO+GPWUvmASlOlk4QldG+8=; fh=geKZnyuh6hDW0V37m/V0CiXTeJBJEfcYKwobjbpoCic=; b=zE79DjsC4bdTB47+eJ01IhhCMbCDfEbWjAoft/bvVHT/rxRthOKs5mqt1i8IOSKMpB jl/q8kmbTq1G5HLc6sYZDhvebNQYpGBxNxkZn2ERmA14cd5/EOgJt8XyuFqQvMNvNWR1 z7dZLvT6aemuAYZ1RM0tWva0u/ctk2sGJxnh1si9gsPK6dMSV6DrH4UmkBgc1BPe9vtc TNxXbvgZ//xEQwMAry79GYrQ0cn7Qf9gz/dkuIpirP1p1J2qPb5oSWK9Biae9t1xPxqM BM0TRERf80QE3eRyOka2h3VAjlPRCba0SjJlXVfYFcQ0SUcS0F+FmRrJMR7RWy2Ueku2 ZLUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=rYdiJfgl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id f6-20020a056638168600b0046412121480si4341867jat.0.2023.11.21.05.02.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 05:02:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=rYdiJfgl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (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 lipwig.vger.email (Postfix) with ESMTP id EFEC480737FD; Tue, 21 Nov 2023 05:00:54 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233739AbjKUNA2 (ORCPT + 99 others); Tue, 21 Nov 2023 08:00:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233613AbjKUNA1 (ORCPT ); Tue, 21 Nov 2023 08:00:27 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40A931BB for ; Tue, 21 Nov 2023 05:00:23 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id F2CF52192D; Tue, 21 Nov 2023 13:00:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1700571622; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ENH/10FZxHe1EFz0Z49wUOO+GPWUvmASlOlk4QldG+8=; b=rYdiJfglM2lxJkg5FvmnBmTB9K+CeB2vdLdsXpcRxh2qr/bixeKfsWAqNPzCtE8tOabYr5 op3ugt38ztywBKOM6/mBpAkFAVgHEHPulCGNMDWI0zyqvez++Y+/PCu2crL6BIAcdbx+Cm ejaViwHbrGGWHZN1x8dTv5NguMxLv20= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C599E139FD; Tue, 21 Nov 2023 13:00:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id nqMrLeWpXGVkIgAAMHmgww (envelope-from ); Tue, 21 Nov 2023 13:00:21 +0000 Date: Tue, 21 Nov 2023 14:00:21 +0100 From: Michal Hocko To: Liu Shixin Cc: Yu Zhao , Andrew Morton , Yosry Ahmed , Huang Ying , 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: <20231121090624.1814733-1-liushixin2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231121090624.1814733-1-liushixin2@huawei.com> Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -1.60 X-Spamd-Result: default: False [-1.60 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(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]; NEURAL_SPAM_SHORT(3.00)[1.000]; REPLY(-4.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_SEVEN(0.00)[10]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[16.91%] X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Tue, 21 Nov 2023 05:00:55 -0800 (PST) On Tue 21-11-23 17:06:24, Liu Shixin wrote: > When spaces of swap devices are exhausted, only file pages can be > reclaimed. But there are still some swapcache pages in anon lru list. > This can lead to a premature out-of-memory. > > The problem is found with such step: > > Firstly, set a 9MB disk swap space, then create a cgroup with 10MB > memory limit, then runs an program to allocates about 15MB memory. > > The problem occurs occasionally, which may need about 100 times [1]. > > Fix it by checking number of swapcache pages in can_reclaim_anon_pages(). > If the number is not zero, return true and set swapcache_only to 1. > When scan anon lru list in swapcache_only mode, non-swapcache pages will > be skipped to isolate in order to accelerate reclaim efficiency. > > However, in swapcache_only mode, the scan count still increased when scan > non-swapcache pages because there are large number of non-swapcache pages > and rare swapcache pages in swapcache_only mode, and if the non-swapcache > is skipped and do not count, the scan of pages in isolate_lru_folios() can > eventually lead to hung task, just as Sachin reported [2]. I find this paragraph really confusing! I guess what you meant to say is that a real swapcache_only is problematic because it can end up not making any progress, correct? AFAIU you have addressed that problem by making swapcache_only anon LRU specific, right? That would be certainly more robust as you can still reclaim from file LRUs. I cannot say I like that because swapcache_only is a bit confusing and I do not think we want to grow more special purpose reclaim types. Would it be possible/reasonable to instead put swapcache pages on the file LRU instead? -- Michal Hocko SUSE Labs