Message ID | 20240710031020.1681-1-justinjiang@vivo.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 F37C6C3DA41 for <linux-mm@archiver.kernel.org>; Wed, 10 Jul 2024 03:10:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4458F6B00A0; Tue, 9 Jul 2024 23:10:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F4B36B00A1; Tue, 9 Jul 2024 23:10:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26E246B00A2; Tue, 9 Jul 2024 23:10:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id F34B46B00A0 for <linux-mm@kvack.org>; Tue, 9 Jul 2024 23:10:38 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9AFD31212A9 for <linux-mm@kvack.org>; Wed, 10 Jul 2024 03:10:38 +0000 (UTC) X-FDA: 82322365356.24.4EF4764 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2085.outbound.protection.outlook.com [40.107.215.85]) by imf28.hostedemail.com (Postfix) with ESMTP id 835C7C0005 for <linux-mm@kvack.org>; Wed, 10 Jul 2024 03:10:34 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=SKxlfXqY; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf28.hostedemail.com: domain of justinjiang@vivo.com designates 40.107.215.85 as permitted sender) smtp.mailfrom=justinjiang@vivo.com; dmarc=pass (policy=quarantine) header.from=vivo.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720581003; 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=Z3PL+S5X7q8r2qnDC/7FUZ7Gmw/iWimRo5Vyc54plj4=; b=KoEb8nKx0ktcZ3+mYkTEG+k6Ejk/09JvXbVTPy8bUf7B2HKtrfe+vR8+ted3nThot7KS/u CP97/p15PXkEkzkKGnf9pMW/Wz4JLv61dgsaK88kt+KskNbp2AIY2q0vQ+LlHP/nh/zGzE TbyIoEDdXsiJb+Dz3pvLVYBcWq8yNrA= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1720581003; a=rsa-sha256; cv=pass; b=gBcynRhH/oAD67VUj+B38AcZ7uaxZwv9olNcuM3wdgXQazrCYlFSBaEGG2brl0NZ/+HSAy nPYz3wGRsXvrzKsUaD5mQnQc/njtIRbSTSrmVc5BGGmzXrdHUM1HnLOVMT1fABxk4u5vEe VIZFGv7NtKhMraoCu/JYfm1wLb3yIKU= ARC-Authentication-Results: i=2; imf28.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=SKxlfXqY; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf28.hostedemail.com: domain of justinjiang@vivo.com designates 40.107.215.85 as permitted sender) smtp.mailfrom=justinjiang@vivo.com; dmarc=pass (policy=quarantine) header.from=vivo.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cOQ1D79OyZaxUkRSwLpAmeL9K2jPP2O/ekYO7IgOkzR4Zk7I2SXDvhtazoIDnxeEW4XjKoSXBfxrZ0ocYszwJ3qwe5gdwvDNRvd3jCHx1JKXCv4cemnayo3atZVy8B44sYUl4WcbTrxeUXN1PBz0r8BY5oBd94bRiH7HmvtwiMSaZk8DU4v5qzEbgsLGOdbVwKm3tJPy4nBkJRJJ/rR3pGIOxRrmXcuGcwXi5NNlT2HJ2f2Dcd3trGw9rDnTPOGISuxLV+QPfmAsEuJUCspYqzQocM9LkLucPnheSZoRAJYE4YTAPgUaUy3QCp5OM6I84pFENBXF9uv1/nsXQMUpQA== 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Z3PL+S5X7q8r2qnDC/7FUZ7Gmw/iWimRo5Vyc54plj4=; b=jMp652Ck58Tv8Ahwg/3NcLb4NdlelbVPgK47Vm2dfdbjxTHLpiwsd0spZXPWHl94M4QY39dg/IZYIqKu1EAJANr02mbdn+SjSwvKqwLXsOMYp/qAuvFda9yvr9346b7aLGIXMkoVM5iDE4fBep8h+GQCrJZ5iHrD5zNOGLGGgmY+AP7coprb0+/uDFjKEMj8VmUe0WxXME4c8FPmlAzOEciiCim6yAmxaw/I5KZzpRFMiuzNlrZArGkMcpTQrQMtTs1TxPaoa5dpIX+aeQCe0L0Nd13pUYxPheeLCz7h2NUAnl6qLFyUnWOI8y5bXmvlMMh/06l/4cgY+CIOsuPiAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z3PL+S5X7q8r2qnDC/7FUZ7Gmw/iWimRo5Vyc54plj4=; b=SKxlfXqYRhUMF//gPmzTfba/NNJLQhjHRXQ8FkFy3bki8+ITDKcAxMptvgKBd9Wzrxh9kqX29USlY8leIge9Xfv6XaqVkKqqh/m3oXdAO5om+Y0/7bdRVuYwcYgYqpLyoLQb0OATB6p7m3V3y5rwRjNA+4/dFmGEbwxPuSuibPHnIV2lmeXCj7aWjmBGbE/uI6cBBLIz3vOunY6D0x9xXkwBZUz5+mi86uyXjjqOpPVJ8xjYLKlsv1zMrmf/zyzuaXfk+sbzNofIf8bRBek1s1Dc9dfK2rag1XUfH7kFvVbWd+C7Sya1RvMiQf6LD6/Rm+fQYbhcdVrCLDA0FAQh2Q== Received: from JH0PR06MB6849.apcprd06.prod.outlook.com (2603:1096:990:47::12) by SI6PR06MB7146.apcprd06.prod.outlook.com (2603:1096:4:251::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.34; Wed, 10 Jul 2024 03:10:29 +0000 Received: from JH0PR06MB6849.apcprd06.prod.outlook.com ([fe80::ed24:a6cd:d489:c5ed]) by JH0PR06MB6849.apcprd06.prod.outlook.com ([fe80::ed24:a6cd:d489:c5ed%3]) with mapi id 15.20.7741.033; Wed, 10 Jul 2024 03:10:29 +0000 From: Zhiguo Jiang <justinjiang@vivo.com> To: Andrew Morton <akpm@linux-foundation.org>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Barry Song <baohua@kernel.org>, David Hildenbrand <david@redhat.com>, Matthew Wilcox <willy@infradead.org> Cc: opensource.kernel@vivo.com, Zhiguo Jiang <justinjiang@vivo.com> Subject: [PATCH v9] mm: shrink skip folio mapped by an exiting process Date: Wed, 10 Jul 2024 11:10:20 +0800 Message-ID: <20240710031020.1681-1-justinjiang@vivo.com> X-Mailer: git-send-email 2.41.0.windows.3 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2P153CA0043.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c6::12) To JH0PR06MB6849.apcprd06.prod.outlook.com (2603:1096:990:47::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: JH0PR06MB6849:EE_|SI6PR06MB7146:EE_ X-MS-Office365-Filtering-Correlation-Id: 24b4e277-a227-43fc-b125-08dca08dda51 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: OWad14J4apFlyZeDILaTQ+NU3F/E2YUFj8mpYKlSxlDDh/F7byIQ42i7KW9wMtg71RBw61op6jhNpE+lOXCVnDqgzbj+Klth1mMgybnO8INhzjL56Qgv+wMzyMc+u6q6qKWMLqGBDJTxLOrZQAbUAu2hTT8yH1+/Su8akded5TDn37UGS999f58Rl8RPw5MFlAA2SJrqtHyfgv3JDLf6FvCT6Qf12knSnLvQmx4FSQKd6t9BXeJ4v7tRjxoWsaLKUwztcssHMSJUar7DU5KMMhT6hijrEpWpGoTmrYURfe+2lU+DS8ZEok10BamEU1sGUVesiHPvTtk4qcNG1IStrGXaVW+ifHA3hphyvKGU/Og8F6pjwr+iu8FtmdC/vQslmORF9nIIovxJm4M6wMeTgcjIe5WFU0XcNwU/zHt0nwJ2K4r/b3lYHhx70LY0uqKd7S5+mQiCvw/O3hC01R8zA9dnBB9qR3ZErKVXlQ0l0xA1ANkkUEsels/qQSzIVTy8cOXwa20l/MJp8+XD7NB3nXGvsB3lRnIQO6dbm1dTWqfCPl0LS6Hch7ExPmnItmXJGaZWB8ZovrXexcX5bJJRARk6bdgduxAA99gHRqW0sEjukuDKM6dQf9TWs1Lb+bZgcaxbmjthZcSRzSzZptYYiqUNaM0Q65/vYfCjCfXE0Zf32LlfbRAHbcgbDU6lkFdn7X9pOXhSWF08YyVhBjUgxDzfQeldTbnZc7hxgcF26R5SG1NtBqdE5tOpTdZFVYZ8si/GQ+KCUZz3Gni2b5ZjlrFBwxPMV6c2csMRMkq5UaKju3GvV1oVOsPEnwD4TMNZFE+IJAGont/zSAtYFkzsV0jHOprMMRPjysJVa88UZMeJeV6Rvak9xmNJvk1NDvwuVn4QlFln3hid7Rsjjs1FJwG7HYIxnREG04aF/q44JszzHT5+APbBghkejHutG+6EWLu+O9h0HjJCQhnRutkEmS8B199i0cQrPzFe2VDOf5qCZmzSZDtvDCTuuek13JuisTr49UfayEs5BGZPKoHm1ZG+zw7dN5pD/a2uXJWfTDA1UEHXFQ+F35GYOMIQuozakBnCOPIl6XSsznjvQd6A/XnJtiiNmKe5jiwuaiYOM0lNgcJ6kZoxE+T22HZ+fFrz64EkRkNk7Z1GcytWehwtquhDeNX0VguHWz46oCUq/0LpdPel5JDXNkXHgS6YIdcQZbbcV8S7UXCf05gnwcCkR9r0EDGNCzBBKXaqGTxqNV4dEwROCRjrKkfThN0g+Cyx8+Ja3jpve0YNU3uF2bzJrUQZKizRWK+JokUhnQSlKDvYbQ/aehEkUtF0UiFoDJycVNbm+TSY6KewUFn3TBRclOXzl0eErYLp4Iz/ACMYFr4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:JH0PR06MB6849.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(52116014)(376014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BiYYEledBTB4NZh72PlArONYTM9oK5TDc9/qgemhGZbXB3KUb8rkN/Q5tL5NgYYi5letucimUNoCyyxsGrOipk5sxIZQfeqApk1RvdHKVEmWg/b8XFRVRAKUYhUyNrD2YckBUI3f53ITK+ZEfgc8w8xmgFGH5YEACdRFPLigMAqX6yOVw33+8hskWINv5fVFmvWySKIjAAWotGr8LFjjrAAksJKfQ+yxkYNgV+UWNoimb6u0p1XRLWVBIUoLHRVWwF01WqSLNGfBBhJww9VNR9I5BHpil7bMmc/LwZhzwLDPXORpvFBQMWXbljQcZNvaBBzH+NUv2QqekKWGA06Ybxi+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4qC5YN9iAStPzlJgqe39RMWGIieiwE6MfaE8ILKH5HK3EopG3fNBzp1FtaOPhZ0F9HSPVj216FfQ81M6dDZaSr6U73Bw26RlMINA6kWE+/PHAP/xS/ZVygn+tYK2aMYSuifkHErvg81Hh+1Bl1T/+wnv+yLHKC3DQ/ X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 24b4e277-a227-43fc-b125-08dca08dda51 X-MS-Exchange-CrossTenant-AuthSource: JH0PR06MB6849.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2024 03:10:29.4712 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IyIJn0lK571+Xrb+YMV/zHTwTgDd6U9zbVPj11TTGhXGr+VNiUSbislQV74mzc4O3bdyZb8Yp/LhBhKrjLwkjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI6PR06MB7146 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 835C7C0005 X-Stat-Signature: k98dmi1bbz9uwpnmymxb37tsr83uw3um X-HE-Tag: 1720581034-831703 X-HE-Meta: U2FsdGVkX1+JDRzZnv6HGTA7M00ATXBqhcqnQGTVJZo6CuzbrsOqM60oTD72+phnidbRIIUJb5yMN6fXO7MDegTy5nlW9Tl7woGoPRmovzXMptxV4BuU7h5WlOszdGL/Eic2wt/hDEu1sEp70YRxG+ryIMsUrhsuErlHCCqnBsTQUZhj+Euuw1+76I76w+WY+B3GE83tLk5Vht+xLh/1iHJbEOO02wSQIor95z+A6sA9ZuUpVW5040kIhbY1TwLOgalgABLTbQ2zc4lcuq8jDqecf2AugHR1Ig4Mi11mkRpjtcH/54a9ZQTNb2Mrsw5uXWPBIZM5m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q210kWsSQuTNaMbI2SU6Qzufxgt6vDVUMFkifhgtdVg/dY6e7jh+7BON/RE2dy0Q== 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 |
[v9] mm: shrink skip folio mapped by an exiting process
|
expand
|
diff --git a/mm/rmap.c b/mm/rmap.c index 26806b49a86f..5b92c3dadcc2 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -75,6 +75,7 @@ #include <linux/memremap.h> #include <linux/userfaultfd_k.h> #include <linux/mm_inline.h> +#include <linux/oom.h> #include <asm/tlbflush.h> @@ -870,6 +871,20 @@ static bool folio_referenced_one(struct folio *folio, continue; } + /* + * Skip the non-shared swapbacked folio mapped solely by + * the exiting or OOM-reaped process. This avoids redundant + * swap-out followed by an immediate unmap. + */ + if ((!atomic_read(&vma->vm_mm->mm_users) || + check_stable_address_space(vma->vm_mm)) && + folio_test_swapbacked(folio) && + !folio_likely_mapped_shared(folio)) { + pra->referenced = -1; + page_vma_mapped_walk_done(&pvmw); + return false; + } + if (pvmw.pte) { if (lru_gen_enabled() && pte_young(ptep_get(pvmw.pte))) { diff --git a/mm/vmscan.c b/mm/vmscan.c index 80f9a486cf27..1d5f78a3dbeb 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -863,7 +863,12 @@ static enum folio_references folio_check_references(struct folio *folio, if (vm_flags & VM_LOCKED) return FOLIOREF_ACTIVATE; - /* rmap lock contention: rotate */ + /* + * There are two cases to consider. + * 1) Rmap lock contention: rotate. + * 2) Skip the non-shared swapbacked folio mapped solely by + * the exiting or OOM-reaped process. + */ if (referenced_ptes == -1) return FOLIOREF_KEEP;