From patchwork Mon Dec 9 08:36:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Ridong X-Patchwork-Id: 13899078 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 F00EBE7717D for ; Mon, 9 Dec 2024 08:46:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 369996B03E0; Mon, 9 Dec 2024 03:46:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F34A6B03DE; Mon, 9 Dec 2024 03:46:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1DE196B03DF; Mon, 9 Dec 2024 03:46:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E79ED6B03DC for ; Mon, 9 Dec 2024 03:46:21 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8F4C7AD681 for ; Mon, 9 Dec 2024 08:46:21 +0000 (UTC) X-FDA: 82874788584.16.F3D9C9F Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by imf12.hostedemail.com (Postfix) with ESMTP id 11A0140013 for ; Mon, 9 Dec 2024 08:46:07 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf12.hostedemail.com: domain of chenridong@huaweicloud.com designates 45.249.212.56 as permitted sender) smtp.mailfrom=chenridong@huaweicloud.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733733959; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=IUjP4OoEQm1MGwX9TIZO0hfmjwYnTZ1mUPZ1GO2NN5E=; b=qK2q1fNY3idOi+GX4SaXTWHjTckSvRhq4O7GxnR9mHBFgw1EwZmk/AhFbQsT10qyPn/GCJ NYv1M/hBstnsuodNeFCP7C1OJd8rbqBMu8QVCk9J/zXUki5gKKHP2oCBZZw3FtQ/JcNacs OHoOLYUYhIT1NShPgU+i/dOiOIZXxhY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733733959; a=rsa-sha256; cv=none; b=4HMoEzS91VWqBYxl3Sghop6NNlDheVMnDQJFx9QUucDtNVJmXc5f2i/I9FbZz3NDuWR6bI QBEk0dLS91kmNHc2rt+2aSxb+ZBAxvvpncidYE4M+I6TYl21CBTY8xChb3C86v8ec+gA/g hjquzoXlJYI2KXnAZ1MlQAUrnDf1pjs= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf12.hostedemail.com: domain of chenridong@huaweicloud.com designates 45.249.212.56 as permitted sender) smtp.mailfrom=chenridong@huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Y6FnW4sDJz4f3jsH for ; Mon, 9 Dec 2024 16:45:51 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id D63A01A07B6 for ; Mon, 9 Dec 2024 16:46:10 +0800 (CST) Received: from hulk-vt.huawei.com (unknown [10.67.174.121]) by APP4 (Coremail) with SMTP id gCh0CgAX8oVArlZn1gthEA--.6675S2; Mon, 09 Dec 2024 16:46:08 +0800 (CST) From: Chen Ridong To: akpm@linux-foundation.org, mhocko@suse.com, hannes@cmpxchg.org, yosryahmed@google.com, yuzhao@google.com, david@redhat.com, willy@infradead.org, ryan.roberts@arm.com, baohua@kernel.org, 21cnbao@gmail.com, wangkefeng.wang@huawei.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, chenridong@huawei.com, wangweiyang2@huawei.com, xieym_ict@hotmail.com Subject: [PATCH v4 0/1] mm: vmascan: retry folios written back while isolated for traditional LRU Date: Mon, 9 Dec 2024 08:36:17 +0000 Message-Id: <20241209083618.2889145-1-chenridong@huaweicloud.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CM-TRANSID: gCh0CgAX8oVArlZn1gthEA--.6675S2 X-Coremail-Antispam: 1UD129KBjvJXoWxJrWfZw13Aw4rCF48Zw45trb_yoW8uF1UpF n3W3W3tr1kGr13KwsxuF1avr15C395Cw13JFn3Ga4Sva4Uu34j9Fy0934vvFW8Grn8CFyr tr4Ygr9YgFWUArJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUv2b4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x 0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG 6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFV Cjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4IIrI8v6xkF7I0E8cxan2IY04v7MxkF7I0E n4kS14v26r1q6r43MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I 0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVW8 ZVWrXwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcV CY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAF wI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa 7IU17KsUUUUUU== X-CM-SenderInfo: hfkh02xlgr0w46kxt4xhlfz01xgou0bp/ X-Rspamd-Queue-Id: 11A0140013 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: g1cnkworbx3qb6mwc58z7r6z38ddptyo X-HE-Tag: 1733733967-937748 X-HE-Meta: U2FsdGVkX1/xyl8mIdz8ckNkQfeBRtvPRjl4rHz5zVLAiEeT/QuMzalNu7qgaaAP9NIzeCrD9+zSaprl0dgC6vYds6hzg7PTcgTDTXmQbCG9QpsM4R4J0oVWLxIcMz9XsbBNEimhCDhpM3HnZHasK509ol84DCA+i4HY4pzA/dBbouf1EDl+dDxjrHrsV4rQApp7REAyLld/MphzJAuGHc8pGqQ3iGSSlxY0fElzycZnBP6kTaMjuzTpLQT1Ac1rPRlCSuLknzYoWAos7c+6YlKlbaLzKpoSXrQic1VUkFrhjVMCHrLH7Yz14VoEef96502TBfb1wYKjU1djZ5n0v4X/bAbLHQs40jJbFudvt33mrFFoG10CguejZ3RpM67h3SNr6qklH6+X50UCXJZFjPzvFrEv5b7CLkQ7kivxczP6OyaFadERPykCLABCsqXmm5KrUq2xngWLA7p64ma95lZCgvspex33DyL8QuKYYlqVW9C73to+4jguH8qNheFfvkDMeHa0dEZfia3VvxR0DsnuFyoL3T5WKG5dkY7Nsok1MqJhdIZsevWYGnhLv3/FtUOAMJci20tUypZqK5GZRTSGw6RtOS76VHPEfkve6edzaZPFSHhMDBZfkx5pcUkOe8rWv/2iN8I+QPqbdSygJW+zm3EOkR2E+5L0LLFkMb2nSDgF1Yx5taZPxtAaO1KqCdVcCd6xw4tGRjXD5mWVlhgaHk7BVfZ0Sy/lCzjpNONAXQFIFBN9lQitHvD3/YlRBoLLR8d/hieeHfVgnChfJNpbY1QO8aD80vAb+Kd56/sRA/an16jFqMYXA43Moi57U1IewmMDAt2AAhtQN4zkLUApoXFzuDb1wUfEpMvdmPB4PJuK5u/ewIR8RZC+zulRW4TNB/+9oi17JgBQywQdnh7ALEaxm956ogwRt9NVhEz3Wo2BMC6xyaFkNeMa+PgsNl36bzraN3HFQHL2cGy buftl8Tk EczYd6XmwdI8yfvCrMAGM9v8HrzTtOK79BA//+lRRVflmgN4xak4ChMzTCsaIKYABdZMNZS4fJbmwvOi2JGBRfwvZkeOfHT/vxFK2gi9FzqFe3E3LZlEoyRiMQPIAn0yR131kVRSg/3Ft0ZRX+FmZpY5wdN3jcgZTVPf/RuD00qp9tvp69gE4wfdepYbaWBwH13Q+ybYU160mv+nYW/hIc+CCp1euAIeFZWDp 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: List-Subscribe: List-Unsubscribe: From: Chen Ridong The commit 359a5e1416ca ("mm: multi-gen LRU: retry folios written back while isolated") only fixed the issue for mglru. However, this issue also exists in the traditional active/inactive LRU. Fix this issue in the same way for active/inactive lru. What is fixed: The page reclaim isolates a batch of folios from the tail of one of the LRU lists and works on those folios one by one. For a suitable swap-backed folio, if the swap device is async, it queues that folio for writeback. After the page reclaim finishes an entire batch, it puts back the folios it queued for writeback to the head of the original LRU list. In the meantime, the page writeback flushes the queued folios also by batches. Its batching logic is independent from that of the page reclaim. For each of the folios it writes back, the page writeback calls folio_rotate_reclaimable() which tries to rotate a folio to the tail. folio_rotate_reclaimable() only works for a folio after the page reclaim has put it back. If an async swap device is fast enough, the page writeback can finish with that folio while the page reclaim is still working on the rest of the batch containing it. In this case, that folio will remain at the head and the page reclaim will not retry it before reaching there. --- v4: - conbine patch 1 and patch 2 together in v3. - refine commit msg. - fix builds errors reported-by: kernel test robot . v3: - fix this issue in the same with way as multi-gen LRU. v2: - detect folios whose writeback has done and move them to the tail of lru. suggested by Barry Song [2] https://lore.kernel.org/linux-kernel/CAGsJ_4zqL8ZHNRZ44o_CC69kE7DBVXvbZfvmQxMGiFqRxqHQdA@mail.gmail.com/ v1: [1] https://lore.kernel.org/linux-kernel/20241010081802.290893-1-chenridong@huaweicloud.com/ Chen Ridong (1): mm: vmascan: retry folios written back while isolated for traditional LRU include/linux/mmzone.h | 3 +- mm/vmscan.c | 108 +++++++++++++++++++++++++++++------------ 2 files changed, 77 insertions(+), 34 deletions(-)