From patchwork Sun Sep 12 11:54:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Yongmei X-Patchwork-Id: 12486799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_HOTMAIL_RCVD2,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA52BC433F5 for ; Sun, 12 Sep 2021 11:55:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4AD5F61076 for ; Sun, 12 Sep 2021 11:55:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4AD5F61076 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=hotmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 933C16B0071; Sun, 12 Sep 2021 07:55:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E3576B0072; Sun, 12 Sep 2021 07:55:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7AAD4900002; Sun, 12 Sep 2021 07:55:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 6E42B6B0071 for ; Sun, 12 Sep 2021 07:55:04 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 1ECA5248AE for ; Sun, 12 Sep 2021 11:55:04 +0000 (UTC) X-FDA: 78578765328.25.BAAC54D Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-oln040092253063.outbound.protection.outlook.com [40.92.253.63]) by imf19.hostedemail.com (Postfix) with ESMTP id 0A246B000093 for ; Sun, 12 Sep 2021 11:55:02 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TXCcWjeBqvvZ/EIFvIoAjixam17crm3Cl70OBq59vev6NsZvKkmBp37ose8dkrRt8kEhyns/YldtOT0uKIslDuGsZlfNVwcSu14mxEZ81jGXQejznhWZH1oPK7p6UpDhm6z6dDAPGi4aregvMOm8S2mxVQR+ISlv0/KryUStH2VUYB0V+AUf+66oZHoBaEtBX4nP7o0okrDxaYm9CCX2nz9rGdLhFWxWx/GzDbL8sJEd/yLm4EDIsDy4CfcIgV9AWtjeAPqrXU1mIh4Gyu7Wy81Wh/djAsK9rcb2sKQplAtoII/7iqCbdTgBDlJ7eo/siQIhyfFZWv/hknco7RaOXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=aVlZr19c4kOOo2q/4/U3TT34inYY3edAcmk9kO+ON20=; b=khWTkfr85/4KY4HlY1/zhH5quETwjRC8MsGVCVlY1DD7j7MD3rUyB2usp5qc31zBEUBlv4woFyKg7Czclttf0/JVtqAYydaTawh++ESEq2CAa8Z07DSGCpkhPcVmiCh7WlF6s5/gyueGNc7Ne/shyXY8MGkj0Gr7x72T6BNh6tUhJwuxT1O6JgOYcdRHtHzpwlMMDATGHUitkodrTErWwHy6H3KAcOsgSDDJ23E4+3a8+ZoQWnpC5/g3Q+cAyo2w8E16FkWQviuNNqZ7sg4/kevPVDXf9KJi6UdPKsEmOVPKj0+NdjaFgj7ltikcsW7djXDaV7Ml8+/SQ5ydjRnUQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aVlZr19c4kOOo2q/4/U3TT34inYY3edAcmk9kO+ON20=; b=F2VmPGoFIKLqMWecebZs3BqlOfZKDARhyn1MK5klXba+y98nxoF6nCwDqeS042tUg9hzcpiV7mSjnML664IPdi3aUhZVG/Liumn+zeyNBctR2M5XCDgko9vXFHS+VeoCeCfnD3Ap3auZzdznSWplN4ldl+LB8ycO1by4/JAYN4pN5FnNSBozXvfv2Btvc2cXNfqu2mK5SerqNp1Rlvt2FooJpY6M6ZfzCZIrbjciMyg0txio4wTJnd5DYbmV5+NkPxIxpkU2M7ZJWwP8akv5uZ/nGzwJsz/gwwdLPvxu/qsZzqP9OmIja495AedsHhjSP3IS+cuVES6PYDaRicgTmg== Received: from PSAPR02MB4853.apcprd02.prod.outlook.com (2603:1096:301:92::13) by PSAPR02MB4998.apcprd02.prod.outlook.com (2603:1096:301:8a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.16; Sun, 12 Sep 2021 11:54:58 +0000 Received: from PSAPR02MB4853.apcprd02.prod.outlook.com ([fe80::4ca8:4f5e:248b:9f06]) by PSAPR02MB4853.apcprd02.prod.outlook.com ([fe80::4ca8:4f5e:248b:9f06%6]) with mapi id 15.20.4500.018; Sun, 12 Sep 2021 11:54:58 +0000 From: Yongmei Xie To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, hannes@cmpxchg.org, yongmeixie@hotmail.com Subject: [PATCH] mm/workingset: don't count as refault (file/anon) if refault distance is too long Date: Sun, 12 Sep 2021 19:54:47 +0800 Message-ID: X-Mailer: git-send-email 2.18.2 X-TMN: [vNEakcy2L01EQ3mbija15edDAtoyGC0m] X-ClientProxiedBy: HK2PR06CA0012.apcprd06.prod.outlook.com (2603:1096:202:2e::24) To PSAPR02MB4853.apcprd02.prod.outlook.com (2603:1096:301:92::13) X-Microsoft-Original-Message-ID: <20210912115447.667655-1-yongmeixie@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from 192.168.3.12 (111.202.144.35) by HK2PR06CA0012.apcprd06.prod.outlook.com (2603:1096:202:2e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Sun, 12 Sep 2021 11:54:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 95a49934-b4eb-4544-5a94-08d975e424e6 X-MS-Exchange-SLBlob-MailProps: 6H6McBavlAgyAO2HcWucuLT9fvZv9SwYPFeqAJlPekQvwejTUEen6/iwI2MnbMmulUIyU2vz4huV9/U+fOsCi0aPKEGWUwKw+WWkkVx5L7che3P6E2EBJAefM5/x97L3WSyG/j2rb4JFxGGBsQtxbY6Gtux25pMMOdMvKDwUZ6QKAFHJ/+LlBE7ysg+WvJhOSX1e6iA8YJ2AGTq/btYChgMl8RY6JAFxVMJxI9JiXaAJbW7YiA/ZcVXuuYKaa7W1Jfr40MUynuCYMX22rOCQxUDv7H8F6PWlqLzUVXYFx1oAMcK/IzeBYD3ZyfFYz4TAfUeNJ9fyVRrQdm8FCYFUOWmutYo6V88uSstsr8FTmlr8dAYzGUBhlIl2Gvp9EJpnQZlfWdtmBsd7LjRAuU0f4b4KuZWPeQ05DIDGXxrWUv7dLZqqbb8+KKfYqQ84eempuE71yYB0kxEykAqPOcaDu9rm1b6eK6MKfedwE6f2lTBntLF2vdfn/EFZ4jQ34VXeSHXJ4HmS8F6HaMLZmN71zFTo586mV7UNOENG70Ndv7i4N5zDyR0If4YUUJ5ZPsSXWUyGzU+Ho8ndTXqdiHjhgstjGHIHMURFhDzv4P0VDoXWceiwNNwhKh+/7oCAuUD4XjKnrG4Q92j6Qr936HOxrYhhNWw2IzHShs9ENye5sqNfcdlJkovYp6cR30pDQgqkhtLfVPb5LD4TTNHoO69/KGaqjWkAwG/bj6Q5za1LDoI9c2Ad7ir8Nl0TSIUSvCrs0rMxobHNhmc= X-MS-TrafficTypeDiagnostic: PSAPR02MB4998: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ztlmyRXkYMA/wovW7lN+4PxgV/Z8NL/jyKn2wWvWdiJNPrMaapJ7uvy2uMDjwCfhQMqAJEkQqFl3PQd4zzMfeCSp2gwmtLifhnv+wnE0BW2WqX4CvsVC+CAwzAea8ZYdqS8q060RwTPPnQcuWEt1CyFxOz0RAiB+/T0JXelfTDExHqA/LMDS5iDuS/pkGEBvAc8Yog0vMSfYFL3gsCWv1TIdP5R1Kwt2F0KYn8MNatgCa+vsRdQZAVxoIJYTH307z/nsejuTPkPQ7SdJO8YTFCFBOUnhvwcJpS1Ni9+GqNEnwdeUi0+8b89ppW5uGsLmxNGVMd1w1gEEsJkOzBIQg0qWoiu8aXTOLiKaRNH9BetFOB5nZj2GG4UxA/CiqqWDwdsNNiDZkeUddu4n4c8eSNc1oIqxq3/ODfn9GRV2bdr1PM9dJzoD9s/pNxLww8Qc X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0TFa7cQ2ZWAY7tJgw62sYnGeoeujQE7xNxPGG/gwhigk0DG26FO08hHSIBDJX85aR5oCvwbOD6i5qpW/5g2iYN5rmy+pBVOvn11mJf//5YA6BrYbrZGiNV3T94E6rEenQOr+x2gHFhtSupNqx85JpQ== X-OriginatorOrg: sct-15-20-3174-20-msonline-outlook-0bb73.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 95a49934-b4eb-4544-5a94-08d975e424e6 X-MS-Exchange-CrossTenant-AuthSource: PSAPR02MB4853.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2021 11:54:58.3318 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PSAPR02MB4998 Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=hotmail.com header.s=selector1 header.b=F2VmPGoF; spf=pass (imf19.hostedemail.com: domain of yongmeixie@hotmail.com designates 40.92.253.63 as permitted sender) smtp.mailfrom=yongmeixie@hotmail.com; dmarc=pass (policy=none) header.from=hotmail.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0A246B000093 X-Stat-Signature: 7fg6i8tf4wytx7qptjtfoygoq7q78ayh X-HE-Tag: 1631447702-40649 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000083, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The current implementation count all the pages which have shadow entry in radix tree as the event of refault (page or anon). That means all the pages which have ever been cached in lru are counted as refault. But I think it's not 100% percent correct. Because usually inode has much longer life cycle than the pages belonging to it. So if the inode was accessed from time to time, then it won't be reclaimed unless much severe memory pressure happens. Then if page was reclaimed several days ago, when it's accessed again, it will be marked as refault event. Then page was reclaimed an hour ago, when it's accessed again, it will be marked as refault event as well. From the refault metric alone, I cannot tell whether the previous reclaim process has evicted some useful pages. That makes things worse in situation of proactive reclaim. We's like to known whehter the previous policy reclaim too much meaningful data other than working set transition. So we'd like see the refault rate, but it includes all the historical reclaim. From my point of view, if the refaut distance is larger than file cache size, we don't have to count it refault at all. Because it's too long to be memorized down. Signed-off-by: Yongmei Xie --- mm/workingset.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/workingset.c b/mm/workingset.c index d4268d8e9a82..fa78f064bd16 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -288,6 +288,7 @@ void workingset_refault(struct page *page, void *shadow) struct lruvec *eviction_lruvec; unsigned long refault_distance; unsigned long workingset_size; + unsigned long file_lru_size; struct pglist_data *pgdat; struct mem_cgroup *memcg; unsigned long eviction; @@ -350,6 +351,11 @@ void workingset_refault(struct page *page, void *shadow) memcg = page_memcg(page); lruvec = mem_cgroup_lruvec(memcg, pgdat); + file_lru_size = lruvec_page_state(eviction_lruvec, NR_ACTIVE_FILE) + + lruvec_page_state(eviction_lruvec, NR_INACTIVE_FILE); + if (refault_distance > file_lru_size) + goto out; + inc_lruvec_state(lruvec, WORKINGSET_REFAULT_BASE + file); /*