From patchwork Wed Apr 19 05:40:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhaoyang.huang" X-Patchwork-Id: 85194 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp140369vqo; Tue, 18 Apr 2023 23:08:52 -0700 (PDT) X-Google-Smtp-Source: AKy350Yuz2jG3zqkiaFfJKu2kUqDVwQSgoRO0UACwKZmKtTc2V+6yZJ5FRlVN4VyjrpcpJITZ9bC X-Received: by 2002:a17:903:294c:b0:1a3:cd4c:8d08 with SMTP id li12-20020a170903294c00b001a3cd4c8d08mr3724286plb.38.1681884532289; Tue, 18 Apr 2023 23:08:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681884532; cv=none; d=google.com; s=arc-20160816; b=dn0M9VBtEiPFtzUFpuwSTTCTFItl9Br8dby2k+BB4XZGXtPRz9mscFvm1+n95SWOBO 54It+3O1AN7PfR/9vIwTYJ8wB6JRGsZNOUPce3zcevWfF0IJrIdeMgGdodDeeC2azuTQ cvjPC2bZ9+I01/1ttrT/P4jgVv/+GatyuPjRO+OJugn/TPc1sAz8tCgFkMJPqVOvQnw1 ipO534yE4xkKNEf/tnsgvHUmfEmPPipCQtfmaKjG/myxx3WqLgDjzK+vXP5gIt9eAgcN 9PLen1ggH0ED2OHh3foW/rFUH50SPll8iFfdiO/WEShB4xbbqbdCoFc4iLKyuPCDxrB6 RfzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:to:from; bh=3A5YzfJ4b/LcfKEwz4Fg8Q32Ha/hdTNa3JTjajnUYVc=; b=emHanqY2vbfXiTvB0hyd9X6zToTya9cDsjEeSSdCRzUWFdebXw5rF8vg2loK+qLu95 JQVzWWtRy67CqC5OD4hvfJG3pJb3chmzIegUvBp8d/xpeFYWvdjyEBZVuNjU5TtGi3EG PiS9vZGScWPyAnFT2p2DrAOXApDc4LcEXh0It0KQGxpv9FoxsI0VPGWsckS35HBbKibg bwwlZMkFkkpgUBcVBr8W9d0QnVCcgCyNFwktdWM9KC8C+Q2fjhIQV/oSq8hqvGwSW0JH hHWJzqU72O64hJqTw5g1nziJ8iCE3MvMTjw9QhzVUeEgQXIFlnWFLpHtKdO05FmQbJR7 /gXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w20-20020a1709027b9400b001a1edb957absi14732460pll.123.2023.04.18.23.08.38; Tue, 18 Apr 2023 23:08:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231577AbjDSFmf (ORCPT + 99 others); Wed, 19 Apr 2023 01:42:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229633AbjDSFmb (ORCPT ); Wed, 19 Apr 2023 01:42:31 -0400 Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C16E440E7 for ; Tue, 18 Apr 2023 22:42:25 -0700 (PDT) Received: from SHSend.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by SHSQR01.spreadtrum.com with ESMTP id 33J5ed12070031; Wed, 19 Apr 2023 13:40:39 +0800 (+08) (envelope-from zhaoyang.huang@unisoc.com) Received: from bj03382pcu.spreadtrum.com (10.0.74.65) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Wed, 19 Apr 2023 13:40:39 +0800 From: "zhaoyang.huang" To: Andrew Morton , , , Zhaoyang Huang , Subject: [PATCH] mm: skip CMA pages when they are not available Date: Wed, 19 Apr 2023 13:40:24 +0800 Message-ID: <1681882824-17532-1-git-send-email-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.0.74.65] X-ClientProxiedBy: SHCAS01.spreadtrum.com (10.0.1.201) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 33J5ed12070031 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763583755399587188?= X-GMAIL-MSGID: =?utf-8?q?1763583755399587188?= From: Zhaoyang Huang It is wasting of effort to reclaim CMA pages if they are not availabe for current context during direct reclaim. Skip them when under corresponding circumstance. Signed-off-by: Zhaoyang Huang --- mm/vmscan.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index bd6637f..04424d9 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2225,10 +2225,16 @@ static unsigned long isolate_lru_folios(unsigned long nr_to_scan, unsigned long nr_skipped[MAX_NR_ZONES] = { 0, }; unsigned long skipped = 0; unsigned long scan, total_scan, nr_pages; + bool cma_cap = true; + struct page *page; LIST_HEAD(folios_skipped); total_scan = 0; scan = 0; + if ((IS_ENABLED(CONFIG_CMA)) && !current_is_kswapd() + && (gfp_migratetype(sc->gfp_mask) != MIGRATE_MOVABLE)) + cma_cap = false; + while (scan < nr_to_scan && !list_empty(src)) { struct list_head *move_to = src; struct folio *folio; @@ -2239,7 +2245,10 @@ static unsigned long isolate_lru_folios(unsigned long nr_to_scan, nr_pages = folio_nr_pages(folio); total_scan += nr_pages; - if (folio_zonenum(folio) > sc->reclaim_idx) { + page = &folio->page; + + if (folio_zonenum(folio) > sc->reclaim_idx || + (get_pageblock_migratetype(page) == MIGRATE_CMA && !cma_cap)) { nr_skipped[folio_zonenum(folio)] += nr_pages; move_to = &folios_skipped; goto move;