Message ID | 20240710030021.1657-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 98287C2BD09 for <linux-mm@archiver.kernel.org>; Wed, 10 Jul 2024 03:00:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 269DF6B0098; Tue, 9 Jul 2024 23:00:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 218D96B0099; Tue, 9 Jul 2024 23:00:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0931A6B009A; Tue, 9 Jul 2024 23:00:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id DBE9A6B0098 for <linux-mm@kvack.org>; Tue, 9 Jul 2024 23:00:39 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 8EB5FA1AAA for <linux-mm@kvack.org>; Wed, 10 Jul 2024 03:00:39 +0000 (UTC) X-FDA: 82322340198.21.5FE6788 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2052.outbound.protection.outlook.com [40.107.117.52]) by imf13.hostedemail.com (Postfix) with ESMTP id 7C3542001E for <linux-mm@kvack.org>; Wed, 10 Jul 2024 03:00:36 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=rAra8Aej; spf=pass (imf13.hostedemail.com: domain of justinjiang@vivo.com designates 40.107.117.52 as permitted sender) smtp.mailfrom=justinjiang@vivo.com; dmarc=pass (policy=quarantine) header.from=vivo.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720580395; 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=bWWNqK8pXgK0eAdo6WhK+EsnHwPSAI7WARq3E3sMOrM=; b=gqLwx0ws9Wb+3uwRxY7g0nu556U4WffHN0z2pm7BzQHAQD/9PxU4UeJ7ae9jIIZLWztXBB L84pVf7boK60VHWmdsf1O3xeqBcsaPNqzMC3e03WQHguL5yi1aXdlk0N1OG+1avwyw9c9F IK5QjCMhwgq7WH7Pd0LxaD7ZPQEVrdE= ARC-Authentication-Results: i=2; imf13.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=rAra8Aej; spf=pass (imf13.hostedemail.com: domain of justinjiang@vivo.com designates 40.107.117.52 as permitted sender) smtp.mailfrom=justinjiang@vivo.com; dmarc=pass (policy=quarantine) header.from=vivo.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1720580395; a=rsa-sha256; cv=pass; b=LsWAx1dHnLKhvI0bKfz2uv0uindLHPknbZhijEdDE+9mv7h+L5ksofoEtx1zQWeb/rkkL9 lNRGjqpic9AqJOtxg+ZnxnekHbK/49zxdD7wnqtDAdSJNlo0o/KAAiidsvmvm0sAHNeSP8 vvdFepW8iVUWteZqHhuFjES8fPNvA/E= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G3uPssDhVUBCV9VWJ9IRJl2mRq58KTN69VfNDWJdIeODrtK6ykUwwgqZgMLgt/5IQlNSD0HYj7uEKXh9RYn9Wn5sQIKj9t8l9StrDoCFQa2yhyQwE1vDE+0DstKAOM9vMRQ4T7SGHVcR7j3OfdtWrDuppaDUbeUT5zlmrfIeYXyHUnL3RiIjMNYWnTUCG9VV1QWc7epeekZGh7syOeCA32QTE99+B5Yax0HC0kg9HRjk/GV9GGCdjheY/w20xC+oEDSPVGiXHHH9HCMaiHdFNNi7N/KjFD2JzDwEU8RTMApv4n2fDxNIRvBAhv/eUXNsuGdxTFgwZo1N2tozCdpYCA== 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=bWWNqK8pXgK0eAdo6WhK+EsnHwPSAI7WARq3E3sMOrM=; b=LTFr3UnWgtgiDmZOypcSrYfVtMzy5V0Jbq0lizYp5CjiKclv1L/OptGpxy9GM0MJ0QCY6NYkse9wIUFn98xBg0sSztbwRxMJzgi+LTh312I6eOafH+7hlMhY3VFGwajQyThnAN5c8mLAsMODgOJG6tknpM/QKUXUMPT8tjdgjudAOYF5uod4WbDzZAJyyXtbrUXGdwXLlNCl+WZwgJn1arEeGiFeYfNu5Nq41/ukJE0uXZvs+4MvAHirnWcVPGVDd8cPjJ5gHXPK7Re31zZJUf35e2WuK/2aitzrQOZqAFO7GxqnAR5dGYj5P5UNQ/fSsBkyJ+R/lQvUvh65NseZqg== 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=bWWNqK8pXgK0eAdo6WhK+EsnHwPSAI7WARq3E3sMOrM=; b=rAra8Aej+aYilesNlSdxGMRe8LRqxJWdmWLVWOBgl71IecfkUR+rGp2P5WFpkMesAshAx9WPCyGlIkCfahcwgdtxZ9BlhZalGvg8xEld2ow4iQ3mTXQ3/RjUbpE93IW38wY7BHoJmZ3RxqDzpG6VOM6Yn1frtmFnzJ1zELB5W3EZMBOXlvZ6AxRZjP8Lyeh3KQrjLsIcJkztUnwZC0NeAEMsLUIx3tkVQUb1moXheQknQJkRlXx6984jKCirSL5zKXTEJVlv3VC2tX1z+sBkx1AA8hB6cscqbH7LUwlmCwUi71Ahy4SnS9LbP/kqheEv3X+NGRt0yuk1adPa8Clm7w== Received: from JH0PR06MB6849.apcprd06.prod.outlook.com (2603:1096:990:47::12) by SEYPR06MB5468.apcprd06.prod.outlook.com (2603:1096:101:b5::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.19; Wed, 10 Jul 2024 03:00:30 +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:00:30 +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:00:21 +0800 Message-ID: <20240710030021.1657-1-justinjiang@vivo.com> X-Mailer: git-send-email 2.41.0.windows.3 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2PR02CA0038.apcprd02.prod.outlook.com (2603:1096:4:196::22) To JH0PR06MB6849.apcprd06.prod.outlook.com (2603:1096:990:47::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: JH0PR06MB6849:EE_|SEYPR06MB5468:EE_ X-MS-Office365-Filtering-Correlation-Id: f25301ea-2612-4dca-adfc-08dca08c755e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: 0shDE7Jk7nxtoFAngfR07UQx/m8ky7hy/HCdL8oWvMjQ4IaKNI+kX8+j15WUMYygcdngUiXPc7Fk3m5yXdQlIH07//0f0dWg879S9CeJEDd1l7oh8PbwggaP/Yz+4e0EemSd5ujvCH6J3y5fj7Iy4ch2WZTyItbOp43v/BnGF3eIa9GkprwGgphKszdSSiCb+xV6jCBzucsSR8cpbeBKSLJnRe4TPRxGDZP66bqcOU7Dl7lg0qp6gZQ/AshF4/gO/RT8uV21tRD/YcYwd73nyZ8JElrWIVjI+NAXzkm6/W82vqwOmgvoiB0ybwXNXMPuQ5LwOLfo7EjYKnw5jE3S7cGtFUIAs0lWhLrSo46pYlIPUmDDrjPpEvP20wYD5p5NqQgcg+pcd89PlPVLV7sBhkgaXUPfePzkRHwzCTQmJ1DppjD4zTYrX+tfzeab5xkaIcK7zGfY1ER5LSARFHgAnoWkigNdxybqZioveQ7Osr/oUT2Eti+HI6VWgZpt9jFgpw75/BUPTNRBw0wHEgtbfuHqEeKxRgvweFyL2pL7DGEd5cCnn61XY5KY1DR8oLqXok3PsOTcIn3CNfjtCswfEHSnIBlEjyslNh5E0F7Ga/21bAdG1Z/A+aztzTXUxjHeZCJaD7bWNjTGK61DZQvrZFFEkr3YTUiuCd0tGpcQze1IApe5q89q8Y563CqZpy6iWnVnN+OkEN9yiYAVP6CXfbBLJCi3RzvwOo2dqkhr/k/KqjJeiR64IBQIl90ozPOQ1XvfzADK2y/fEe/dPXpnmRlbmv4blv4HwjnnvIZnJBinBUo5eE7OfMFIJ9rkkcmYtLeBvptqCIjW+wUq89GDZOQytVX9/WUVR/3AmfnSMeSiCFRszZ4cdFndGuUU+IFfrAigR2/UuLbVia7MWA3IBjVC4822Kw318bdtkSrlSitzKqtDFFBycBmsAMN/JH3CA5kDnOiiIgoXpIW7KOTcLrkOjoVaG6poGf9wwhST6yPWz7vYfgpUiYf3/J73R0s4GWBvBVFgpVAb+8uXKL6u8IVQxV/1He33CU8H1AM0vPN8X0W0JWkzE6cfIuhM9/mKNovqWl4jz4SrBCcNTb9pnw+T3IjXTv8hPhglj3Docg1fUFtEQNDT5WBxR7V/HCJxiu4eRDnXLnjH+EMabwFeOitHH6cds30Oj4fiTpfHbVnMh6gDp2GO3fGmtKLYs7zZTwZdAGwl3Iwv+8QgFrAsdeqDPL/pkPNko3Ry4ovKaKCFeSajmA7FURQ7ENjgCjlh24x5ADiZ6vwtkd6P0PPgiUN55EwojTxq/YooYd7ieHFxvxr0t6dLKAzo07KjfEPqYpbX3tx1/Oy4bZPeaPWMg364nubHMDh5o3y9BQFX2Jg= 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)(366016)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4VYqNqikwgnEouOqWyjYtGr7cLvDpVObLVbhR9jCmgNcdOVFb4qJyegKhjCucZXFv0pjkNv26kNsfqdBxC7ii6I8OyV34OF6SGiN4lYGQ/9Hv8+aXdgYOnRK69HWWd74ArMSfQan4dq3/mB8F9NEi8K2FHJajYa5GXYVdxxlGFN+01BpcVJobLp0G035UVpI2wF5ZHadaZbDfH/LSl5V/Y7Mlr3zEdkRv8nqHiOkfMhXkMb+kwpspMjPqmYqVzNjdj98zjT132VU66VuI+/6x9skxnRsyWwX99s/oLbqyz0Qu5KN+zvW3PmRua2dAjZ06fzLssUVukIpQfzzDMGd4uF9hFSo2NxSoYPS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7QngGx1j0rG9oxMZesURLiISWNtnV3JV3fyyAqgF5ByeFz/hj3ZqivLxRveuFi6kIvb7ZgHtmUOTsA5qK8e7bU3jvdZTMIPeNI8f+QpqzBwed/rqI6b1Dx1+DBLfya9mM9S1MZiazYHJEZU3C5xhH2vcrTTgkpfUJi0Vk X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f25301ea-2612-4dca-adfc-08dca08c755e 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:00:30.6019 (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: 0ZLj8DxPRhCzk2l0jzgvheOW0eevWhYO0gLlMWx+hEqPwChz4GpO1IET9BNf5b3HZVdxCWxRu65Ke+VpDVpj1g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB5468 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 7C3542001E X-Stat-Signature: btr7axsrarnhr333aj6bbyk9pmxxf9e1 X-Rspam-User: X-HE-Tag: 1720580436-614481 X-HE-Meta: U2FsdGVkX1+oYVhmG7CiuQeenHGPt8Q9r3aU9Al5jDGdcrpCghGtGQhFtyUh+ke15sGeryc4odIA25LmnSFQTpjKhdyFIKRaY2uznVvapn0fOSrBzo6rhwyamNoJ3QXClW2NZznm+EEZcy0qkV05SRUwvIxYoLqEocAYR+CmD6nLZUfnxas11sV5k1gj3Pd3C0KZVEFM3Wl/QbBCRcaZ1eUl8XSTp19DJM3iXcY9/m2XWTyIATPj+/ZRoYW63ElIDuYZdtpq1vRdz8psTCoN1R2OlViY9YHR5+stpbXSxlCY3pvdiZk/cWihe1PPbZ1A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AwQXLpZBc6fEtuxtHW5Z6cL0F8NRUS67MvoXmuyjSLl2aeJHpVZ/RDgQ//MHIHW6t1Cgg== 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;