Message ID | 20250403141032.22743-1-donettom@linux.ibm.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 E1145C3600C for <linux-mm@archiver.kernel.org>; Thu, 3 Apr 2025 14:10:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 36A58280004; Thu, 3 Apr 2025 10:10:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 319BE280001; Thu, 3 Apr 2025 10:10:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1BA20280004; Thu, 3 Apr 2025 10:10:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id EF054280001 for <linux-mm@kvack.org>; Thu, 3 Apr 2025 10:10:50 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D5865AACB3 for <linux-mm@kvack.org>; Thu, 3 Apr 2025 14:10:51 +0000 (UTC) X-FDA: 83292918702.30.727E0BD Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf20.hostedemail.com (Postfix) with ESMTP id 93DE71C0006 for <linux-mm@kvack.org>; Thu, 3 Apr 2025 14:10:49 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=WvCsux6R; spf=pass (imf20.hostedemail.com: domain of donettom@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=donettom@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743689449; 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:dkim-signature; bh=z3Ll7BaePbzKlsIQORJqYY/wT4JTvpd+uyOY2GQT5No=; b=aAGID8qPnvX72FO4GDOKvF0dsCO4jNRD8UoKTUs4EGtehw4y+thodHm8h5vqFoJMgNSrK8 XzYu6fzbrGMmFG7jdO8pnBhUaib97pxYbSWWUhdciKYMSlg9F2l10tihfcfhEPIXFV6ORx ZOvKDXNMMriviXP80/TtIpyv4gl0ZhE= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=WvCsux6R; spf=pass (imf20.hostedemail.com: domain of donettom@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=donettom@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743689449; a=rsa-sha256; cv=none; b=aAPag4W7be8OoEKQMOo12lAroKspHgiA15QPVhlLGkO3UJoIKptbRe5r27n74ARQQS9ElG AchstLlmMqQbofPvgbWazlQY3gnp2RA/gvu1gciF6Xjpgfri0hlktFkf521EDsQFxXDYLF SwDUu2uh3X4cyOykpz6SRmnNfym7uF4= Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5333k0Qh006951; Thu, 3 Apr 2025 14:10:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=pp1; bh=z3Ll7BaePbzKlsIQORJqYY/wT4JT vpd+uyOY2GQT5No=; b=WvCsux6RWqZNE8pUXQa6Jh9SPvVxHZ+64qYnxy6Xte0n uxPtxJasofpQrmzADTE5JpGrDNBEkSxo7JvL4aI4KxfVOHonWyN9Kii7TBlev667 bAIeB3HQ4pegpvMrCf1B67A6Uv0UFQOGlIIvCd91ucPh+3jruN9JoF4oihlhxJR9 ar40vd+B7ZornfVTmLHmk7tUQB7P9f1oTgaRCnNblm/y8eQp54Edo0H+YW6Nfzgr nHNVstJs+xTIt4Qvfh68Dw4UL1lSWDDDOnybMyhy0V2SLZGlETH5pCQLbEvTiwf+ S/rIlD1L3fpjYv1lOPlXspg3z1SuHu6XI28BBYo8vg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 45sjq9tqyv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Apr 2025 14:10:40 +0000 (GMT) Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 533Dgn8P003008; Thu, 3 Apr 2025 14:10:40 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 45sjq9tqyp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Apr 2025 14:10:40 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 533D7GJp019413; Thu, 3 Apr 2025 14:10:39 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 45pu6tddk3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Apr 2025 14:10:39 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 533EAbGf36962770 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 3 Apr 2025 14:10:37 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7082C20043; Thu, 3 Apr 2025 14:10:37 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8B93B2004F; Thu, 3 Apr 2025 14:10:35 +0000 (GMT) Received: from ltczz402-lp1.aus.stglabs.ibm.com (unknown [9.40.194.31]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 3 Apr 2025 14:10:35 +0000 (GMT) From: Donet Tom <donettom@linux.ibm.com> To: Andrew Morton <akpm@linux-foundation.org>, linux-mm@kvack.org, Gregory Price <gourry@gourry.net>, Matthew Wilcox <willy@infradead.org>, Yu Zhao <yuzhao@google.com> Cc: Ritesh Harjani <ritesh.list@gmail.com>, linux-kernel@vger.kernel.org, aneesh.kumar@kernel.org, David Hildenbrand <david@redhat.com>, Huang Ying <ying.huang@linux.alibaba.com>, Johannes Weiner <hannes@cmpxchg.org>, Donet Tom <donettom@linux.ibm.com> Subject: [RFC PATCH v2] mm/swap.c: Enable promotion of unmapped MGLRU page cache pages Date: Thu, 3 Apr 2025 09:10:32 -0500 Message-ID: <20250403141032.22743-1-donettom@linux.ibm.com> X-Mailer: git-send-email 2.43.5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: oeQiQzqlA6q0-_K7b8-6wh1G8cwGgXGA X-Proofpoint-ORIG-GUID: tFHv-EUWfygQXmd0IHosonsCST40ypKP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-03_06,2025-04-02_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=999 clxscore=1015 impostorscore=0 mlxscore=0 suspectscore=0 phishscore=0 spamscore=0 bulkscore=0 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2502280000 definitions=main-2504030064 X-Rspamd-Queue-Id: 93DE71C0006 X-Stat-Signature: qrboirdn8fzfnb3wresi4pstzsrdhitw X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1743689449-966636 X-HE-Meta: U2FsdGVkX1/w3zzY/3VcsDVIfh5CvXM/1l9ReafONSqCNBlruKBDVc+YinZAWPsDVUlRAwS40QdndGspDuDR2tfQjq2gcZx75R3AHBZ3OCfuvqwUljOoh2YcBsVFPqShsYOc7VCeZzBrIDwQHTfaXQYZFtvc68fW4HWepVsHj9X2T53DMUJjsC8ifRvUys2d4wTyhDY5eFnju7gq95mlwe4PoDKY8PsHrqSS+43pfn19kKWjcM9naLrJKbN3dHBe9jxHNk6I0XeVrvbp0vRDbx1lyO9NG8rtzmLiVbRx8emfgr95E1lwGx6abDYEU2PzWXAZK9GuhK6cmwwFuduUkGTBa4eV+Woya9wJasIuWEFGQrzXxWb7JtmKp/Q8JzyVzDSKpjJ1pXr4wLer3+V8RMvNHATV9qe3/irjRE7Umo85oJUO4XcLcy1IZh1/TC+bkQ9MU6+Ijbg2Mj8JTdSeYVpKR/vGHqtEmnV/vO/ecIl4bXGtwpGbZSag3eVxljKN1gdrdwupZUrUyfy5ROc387Gve33C0V7iK7XCG6OyZl7oIL7O1jt0aI+IjQFVoupK6fE4cKOasY/nFGbHs1aRhrcfw8VEI7BPd+7FNRvcHWx+PkEgKjUvizPpC+TWGpTuC1osXslbn2i4P7Jq4mJtVyQzsYyArlqKs6WKRKg9KgIzZyQQOI0xywgwzVFjk6xcgfhjcw5UnN23Qqv9JOvLTojAlcWWKARit/G8HPN/Yp5r18pHjzE5bhvLxq5mHuOQx0Im690q8ZFrg2QMuzV43YDBYnag/AhJWE9YMYFc3EdnCXc7+eLzI/QLRLCK7zPOSfBaWm+4Y7TyBkSK8GcHOaLlneEeTaQu/BAAw5jLGsFcr+x2h6PUvinwLKvnWga1fOEppNaV51pgCCrdI5DEXUzD390mG5w0+pWGRW8X1srMqADu2FtpLRNPZzUEj1l/4F79Iwreu9j++toZTko RwCmiLpY aF64hvD/Q17+oZPkABwTAicDX6PnA6FxmwpYF+PauX5rXxHvYzPBU9xjiFnk7XqbXqVMwkUqEOxQu+KefSUpBNVx3xsPCnauAsgLA/K8a41judalNlv8nPIYCOfkV5cxek+/VDa8rCYsCH3fJ/qTUt/ANKLo2lqxW5IoAhKb4POoUcKfhXuc0ewhwlZtJn8Ttyj4LjbYsJTJDw+tS5Mqc/GANlYO/GWu+Ex7XLnb4XgtF05KKylbpYqYCT110DVPG5UIt9QeDv6H5vsNjEVBbJuSXRQSLwNIZZOuCW6kg2jxZBdBp5gMAx4RnSHIeC2pdn2Vc73AeR+iLhzjgrH2BomK6pltqp+LovdBX2WiPmXH5sq1MI4F4u0+iSLIxofJlqG144WIjsaDJf2N6s3qY/RY+RsZch1ayrXt8ppapEHKLbkQ1qs7jw0Mx/2wLzCXZeICsWeUMRtGVjzg7IWM4joLRXmOQtxterbqqfOKr66UtaTk= 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
[RFC,v2] mm/swap.c: Enable promotion of unmapped MGLRU page cache pages
|
expand
|
diff --git a/mm/swap.c b/mm/swap.c index b2341bc18452..f3c19d563556 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -399,8 +399,13 @@ static void lru_gen_inc_refs(struct folio *folio) do { if ((old_flags & LRU_REFS_MASK) == LRU_REFS_MASK) { - if (!folio_test_workingset(folio)) + if (!folio_test_workingset(folio)) { folio_set_workingset(folio); + } else if (!folio_test_isolated(folio) && + (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING) && + numa_pagecache_promotion_enabled) { + promotion_candidate(folio); + } return; }
This patch is based on patch [1], which introduced support for promoting unmapped normal LRU page cache pages. Here, we extend the functionality to support promotion of MGLRU page cache pages. An MGLRU page cache page is eligible for promotion when: 1. Memory Tiering and pagecache_promotion_enabled are enabled 2. It resides in a lower memory tier. 3. It is referenced. 4. It is part of the working set. 5. folio reference count is maximun (LRU_REFS_MASK). When a page is accessed through a file descriptor, folio_inc_refs() is invoked. The first access will set the folio’s referenced flag, and subsequent accesses will increment the reference count in the folio flag (reference counter size in folio flags is 2 bits). Once the referenced flag is set, and the folio’s reference count reaches the maximum value (LRU_REFS_MASK), the working set flag will be set as well. If a folio has both the referenced and working set flags set, and its reference count equals LRU_REFS_MASK, it becomes a good candidate for promotion. These pages will be added to the promotion list. The per-process task task_numa_promotion_work() takes the pages from the promotion list and promotes them to a higher memory tier. In the MGLRU, for folios accessed through a file descriptor, if the folio’s referenced and working set flags are set, and the folio's reference count is equal to LRU_REFS_MASK, the folio is lazily promoted to the second oldest generation in the eviction path. When folio_inc_gen() does this, it clears the LRU_REFS_FLAGS so that lru_gen_inc_refs() can start over. Test process: We measured the read time in below scenarios for both LRU and MGLRU. Scenario 1: Pages are on Lower tier + promotion off Scenario 2: Pages are on Lower tier + promotion on Scenario 3: Pages are on higher tier Test Results MGLRU ---------------------------------------------------------------- Pages on higher | Pages Lower tier | Pages on Lower Tier | Tier | promotion off | Promotion On | ---------------------------------------------------------------- 0.48s | 1.6s |During Promotion - 3.3s | | |After Promotion - 0.48s | | | | ---------------------------------------------------------------- Test Results LRU ---------------------------------------------------------------- Pages on higher | Pages Lower tier | Pages on Lower Tier | Tier | promotion off | Promotion On | ---------------------------------------------------------------- 0.48s | 1.6s |During Promotion - 3.3s | | |After Promotion - 0.48s | | | | ---------------------------------------------------------------- MGLRU and LRU are showing similar performance benefit. [1] https://lore.kernel.org/all/20250107000346.1338481-1-gourry@gourry.net/ Signed-off-by: Donet Tom <donettom@linux.ibm.com> --- v1->v2 In V1, the folios that were part of the memcg and the active MGLRU list were being promoted. However, in MGLRU, file pages accessed through file descriptors are moved to the second oldest generation. This second oldest generation may not necessarily be part of the active list. Furthermore, this movement to the second oldest generation only happens in the eviction path, so if the system is not under memory pressure, this movement will not occur. As a result, hot pages can be present in any generation. If the reference count is at its maximum and the referenced and working set flags are set, the page becomes a candidate for promotion. v1 - https://lore.kernel.org/all/20250115120625.3785-1-donettom@linux.ibm.com/ --- mm/swap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)