From patchwork Thu Aug 15 12:33:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gaoxu X-Patchwork-Id: 13764736 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 ACDDAC3DA7F for ; Thu, 15 Aug 2024 12:33:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3DDB86B00D5; Thu, 15 Aug 2024 08:33:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 38CF16B00D6; Thu, 15 Aug 2024 08:33:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 22DB86B00D7; Thu, 15 Aug 2024 08:33:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 044296B00D5 for ; Thu, 15 Aug 2024 08:33:18 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 83F86A8822 for ; Thu, 15 Aug 2024 12:33:18 +0000 (UTC) X-FDA: 82454420076.02.BF78C4B Received: from mta22.hihonor.com (mta22.honor.com [81.70.192.198]) by imf02.hostedemail.com (Postfix) with ESMTP id E5C0880028 for ; Thu, 15 Aug 2024 12:33:15 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of gaoxu2@honor.com designates 81.70.192.198 as permitted sender) smtp.mailfrom=gaoxu2@honor.com; dmarc=pass (policy=none) header.from=honor.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723725160; a=rsa-sha256; cv=none; b=xcj+Vk2KqiS1S3JKN/Jx6eBn+/zQFN80fs/3qc9SD42VDaAp+vrH9FZ2Ka/MAJK9x9V85V MVGhg1PioeEi2wu4+voIOgBnraIAOlfVsT9OJcEhynZNuS4VSYTF0Wm+ssqayApye0DSJk jl05U+GFWQsPJaCAYRoylNKxgnPhT3s= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of gaoxu2@honor.com designates 81.70.192.198 as permitted sender) smtp.mailfrom=gaoxu2@honor.com; dmarc=pass (policy=none) header.from=honor.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723725160; 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=wzIkoAnvjNhC8IujAHq4bsBjuM4OFfBPrl1PuZoYHYI=; b=HfcfY56Ot7UDuup+Ns89E+7jl5vsk5djM4vyfE/VHi/aIn9jM/vMmTQm3O2l1xwKf+m17E kehMsqOTqy8mTPVibj+mlewM7sTJlx8dZtkqP3SgaHqwSqATTL0OE0jm4aXsgESFQNsn+G HjAfBglU99kH3I6kcEwzCnsXDmXlWLc= Received: from w011.hihonor.com (unknown [10.68.20.122]) by mta22.hihonor.com (SkyGuard) with ESMTPS id 4Wl4Gh0MjTzYkxh6; Thu, 15 Aug 2024 20:30:52 +0800 (CST) Received: from a018.hihonor.com (10.68.17.250) 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; Thu, 15 Aug 2024 20:33:10 +0800 Received: from a007.hihonor.com (10.68.22.31) by a018.hihonor.com (10.68.17.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 15 Aug 2024 20:33:10 +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; Thu, 15 Aug 2024 20:33:09 +0800 From: gaoxu To: Andrew Morton CC: "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Suren Baghdasaryan , "Yu Zhao" , Shaohua Li , yipengxiang , fengbaopeng Subject: [PATCH] mm: add lazyfree folio to lru tail Thread-Topic: [PATCH] mm: add lazyfree folio to lru tail Thread-Index: AdrvDo5mhFpHwjY+TGSie/L6+cGQzQ== Date: Thu, 15 Aug 2024 12:33:09 +0000 Message-ID: <37bbf461e81342a7b5798923b783e349@honor.com> 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-Stat-Signature: qkd7yqfjfzdwydn136f857o99i5c1bhk X-Rspamd-Queue-Id: E5C0880028 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1723725195-366328 X-HE-Meta: U2FsdGVkX19VKwr7VAQIDvNv2e9SqbXtS3yvWMjkGqDEjJIjs3oY9zjdpdaGd+XuavYsmMsWCoTAm9a1ZyHYt4Q3hLwMuaCRETNlkD/nSq16RWRpSlyZxN8LjZXflt2ncQDPQCWEfOKEqG0VqP2SL68a+BaUxU9lnmURHcv72dwbOSrkVeexyBYOftYjHFQqd165dc9Qm8H2jPZQQzkfCq4IaCbnL9pZUeBbjDXJ45REMY5KWLUIcNbbxpH9urC98sWRf35SG1urw/73Qi0XhUuuJxgspsW+4/taXvHup7KpgWhyZxWmClTyx/MIQf7wzBguyaLpaBPAam5iLjGS54J8t/+bgq86NRdMKxFYrN+vnJvsKTKhnquAo4CrUeleZFlUbhBmtueR6p71sL+cMeAWHHUV56hDVDjwBvh6YZm/YAHi/ioWCpRxmKtqBwT9YaAr8297pSRBq8beQH5HYsyrRzqNktnCV6qEpHDQvEEEu03AbUIIPg7eKs2TmjINDkhStx0QVifEm71pswzDD6Lo6wokd0hnUDByPnx42A1/lFgs+GEisql1JESyAUmJI4PBSzi/kaN+DzNsL30DOIC7/EugdU/WL2lSq6sImULetUCOpcgvjEPL4ls+YQLMG9jKiMz2pl8hUvccosVg4FlPfa8elaF/4hShiSvF0xXcpI7y5sxJSB0yDzwemr9A/OmiLjWsN4dVPp87+opSXRW3sc+9SbrpYjBbvCh1t4YiFnSdbvIiPNxAwJaWwga10e0rwW4nkMbkR/6fBmkU5Okm61AOOhjp/Kr4gYog1RR1CsfJDFFn5lgLcLhkkegcX9SnDnk9/Tmu37kkqhkzCQ6MtsZ4Jgnl4OvBeD+t3+8dqZOp0C6p35rvbFe425ENRgmv0MZ3PvUMoTGdhU/eicn1sggBdr3DkpUrPh8Aibr25RPLCv1iVybryGIVPEPtPBcF9YkaKThLSs+/8MR z6rsDFad TKmSKfP/cDc1NLw3f8W5Y03BS5zPJBGsCqFVwiLFtw5cU9mZd2hSCMwetjcm9dZ30n41LK4x0cWLAXPEBwSXWAPWd13jBo9hk9ovD06BfEUVF/M7peb955i02/1qmQ8Q6yZSpPaUY21MECoA5wJBxTm+CkbusU5zaEN1e/pCtfzeD53aa/fxRf1qbkID9qab+Pkm8DyIRNrwOKlpNnIpRhAHsaGqMEsIboxijHb6YO4a7/fA8vl6JEaIQLKCDQBAHzYAIlsYcu6C+7+mywORwHAQXf3eHz/FdVL0EYwKcJyEOajse7vd/e9utBkVMIpK6wunmVcZcGngU7dV4pNI3ru60/ZfWoSQUIUxNiHcL6DTi0bo= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000007, 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 --- mm/swap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/swap.c b/mm/swap.c index 67786cb77..ed49643ec 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -635,7 +635,7 @@ static void lru_lazyfree_fn(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,