From patchwork Fri Mar 17 06:49:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianwen Jiang X-Patchwork-Id: 13178592 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 EBFA9C7618E for ; Fri, 17 Mar 2023 06:50:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DB1B900003; Fri, 17 Mar 2023 02:50:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 28BBB900002; Fri, 17 Mar 2023 02:50:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 179C2900003; Fri, 17 Mar 2023 02:50:13 -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 058A0900002 for ; Fri, 17 Mar 2023 02:50:13 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C40A7AC028 for ; Fri, 17 Mar 2023 06:50:12 +0000 (UTC) X-FDA: 80577465864.10.DE4E841 Received: from smtpbgsg2.qq.com (smtpbgsg2.qq.com [54.254.200.128]) by imf25.hostedemail.com (Postfix) with ESMTP id ED2B7A000B for ; Fri, 17 Mar 2023 06:50:09 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of jiangjianwen@uniontech.com designates 54.254.200.128 as permitted sender) smtp.mailfrom=jiangjianwen@uniontech.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679035811; 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=7msnFrSeqttOZFdFqPgrJTN+6e0cMspbyBTd3+s5aNI=; b=es04BWTPp3aWXIoAe6bn1hX1209xOnirQS6Qt/In6Im3yHGnCdo8dKFda2HHN+g6XiDYRg zPCjUNflLQbECq8jrWPCHF2QitbYRIOiXAetO41Pr9Ojna0cNabei7tFycpHJhZoovU9hq +lOxiUk/ZrcJmJKIDlcgpWC9OZXN5HM= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of jiangjianwen@uniontech.com designates 54.254.200.128 as permitted sender) smtp.mailfrom=jiangjianwen@uniontech.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679035811; a=rsa-sha256; cv=none; b=HNwVdgDLVCnIoMdM6nqqtYUJTM4kwKZNVkQLMyekFC93FgTXmJNwzhS4gq2K11p15o3DFF s3OTKlN41Oz3QRDYzz4MS6KOdhdC1YlmjKoyysEUYKpI5kwX9V2YlU+dS6ZesMo3Z9oQ1T LLfJPp65Nef2QZcCpK7zFAMgBkKu8Ts= X-QQ-mid: bizesmtp84t1679035776tgbpfpnz Received: from utnb-jevon.. ( [1.202.39.170]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 17 Mar 2023 14:49:27 +0800 (CST) X-QQ-SSF: 0140000000000070B000000A0000000 X-QQ-FEAT: dKvkn8qoLrEdStsMLkXGi1P3bKv4zF9smMHGhqZHCQB2/2FlEeen8CmUBHHf9 3W34kGB4LUMxRR+n9YKaBswwi3AI9smFxMUGMjOenJVm171w0yWkJTjPofQBIcGLuzK2Pnn RxC3qRhCkWrMHBl488TbBfhzGG2RWK77s7hyygzMjyJY7HxrQqesiE/TWhqAt3bSO12fXJX E9Ul3DuAzMqZVXtdqB1YDrIY1TnX2n3A2ukpcgQ4TDm7XxZydnqL1yFvBKv8P/ieZNHM7Ce brLgJ2RZaErzdLGoLmWSSjXGgYUgrswwHxvH330+Vhi0LywllPZXAJ61mkHUbNEyNLXftAe nm0XHMx5c8dS0Kt0THg5vzFDdUHt+ulP77GVX+dnavKbVS1cg23NFy6NyHAncx3LW4l/MOo FVBrqgdiQc4= X-QQ-GoodBg: 1 From: Jianwen Jiang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, guoke@uniontech.com, jiangjianwen@uniontech.com Subject: [PATCH] kvm: mmu: move the added page that exists in current lru list to its tail Date: Fri, 17 Mar 2023 14:49:20 +0800 Message-Id: <20230317064920.12700-1-jiangjianwen@uniontech.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybglogicsvr:qybglogicsvr5 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: wfso3ed1xsow9niibkkyi3xokn4bi9jj X-Rspamd-Queue-Id: ED2B7A000B X-HE-Tag: 1679035809-611829 X-HE-Meta: U2FsdGVkX1+8vMw179as/nzlkUof2Nwe2GCiRy8Fnb6Ry003PMSQlK2CBILDTeDozj9hbol6XHeixeA+Go0My771Jqob1HBcCHgK9DauaLAlX+Lem/TAMBZiZCp+qzgQfza9JS/SvYj4yqqKl6O3kD2kK9QTof4aiGUMN1e0Cfof+xNuORBZS3eLGz/MxUKK+aYXUneoVzHgUDy92dCGPzT8z3D8IOK5+74SMVPrDTX2Ba01MJiPhovzir2PdkxkJtfknYn6JM8vdeIKieZSgozyfmVEJwXHSULbgYY/WgJavGMXuX+7WIzXgl00fJMzSE2rtkXPGyMTzpcKow/La8FpS8M4c/gyJ54isVWAL1IqVskzGA14jSnsKARnVw3YCVGJd62FiRMxS66fYxd6wt9jwGxSW68tlH2FBYgA6QrqV572ktsrPPYI+cAiC6Rxu548HIDByd9IQ3w5oF6CPpmIoiWEJjev1+DqqTogSHfUCxhomAAWVxXvn4nzFY1QEx3d5ZDHnSJrXPS79s1hLDsQGQtaHr5dm0cklpmKSH+9VuyKyFu/aSErySCmu/1tf6C5u5Aoqjo2FYKpyHF8keXZ1zoLmfkBhTPZa71vYNix//q9eMREtV/EV2Lwd+INVWRUmexMWv40odiivwpvlCt1o56cPSUhRH0RD4AQqjcsuiCvtGgNqYMWykf3Vr9aDaVhrEPyrgOrvXXh+a6d+Qw980H6C7FU4wLoXUKgaEjSDEsfT3KdTKUhECwsCWYeve2R3aakuTxqlkLIAW+0WHSr0JLWwWY36gCNTspHemq53hwK6vQ033Bhm/ku5uMZlnJSjrFdKzksFPQp4TGHIVMjvkGZ/mGzUNL4AUDtS+RmDpKFwoPP1PPRqxbiAJJAJg3Q+SXMTBLkw4UYZsccYZ5LFpuUVcjJfnAPjwFPVYzZD+k4NkB9uOwHMF3f4cvuyxKvpUrfT6oUI8ObUVE IabJijEt nW5cMtagmsjEN+WIMP0czyw7MFaa0Sf2b+f3QNqsPHHG1HmM4vFWZpqIWXCkXAMsKTyF8SvNmqUuEkrB2nNN3Fs1yhVGtTusXE+nngFBzECG+QuzoYRuzKegIEXyeAEPxauu/6EZfqpPlfidBEEeF4uNY0kvREo0GC7PvXWSYcoJk5pMDc17uqwPf2og89jtwK4E3fDrNUcGj6TiUxNXfQfBj1wC4y/sqSEtJgAcv51PeU1bVL90qQ3UDOdRlckMpHy2T7Z5RsA7PGSKl/KpSfluHimJMOOk56Knq 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: From: jevon jiang If the added page existing in current lru list, it's better to move that page to the end of that list. This modification can prolong the lifecycle of activated page and decrease I/O requirements while memory is limited. Signed-off-by: jevon jiang --- mm/list_lru.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/list_lru.c b/mm/list_lru.c index a05e5bef3b40..9562e7aea535 100644 --- a/mm/list_lru.c +++ b/mm/list_lru.c @@ -124,7 +124,11 @@ bool list_lru_add(struct list_lru *lru, struct list_head *item) struct list_lru_one *l; spin_lock(&nlru->lock); - if (list_empty(item)) { + if (!list_empty(item)) { + l = list_lru_from_kmem(lru, nid, item, NULL); + list_del_init(item); + list_add_tail(item, &l->list); + } else { l = list_lru_from_kmem(lru, nid, item, &memcg); list_add_tail(item, &l->list); /* Set shrinker bit if the first element was added */