From patchwork Fri Apr 29 01:44:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 12831405 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 9E225C433F5 for ; Fri, 29 Apr 2022 01:44:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 28A176B0073; Thu, 28 Apr 2022 21:44:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 23A996B0074; Thu, 28 Apr 2022 21:44:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 102DC6B0075; Thu, 28 Apr 2022 21:44:37 -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 F31FB6B0073 for ; Thu, 28 Apr 2022 21:44:36 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D578026BCD for ; Fri, 29 Apr 2022 01:44:36 +0000 (UTC) X-FDA: 79408222152.28.38A0777 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by imf07.hostedemail.com (Postfix) with ESMTP id C88F140065 for ; Fri, 29 Apr 2022 01:44:33 +0000 (UTC) Received: by mail-ed1-f47.google.com with SMTP id b24so7434411edu.10 for ; Thu, 28 Apr 2022 18:44:36 -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; bh=+4RPuhRbJcqGBRmGZ/vT2sq/6yGsxiF6XTgQi2iiQ14=; b=iOCgSBc8Y/09hWyJUCqX0rUIF0jDoz6bNDRvfjsfTJmyfVPtEV33y24CDubx1gtbvi lIhFpNDJVydoRKPQdZMrsb59/Av96ixKLMFLnSoA9uqgaGUU3xIFownr8Uil9wNIL8d/ 8P5lFVQVInlC0nji/1OcMsqvQF4Bu363PXLW7pt140/Cqc2ShrvI1Mbub5eL04DhKVyu 9iMvLBDHnHz6qKQAzbzEbQtfbZlRptCY21vbr7qgKR+XA2xQee178A9alN3vaWd8b7iV K6hBtph+My7EAjvug+s2kjgZj9Tk0s1GboWsZZ1kiF6TOwwKCmd111dtX0UMT3/JJujn V9Ng== 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; bh=+4RPuhRbJcqGBRmGZ/vT2sq/6yGsxiF6XTgQi2iiQ14=; b=OgIFGnc3sAyBme5GxQD3ahyh/LY3NBlGcFn3ALLpqlNiaCeHaroKYUdh6dS+351x5u cabBjfrtGlSzYEGm5LID+RJsqmanb8Pw0xTWlPPUS5TxOmik29zIbXyvtwx+4Xg6DeuA PeqdvbvPJqbSOI+LPX0qIlFZU+oaEom8vuIaVBFdfNmLnUd0z2AKi4ulmlAhwCFdnmFX ETS4Qq6dQrEahqAU+r34Bbtlyk5+0XzEEnGb0VvEXqNTOncmTOeSmYDHB9bDvYFUg7yK LlHFWiSNGdagiKHKMjwr/X1MlltPse7looNbB/cTFDF76qR1ygTnaiqPutIjxmC3psmu ks/g== X-Gm-Message-State: AOAM531PKRMeyskM3GSQhPJm9I4JUaHczxfpK6KDsHngED3bN4M56NOs Nwd8tZqCNK+1MdD5JtTztFE= X-Google-Smtp-Source: ABdhPJxMCXb0Jjj3Jm4O3ilm3ZC6LTTuRr4yWFjKQgJBAvBlNqGfQRu5VM6l+li51W61lMY77vGKdg== X-Received: by 2002:a05:6402:43c4:b0:41d:9403:8dca with SMTP id p4-20020a05640243c400b0041d94038dcamr38284975edc.184.1651196675059; Thu, 28 Apr 2022 18:44:35 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id e7-20020a170906844700b006f3ef214e39sm185395ejy.159.2022.04.28.18.44.34 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Apr 2022 18:44:34 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [PATCH 1/2] mm/vmscan: filter empty page_list at the beginning Date: Fri, 29 Apr 2022 01:44:25 +0000 Message-Id: <20220429014426.29223-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=iOCgSBc8; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf07.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.47 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: C88F140065 X-Rspam-User: X-Stat-Signature: 7nopdwwrytcizecrqe96q18emfz8u5pg X-HE-Tag: 1651196673-383580 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 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index a7ca3916e2ea..085982d53a32 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2549,9 +2549,12 @@ unsigned long reclaim_pages(struct list_head *page_list) struct page *page; unsigned int noreclaim_flag; + 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); @@ -2564,10 +2567,9 @@ unsigned long reclaim_pages(struct list_head *page_list) nr_reclaimed += reclaim_page_list(&node_page_list, NODE_DATA(nid)); nid = NUMA_NO_NODE; - } + } while (!list_empty(page_list)); - if (!list_empty(&node_page_list)) - nr_reclaimed += reclaim_page_list(&node_page_list, NODE_DATA(nid)); + nr_reclaimed += reclaim_page_list(&node_page_list, NODE_DATA(nid)); memalloc_noreclaim_restore(noreclaim_flag);