From patchwork Tue Apr 26 02:17:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 12826420 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 BD73AC433EF for ; Tue, 26 Apr 2022 02:18:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07D286B0073; Mon, 25 Apr 2022 22:18:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 004306B0074; Mon, 25 Apr 2022 22:18:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DC0556B0075; Mon, 25 Apr 2022 22:18:28 -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 C931E6B0073 for ; Mon, 25 Apr 2022 22:18:28 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 909D82B1 for ; Tue, 26 Apr 2022 02:18:28 +0000 (UTC) X-FDA: 79397421096.20.0D295DA Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) by imf13.hostedemail.com (Postfix) with ESMTP id 3B56720041 for ; Tue, 26 Apr 2022 02:18:22 +0000 (UTC) Received: by mail-ej1-f53.google.com with SMTP id bv19so33167239ejb.6 for ; Mon, 25 Apr 2022 19:18:27 -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=IGRYgnE1lMPbLi7u/6ssra+FaSfoG1U2uhawec1PdkQ=; b=E/gcqL5sIYie+YjznKBL/8H9aAGws1YtdR+qBvb415NP04cHSVoENjr8GRthSd+jEu UDCmLCueFt1FEOF7fYcCXtsxU8siD5s+Q01pkzgOZIpQP0uUi5uNc/zNnVaaKRD17XQu JOTH2QTYY/RhlA2HjJyoDfWUFCrWHQJ1DB2usysH3HBY7yLr7TNTbPE1HiYWjJLt5UcK Mn3YCjQ+RXqOSRSYxHsYfaW7zqu3pUos1JzQMg1n1SKX0sMWBzzU/MB0nCUga2pS2y2v G/0yJ0P4jjX2DbeD/XJ+tuBPa33Vv2fjW7Ljw8/UvHfq2TNoBgVHmILW6VpEiGiThHnT pluA== 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=IGRYgnE1lMPbLi7u/6ssra+FaSfoG1U2uhawec1PdkQ=; b=0hesP/apGcH543+lxzzT1SfkNJYR1dBsn5ouhi/cTZE9tDPtvhW5dkvYPKZo4/MH29 3yPtVRQqh59V21RMqDTK6haQERqVACuLbCGSQDmmlc/69ifySjKoBGiIg3GQeepJJZVQ oaH3Rh7j+70hwVTuAgLIaUobGhhMPYnLm7EJDX7k2r97Ce37G/N7DsdRf1YNtfy4y3nT 2KysMgUqxIW8BnmGQaesCvDZ+2sqlLlrR21Q23ueg80mRcNAOYdp480pE3s6hr2P0S5p jp6lIR0oaHzoLiRz0sRj2mLYUcn0etqGaCRj45EtpfmWlecP5IKUMDsyaPYLkn5N5d7X 7iRQ== X-Gm-Message-State: AOAM532+O03UcGyq+vc6GZZ8o0ZGmPRRs9NdRt+QIAnHoxPfWgc64qsr bFZCOzqY9Djz/keV7pxFArg= X-Google-Smtp-Source: ABdhPJx8fs1FW1VajLGUOqUi0WR5XhBn4zS/E7u7ovmWQ3yNgS8ZnIBvzqWyfal2i7wEFu3hWKAU6g== X-Received: by 2002:a17:907:2d93:b0:6f3:8524:6f92 with SMTP id gt19-20020a1709072d9300b006f385246f92mr11003860ejc.556.1650939506691; Mon, 25 Apr 2022 19:18:26 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id vw17-20020a170907059100b006e8732d1944sm4152180ejb.5.2022.04.25.19.18.26 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Apr 2022 19:18:26 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [PATCH 1/3] mm/vmscan: not necessary to re-init the list for each iteration Date: Tue, 26 Apr 2022 02:17:41 +0000 Message-Id: <20220426021743.21007-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 X-Stat-Signature: ruw3oktucxbptzumdrziuoyed4ko5jkf X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 3B56720041 X-Rspam-User: Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="E/gcqL5s"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf13.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.53 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com X-HE-Tag: 1650939502-532038 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: node_page_list is defined with LIST_HEAD and be cleaned until list_empty. So it is not necessary to re-init it again. Signed-off-by: Wei Yang --- mm/vmscan.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 0b7cc9309e70..9b5ce5778e9b 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2539,7 +2539,6 @@ unsigned long reclaim_pages(struct list_head *page_list) page = lru_to_page(page_list); if (nid == NUMA_NO_NODE) { nid = page_to_nid(page); - INIT_LIST_HEAD(&node_page_list); } if (nid == page_to_nid(page)) { 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); From patchwork Tue Apr 26 02:17:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 12826422 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 5B2ECC433EF for ; Tue, 26 Apr 2022 02:18:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 427B36B0075; Mon, 25 Apr 2022 22:18:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 363146B0078; Mon, 25 Apr 2022 22:18:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 18C356B007B; Mon, 25 Apr 2022 22:18:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 06F4D6B0075 for ; Mon, 25 Apr 2022 22:18:30 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id DE79921F3E for ; Tue, 26 Apr 2022 02:18:29 +0000 (UTC) X-FDA: 79397421138.02.5336A26 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) by imf19.hostedemail.com (Postfix) with ESMTP id 08ADD1A0036 for ; Tue, 26 Apr 2022 02:18:25 +0000 (UTC) Received: by mail-ej1-f47.google.com with SMTP id gh6so9110297ejb.0 for ; Mon, 25 Apr 2022 19:18:29 -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=clHSgaZZ2YR0zIZFMmaUuVfrjHIK0ovVC2GMtpd+qEA=; b=QjF2GNrqmU7aV1ArZ847TPzGNZuylgkBHaPpk+zCV3LbCa25iSVCJYsZDqTUhc6w5p WKPMioHA9IH8z7JQF9SRnFTuyuSMU0VlG7QAOdIs1i8ykIW8w78faEW1E2RAgvTZ5c6N EJEcEdMe0G3JVRRwInUb69chY3QbfmsLI45QFzbz4CmGCu94pwJVLc1i4JVgEwFdChuz 8oj75I+5bPLXA1puPGDUQ5ST3xi6NCCAS7B8FtNIMqFlogGP8li/vP8zFQBVy6e34tLu 0+Mdoy6ISqs9eJ1gc1JTOT4iokpdDhEdF6DOZj51RTf53tPCTPWtSOPuTBsRfGsS+DqG vywg== 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=clHSgaZZ2YR0zIZFMmaUuVfrjHIK0ovVC2GMtpd+qEA=; b=HxNR/OPPXh+7168eorvAro9+kOL1lrFrJ/Wm1gtHvLxw6WYxBHezswYeJchib1ytBC HBLp16I64/OP2pNLDXifbknGWQnz4BPIPo/8PaNLUn6srxEQLhVU+4p1Qw3UrFMWrgx/ lEmvikSCDz+DOEjGTFMd9yjyPaBBCICoqmI3m6wZCAlKpxVZIm8QMUAV0rRHwugN0Nbh Mdl6MP1LrgCQMxMdu3fvUh3hqgi+Vvovw/yGiexjEzEaMvR7WFRF0Ka8Ma2yqx1rhRKj lsbwVBiENadrIllJEBje08msHBXDozg5OeJzYxp8oCkxw/n2A/PNrf/YgIiQKcS6EBxF +8uQ== X-Gm-Message-State: AOAM532Oxsml+XEAPClLmAZWu9cduYO4wfQBIb2yjNg0JMxBfwti0DLv x/IxjHtJ8YPoCSRlQ6BwyPc= X-Google-Smtp-Source: ABdhPJwRVNA3FjljoxIQEWKzL0zvRUWdcFbA6109kwwY8pYNmShdalyJgBvS0X55C/Xh91cRHLQfJQ== X-Received: by 2002:a17:907:6d11:b0:6f3:66a9:b57b with SMTP id sa17-20020a1709076d1100b006f366a9b57bmr12857347ejc.374.1650939508334; Mon, 25 Apr 2022 19:18:28 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id x24-20020a1709064bd800b006ef606fe5c1sm4185242ejv.43.2022.04.25.19.18.27 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Apr 2022 19:18:28 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [PATCH 3/3] mm/vmscan: not use NUMA_NO_NODE as indicator of page on different node Date: Tue, 26 Apr 2022 02:17:43 +0000 Message-Id: <20220426021743.21007-3-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: 69papgxx3brqufujf6exstis4u1ysdnr X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 08ADD1A0036 Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QjF2GNrq; spf=pass (imf19.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.47 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-HE-Tag: 1650939505-309031 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 | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 3a36ebd6295d..f9998cba236f 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2519,7 +2519,7 @@ static void shrink_active_list(unsigned long nr_to_scan, 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 reclaim_stat dummy_stat; @@ -2538,11 +2538,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); @@ -2559,7 +2557,7 @@ unsigned long reclaim_pages(struct list_head *page_list) putback_lru_page(page); } - nid = NUMA_NO_NODE; + nid = page_to_nid(lru_to_page(page_list)); } while (!list_empty(page_list)); nr_reclaimed += shrink_page_list(&node_page_list,