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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 927CCE7C4E1 for ; Wed, 4 Oct 2023 16:19:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243348AbjJDQTS (ORCPT ); Wed, 4 Oct 2023 12:19:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243333AbjJDQTM (ORCPT ); Wed, 4 Oct 2023 12:19:12 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77C8AF1 for ; Wed, 4 Oct 2023 09:19:08 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BD17C433CA; Wed, 4 Oct 2023 16:18:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1696436348; bh=5YCSUKis0P5pMUCSTy8MQPFGAhbMIzReSfUh9/11U3o=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=mlU6hD5lL7ftnBxbxSbvDTrDTX7oWQsdqm4XXjIXKuLcfZ7O4e8TxUONMIg3T2pMg TDgwfWWHKHMMVuSOp2uvxJ2ypKkRs+anqw2pwCyd8I3oHZDqgT6d9nObBfjQprIStN L0Xhxj1gYSjldhBX2CAKV+lfF7MThHLQgJXLS2QE= Date: Wed, 4 Oct 2023 09:18:53 -0700 From: Andrew Morton To: Liu Shixin Cc: Yosry Ahmed , Huang Ying , Sachin Sant , Michal Hocko , Johannes Weiner , Kefeng Wang , , Subject: Re: [PATCH v6] mm: vmscan: try to reclaim swapcache pages if no swap space Message-Id: <20231004091853.9be5aa562f65e0305e06b14c@linux-foundation.org> In-Reply-To: <20230915083417.3190512-1-liushixin2@huawei.com> References: <20230915083417.3190512-1-liushixin2@huawei.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 15 Sep 2023 16:34:17 +0800 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]. > > By the way, since there are enough times of memory reclaim before OOM, it > is not need to isolate too much swapcache pages in one times. > mhocko earlier suspected this might impact global reclaim. Have you looked into that further?