From patchwork Tue Apr 26 02:17:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 12826421 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E999C433F5 for ; Tue, 26 Apr 2022 02:18:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E6226B0074; Mon, 25 Apr 2022 22:18:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 66C856B0075; Mon, 25 Apr 2022 22:18:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E6B46B0078; Mon, 25 Apr 2022 22:18:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 39E996B0074 for ; Mon, 25 Apr 2022 22:18:29 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 1DB5960459 for ; Tue, 26 Apr 2022 02:18:29 +0000 (UTC) X-FDA: 79397421138.25.FD4F977 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) by imf31.hostedemail.com (Postfix) with ESMTP id 7AD3820046 for ; Tue, 26 Apr 2022 02:18:21 +0000 (UTC) Received: by mail-ed1-f52.google.com with SMTP id z99so20597675ede.5 for ; Mon, 25 Apr 2022 19:18:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XGTM0daqX8uFzIdh1rUjZpwYs3nCrPfQvtExGVnXet8=; b=OYqo/jloBUNBOYYP/Kp1N8Q5byImZc/y3CRRez0TbTxlw18EF1+FmzJCz3MK5a3j2B xMsWx8ZNEs1hbsHgtjhxKb5W/EE2igx2+QUXefQkfdKoPIfId2YejQvgrGzyQoA7WO60 R3vDELX3ABcXjKi2i6onFoBPM0m9f3+17rs4jo8/S7epRUxCo4MfEG64x3ZxeIML5UzO f90XVMqfjvjRx78njXTUv5DfU8oqYOVLl+IfQ355mJq/7RmN+8SDwdq4y44sHSgOPq7I 2Pr2JtumK8WmXcjt01NiexZqCA2djQoU/x5J9U++kIaQQkzp3+4zw9qkv/6edIjYM3PF NAIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XGTM0daqX8uFzIdh1rUjZpwYs3nCrPfQvtExGVnXet8=; b=GYfDltV8IC+N/RhyTee8SeLvIcBo7KhmS0N6sUzjez9Ry1OGk1WYjWJd4DbhFBwuY2 fe6A3k3Ejo249tdcnZxynDFayr3iWZb7mSQJQDALAd3YepjofjazXPoL4idv4b2QL8ib vc9S3Phz3Ogy4FYA3Vm7V+svko4sI83JWTUxKv9+1MHRPqL/GFgVAGaKAbEjQnT1rF9M 0PNtmoLp7s9cX2ptJPxOhiQ0AD04OZNT4M9dwXPFnlva5XK4Qo2zOksV0fXI7gCcg8EY +nN36ivTH1k8jGt0wgouP9T7DpY5g/VixKajbPih0aHQxkTjBzUluP05uz8BiadoqgA+ f+Uw== X-Gm-Message-State: AOAM533MefLs5DeSMQRD/3W5a5OGiF16zSrxJy/2s9b29lpbEhg2vRqI xluaWK5x7tKDDI+GX2gNV3U= X-Google-Smtp-Source: ABdhPJy/GbBizyEXrzBPyZaTs3C4MfKp3N2OIw4o4FNEgnYQgVh9r+QJRAqYvBN23e5t+rUCMHZpzw== X-Received: by 2002:a50:c014:0:b0:41d:5ee9:f354 with SMTP id r20-20020a50c014000000b0041d5ee9f354mr21995980edb.257.1650939507583; Mon, 25 Apr 2022 19:18:27 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 27-20020a17090600db00b006df6b34d9b8sm4126816eji.211.2022.04.25.19.18.26 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Apr 2022 19:18:27 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [PATCH 2/3] mm/vmscan: filter empty page_list at the beginning Date: Tue, 26 Apr 2022 02:17:42 +0000 Message-Id: <20220426021743.21007-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220426021743.21007-1-richard.weiyang@gmail.com> References: <20220426021743.21007-1-richard.weiyang@gmail.com> X-Stat-Signature: ez4fhof19ued87i5cgf5ifujj63y9gdz X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 7AD3820046 Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="OYqo/jlo"; spf=pass (imf31.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.52 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-HE-Tag: 1650939501-483087 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: node_page_list would always be !empty on finishing the loop, except page_list is empty. Let's handle empty page_list before doing any real work including touching PF_MEMALLOC flag. Signed-off-by: Wei Yang --- mm/vmscan.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 9b5ce5778e9b..3a36ebd6295d 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2533,9 +2533,12 @@ unsigned long reclaim_pages(struct list_head *page_list) .no_demotion = 1, }; + if (list_empty(page_list)) + return nr_reclaimed; + noreclaim_flag = memalloc_noreclaim_save(); - while (!list_empty(page_list)) { + do { page = lru_to_page(page_list); if (nid == NUMA_NO_NODE) { nid = page_to_nid(page); @@ -2557,17 +2560,15 @@ unsigned long reclaim_pages(struct list_head *page_list) } nid = NUMA_NO_NODE; - } + } while (!list_empty(page_list)); - if (!list_empty(&node_page_list)) { - nr_reclaimed += shrink_page_list(&node_page_list, - NODE_DATA(nid), - &sc, &dummy_stat, false); - while (!list_empty(&node_page_list)) { - page = lru_to_page(&node_page_list); - list_del(&page->lru); - putback_lru_page(page); - } + nr_reclaimed += shrink_page_list(&node_page_list, + NODE_DATA(nid), + &sc, &dummy_stat, false); + while (!list_empty(&node_page_list)) { + page = lru_to_page(&node_page_list); + list_del(&page->lru); + putback_lru_page(page); } memalloc_noreclaim_restore(noreclaim_flag);