From patchwork Fri Aug 16 07:48:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gaoxu X-Patchwork-Id: 13765631 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 E0CB9C531DC for ; Fri, 16 Aug 2024 07:48:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5689B6B00B1; Fri, 16 Aug 2024 03:48:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 518196B00C0; Fri, 16 Aug 2024 03:48:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3E2796B00BD; Fri, 16 Aug 2024 03:48:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 1A8C98D0056 for ; Fri, 16 Aug 2024 03:48:13 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C700E1C5100 for ; Fri, 16 Aug 2024 07:48:12 +0000 (UTC) X-FDA: 82457330424.05.3147A2E Received: from mta20.hihonor.com (mta20.honor.com [81.70.206.69]) by imf06.hostedemail.com (Postfix) with ESMTP id 69EAC180007 for ; Fri, 16 Aug 2024 07:48:09 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=honor.com; spf=pass (imf06.hostedemail.com: domain of gaoxu2@honor.com designates 81.70.206.69 as permitted sender) smtp.mailfrom=gaoxu2@honor.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723794476; a=rsa-sha256; cv=none; b=jSlEWQuAXRjFOr02rSwDm2Dojk5eiHgnEAtjocG6d+/6G80qAOUSTsgxat4BSPT2Kv9glG /RDGYXMHfaiakvIhIKeRkoI2IdRzVMwJCCZwK79tSEfKGzO6zsNDJOnejzjUiFz1adK8OC A7pjCPJP/Lx90bPCc3cXB3YnNCTB7Ac= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=honor.com; spf=pass (imf06.hostedemail.com: domain of gaoxu2@honor.com designates 81.70.206.69 as permitted sender) smtp.mailfrom=gaoxu2@honor.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723794476; 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-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=g4mcBYcFzhVMu5gQ+5WbNAYNu5fDd7oX3yiksydV/lw=; b=m0CB0TrOs9055c6HX6DvNQlBPpwq5/QXqW06FKRGUyxRdULT/MqGDVkyCg6r11xL67bvbp uFExobkypoPcA6jylLIrHQPa6mEkMfE8Ip95ehxEYzlUvbnfPuLG7K1QBLct07Pu1qsVuD sYCVrH4VifEkqRa121IXBFiHMIEAU9o= Received: from w011.hihonor.com (unknown [10.68.20.122]) by mta20.hihonor.com (SkyGuard) with ESMTPS id 4WlYwn1NRmzYnC3q; Fri, 16 Aug 2024 15:47:05 +0800 (CST) Received: from a016.hihonor.com (10.68.16.211) by w011.hihonor.com (10.68.20.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 16 Aug 2024 15:48:02 +0800 Received: from a007.hihonor.com (10.68.22.31) by a016.hihonor.com (10.68.16.211) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 16 Aug 2024 15:48:01 +0800 Received: from a007.hihonor.com ([fe80::4407:dd67:71d7:ea82]) by a007.hihonor.com ([fe80::4407:dd67:71d7:ea82%10]) with mapi id 15.02.1544.011; Fri, 16 Aug 2024 15:48:01 +0800 From: gaoxu To: Andrew Morton CC: "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Suren Baghdasaryan , Shaohua Li , yipengxiang , fengbaopeng , Kalesh Singh Subject: [PATCH v2] mm: add lazyfree folio to lru tail Thread-Topic: [PATCH v2] mm: add lazyfree folio to lru tail Thread-Index: Adrvp/sHXyayf1r5TQG6pnGY8/qB0A== Date: Fri, 16 Aug 2024 07:48:01 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.164.11.140] MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 69EAC180007 X-Rspamd-Server: rspam01 X-Stat-Signature: ucjt37rwe4wpazas46yzpa5f7mcob4cr X-HE-Tag: 1723794489-266621 X-HE-Meta: U2FsdGVkX19DENkbhoxqvfwK+u8+vvklSTVITGAA9NZ8h2TSL1uhCYJog1bZ9l3Srbhb5x8/qlevL+H8NT5g7KvZbCbMEXZyDkyZd5SuQi9CT48BYp+UXQfHlTlwUIB3II22PQ0AymQTmOdOHlt1qlACiYAYARWuiSPjMdXGVF+5G8lZgwhUjbHnXjhNQzS7EGpHjVCpoyebs858HPSf2AW2VsalaNc1K4w80xyD8hz/CjZQt0bWcGSuc29YKdDbCJAMxwdX/chaAqBvyqyjcThRULch5HptipnaRbadQVZE2iGyeWvp/mokX16umVf0CuunsHhAJZ0XjR2NerfrgRB/tmO2OxyCwFqh6D/xk/0tbMvmRelnoMGy+SvnaTwJXyzl7mMMS+Llht+A+yC6kqmy8GBQ+hNBhz+f6MKsLpY/g+CPMmyKAEg9+UiEJxyjMbJIUUwg60xPP3s4s+oObEDd/RdbL8ffGh3YORDzsXyJwfNPTLB81WP+6AhvGPxaGLCxYh8Sl2V6DusX2E+Pj/zmin5TW4sBc8bFH44E6N/ZhUv7CWhWdHD6LBCW9fd6GGBIjcM3LFyES7m2y64N9F9mXb8Us5KDPlk15BD7R8yvQVWkt5HN6H/58O65WojsbsBgyhWtfbx+zYKNGnAbqp7i8hpGMGau6yQiSYXhNNOktj9e8vMUTdQFiPsAQ+AFWiMIadX/G+taNZ6UGU1nChIaiTeg88Dd2C+2vS2aB8Q6xq9C3QZu6XURrK/OxT5e1ylexKvhbSOBpVIsMwLv0PGZZTOyv0z08M/SG+Pp4SlZ7PFPdz48Fm3ogoF5puh88Wf7PD4SHIJG8DwT/SM+XLGnnEAHvEmXX/RnR4odMmEPf/mzloW28OhI0bpYQZbYA0IGAKRE44XTPgiWT6LBYZDhKsQqMsPE6vZAei6ctSRuGcUHAnEjtjZjv9JyuvE8kriNSAdxMGSW93hMejo TNTBRQRm PxUviBA0+ZZJRs7PhGRDBulb+r8kjlq0NAftIcSrkBv4pKxaGDdYVlAw2HkCsVyx+dD0EMgGyny89vF2UMUBInRCjxMkm9zfNnYDz+m0Ri/iVTQ3Ixib40/fcFtTxh2uWRU6UawTfwsglVIMtFBjQfZak9jr71qoXRfj6cz4s1ZusoO7KhFkjqJugH2slvx6XS3poOTv4rF5x0a+YskcL+FrwEMm03kUxWZBhFdKWAmw79sssanUQse9cDHHUC3IVveWnY1vXX/MFdeJh28o+D6ogUSME0RqO9cBeg0P2/6WFaJ/BmTCU36D1q8Rh48yNCsnoiiGncGJSVegOEqJtJSVkXeWgE3Jm06TMPATRFDINuiY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000037, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Replace lruvec_add_folio with lruvec_add_folio_tail in the lru_lazyfree_fn: 1. The lazy-free folio is added to the LRU_INACTIVE_FILE list. If it's moved to the LRU tail, it allows for faster release lazy-free folio and reduces the impact on file refault. 2. When mglru is enabled, the lazy-free folio is reclaimabled and should be added using lru_gen_add_folio(lruvec, folio, true) instead of lru_gen_add_folio(lruvec, folio, false) for adding to gen. With the change in place, workingset_refault_file is reduced by 33% in the continuous startup testing of the applications in the Android system. Signed-off-by: gao xu --- V1 -> V2: Based on the latest mm-unstable, recreate the patch. mm/swap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/swap.c b/mm/swap.c index 6b838986d..e0dbfc983 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -641,7 +641,7 @@ static void lru_lazyfree(struct lruvec *lruvec, struct folio *folio) * anonymous folios */ folio_clear_swapbacked(folio); - lruvec_add_folio(lruvec, folio); + lruvec_add_folio_tail(lruvec, folio); __count_vm_events(PGLAZYFREE, nr_pages); __count_memcg_events(lruvec_memcg(lruvec), PGLAZYFREE, nr_pages);