Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2718147rdb; Wed, 4 Oct 2023 09:20:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0ejhEVuMuyv0nJg9c4J7qh1ZmmN1mSAgQBVr8pQcax5NBFPevTD0OLE8Op50RNXgy9NFk X-Received: by 2002:a05:6a00:cd6:b0:68e:380c:6b13 with SMTP id b22-20020a056a000cd600b0068e380c6b13mr3290485pfv.15.1696436433671; Wed, 04 Oct 2023 09:20:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696436433; cv=none; d=google.com; s=arc-20160816; b=IdctQYhdh4v3XtD3M4wvGT5aUzYmrK/ls4CD3mRkpGynxvPtUheOlUSGhocDasqE0a NQzE1OqxIjliCzU12tLc1wvcaxeq34pMKWHwYDLgg9Pf8kr2b/IICVwA0rddYgdrciEF L8Oae4MZZ5ZjWVnKyjanozJdNoofTBn1pPabWEDUmgDF3cJhZ59a7OnvoxOMy7H52eV5 2mA9hfDUMQm47xzAn5UX3tYD1JrJopu3PHlhOybU2otDJyU2+1TOtZ/IT3L204OcMNGG gczS976wov7Nywm7rF6vx9SsDTEv0xbO1qwWUiELh6edsCdo09Azx9/B0sPY5/S8EOAJ GNyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=/Oa/g6o6hT7IwnhpQvRzhwAyPVyeHnwivKwouITERmw=; fh=2M2sE0dfW+zAL6I4Y1UXYpaHba7RLo163nxRoo84MpU=; b=A11VCo/1skM42tPB0O7Fj1C/yA8ildzrYA/YPMWYjkPu5rARpm5uVulkSGMgP9dznJ D2i7RLiVDRq9lBkYRwUjkqA2/b3rHVQz3j90+qm4ssddsBoXy76/6i/eF951kHDmg88d 2ld0kNJQ6inRLC8iuik5yvF5cHOMQ2IHEAM5WbhvyftacMQZM6cuXgDFFtM3A8LJKNKh oNMD9pfYe6BwoyM1Zg3RF5Inx+MwvVs9ruYpUnCUz5oNJxCLJ75E7BqhH/Yp7nDthujy 797uMQPHDOBmM1kfJls6RAnI7X9tyoNJ7pyPiXEzq1bGZzaSCd8t5fOdUGcTEfgSfV0D 7GQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=mlU6hD5l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id k70-20020a633d49000000b00578e6f108c6si4065511pga.173.2023.10.04.09.20.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 09:20:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=mlU6hD5l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id A458E81A8AB4; Wed, 4 Oct 2023 09:20:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243359AbjJDQTR (ORCPT + 99 others); Wed, 4 Oct 2023 12:19:17 -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 X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Wed, 04 Oct 2023 09:20:12 -0700 (PDT) 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?