From patchwork Tue Jul 30 11:44:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhiguojiang X-Patchwork-Id: 13747281 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 30BC0C3DA7E for ; Tue, 30 Jul 2024 11:44:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8AEFB6B0089; Tue, 30 Jul 2024 07:44:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 85EBA6B008A; Tue, 30 Jul 2024 07:44:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6FF226B008C; Tue, 30 Jul 2024 07:44:45 -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 51DB26B0089 for ; Tue, 30 Jul 2024 07:44:45 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E2A2480280 for ; Tue, 30 Jul 2024 11:44:44 +0000 (UTC) X-FDA: 82396236888.12.ED64A94 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2061.outbound.protection.outlook.com [40.107.255.61]) by imf30.hostedemail.com (Postfix) with ESMTP id 66DB48001E for ; Tue, 30 Jul 2024 11:44:41 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=nuIjzXVB; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf30.hostedemail.com: domain of justinjiang@vivo.com designates 40.107.255.61 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=1722339827; 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=kY2aCP1qt3NA2Ea6s+1o17+wGFhjsxPr8n1X6jxgy0M=; b=c7Cb/RJDNMt6N6H5MieKlCKYJa3PNSxvYqEKLY/kaViqeKj8EqJ62AuiEF8HnzmUyJF4Hx yzPEKK2mNfdnf2vg0Fbjb/JzcPaiJPg1t4Js07U9KapXdpT9OlzppHuWIeO71t/TiUZsMG 5/LT5JwvC6njTyS77/hzpOoC20lQH6Q= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1722339827; a=rsa-sha256; cv=pass; b=6pi0B73eDrj+bBdI1pAxnJ3AntjrR1FFte/M8fLpBGLCIBLnTUUO0ClGIo5qC5a/8xyvH/ i++E2Y7qzDxpKj7AdeuFhlSKR35FeM+55w2DU6AYHB1UPpdvsx17dfU/TbQRxUGFUsHvm8 qEzz/IrXiqYnPb60WMF9PswSQGF6LMc= ARC-Authentication-Results: i=2; imf30.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=nuIjzXVB; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf30.hostedemail.com: domain of justinjiang@vivo.com designates 40.107.255.61 as permitted sender) smtp.mailfrom=justinjiang@vivo.com; dmarc=pass (policy=quarantine) header.from=vivo.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nEpNQioD/UzgFOoDfLvKzDIR5yfeakUocS4Kw9ulhQ5M/MqfR5a6P3rWg+z3KPEW45vEILCypejctFtAgEqMlXVK9iKSdPp+uzB6IHk6Ae4xlYcXZH2gYIwTGKqfIEkfy+I5YhruW0VFcdPyUE03SSaOcIN1zhNaf0WiEiqfg+2OBOJEFjrM5OIAnYvKzfIUyKti22a1kpbfMP8vXgraHq9pS/oqEq7KcWSs7j0+OwjKqLlCvDGprbfLnex7LbJXmKM3hDigd6ESqZ1MqFfMOriKGmKJvGLhBrWVmjtKcwl+SLUqS14ObdXqSu1ez2nVud4kyPNEbwC4MD6Ths5QRQ== 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=kY2aCP1qt3NA2Ea6s+1o17+wGFhjsxPr8n1X6jxgy0M=; b=TniQAomgfOjngG97toHBOJ68a4SoVcXV7pm6pi/xkwEvbNzgBae+Xbhto+wTLKvDsVTazDkeoOAWk5GE8YXdihiE2CnOZxcPjYMzvwcWhEppZGeF15P9nISoN+NT8LXehY8eB6Y8F3EpTguWSmv4ip7MX0XrbqqIuR+advSUjJifMcE6zUiwAuBie6HaPJ7BB7x9Xm+9Ovr7LVE5BTTehxUQyDVCy27VjIx20m8UOHSui5lvNt7DQbYNGB8fgCfK4UnoGViTBNz4XwE2xZ1t4cSpDzpjzBiX5+zTDRQLUWXxe6MI/HeiP02sYhU6/GNr46ke+5j5VVTnDhrBQO27gw== 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=kY2aCP1qt3NA2Ea6s+1o17+wGFhjsxPr8n1X6jxgy0M=; b=nuIjzXVB5VXPh4C39vQakFHA91rwh26dIjAvIstAhfo0kWkjV7rilQz59DizPcIuAbdYBrOYI3vWE9j6X0tWF8f8VQS4FbFhcV0/APt/Sw9TWuwoOumeQWsz5Dak3pDQsI/iNDd9qWs2DfePIhLsVMUlJo1INbyuW0rrVj40OBhWRT/NnxBf74Z93giE3px4iuJZI6Jv6Hb5cNeKJqgHTgT3sPkTLZ1UxZYkDBqUvvsWI6SeKK6x9Fu1Fj1ouzbg23PGb9OOwVTDaLDTi1oNnt0DnnfvVnjYymR3zygqlxVHedNMeYG5vr+1kHNp8EMEoiwfCDjggO9ypM0DQBwx3A== Received: from JH0PR06MB6849.apcprd06.prod.outlook.com (2603:1096:990:47::12) by KL1PR06MB6520.apcprd06.prod.outlook.com (2603:1096:820:fd::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7807.27; Tue, 30 Jul 2024 11:44:36 +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.7807.026; Tue, 30 Jul 2024 11:44:35 +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>, Zhiguo Jiang Cc: opensource.kernel@vivo.com Subject: [PATCH 0/2] mm: tlb swap entries batch async release Date: Tue, 30 Jul 2024 19:44:24 +0800 Message-ID: <20240730114426.511-1-justinjiang@vivo.com> X-Mailer: git-send-email 2.41.0.windows.3 X-ClientProxiedBy: SI2PR04CA0018.apcprd04.prod.outlook.com (2603:1096:4:197::9) To JH0PR06MB6849.apcprd06.prod.outlook.com (2603:1096:990:47::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: JH0PR06MB6849:EE_|KL1PR06MB6520:EE_ X-MS-Office365-Filtering-Correlation-Id: 7639269d-62c2-4e34-d70f-08dcb08cfc7c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|7416014|921020|38350700014; X-Microsoft-Antispam-Message-Info: g5BIEAgVU+bzDXftWfLSgpZ2LGnYCDNGm+epgyBQGb+W6p18oXlKidimdevQAnj1fA05RU+xuyT3xWyd4XgphPI3en5ZIBKZHHcteumuPD20SbA1Lovp0jdAGqbo/3nremUmOhFjuvsQm4iMw2OZFSApUGZGO6KIpq+zXJwsBqc8fKMHs04qWsI3DmQfQqYEz4mJGdjUubMbod8VIo7uUi/qvXuiQEbn/8T84o7vwSR1xmdgsklchLAtUyuXmWFLHsGjgPJlO7k9NvrEJJIrVhWa0KPsLnRPEJQoTIrGnSUGMOFoulvkhYl+9PGamaFAjVdHqU7WJ1PF1AQyFt4+Q03ZrI5dWzekSGdHgE/UMh9EmOyY1pt2birgrg4fGIgfewMXY8gY01W/8/7LxnhmqtAKaNPGh6fczDjTH9sFZ1zA4HNqSh2jNjQYqSPDmSXU6DnF2HIiYI0x5ynXM+Vkx5PSIltcHqeyWozjfG9IHbEvBf7jQCouxrCC8lk6vQqzfWkZ6+h1RDqrzYr9JBpUbbpIyDhem+v3kgvn1hk7GZJCVCdwFrciihcwIOwRsfttl3KFzRF4SRK+nO9st4jZ7RYf1k8qB3tieL5BTX511oTP4rlxNrf7CY6C4P9TIaIKA0A5V9EqUaVHopDkKBd+ghdvwToWW8NrA406R9b7jx+wepcvbsBgacvmvQMb9EBg9k9vtYzNPKY72k2GP+U39KDNi0fzqZMIk15blWeSvAMXckc10fAvZZeGsJ0y9XSy/SxaxK6T2yGZ2pEND6e1GY+s7xaCHp81DwQh9rth/TgpBBolKv5LVZv3MejBRotJFcUug53rhB3s+UFl5bFzwBz0lhwXTcsl4NIPfHVnJFBQ/7PQOAaedKT9mCeBI6R4aJC3q6TLOYv9VDrepO/K5NY41avnlwpRwsslTf0ia0ty2NmEC474mpfDtvJqfDxTFMn1jIn7XjsgyZC278ewf69Jc0KlhlhqJY1ofxi5LSijfa8MpRjX8yVCMAF6sqh5LPDD9NSn884pYdoxN2lchP/KdjZt7bu4d+BbyP9F5eKTrJf7Xu0NWpOy6jxz8ip5cRnaEbGohz8AvS2yq3cFkrFNIhlrlyIZA1dAapk6y+x4PQCIRZ6SYGOhaxt7CLTqtWrgm8BtAg33k99lKgn32cX4uJCKzjqUPSGG4P61HUqy5z8RFLfFA+2npgzZfQNC5yQuIEfL0G0ifzMpKT1qPPHE+3ovPR/yDPJDKnkdjDssVOtyk/s/KopVujuW6PP46iPdFKuQqERYqRswlCHAgn+P1ZjnjtnyDU0zQSLhVByenzv8x6ZyUoRjjVqyH0NA0s/m6QB/NsyHZMZiuCy287mEo/lPBFKnb69ZYWtbgQZQ7oB8yf7e7zeAZ1rzpHbdtcGR4/H5CZtSTRz/6abr9zK/20wB9dhdAFD+jFuGn0s= 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)(366016)(1800799024)(376014)(52116014)(7416014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4acl5saLglfRzLQtH8ZGLEgeOw6/BrlLn3G3SzNYAzdLRpyLb1CAaWHoivcdUcHc/mC+miXy3wtu658OmOxGtx274yY5PNyERN4VraImKDB26/NLD2CBb0L9Y0MwpPtC8OOGra87GeYq6eCDHboCEum4n/byIFqLbNYUueV2+BSKZHBlXHJ5ELSk0MpR6+zFUl2RZPT59pYy/niWtyB6Eivee2uWwQQvc4YdoaYCQTnVTdIWGNpCgAaVUM/PUtXP3uFfij+vAGRw4orfYFMN3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2KCa6I2A0FOtd9PCoI1HONcMtIgaQoJApyjp5Q/Xaq74v6F9RdsD2G2jvz3e53r3/vBAnHJLUm1yvg9h7IDGpmOWn+GNjJU6BjtoZjaww/Iw9tCxQHM8gh5kbWbohX+BQOoCBEa68ZDc93i0lMgO37fmnm9x3Dv8jGjSZbhWQSetQ/HH3XpXs9TMzbaGRYVl3796JEEh6yIEISh7N6cQKGMyVfF79VYWT3IshzdSLnaPWHI X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7639269d-62c2-4e34-d70f-08dcb08cfc7c X-MS-Exchange-CrossTenant-AuthSource: JH0PR06MB6849.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2024 11:44:35.9587 (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: LF4coIADzOiygmEf8WGfMgLCpaLVL9DuwqX8rJEf1Gob59lKjvD6gAXF25IThBRhKjyMDXEXG+x0VFjjAR288Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR06MB6520 X-Stat-Signature: xutaxreud6e53ip9ucgbw69hgg1f3zow X-Rspamd-Queue-Id: 66DB48001E X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1722339881-910440 X-HE-Meta: U2FsdGVkX1+HOhy5nSp9rf9Vs9e1TxIw905qmAAzAvJMaPrAwCsakGledZ6S1YV07ShNoLH7GsDbxesAIsIrmrWcH+/lQRRF/deWKE6UZJ7nj+hIJZ+c2pcrBVTz5sK3vxU2gcilLT1Zr2BJmGKrw331Vb9VL22624Ykargq9e95bMOwQ1iJZgq7pKfBSH5OH9I4gMSz/ir8BZeDcxzHolgINJi/e/ERcieyOR2e5Kn+FeqQa9dSbspxgoEKsubnpA1lQzuiyExkdQhrwybB+SElTOQoKiFIU2Bv/jihBsJeV/Dj0tUNKE8n5HfpdZrrroe0ahD4wXvynbD6Lh9r2Sq0I9oYhev4RPb2rA3pw8t5uP5PVz0+H774zx0/8d4J0sjBmW+l3SQ9IazQEt5YaunQAfamhbfnramHsB49/9ydR9eiqTmedY6vWkAk6CMk3olQNTlDBfDH1jf1mZlmE6yFN7XEh4HZTc9evKoa7MmuzZr7Ugo2a5jgMLWOfemBbBsn8FZcFqNX4leeNMgnJWtQTIyFJnSYKQqMXqIMQr11ddrjYGgp7Eq209kDPpwV+eIpnK4OEcZe0dX8SsT710YWVQghU+KjCDxNbwrHo+FWfMg7m2T1SLZaXvd1D+eIHrvDXRrs3oeP9bKqRhWmCYtkgRUy5jIfm8djF66YEOu68iNNCBAFUUUEfd7F5Ia7Vxbc6Bbzpu6H18hXyE0ro41ToBrz4Jv/i+Csjr+QJZIRkUmFCv0uz98CCB+EOghMXn2yD6v1W1Dy0UycZKx3LVT83nN0NHobwuZ42JeM852rcvFKIfEnEa7yKMU6q5Wxdj/u+bH0wyAh9GlNgdL6HTWwuWoTq5uIH3QUZCXMGuFddCYVKm1C3J7jzcwozeGn/WvyF7ENGLTSRLXLoeX2WUTxtHzbDAsW1KuIrsUkUC90CVetiPpoamJD6po7CcUoWozIqH5qGi9SWdktCxg C/gwfzPw bpeuR6x9MuCn9wXFHBJYPUSERtVsdykZpy3+srk3y86rECwM/R54rBoRJELSyc/hlG05osS6xctDUffjfnfbefDLCCZGDFgl6PiY6qUVZEjRtP46qzL4y0zYjHDcMR1OHa/cA6/xAV1BEPhRSX2rqhn5vP+MP07e+B6RY0WCvLnNxJVdI0/60n7RC1LwJZGyr+5zSPqUoCJeNvhexNi/PD1/6rCv3seKrriQewze0aL/uAGoHKoIv9mOcGw== 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: 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. Zhiguo Jiang (2): mm: move task_is_dying to h headfile mm: tlb: multiple exiting processes's swap entries async release include/asm-generic/tlb.h | 50 +++++++ include/linux/mm_types.h | 58 ++++++++ include/linux/oom.h | 6 + mm/memcontrol.c | 6 - mm/memory.c | 3 +- mm/mmu_gather.c | 297 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 413 insertions(+), 7 deletions(-) mode change 100644 => 100755 include/asm-generic/tlb.h mode change 100644 => 100755 include/linux/mm_types.h mode change 100644 => 100755 include/linux/oom.h mode change 100644 => 100755 mm/memcontrol.c mode change 100644 => 100755 mm/memory.c mode change 100644 => 100755 mm/mmu_gather.c