From patchwork Mon Feb 19 14:17:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5Z+56ZSL?= X-Patchwork-Id: 13562756 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 E21A1C48BC3 for ; Mon, 19 Feb 2024 14:17:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 10AD66B0074; Mon, 19 Feb 2024 09:17:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 092676B0075; Mon, 19 Feb 2024 09:17:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E26E56B007B; Mon, 19 Feb 2024 09:17:32 -0500 (EST) 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 D141F6B0074 for ; Mon, 19 Feb 2024 09:17:32 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 6FC6B1603B6 for ; Mon, 19 Feb 2024 14:17:32 +0000 (UTC) X-FDA: 81808756344.24.5A4DB93 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2103.outbound.protection.outlook.com [40.107.117.103]) by imf24.hostedemail.com (Postfix) with ESMTP id 3812A180005 for ; Mon, 19 Feb 2024 14:17:28 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=oppo.com header.s=selector1 header.b=hkfPydXo; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=oppo.com; spf=pass (imf24.hostedemail.com: domain of lipeifeng@oppo.com designates 40.107.117.103 as permitted sender) smtp.mailfrom=lipeifeng@oppo.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1708352249; a=rsa-sha256; cv=pass; b=7tv0a/6YX59VzoJQHC5YTL65f7N9q4Re4E4au0YnNqpPSCAmvVQxyvqjnX0VQMy2j0krFg h6tIQ7WlWVo74HI1qX2gSu5n6NXBwQlCafmSZSHN8N9ZHCBZLhLxC2MzJDXgqYP470lf3W vq/3zkuIxtu02z9nPhun23QqIb6dwL8= ARC-Authentication-Results: i=2; imf24.hostedemail.com; dkim=pass header.d=oppo.com header.s=selector1 header.b=hkfPydXo; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=oppo.com; spf=pass (imf24.hostedemail.com: domain of lipeifeng@oppo.com designates 40.107.117.103 as permitted sender) smtp.mailfrom=lipeifeng@oppo.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708352249; 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=IFfkghkmTAOy10L0dVJZM1Co5F9ETd4movKOzLTtlAE=; b=gzXghGa/VHcybiyzqAM2xFCsfyE0lLAyVGGPVAHQPyrc0lMZznjUnEHMlargCSFnlKIt0Q 274SieYSIdTP81yPe1h+aciQdgWBy3MG6oiyGcTHwAyRqRHQIWdUaQffX15jKciuNCgwr2 s9m3kS7dXdRrd9LBSd3rbQMZTZZ9nsQ= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=abpaqMXgmPYhjEgO0rKudFVdfWGFU2wr5sX7dNGjik++SZ7pqTGnAqISPon4npNGW9ngrH7EXLSKcBY75dmq1OYhGQ2BGEb7Z9F0iKjIXE2k5PgD7WYd4vdYPl8pVHfOE0wz39nRBpv6Q4/H9oF0M8/FAopr23XyVnDxaW99gcU+hssoJwFF2rczsePTYMvzYgt172gfbyIavB7a5gf7piJUbKcV3LzB3mEQ/DeI/FOWzMwi+nGDv6Wfdb7TjPDocgU8X2srs79rXaKjB3Hej3CvN8P4iLFpjKSlKEzno3LmhGVA5X8Cm30GFk3QcVdtfqK1V0mKDKFgkZF2FGdVtQ== 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=IFfkghkmTAOy10L0dVJZM1Co5F9ETd4movKOzLTtlAE=; b=Gcy40bThXZP8snW+nMRluItOaaDhKs5UmC1/MP6I/WlgTmanycGWtyJI2IOznv89ZPQdui5DQhWqBwmo1DVlPmhz7zpBeUAcgKB5NoJ2qDpfrQTxEr3MDRrWDMYomk0T2UajJHhZpVcrD1PsKsgPQY3QpZgzVLsfmBEcj39BSHXG4yno4ojjSBczRfvJI2S8eLNxsr3HkSzKmynki5MZwcz7Y8hPdieRPHCPHnaXQYARUj3Oy5Ax/KDpCsImDyZWxsSvbPeQa+Nhge4+4LFPsUU2lGByZ4cFinDLmerDruOr/TGoKLWi+RKichurI9INZFJ0xFRoVuKEs6sP1+YVBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oppo.com; dmarc=pass action=none header.from=oppo.com; dkim=pass header.d=oppo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oppo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IFfkghkmTAOy10L0dVJZM1Co5F9ETd4movKOzLTtlAE=; b=hkfPydXo2XeGyTFb9eiYEl16Z1+pPSG+n47lNythhbtVCJoTxBJGoTF/qcyl0fhA7sVzzA0UqAhwCNuRc/aVFHjemegvk2nsJgNzIEDZS+vAN5XQm+ft7aXslYEbgh5h7fNWTwNtFf7Xtx7R53TY4JL51VfUuo+eWTclIIDh1m8= Received: from TYZPR02MB5595.apcprd02.prod.outlook.com (2603:1096:400:1c5::12) by SEZPR02MB5864.apcprd02.prod.outlook.com (2603:1096:101:73::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.32; Mon, 19 Feb 2024 14:17:21 +0000 Received: from TYZPR02MB5595.apcprd02.prod.outlook.com ([fe80::9b7:25b2:5977:633a]) by TYZPR02MB5595.apcprd02.prod.outlook.com ([fe80::9b7:25b2:5977:633a%3]) with mapi id 15.20.7292.033; Mon, 19 Feb 2024 14:17:21 +0000 From: lipeifeng@oppo.com To: lipeifeng@oppo.com, akpm@linux-foundation.org, david@redhat.com, osalvador@suse.de Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 0/2] Support kshrinkd Date: Mon, 19 Feb 2024 22:17:01 +0800 Message-Id: <20240219141703.3851-1-lipeifeng@oppo.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SG3P274CA0008.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::20) To TYZPR02MB5595.apcprd02.prod.outlook.com (2603:1096:400:1c5::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR02MB5595:EE_|SEZPR02MB5864:EE_ X-MS-Office365-Filtering-Correlation-Id: 37093360-a9fe-4a87-ff4d-08dc31557ca1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hnqJ8T9Ndm5QhfzRTpSZQoSQvs7zKHoQZrGcsscdV5/cNBNo1By3rV7Ws+GedGOkOBpglbWRWduSy7ZwEYFoKV5cXDx9A26TQFE4bE0UBntHkpg0EA6h4CprX9ATU31FX92l+Iw2axOeMtBmPsmkGDMCvOIZObfScwiVZikOySyqeT8oZwZPVYHn4ZJe7JePhEEAcOzSbqZPFSt0mF00m2Ecf3c9njQoH836Mt1JYgr0vEuITWqkNIYRBIZ1wjunmz3yQVsEClnf88az3zZH4/uu2LTcm7xASR9dBAp5WD70quw70VmQodXPolvO33VS9ISilwLneM3RR5oKfakm8ui2L6dCGHqfyFXRYP3xKIj5rzQFEkQrdLb+R0FQqeYBiU7zAhiu+Mz3oG4cJ6JAZ6bA50akVmaSdJZzMbO7ykBfEFRBwdbK6HrVtESNbt4iQNxev9r2BV9K0+vf6neQQR8LtShH9zUG7MKq1KhYTCbjvjPf5qzs0WLoWMuBewkHStmbC4+NRXBNLJb7mEWGvyigw9XefkPhtYWwLnwNCjlgtC/IFDEmCcFEgvmMbpOqYAshhthr01KRvnpZQcnPObfS/RCElsKTieM2NMLiOSdm57XR3AmT/1raR4te+68h X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYZPR02MB5595.apcprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: t/KLub6oGiiZXcenitmS37R4aGIeXcPJIasuek1XgnTsxt9koxtU5/WM9BeHFIbt5NDP4VEFVr2yQhL0qu1SZxigr92WDmBYcROajT8q6BK8tDfycwkXAST1CggfBaHuBd//Ron9S68v3zGP3aNK9AgoCRcqfi0WVrYgqk0m3VUzR2k6tSYfE3e7r4y0xTZAxbX8fO9NdZnYQm/AzDziAVyiVAuRNKNzn1yS91sokUnHesDN6zoQJp6K9SSsLmbfwbnDeNd/AJ1eBVLnlFyJ80GxG3nVunLPUbm0XecDphpzeONL7r+1PwcEOQrv+3FhazUx4/GO9nnLI4t87+PhG71ScW4hhlT7KJv9QbgZ2KpgjBVFno0sOIJwG6V5WbHpWxiVtfy0+T7Eo5yQWlh/ljH9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OpNQC9faTNG87ioNcgDmJTeGoXBVFoiATKgL2eUYgOXD1EioqeLbdDUj5vYNogSCJkptO/tJZJlzV68SkXgFRipySJJa3yqE7wOPmLweNCzhR5KE+8WhPAy+HfpBzKnB0VQptbAHw== X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 37093360-a9fe-4a87-ff4d-08dc31557ca1 X-MS-Exchange-CrossTenant-AuthSource: TYZPR02MB5595.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Feb 2024 14:17:21.4777 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f1905eb1-c353-41c5-9516-62b4a54b5ee6 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: k46Zj2o+VCgKclNvmh/xqs8s5df1oshsUbOgvVIOffVMqDtk64Va9fl8W0qhsGtULj27ih2EN+TyJViOLVVqYA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR02MB5864 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 3812A180005 X-Stat-Signature: qnggt877ji7c8nt111qn8bahe1gur7pu X-HE-Tag: 1708352248-182814 X-HE-Meta: U2FsdGVkX1/F77ID71n8S2/YsWdo2iopo/902mNMUGHRUER4wRUPH+4yhbvVnVjKyY6W4w2fyMKq5qjhSaK6jsfWXwxKiTU7CqB4PyxsrAKiE3UITfNtH0ptfGDmfPO1zxcYaiTZRsMrwLV4FMy8e1FQZirgJ+rOyrqTIwOQgh8xlY86eHI5KrQ4MYdCFM32tWk3havvYh4TCp0PQ4TVhOlQZzsdNSsjgcAJcjbR1/ObbDWnzM+8ukR1zXp/ikwyX1t/jzyBjbKoagnMUPFiP/2AL+tLQ7dlffP92N3Rk63uqNt1EXhVU//bWiL8F6lhDnPAB2X5Q+j6dmPC16E6sOTKhdOKTKf6ETkgUhRhuiAoJHOBHv+wkTwt17w8uri21bxPtJcvto5PpXwq8W3ZoPzZdsLgbZM/GqaUCaPrkFskdt/mIqw29gEXPv+us+Z4tNjxW9okjmPuhY1GWSYbERshCuE8W5ssyXyb3GjYGxLh/YmP7rIWrgCxLPYvkTijab9/AJ0xG5E45iLaE9+vPvmvL9iPpsDg9aVRcApdQsD3y1bB4WAfUlf9al9wvqrCy15PgHhmc7bk2v409TD8ohO7kvHG4nAnhSbDDstOsCa58GkZRCF+RY9w85ZMIsacKzIibzDLtJDQ4pnv9RHyfo4p/emOQOhan8xJL1Nrn84fQckdxE0STN8Lx/70muD40MnVc5v43RRcKXMhQEiQcU6qCVQsqzhcumHICQzMgJalTVNDnNH0D45smkAnkRxSeKpwdD0R6C/JPya0xzi6/NVixjLSOKRHkDIUdN4k9gmy/H2/Xw/1gBX3UQdCDyiMkfhhsYKN0p6T9ZC6PpRI55BesHg5re3jc37J95KZ3NG9YMG2ZyIRibmVas9LQsxdYf3l6syFEIvSicOgRcXetZ1oj9mtZX6A6akquFmum3m+wo4Kom1DDDifmkcroeMeRCjEvNKTsSzlr6zofSq S/F+5fzl CY1vCQxP4OUcSR0z/v1UtWCuU9W9U30uQWa5bl2qg+AtwQPCOJqLI9JtFj3OoWaP/YMflH5Hkc3jVU01eQLTD408g0OEM3z3modH8Pv0LwgsjMZGxSRK9Iypvofdza0ndO4d/ILL8fMq0Rh2eCxY5N6jTMHz3OzLrFjFyL+GU9OD7Qn5G3ldWkTZejNLtPWlCPp34qobcS9QitDmnzoOFd6+6XtMyZv5E/J0TERR6KYfHYHHT1KjeBh//T1ndxLewpbJw/8v3SBh5NXxelmwTA58N0iTGaA/ST6Gi0YbeUBy7VVTjH9AJeaD2ON5Z029/ZNQ2HN6mfgnq/1ikW0FbMoMJMw== 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: From: lipeifeng 'commit 6d4675e60135 ("mm: don't be stuck to rmap lock on reclaim path")' The above patch would avoid reclaim path to stuck rmap lock. But it would cause some folios in LRU not sorted by aging because the contended-folios in rmap_walk would be putbacked to the head of LRU during shrink_folio_list even if the folios are very cold. The patchset setups new kthread:kshrinkd to reclaim the contended-folio in rmap_walk when shrink_folio_list, to avoid to break the rules of LRU. lipeifeng (2): mm/rmap: support folio_referenced to control if try_lock in rmap_walk mm: support kshrinkd include/linux/mmzone.h | 6 ++ include/linux/rmap.h | 5 +- include/linux/swap.h | 3 + include/linux/vm_event_item.h | 2 + mm/memory_hotplug.c | 2 + mm/rmap.c | 5 +- mm/vmscan.c | 205 ++++++++++++++++++++++++++++++++++++++++-- mm/vmstat.c | 2 + 8 files changed, 221 insertions(+), 9 deletions(-)