Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp810248rdb; Fri, 6 Oct 2023 23:26:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEcohWxu39Lv9zA53h/p3dm4rhkOaBMAp1qYWP5WjWiGuPRqZTuuTfnr77lndR5ACeLqUfq X-Received: by 2002:a0d:d788:0:b0:595:80be:fc6b with SMTP id z130-20020a0dd788000000b0059580befc6bmr10132557ywd.18.1696660013775; Fri, 06 Oct 2023 23:26:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696660013; cv=none; d=google.com; s=arc-20160816; b=k3mq7T3Ba9oWsLCaWOsJkF9h5XxXteoF/g5A9iJPFutsXqij88ACsB5GqvwDvqmEs+ UDNQX+Hz75yrt/fAtJePLWrUYjn0xF2QmKpmDf1q+Z0K7s7o4knNI+piw5jAE5UtATQy XToRgkYXR/XnwdigVTcabTSnZqYq4pbt2kxFbT036lsJN+/6hTIGykvToGbw+3M1fNlC el3g25erQ+s8NwZ0205Nly0Vcz05FrjbPSqVtJixDE5pKoSLy4CzCWK/wMLhOL5y0N0x xdKqE2+nXuvsoPx78h35O2ql9yIhGK4aZWCXTgW2ssmdZGD/KQV6XwEj3IOP8+r1ZWUG a/3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=XZOnzZI1c8ACAXaMzxy6mYOWVKJJB59fma6i0V4RrCc=; fh=NfPIWFaFWWZNPZAfL8rva19J9HVkPT7BTsx3ObqdJ2A=; b=Ce4nv67dPLlPH3MSbq1bJP3ccu6OpWy1aQGCdhQNpCbhb5HW1JHVuTn7456k20genK //ew/oS9WVXdO5FnjZgNDcf1jmM4da8yD3ZiRFIqCexbGyZy8+r/r/vIOJyKu01ATgls fI3kPWOwBoMIJ4YzlB1nGA59VY5f6m2vxqnCEUxjTH9WfJeZ4MEwxHsYJ8YpziDiwP/V AhdmKWjq9EkvHA6PVtKsj5XgsgA8nBB+JA+Rv0qSkYeLknYhGgMpqh/BmS2gZ7oFtCeD I9wehbX2TjFCViHbOWjmcd6VlqZyIi6Ys1XPyN7GhadTi7KMTfk/cSfADM86t9GFfHx4 XUoQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id 9-20020a630f49000000b0057744d09d2fsi5357642pgp.18.2023.10.06.23.26.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 23:26:53 -0700 (PDT) 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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 689418038F85; Fri, 6 Oct 2023 23:26:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343532AbjJGG0k (ORCPT + 99 others); Sat, 7 Oct 2023 02:26:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343551AbjJGG0i (ORCPT ); Sat, 7 Oct 2023 02:26:38 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C1ACC5 for ; Fri, 6 Oct 2023 23:26:36 -0700 (PDT) Received: from dggpemm500009.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4S2ZvY0h7RztTQg; Sat, 7 Oct 2023 14:22:01 +0800 (CST) Received: from [10.174.179.24] (10.174.179.24) by dggpemm500009.china.huawei.com (7.185.36.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Sat, 7 Oct 2023 14:26:33 +0800 Subject: Re: [PATCH v6] mm: vmscan: try to reclaim swapcache pages if no swap space To: Andrew Morton References: <20230915083417.3190512-1-liushixin2@huawei.com> <20231004091853.9be5aa562f65e0305e06b14c@linux-foundation.org> CC: Yosry Ahmed , Huang Ying , Sachin Sant , Michal Hocko , Johannes Weiner , Kefeng Wang , , From: Liu Shixin Message-ID: <38420ca8-9c83-bb06-041f-ce1cf1f084ef@huawei.com> Date: Sat, 7 Oct 2023 14:26:32 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20231004091853.9be5aa562f65e0305e06b14c@linux-foundation.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.24] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500009.china.huawei.com (7.185.36.225) X-CFilter-Loop: Reflected X-Spam-Status: No, score=0.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS 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]); Fri, 06 Oct 2023 23:26:51 -0700 (PDT) On 2023/10/5 0:18, Andrew Morton wrote: > 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? > . Alreadly test the case of global reclaim using ltp testcases. In previous version, the reclaim can stall in isolate_lru_folios() because I didn't count non-swapcache pages into scan so it will waste too much times scanning non-swapcache pages. In this version, I count non-swapcache pages into scan too and terminate when scan reaches the threshold. So it will not stall in reclaim now.