Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1003365lqp; Fri, 22 Mar 2024 02:36:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXSdJ7ZqDMhhf5FaoUP/sdkQ9VsIEu45cEnIbUP5XD4u4JFheboWW9VRsFyL30NU0hu1MI54igeD4kANi+LCrkW4HZwfDsXaCmrBqTGwg== X-Google-Smtp-Source: AGHT+IHagMFrKjw6xWCzMzE9WE3xFWFv3VePm5+pangAgEOaCpBTHih4JtCduWPF0AXDtJ1lkufJ X-Received: by 2002:a05:6808:1786:b0:3c3:a3df:f1ef with SMTP id bg6-20020a056808178600b003c3a3dff1efmr1721472oib.26.1711100206190; Fri, 22 Mar 2024 02:36:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711100206; cv=pass; d=google.com; s=arc-20160816; b=lExYeO8qYevAZrAeeODCUHwatMK9fOYSDS+rXTzq1Ld342pNmOd9kwd68X9QQ/vlnd tfd/ku3z+8yxEZZHShfyEw9EJVKSIfM5Rz6N2ExpfQquAAoTXvAkKrhPCWV4udJgBl/b 2i6dNcx8ONrNCVp88Sp8EYQvxv6jNMrd2akT3qjqDpM/yJfBNHKFjoankQzewqK2Pr0d eNjOni9KrAz2VYBTL4fmXYXu6AOp1J3HBbXxUqG2/LlI3dx8DnS4sC2SFx4W9dwYteiP kIbI8R+h06e0aoOd/sOlyvYnqI+9w7+7lTSySs6LEd/yuxxVjDEJubiJHMJbejt7p0pr ksag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=6fo+DJ/eKF+RnrUfgp9/auEJ+mhPlykcMF8nrNgnGNg=; fh=JPsdd6h06AA815xES2bFeKm85BIKkA8uK8zn2NVxFhA=; b=bE/y5f7TjUSChJCOCCUkxU1BJAGhl07L7ywfge6NV7KJZ4nwg3cAGSwMpq3GHAY1AX DLLhI4vM+pCUtcVnRbGrDvOuNKlTAJzYaOroJmaAzwLrZ6YL5fvr0/GIbDzqpasA+ndq lSzYSEGYVXVhqXVKO1fZlqO7SXkLF7YZSy50apz717VH/5e5F2Oxi+MpuD4bg6haqrPS isdz5XPzV4NUg1dZSjl390HE/NNEqwU2KmOUg+RNQzPO+hP+VGx8qIMsR/TFQ5TbKE4+ 7271USh1Gpu9fYjBZ1oa7dOdHcMF5LGcQup6hP7weMa7fRZk4CB3k/CxGpUjoGnX58z0 5o1g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-111226-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111226-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x27-20020a056a00189b00b006e68194dcb7si1675294pfh.401.2024.03.22.02.36.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 02:36:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111226-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-111226-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111226-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D199928ADD9 for ; Fri, 22 Mar 2024 09:36:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B3D1036B00; Fri, 22 Mar 2024 09:36:26 +0000 (UTC) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C80D224ED; Fri, 22 Mar 2024 09:36:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711100186; cv=none; b=ofw93lK2Xy6pxhMgYXr0H3n2S0t7UwD9NZy7mJ5C1kI5xUYNYdDNbT/oAvGbNZuHUnelQg410wYXwlhx40iSSayiV2JxT8TUbzVRDpJMNRSw+rDUf6nE+LWKWPLi7Doq+6mlzuJd6UIrF/yUfMgMKb5vq6yzPfBiXWzX7PATJTk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711100186; c=relaxed/simple; bh=ecB2yv4xVDWojcVvrnD4p1dguHQ3ccRU+epK/KdXcN4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QvQKfprkEzV4VwRqIIZw6y8F549E/rLNTSzigFuyYl8YEa1I9qrUkzHoYcGRvMaJVcN2ru84HKZ0wsQGEKqgCpTFGInv0qpPXv7RORBxiEjGBXNozCn1ggGDJrqW3pJgxBN7dkXdAUvOysIbRKvhl2j/DMApmfO+JYAo2UdgNx4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemd200004.china.huawei.com (7.185.36.141) 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 --- 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 -- 2.25.1