From patchwork Wed Jul 31 13:33:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhiguojiang X-Patchwork-Id: 13748802 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 51C6CC3DA64 for ; Wed, 31 Jul 2024 13:33:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD9D86B0085; Wed, 31 Jul 2024 09:33:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B89576B0088; Wed, 31 Jul 2024 09:33:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E5EA6B0089; Wed, 31 Jul 2024 09:33:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 809986B0085 for ; Wed, 31 Jul 2024 09:33:37 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2BB0CA0363 for ; Wed, 31 Jul 2024 13:33:37 +0000 (UTC) X-FDA: 82400140074.05.4C5276B Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2087.outbound.protection.outlook.com [40.107.117.87]) by imf08.hostedemail.com (Postfix) with ESMTP id C1A82160015 for ; Wed, 31 Jul 2024 13:33:32 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=deKRmXv+; dmarc=pass (policy=quarantine) header.from=vivo.com; spf=pass (imf08.hostedemail.com: domain of justinjiang@vivo.com designates 40.107.117.87 as permitted sender) smtp.mailfrom=justinjiang@vivo.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1722432809; a=rsa-sha256; cv=pass; b=4gcqFwICkX0UrA5gedzPJOlpDHPHo6VCArcI6bqFKG/XT2dEiAviH+0Q2Ou9iT6WWsd63T xEWqp03g17LJBwNkg+l/L/jVhjYR26zfnAJHJ8rHnMdQEbnPCgbarQa/Q+4XYaxzwQwmSz lnZfPhTR+kW25oT7n3/frHZrU8PvfPM= ARC-Authentication-Results: i=2; imf08.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=deKRmXv+; dmarc=pass (policy=quarantine) header.from=vivo.com; spf=pass (imf08.hostedemail.com: domain of justinjiang@vivo.com designates 40.107.117.87 as permitted sender) smtp.mailfrom=justinjiang@vivo.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722432809; 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=739J4L0eZUDa9JBOs+I/9WEAuUcr7cIQUlrDGorXYWI=; b=WALk38YVK+zJcWF/7HuRc1kDdW/Cn3xcSYKN9CtZwMTJSf/gE6pSp+fEA6UQgFDktSI2+M eH64z6UPAYkqgrmO/6lzVYNxVIZOlfwEirLtyRGcJD1tMzA8knn+UNN0rHm1trRNBJoafj AtQRkBUHCUkdZfPrpjBUV04XpRxF9AQ= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ei6sk+BpT7vSAbxcCnDrQ/ryQowujcgU/PF9BbNS4I1LhLEbcJCc97AcfsLoKkKzQLY48ow+NVDVts21kGuqwjU1aja5zF3UVdUDtc9P9cAWoWIPC0qQg0qSfUvh18t1R0JCny/eFZ9sBdiQZzzWmaF7GBXRvOtglGc2Exl/2ib7r/Vbzac0VUXLiH3xvnPOvAGmOglPCD16OHEN5qBgPdZrfGxUHjIaVmZG0g0xgc5/iDi+EPvsoFwsJSu0wLux7BH7bompRD6mhpJXxThz/O2PVHG+QJHomSmAatk3FO4Toj4t9pooNZDO/tEtZ2hk0L1AbGIKmDsT+6/PENGg2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=739J4L0eZUDa9JBOs+I/9WEAuUcr7cIQUlrDGorXYWI=; b=Rf3tA1XpwYaXjLplkf6jRpoS30sMdZG7ieV+nIEbS/tm4roRzSw02nG59/sG1jrXld0zPOueK6I/6sRTrrfQbR562MzU0UxU3RM3FMQWgRJl3XjmO/kLHH9BLrPdL3xeKXgoEiDfrv3k5+YOOlnMJ0McvKt2MJE6cPNhn7UNY+acuetaIzpKPPE0FDsBNrJUkYb2Il5eQLf13N6uC8IoES2q+SE0KYx88lJwuTvQLOy+RWeH4iEmJymZfwNRRV7bzX2G3s6EzK8epoqz6v4qJX06z9BN5Ny2L1VnvJ7VjrFC70iZOhtyHzacY+y5dCDxZQH608bAJ6MZ8GSZbSdjhA== 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=739J4L0eZUDa9JBOs+I/9WEAuUcr7cIQUlrDGorXYWI=; b=deKRmXv+xn6HcAR38Zzm9DgtRvrFHAAmfpC5WCbVsqihtl9Uti6dToO52d54GPUX7TrYhbOCksDauo1SF7bdcvHAIVmPyx00L3KVy+YkxRnWvm7uRK3NoOPWIDL7CgFv9J/p0OGHJD3Y4LxJCFQ8unZubU77yohPrdzmW8JtRyWryiq+3pjfh4XeXhgzH12bfbaxY7NVTEB9PjfKhled0opzTRBouMv0YOZgviTjdGjSR1No2OPjEHEGCrjqgsqXuL4/r/N+OVqpIApnh8C81oYQHOMwE/ba7n4Ye4FY8kEbs53pFAXsFeEgMLC4JB9sptXy21tS2bZ7NoEVrLi7Lg== Received: from JH0PR06MB6849.apcprd06.prod.outlook.com (2603:1096:990:47::12) by TYZPR06MB7334.apcprd06.prod.outlook.com (2603:1096:405:a4::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7807.27; Wed, 31 Jul 2024 13:33:27 +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.7828.016; Wed, 31 Jul 2024 13:33:27 +0000 From: Zhiguo Jiang To: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Peter Zijlstra , Arnd Bergmann , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , linux-arch@vger.kernel.org, cgroups@vger.kernel.org, Barry Song <21cnbao@gmail.com>, kernel test robot , Zhiguo Jiang Cc: opensource.kernel@vivo.com Subject: [PATCH v2 0/3] mm: tlb swap entries batch async release Date: Wed, 31 Jul 2024 21:33:14 +0800 Message-ID: <20240731133318.527-1-justinjiang@vivo.com> X-Mailer: git-send-email 2.41.0.windows.3 X-ClientProxiedBy: SI2PR02CA0019.apcprd02.prod.outlook.com (2603:1096:4:195::13) To JH0PR06MB6849.apcprd06.prod.outlook.com (2603:1096:990:47::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: JH0PR06MB6849:EE_|TYZPR06MB7334:EE_ X-MS-Office365-Filtering-Correlation-Id: d69485cb-c47e-41f7-1951-08dcb1655bb1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|52116014|366016|376014|38350700014|921020; X-Microsoft-Antispam-Message-Info: CYZVpTy+VrJkOcJQcGUeBzFG6SoZLhes0vjh8XzOnoFP1NeeHYuqwHnO2+N3lVG07Qb7jS31teCs7QHUHOIwXYNh076++kCumIdRWu8wshy0NaLJqefvZRlOKKgJTtv1c9iqBuq683jRLjfVOuLFCgoKyjuWQ++XnXIyXZ1lE9VNrnG74XybAUcLfV8gGZ2vcksXKEPQcL6XjHYyVe+ZEsujsuFWyohj6T4w+MVi513qp1qRjVA8mZ5zSdyij6KJIJlMeTFuSfIrPamIUm1RBLvWA8wVa9Edm9veHv1ouy5mGujVcbTfkTZtrUK8nNFiuTgVsdc1Ij6nOTkvR3/dlPnZTUf6nVYyL9BwEhj/ZiK33Zyx1hL5XHPeMNmBkKe+uFO8+tJ95L6wcSd5yad3E66P3qahviuAudqGjaSEJKjXjDxBuSdAmVsceEWBXnc3aIIJ4jTHElZmdO9kLSuu+evJX7oslv3mmACO9KCbR5qi8QHa0PMownCQSTQZsL7cZBEDplRFBBT1NwrBmIcnrwGRXDJoBwRs2CScoOWNRarX1z2zjIB1+6gRxzd8dGsmxVKokMwkjkQcgvp3t5YE9EElyxkbYpbg4qsFkk3Ayng2pJuC0ii2FvccA31r7g5rUenYIkHfO+oGzgaI3F3EBnHAu6Y93m1Gvxk9KWeSMkaNaECy587FS/292k79yIlcGoy0+KLhcb//42aSehqnc6+8n7Xmqz8goKrc4s79DrE5q29i/wZ2EU+RoTvuhVvWbdpZm2QswBgjn5ZaWdNqcrtni4YxtbzFoMR8pdZSsjGJn17YE4toQGOlyH9NrsJ1eR4+xHNHDJ1GhwHyo8vD9UCuPVK6FhhNo2X161Siy9nefBQzEAegv0rGlqOAI+S2YXVva00wW1NWpFoVLmAK8Nh35NekHwYRIORgWbxX2beeSKgPYAVcBGuRHb+wqztsQujxJXdhbJRuzGoUOzKZLgcikoIwrFETO5C6WNQvEDv8Kr4U7FOA+ABSxNzUisM21VAj+2Cggrb/MTXx+aVY+ZccRZXDIPYyIVqqA5iwNj1udgkBSXJ5KKmJUeAA8XlH148oYtDfQZa321x/b8i0DOhJ8osJRN77ikUpfTx4K/Bz9YAGYIFX2JyBgv9/A3grKcfRT6tQgDNKFsZfFKIoAKQ5U6zaeors7JK3EnFfwFbAEEoPPay+Ved98VScahlLNIu8msayEK51Ubg3wex9tW1LH84ScKfS7zjLLuBAIUkjQvtff+XGpv1Ee0hnP4ItSGVzrcV1Xxp3tbyeKUUCZU6CYFtyTZqZGNpMYiipuOT8odp8RDz0Boesr+M/gFrcidYXcPmz8SvlZh7uPb0DuVd7rIjoo3ZzWSAQc+oEk5/20GMYBarQlrpWUL9/d7bv 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)(7416014)(1800799024)(52116014)(366016)(376014)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5PXMCK3cLVR6rlmZq36v7Ex/1GwUrhRVxK/1vBy6klxuXHTnS/Q5Ueo3OV7sHzCVlLBo1Dr5r1+OXM1GRG6xY0vHshZi9E1vQ4ZKjesLzlgX2fq9Yy7zwPPqRIQWZdBBh1pTD3vqBNDo6PnkFRETNktp4lt8NKihlU9DH3Y3lLqnWmPjVG1J64S5Aw3eqNYc85deQFSui152LdrBqIuErHw0IGLLUa26xzqZeKKBamVVNtBJqoyBlz/tonjtoRwAKtDm+kZfZ115YN1mekDUjfyCtgPusTy+TtvZnWfOp44YgPhL+b+rJDK0NlI+rI41HtPbQx2X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4/n159gYSwb+GmcKoNlv6b/nXOOi1/J0BEQ9x+UZoxRQ2U/5G1eoq+c2vV3j1Eo+b3kZOed9/usYN57H47TWeGSZuEipY6u+i7tayueqajPq9QwQVCScglXijgq61QNzRqIqjL/O2/mltXyMRrrwYb8zjEqOd1u4Roy3lqMWkI+mI+xVnkVCs2 X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d69485cb-c47e-41f7-1951-08dcb1655bb1 X-MS-Exchange-CrossTenant-AuthSource: JH0PR06MB6849.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2024 13:33:26.9378 (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: Cko4TKMobaPu1w4yA91w8i3pJK8HiF4BezVs4Q+A6GqeRCcK8fgdZmc8ldtQdKvQqpiQnRZ/eZlHxfTJW8nACA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB7334 X-Rspam-User: X-Rspamd-Queue-Id: C1A82160015 X-Rspamd-Server: rspam01 X-Stat-Signature: m69rai3cpdoo57nq7tmh8ww9zzfdsdwd X-HE-Tag: 1722432812-181010 X-HE-Meta: U2FsdGVkX19t/LkajWOxU1jlBwVIt0+G0G/WjvP+OIQplfAu7EuMYaIFvWlDxnKqypgGxj/8zt9N0MZkZzUhn8YcdyIhttwtWvXVwuLH77weyTkUlL2ru6tWDJcWKECHMoEa0ET9B1P3ASdhdRfTNqNUvp0eExHBulVWdjaz/oIQisVJeuaUqdrfVO9i6f8L4loOTzTnJTaUavDQ/UqY4G5ZhCYgOvj3BhlP6Hhxm9NuyoN1dsfdY+/CMydZmwqUnx7Z5C0Ab8rNOb8uaLgSjw8Q+WzdnFQs+XVo/3u1x9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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: The main reasons for the prolonged exit of a background process is the time-consuming release of its swap entries. The proportion of swap memory occupied by the background process increases with its duration in the background, and after a period of time, this value can reach 60% or more. Additionally, the relatively lengthy path for releasing swap entries further contributes to the longer time required for the background process to release its swap entries. In the multiple background applications scenario, when launching a large memory application such as a camera, system may enter a low memory state, which will triggers the killing of multiple background processes at the same time. Due to multiple exiting processes occupying multiple CPUs for concurrent execution, the current foreground application's CPU resources are tight and may cause issues such as lagging. To solve this problem, we have introduced the multiple exiting process asynchronous swap memory release mechanism, which isolates and caches swap entries occupied by multiple exit processes, and hands them over to an asynchronous kworker to complete the release. This allows the exiting processes to complete quickly and release CPU resources. We have validated this modification on the products and achieved the expected benefits. It offers several benefits: 1. Alleviate the high system cpu load caused by multiple exiting processes running simultaneously. 2. Reduce lock competition in swap entry free path by an asynchronous kworker instead of multiple exiting processes parallel execution. 3. Release memory occupied by exiting processes more efficiently. -v2: 1. fix arch s390 config compilation warning. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202407311703.8q8sDQ2p-lkp@intel.com/ Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202407311947.VPJNRqad-lkp@intel.com/ -v1: https://lore.kernel.org/linux-mm/20240730114426.511-1-justinjiang@vivo.com/ Zhiguo Jiang (3): mm: move task_is_dying to h headfile mm: tlb: add tlb swap entries batch async release mm: s390: fix compilation warning arch/s390/include/asm/tlb.h | 8 + include/asm-generic/tlb.h | 44 ++++++ include/linux/mm_types.h | 58 +++++++ include/linux/oom.h | 6 + mm/memcontrol.c | 6 - mm/memory.c | 3 +- mm/mmu_gather.c | 297 ++++++++++++++++++++++++++++++++++++ 7 files changed, 415 insertions(+), 7 deletions(-)