From patchwork Fri Mar 22 09:35:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 13599848 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 DCEBCC47DD9 for ; Fri, 22 Mar 2024 09:36:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 697136B008A; Fri, 22 Mar 2024 05:36:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 644AF6B008C; Fri, 22 Mar 2024 05:36:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50CED6B0093; Fri, 22 Mar 2024 05:36:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 42CD06B008A for ; Fri, 22 Mar 2024 05:36:28 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B8F8A161514 for ; Fri, 22 Mar 2024 09:36:27 +0000 (UTC) X-FDA: 81924169614.24.28B9171 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf30.hostedemail.com (Postfix) with ESMTP id 555B680014 for ; Fri, 22 Mar 2024 09:36:24 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=liushixin2@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711100185; a=rsa-sha256; cv=none; b=W1yKi4T3aM2u2cTbbrH4NZKs6MlTyqGu6VQbBTFW9nBDjN3ECrOGAy3UY40m7SaugkpPlU f0yrs0mma3eSBgQKLXcjxM3nhPWfS7z4nAg9TRk6aaXC9tEh3jLAjbxqeFTTFFe7DekXP1 kSvzzGYFeJ9+v36T0tGIa8VMaRCgFXQ= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=liushixin2@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711100185; 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:in-reply-to:references:references; bh=6fo+DJ/eKF+RnrUfgp9/auEJ+mhPlykcMF8nrNgnGNg=; b=iK8gOVKng9okt2fRiYcFcoxY+wZNySUOF0Rsnzw3jlSALGF4CRbvn5DPI+ZaiYFW8KO33E M4tIOqfiucBNXmg/+7gmZp6mxnrZ3yAZ2RJj30gxW7WEQrj/N3BykVO9/xcXuQDB/+qdGh xi9xhBZTYYA19x2JiDL+uWk9zji+jcI= Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4V1HFk6jJXz1h3SL; Fri, 22 Mar 2024 17:33:46 +0800 (CST) Received: from dggpemd200004.china.huawei.com (unknown [7.185.36.141]) by mail.maildlp.com (Postfix) with ESMTPS id DAF6F140384; Fri, 22 Mar 2024 17:36:21 +0800 (CST) Received: from huawei.com (10.175.113.32) by dggpemd200004.china.huawei.com (7.185.36.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Fri, 22 Mar 2024 17:36:21 +0800 From: Liu Shixin To: Jan Kara , Matthew Wilcox , Andrew Morton , Alexander Viro , Christian Brauner CC: , , , Liu Shixin Subject: [PATCH v2 2/2] mm/readahead: don't decrease mmap_miss when folio has workingset flags Date: Fri, 22 Mar 2024 17:35:55 +0800 Message-ID: <20240322093555.226789-3-liushixin2@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240322093555.226789-1-liushixin2@huawei.com> References: <20240322093555.226789-1-liushixin2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemd200004.china.huawei.com (7.185.36.141) X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 555B680014 X-Stat-Signature: mt59j3e5cfr383us8ry8i851sggtqiad X-HE-Tag: 1711100184-811170 X-HE-Meta: U2FsdGVkX1/2fGmWqXcrCT1ZGkw9LM/Oy37YilnPTCr7DWxsvWJOJCtIO87yql7HXgmshho7PybOs9qQv5+o4Djgk7nnzLs2oOheGHeDrbVWe0YeiJnKv/mQoiP6iXOQg5piiRLj6Jwrik7aMVe1gSAwjSJfm6WEnYNAjn+LTKGAUeJ1N0vewHhbNXCEqaL1sCXz9yzlJBVgyc2ldX6L3wL1yRiEe181GjPLuYYIn0u/+0mjYDn0A36xNJAfcjCqx6bUtiuCvdZr1aS6uRwKjBZ2svg6i7WWyM9Tqtp3x/r4PVFXMaqj+Cp1SI2a/vguNzVNA5VgtKLtdhPZXWyJ0Ooo0x/prIflFMIu07bTEM6j04fCrKM40kf1BbnxEiCypRF2oVkqycR1JWPIT6PTCYL5NEnxmbj6IayzNMtj9BPywPV6P+dU8wG+vG5LkELMjxaCnB/b3+6yZUC1wgLmXBtDvGil3MfMiIsBedjPuNuiKMTTUgPec0oFj57TGBA5jDLj1vfd08oWxby7DtSYZSnhPwjIv438UnDBEKxUR7WLOjHTwZhnbEqovt2sdkfnFssz7xjaV0hb0v38TapuGnjRthRXHEXgcle6KtcQKKJsizWnDSCvKX3atmmrUVgM3m2ECoMgMO+9AzaaFMUzE92o/YwDJpBGGVxbVvgSiVrtBuYCBlX+BeD1qsoTNZC6Z1TEmrdjH7/iASAXkZzgzFtWmovE5izWV/0NujAFB5B658Z+l2xa+1Y/yMxOYwXfnZGREDevQkGVXUNZt9xECh4KcV9aA6WJnoTNXQ45dN6wIb3ezAz3TMrXSGziKWvRIWZWlQBrLlDhjO0iDae4rrLgZUCGMXGmrMbqFsVHhn5dg94/5l7d3cPiM+ezRfWlMc3USLoy7843d7gyDt2/BDGzUr5yYHM9aR/xM8YNo9oTNJsoj8fD5jHnECZqoKHw1Zshy8chscoCCfxf7zn vAVIu4kD IxfotHQbMP5hENVVKSO4a4IgACnrXWLev6/LvN/2JeV9HgEvfklZzMWFrf0RdggKY5XHMFG3b0hB61vQZsULfXahO9VQ3ntdC54HCwlXGOt0foITXQHRMkypbxmoSoj1DPIrBSQIfuE5ak3MWg8Blzo1QtTnChfpvLvbCq51OapZbA6bPCljLRz/sQ53VHj1c6xZI 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: If there are too many folios that are recently evicted in a file, then they will probably continue to be evicted. In such situation, there is no positive effect to read-ahead this file since it is only a waste of IO. The mmap_miss is increased in do_sync_mmap_readahead() and decreased in both do_async_mmap_readahead() and filemap_map_pages(). In order to skip read-ahead in above scenario, the mmap_miss have to increased exceed MMAP_LOTSAMISS. This can be done by stop decreased mmap_miss when folio has workingset flags. The async path is not to care because in above scenario, it's hard to run into the async path. Signed-off-by: Liu Shixin Reviewed-by: Jan Kara --- mm/filemap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 8df4797c5287..753771310127 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3439,7 +3439,8 @@ static vm_fault_t filemap_map_folio_range(struct vm_fault *vmf, if (PageHWPoison(page + count)) goto skip; - (*mmap_miss)++; + if (!folio_test_workingset(folio)) + (*mmap_miss)++; /* * NOTE: If there're PTE markers, we'll leave them to be @@ -3488,7 +3489,8 @@ static vm_fault_t filemap_map_order0_folio(struct vm_fault *vmf, if (PageHWPoison(page)) return ret; - (*mmap_miss)++; + if (!folio_test_workingset(folio)) + (*mmap_miss)++; /* * NOTE: If there're PTE markers, we'll leave them to be