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); From patchwork Fri Apr 29 01:44:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 12831406 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 5539AC433EF for ; Fri, 29 Apr 2022 01:44:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C28AF6B0074; Thu, 28 Apr 2022 21:44:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B61286B0075; 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 9DA826B0078; Thu, 28 Apr 2022 21:44:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 8D0136B0074 for ; Thu, 28 Apr 2022 21:44:37 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5D1DE270B4 for ; Fri, 29 Apr 2022 01:44:37 +0000 (UTC) X-FDA: 79408222194.07.987ED99 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by imf07.hostedemail.com (Postfix) with ESMTP id 61B9740002 for ; Fri, 29 Apr 2022 01:44:34 +0000 (UTC) Received: by mail-ed1-f44.google.com with SMTP id be20so7424374edb.12 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:in-reply-to:references; bh=+avWVkUZVmhlSlBLUHwLumdWUsDPdQaIXmA5/dzPdCg=; b=KuQRQdP0IUjAG15MToInzk2ghm7ttKjTUo9eB8EcbQxPgl3GlRN6oeE3cEo8lHrJuk 3imq7fNzA9oiUtjiUYQamZ/AvP87WE3e5t4XDrtyweiBSH6xqSjy2JvtjhqjOkcUcmNM D7ueVu6JYZXSmpdGu6m748uJ5jH5D+oH02/f8LrJOJ4CR5OEG+sQKVM+BeJLNpwWZTAm iNPT5waL/7z4QZ8AmFAFYz6RPBN+c/Q9mW//ce+T8grYgSlhvFZXlsb1Fk+zNKgUmDkW NxnQFACFaMlm/rEZPMdLiqhZHm95Hyf/xkyZbpPHnClPS+S6QGJu/rUfn6Brch3f1sgf pECA== 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=+avWVkUZVmhlSlBLUHwLumdWUsDPdQaIXmA5/dzPdCg=; b=lL6+gGWRCS1bNpMvTPKsYJ+lx3m4dz9oHPaSBJe2DzU97t7OZOiFkE0UKWd84hRq7b zF//EW1TETRXsEt7psJK93KhaOPZEL7OVHlVz2z+y7GMC6WU8DgBTDkaLVUATqWkkG0x eLSYOZfOrqgx3VeinLR2yDY+h1+FWZiolCaK+oQ8QCX4LfMaI+jua6reBOo4euAjY5iS zwS0w4ydv47pN60EQ5MNOG0oXonXfIS3xEex/uP/JDcQ/XCkbhEBWu2Q4C6injaQAzUQ iMuIeCbSvgCcjefslW0i53UvHEQS2D3zDZJznIp87J2i/JXX5A7pwmCHxf+yzdgZ/WFE FsBw== X-Gm-Message-State: AOAM533wgrMDyzVWJii6eGokRs5yInJCgTYTu/SwnoRArHmv2U82bteM smvZ5/Ogakp1muX5/ijTvuPWPAoatGA= X-Google-Smtp-Source: ABdhPJwSEok8YFahrTU6TQoMpFUlu61m3WiW2MfdU8A2eZ4rd66ORwyCFD90SI5hWxjtirTPdqHDTg== X-Received: by 2002:a50:d79a:0:b0:425:e577:c71a with SMTP id w26-20020a50d79a000000b00425e577c71amr25314373edi.188.1651196675846; Thu, 28 Apr 2022 18:44:35 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id dq10-20020a170907734a00b006f3ef214de9sm186114ejc.79.2022.04.28.18.44.35 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Apr 2022 18:44:35 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [PATCH 2/2] mm/vmscan: not use NUMA_NO_NODE as indicator of page on different node Date: Fri, 29 Apr 2022 01:44:26 +0000 Message-Id: <20220429014426.29223-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220429014426.29223-1-richard.weiyang@gmail.com> References: <20220429014426.29223-1-richard.weiyang@gmail.com> X-Stat-Signature: 349b7p13qn81z4gdgksicx6q5csqkogu X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 61B9740002 Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=KuQRQdP0; spf=pass (imf07.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.44 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-HE-Tag: 1651196674-48320 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: Now we are sure there is at lease one page on page_list, so it is safe to get the nid of it. This means it is not necessary to use NUMA_NO_NODE as an indicator for the beginning of iteration or a page on different node. Signed-off-by: Wei Yang --- mm/vmscan.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 085982d53a32..0c502dc42222 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2543,7 +2543,7 @@ static unsigned int reclaim_page_list(struct list_head *page_list, unsigned long reclaim_pages(struct list_head *page_list) { - int nid = NUMA_NO_NODE; + int nid; unsigned int nr_reclaimed = 0; LIST_HEAD(node_page_list); struct page *page; @@ -2554,10 +2554,9 @@ unsigned long reclaim_pages(struct list_head *page_list) noreclaim_flag = memalloc_noreclaim_save(); + nid = page_to_nid(lru_to_page(page_list)); do { page = lru_to_page(page_list); - if (nid == NUMA_NO_NODE) - nid = page_to_nid(page); if (nid == page_to_nid(page)) { ClearPageActive(page); @@ -2566,7 +2565,7 @@ unsigned long reclaim_pages(struct list_head *page_list) } nr_reclaimed += reclaim_page_list(&node_page_list, NODE_DATA(nid)); - nid = NUMA_NO_NODE; + nid = page_to_nid(lru_to_page(page_list)); } while (!list_empty(page_list)); nr_reclaimed += reclaim_page_list(&node_page_list, NODE_DATA(nid));