From patchwork Tue May 21 11:49:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 13668888 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 53145C25B77 for ; Tue, 21 May 2024 03:41:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B08816B0092; Mon, 20 May 2024 23:41:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB8436B0096; Mon, 20 May 2024 23:41:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 958B46B0098; Mon, 20 May 2024 23:41:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 766E16B0092 for ; Mon, 20 May 2024 23:41:48 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id DDA47C0EC7 for ; Tue, 21 May 2024 03:41:47 +0000 (UTC) X-FDA: 82141003854.12.05A4343 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2050.outbound.protection.outlook.com [40.107.6.50]) by imf17.hostedemail.com (Postfix) with ESMTP id 2EF8B40016 for ; Tue, 21 May 2024 03:41:44 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=nxp.com header.s=selector2 header.b=hTjkG08T; spf=pass (imf17.hostedemail.com: domain of xu.yang_2@nxp.com designates 40.107.6.50 as permitted sender) smtp.mailfrom=xu.yang_2@nxp.com; dmarc=pass (policy=none) header.from=nxp.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1716262905; a=rsa-sha256; cv=pass; b=31VQqBBs6phXivz4+0Fjx2zoAC8Vxzu6ckoRSwa3Gu5qt6UDuscQGnLCqp7vk057F6Y7sA 7tMtU5Jbbq3h9C4uHIR75unEknGIaB9G5xbg3PeApO46ozotSqZrKquvTpeDgpTsfsyMxA f0c6wguUuddcHbwkS13z0eXwmd79Mlk= ARC-Authentication-Results: i=2; imf17.hostedemail.com; dkim=pass header.d=nxp.com header.s=selector2 header.b=hTjkG08T; spf=pass (imf17.hostedemail.com: domain of xu.yang_2@nxp.com designates 40.107.6.50 as permitted sender) smtp.mailfrom=xu.yang_2@nxp.com; dmarc=pass (policy=none) header.from=nxp.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=1716262905; 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=xoD4U5KT5tLz3wUrOl0GKj4h7wjVLs02V9P6S9Sa7+4=; b=rh8pBxY7UzMMlSP1yGxOa+AD+vs9jOadTlyuifCHEyhhAZ2s6OH7xcr7X19AflzGXQaA2c ZAwVXnPfoym/ClBa6cceDdqUR9QASNr7SFnkuvWUofxkV0APUpbgrn0zCTM6Y2+0qq69ZN coiD3+nGuwRzbWGZ2tyV0JqDyGYsx4w= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KdvauhSZ4qLgTnl32v9stb7pL+AJtxsSdHWpih2OpUzpSBNR1q9bKtRZoL0FgTuFurWdPdhu+0wQE2Ce83gw3TASMfPZCqzRLZ8H5wMfJKsupgys3OJwzorgrdQTw0gLlQaPDnglgqtc6gS/YG+ODPptVEb2IONrGrSZUOls4LfFGbqHmtQ+azWP/coOsNA8KzziI9BKuNrGOSwUgPhlpVhAyk0OL2phRcPHGcCMampZS8QRApRGL3OayYv4HA8ItqNwRBdyJjUkrgrE362sVtcEencTMdKMkHQ2qsxX9rG5UE38Dl/4zhCQ4sx6aZQm3Jir9Ap25bX08fIPLMM86Q== 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=xoD4U5KT5tLz3wUrOl0GKj4h7wjVLs02V9P6S9Sa7+4=; b=oaiV6SLZYhVumquoaFFAeyJKYTqkCT8vlMy1xpFv2wqcayxdFqYimdR7TmDdXauIfMHWdti4iboyu5Q529MiQXAxNGBpuBzKderFT6ZXMxc3h/MoCRyftWAlkgXrDvU1aGSjxCG08g0Y/a3arKvY0JQzWtVGUFx8hAaN3C0qMbXTXTKGwao6RYGuxcUET8FHyOl+BtgmQk8ONNIBLafoRkZfsV7mBITuJjbS7ukc4ipbUG7IU0jojihciRAdgasydggiQwFdl8qNIc7rxOKKqB1YBDh37dTs1pFz59ptyr7pVdgmmkQtn3RJxmBXhyr8919Xon2Wrse+LRPA7pABCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xoD4U5KT5tLz3wUrOl0GKj4h7wjVLs02V9P6S9Sa7+4=; b=hTjkG08TVrbSsn2gORJ8zEs2nmsnuvj/6/GcvURCJj3ntTsU33WaYmAYY4TvvnVQpgwsSRXe/QY2tU+FXh4HNKSgJYMWgRdWJgcHhmeGA/cSPuqXJJciTDp2UNy8+dRvPjKPQHYwEeBvhJC5RRTWYkadKEhBRNp49QaYQC9rM98= Received: from DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) by AM9PR04MB8212.eurprd04.prod.outlook.com (2603:10a6:20b:3b7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.36; Tue, 21 May 2024 03:41:42 +0000 Received: from DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::8d2f:ac7e:966a:2f5f]) by DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::8d2f:ac7e:966a:2f5f%6]) with mapi id 15.20.7587.035; Tue, 21 May 2024 03:41:42 +0000 From: Xu Yang To: brauner@kernel.org, djwong@kernel.org, willy@infradead.org, akpm@linux-foundation.org Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, jun.li@nxp.com Subject: [PATCH v5 1/2] filemap: add helper mapping_max_folio_size() Date: Tue, 21 May 2024 19:49:38 +0800 Message-Id: <20240521114939.2541461-1-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SG3P274CA0016.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::28) To DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8822:EE_|AM9PR04MB8212:EE_ X-MS-Office365-Filtering-Correlation-Id: ef153253-185b-4de2-7431-08dc7947ee16 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|52116005|376005|366007|38350700005; X-Microsoft-Antispam-Message-Info: 62iSDpyhjaKEEEaGGhgBQvd4WKW1jPkEyNFP4OZlw8ih6Gh4ntssEUrzer+TiUBFCGUxhfwOWg/PDcApjIv5WY8uAwPZi3ZzMr41dDbbFzyWXuMBGQmQJ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uuLtZkamU7Mtl5RLJ4LDPRhxc57NFhpwTATPPTTlOlh93pWaCeF1h82Y5UbRqRwOeWa+U/azR7MZ48vs36B63DZXtzRxgx/y4JrgVpSwQMpwr8KfDsuKcT9sqLLkJq8xzZZnRtkvDghTQ5Jk15eiFkIO X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8822.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(52116005)(376005)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GC4fkTpFf8vjSdT+GNrHAFQ0yPBh83w7pKjQTrG9R5C+aX1fYHWrK3bBVkXQDn3uHUoNFsuIWKr+o/fxd7pajkOk13csLIpWV3tr0mx+XEDR42nu1es6ZkGgUjTkbjMaK+8dlFGJHVXoWVzzzTrArzJ8jIqPCrtqDhEtEzqiRq2xkeXASa3x/v0Sf+5ATrj+TYA7kdVDDTr7nwJJNdQ3XRSMpxebTpYjQvPROJfHTfcZ3XC+Cg8sX4XqiMHH3TocSv0ddVDAa/sJes6BVT/apPxETkWW1hzVCZfEJ4/zz7sAyf9Fy0pXyus9YEdi7AOjAn8wbRJgYks/ArN59SV9RBgfSA4wekgYarIa67XEosF2u9Fwxgn8V+XXhkn82U09bsHWC8C/BrYBoReU/aoN22gVvGzq94OIWFJMRLfXFvTI7rNJEf3J2FL066aHayDwuHq0k/dlw+CZafT0YzGN6wNTNRxEsJ/kG6vCyP4krGBO5n5ascPL+Jj3EhO6ArYZn1nFYyd+5JKDlmw9Lknr53tYDbzLU1+T5QceDh7ifdUFFDDxuEPa7VNwDNqv0bOia149B9XNKoSIcbxrDuoTEaN+6usexZkQ66xP2n+l5hPj6C64wRk7DpnOwYXVWyGGh4ryAca52MrGLKzte7S4AfDEeLg0SUnTwkE/afc59sxUkxuKp4joON1D/6Qkj/QTWmr9gabJ0e/Jc2r9U0MxxCf+GaEDl/KgHJeyPy2zryK2PgmhPiiWD1/pSLHNCktw49W44piu6kuO2pe8xg8wQ7cFqtg77ueSUPCzRgOrw+4zQe3E8F1KRNh9V0d1aZeik8e6Xh1xCMqlmDe/NhI4DpG5qKOlkpktbyz5ekVzEfMVMPhliANUgON379gyLVMOTkLvNp72cyoExIJ7SjiP+0VmT5lbk1JOnbiMgDLUFCjd181jFdZ4ZLcqMWFvmpr47mACs3t0Ja2++t0+oWm1ypRu+OO4DLx+G8KGZhLBfNCKstHw7jGLOX+GJvOliFaSC0u6PaiGyBUNTXkYByEsjBtjzaD9uJ/2czI1JjkBYA+0F0Ni3iNuD/nzMHS375jNAaXZrF5vnaHvPBGMogeW1eg1ipTT5Y4j2iUJj9SyjjniBWX1+/qwYTJaEZTNhQWWz2g2ByVT+FMNzOY+kyhN+OjMJzCtjpAFKYe/mS4V8Yzjza4smGaGbUmKcQNWu3BwCO5tBUcGkiibWJOxWL5b8i9YeO5PFNxilJJ4cxI5mwab1b6y7IRiWoI9jTWbJ4aWYqXNo3ks8HlXK/Rjl8gVaMTNzz4NH0v2AmUh3sWRWnNT8t4QtyeaSZhPDB0f1MryC+h2WRksArmpltpcfsVfNJsCR1nnRdNvDneT6yCUR7SHEe+zQjXXq/eR41q01bbptNlx+6gkEEMkKKPTCzpX2bF2WDtzpf93M54lRDh7R7I1QWGE0OyFPO/H9eqB/qgxIbtQ6cuCt6+pKdjjBgzN50N5XoTBpYJTz9kQRsHF6+gVcUWEPVCijjJzxP7ljUmjK/lP3BbN4SpYD5/wMe4h7bUudiLD28vvFdeX/sAQoWYm8XdoSAardxpZSKIh/51q X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef153253-185b-4de2-7431-08dc7947ee16 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8822.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2024 03:41:42.5220 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xY7871XynTdTnSjQtcIG6GrB8YJHXe/SJwB6WsB1ITXO+8W7/7HvNeskIS9ULwLqnIoOphTCpwaLZ/cU8hrVEA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8212 X-Rspamd-Queue-Id: 2EF8B40016 X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: y7xqgkjqmrdzwk3hsaet1gc4uwbdth7c X-HE-Tag: 1716262904-586025 X-HE-Meta: U2FsdGVkX1/MLvlkDbNiYzqgeKmHOTYDdrmX2uZxaxR22RZbYPt3ZD03ouEzP8sn0PnZCPQ1ViW7jtoAa33s7zhRBlxhLmvA3J/KNE5GHJgPK+FZw8EhVieQEACcDhX3ShvDm9OLDB6J6xgrn20PQeMzgG/d94n/CK0D1UHHkeXo2ONCUhD6Uaeo+A34lzf9kK7sCF9n6oAI+kVgFErJYG0iYoLbq5CjRd/XInql7RGWu8+swCCDK3ibMZOAmYEENSfK0uikwXLCbWcJ9H2kGwEx42deB85lZpxIK2Ix8WKdZe0/QMkcMJxenztHEKykSC8S8IVRxOVV4frcGIe+kuHqRdoVl+JfK7VNybOIHpBUZT5qj8xRZkgiQasJksquWSrMyLsLwF45YyhuOp3NV8tCtDGhBupGE5rjHPKmC82iN9PkZVqujOmLFheOwN5koE1YD8cLIaUZ355kD2R/AENoKyi6NG0V8/IABHb0WL/9Sl9oi+53R+LI9UONlgPQbQ5eV29k5Dx5vNF38x6uuLRocBYxzdOkyzLVkPWy4lT+i1DnEskBvb/Sq3z0aejHV4uDTxh+2naxZXLIKm3SOXvH65uQ8kjb/cbKdSrtmbd39L3tE4NP+kj51plZ9EOch26x4ltGF9I6mw+pyDOK0Rmwm/0IuIs1Bwl0r3mepWZolKkxH3GSUqYQW+pdla7hREvpTdBVpweYo1XOCIOdfNV+ekRclmFv2pcfZFPrUkZPHadjA4M76v8uT32BUdVFHprONutLlWN0Vhy1o/f6dT5Jn3ZV179Z+UIylMWpO9u1gIeb5PE3lt0paWmgYgq1KBCGaHG8H1/4iRGThR0h2y+oWu5xYJZsYtjMz2jAP8lLgG5sO/5Ybg3O5nxwoVv4Sb7XsTwIwN58CJktgL1H4GuYbruKDQN4Ob8LD6h1WsGe6el91v12MQ5DlM1+W6haoRBDZKsW8zbyYorGcJr E2hrn7NN ooGnoZQonZb/fI6VsZGF2jpqKzeflZjObYPbq9O0a0S5f7LSF9wHhyZu8RbY4nLXhpAoDDwEZKXRKiKNMQyuUL2rsZSMfTRK4YMNv9u1Qb2MzuDLZh2E4IZoX4jLVewXmFN2iBgH+t7CQIckwlmNZ5JcnOQxW/UgfTf+Gc7U9XgTzNDlFmBOBYOAVoJjGbeSMJK9vFgCPyi8B3Mt0fDq0+W1BtoOWDJF5Vd5vpiv/aoBtrQc4I7lkZkmIwSXB8QrQTnp/n+QslfoatEgM6s6T3ZUXiyznOvCcPK/3bN6g8O+ZILXycPpyr5QsGpe7Jjeb+mg26u58bICLDxdRhcc7CROw65y2Yek95Ex3psjREtKY2ASossRn8ZvoazG9X6U9RJ00+jpnnE0Ogig= 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: Add mapping_max_folio_size() to get the maximum folio size for this pagecache mapping. Fixes: 5d8edfb900d5 ("iomap: Copy larger chunks from userspace") Cc: stable@vger.kernel.org Reviewed-by: Darrick J. Wong Signed-off-by: Xu Yang Reviewed-by: Ritesh Harjani (IBM) Reviewed-by: Christoph Hellwig Reviewed-by: Matthew Wilcox (Oracle) --- Changes in v4: - split the mapping_max_folio_size() from v3 - adjust mapping_max_folio_size() comment - add Rb tag Changes in v5: - add fix tag and stable list --- include/linux/pagemap.h | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index c5e33e2ca48a..d43cf36bb68b 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -346,6 +346,19 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask) m->gfp_mask = mask; } +/* + * There are some parts of the kernel which assume that PMD entries + * are exactly HPAGE_PMD_ORDER. Those should be fixed, but until then, + * limit the maximum allocation order to PMD size. I'm not aware of any + * assumptions about maximum order if THP are disabled, but 8 seems like + * a good order (that's 1MB if you're using 4kB pages) + */ +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +#define MAX_PAGECACHE_ORDER HPAGE_PMD_ORDER +#else +#define MAX_PAGECACHE_ORDER 8 +#endif + /** * mapping_set_large_folios() - Indicate the file supports large folios. * @mapping: The file. @@ -372,6 +385,14 @@ static inline bool mapping_large_folio_support(struct address_space *mapping) test_bit(AS_LARGE_FOLIO_SUPPORT, &mapping->flags); } +/* Return the maximum folio size for this pagecache mapping, in bytes. */ +static inline size_t mapping_max_folio_size(struct address_space *mapping) +{ + if (mapping_large_folio_support(mapping)) + return PAGE_SIZE << MAX_PAGECACHE_ORDER; + return PAGE_SIZE; +} + static inline int filemap_nr_thps(struct address_space *mapping) { #ifdef CONFIG_READ_ONLY_THP_FOR_FS @@ -530,19 +551,6 @@ static inline void *detach_page_private(struct page *page) return folio_detach_private(page_folio(page)); } -/* - * There are some parts of the kernel which assume that PMD entries - * are exactly HPAGE_PMD_ORDER. Those should be fixed, but until then, - * limit the maximum allocation order to PMD size. I'm not aware of any - * assumptions about maximum order if THP are disabled, but 8 seems like - * a good order (that's 1MB if you're using 4kB pages) - */ -#ifdef CONFIG_TRANSPARENT_HUGEPAGE -#define MAX_PAGECACHE_ORDER HPAGE_PMD_ORDER -#else -#define MAX_PAGECACHE_ORDER 8 -#endif - #ifdef CONFIG_NUMA struct folio *filemap_alloc_folio(gfp_t gfp, unsigned int order); #else From patchwork Tue May 21 11:49:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 13668889 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 1182EC25B77 for ; Tue, 21 May 2024 03:42:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D2276B0098; Mon, 20 May 2024 23:42:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9801F6B009B; Mon, 20 May 2024 23:42:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D2C96B009D; Mon, 20 May 2024 23:42:04 -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 5D8AB6B0098 for ; Mon, 20 May 2024 23:42:04 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C0E86141015 for ; Tue, 21 May 2024 03:42:03 +0000 (UTC) X-FDA: 82141004526.14.67CD916 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2062.outbound.protection.outlook.com [40.107.21.62]) by imf21.hostedemail.com (Postfix) with ESMTP id EEE811C0008 for ; Tue, 21 May 2024 03:42:00 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=nxp.com header.s=selector2 header.b=hb18RWC4; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf21.hostedemail.com: domain of xu.yang_2@nxp.com designates 40.107.21.62 as permitted sender) smtp.mailfrom=xu.yang_2@nxp.com; dmarc=pass (policy=none) header.from=nxp.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716262921; 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:in-reply-to:references:references:dkim-signature; bh=VioMiY8TvLlw52PeygM9+PK61Y19grDV3m6pKMV7lao=; b=0Z2rQhwDarmg/MBGKYUWWmdIKEStBpUGTBLtf10dr0gdIE8SO8hqr3l4te/NDbg+t7vtL0 /8bsiYDSdYCReT2l0iQIhxW6LukyNpQeqdsOmao8tlLCMTHyxtkFgvNbSOJQu6wkk6NUk7 aDNsfmgdME0SfE8LQU1jI6Ikk2RfQug= ARC-Authentication-Results: i=2; imf21.hostedemail.com; dkim=pass header.d=nxp.com header.s=selector2 header.b=hb18RWC4; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf21.hostedemail.com: domain of xu.yang_2@nxp.com designates 40.107.21.62 as permitted sender) smtp.mailfrom=xu.yang_2@nxp.com; dmarc=pass (policy=none) header.from=nxp.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1716262921; a=rsa-sha256; cv=pass; b=quEgRbpdUZKJ1V45mahlJjTwreIxHZOuPvY2jJNiN2OnWuN/qIJKnh4SKPk9uLinWqhdQc ML0BguuDFaL90kJnzcGVyuxQBrh3p0temjJUB5+BkARu5CSBJnUB1eip44buT3Vs5UYUA+ aky9gM/jq4B5jh2XQoX1+Sbfsx90Jmc= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cCh0okGYE2JdN1hWfAlWLxs/n4jI1nhYPUQBbu/PXxMRRoT84pZH3diz4VSLiTX5QlzH/V/zIgcSesTp9GcYmMfdtXvSjI7t+ygIPmqVGxf2j7hpLS51z65QQ1QKMCVAxw4nRXJOGrhQiNMwkbIQtp0z6hONlbGRHWoaNDecPA/eLDdyP/SuktX3w+FwfMFM+RBGhjKFx6CVpi7XXlNC08lRSg8LsrelwQI4YMjMBuG2cio+cDYj5T6YTgsyklCqWT+eEA6X1BRS7HNeTdsqyxRVVZuJRDxa3O1TB2tMSnqj9aYx8wrpUTzXAPwr1hsAnIjJHliY7ZtGs/njCNXcNg== 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=VioMiY8TvLlw52PeygM9+PK61Y19grDV3m6pKMV7lao=; b=bPDSibbNuxAMmrIBeLcd45KF5yII4OhIDGad7qQBYAhaG0L4/9WgSJLGmeT8HPPZP8MxPSsGhwcwGp8LjBGAaRdPmT4kDsRVCj7c0kt+Px3mfjYEJyM7Rn4PfAfRzkOmgOnCk0B66J4fUevJ/qT2KHviqNh6NE1q+Rx31i+0lERr3R14y6Swxg2kdYLjjuV/zauC/gjxfpcP3GhCa/E5vYUaESNPLbqIk06VBJVBe3WreHrWa/4Fn1pHLrvjgHcH4RyukigrEtfrURSEmq4XkHm5ZF9ut76V6NE2ikOud3ykxRS5+u0CD7Jzqk6fASTuu4zayOY4SfR0dR0grGFUnA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VioMiY8TvLlw52PeygM9+PK61Y19grDV3m6pKMV7lao=; b=hb18RWC4UFbylLc5RXDDoBR3mYgNsAeIkBfmGSrRVL9PugNGB57PO9UkHr4NTEu+zqejO5rHwC5YseIYm1QA3Z2K+FLALOwkRcHxpEZXJmhvV9+7RHF8/CjeXQIFXFxGYrTiRCGIua2Xih0DE9Oo7siug13IkumcNHA6Rj+KACE= Received: from DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) by AM9PR04MB8212.eurprd04.prod.outlook.com (2603:10a6:20b:3b7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.36; Tue, 21 May 2024 03:41:45 +0000 Received: from DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::8d2f:ac7e:966a:2f5f]) by DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::8d2f:ac7e:966a:2f5f%6]) with mapi id 15.20.7587.035; Tue, 21 May 2024 03:41:45 +0000 From: Xu Yang To: brauner@kernel.org, djwong@kernel.org, willy@infradead.org, akpm@linux-foundation.org Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, jun.li@nxp.com Subject: [PATCH v5 2/2] iomap: fault in smaller chunks for non-large folio mappings Date: Tue, 21 May 2024 19:49:39 +0800 Message-Id: <20240521114939.2541461-2-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240521114939.2541461-1-xu.yang_2@nxp.com> References: <20240521114939.2541461-1-xu.yang_2@nxp.com> X-ClientProxiedBy: SG3P274CA0016.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::28) To DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8822:EE_|AM9PR04MB8212:EE_ X-MS-Office365-Filtering-Correlation-Id: 7bacdb00-c3e4-43a9-3d71-08dc7947eff9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|52116005|376005|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HSR0Yu7L+kvlMGrydFlM5K/BX3nAINew74wDfXzDwMgDuY0dKA5ykokYzcKFOKq13V8Vu2EVZg98lXz/ALsdN5wnW14tYUzUjGRXjXR0g+imEY3ECHfcg/Rh+p/Z/+nIa3tiUTMA8pp5FYkK5xwBIkOwLrOe85kVPSB2+rXIs4vt4xuaAcCtoNLfOBjnaP+PAE6hAnl8Kvv9hu5YUUmvg6VsHCbcCyBZ1IfcpK64PYBYdQRcYS+l3lgqx3o2/muFL6MiHVix8pwhlvuqwJXkBApPQxX4tAMV/hEkUSHyquXUItEwuumY6h8HzpNCfJaPThakg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8822.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(52116005)(376005)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pthm84TnfcrQZK15VfVY56LsnkeeXb9llGHKZyxcfs0yRnNYyr0cnu93bgGtmyx8HqUMHawHlTRUNyZk0hHej0CyZTyYCGn+z9UbhpFtFxVd8tPFYWkkNg8PrjaOT72yuVUrM8oEMNjyOKx0WeUQ8G0QpmRwdX7TBPK2I0kBEZjjV8gJ65vEm2V4JuqXhsd/fDv6kRMkcd0vbue9kXprphFeQcTyrQVNJy3Z+5a/4U4mNeKeNQPi8kLX6EDIpVmcjrOqFudMQ51WKrUc/Dav+f05U4cmz5xRcZ3zfaDgiDQXlcSBtStZEkOMLTc/92hP/4BuGPy49ZpN2Tf7/Yp2FSfDfFUGm4u/8oCP2NPOyMhiOiqwGzmFx9Kb91jjC2oaBwsVSmntGbmBAnGCz5MDmInFad9Bp1Of9+rXgusEoFV6EiA7Y5E6fLl+BC2ZBSEzHXnxc7tFq8peDUD0+NGmQEgpYuwNIGgNLnnPJgyCWiPjdIljre7wOmEd4AVVYCgArj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k7JJnK1sU X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7bacdb00-c3e4-43a9-3d71-08dc7947eff9 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8822.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2024 03:41:45.7338 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Zv5pJ8QQYxYa6V2URaGW5vDeU5PtKctylJ+GiyKO+RARCzOCOO9yxdAs01jx5ZnjPMidQmosoVCnQMTRBitttg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8212 X-Stat-Signature: rdpzsb75rk8wq4hnboept47iqs8qsoub X-Rspamd-Queue-Id: EEE811C0008 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1716262920-730124 X-HE-Meta: U2FsdGVkX1/wbBnuUegBezecZdi49YXWK3dJVcVNjbvwYmEoJM8ZwAmDbws3jFuVKIAfPRiqhskk0BmC0CSPozQZSpF6KUHdXFudjLs6HK5/Wz1S15Yhuidd+q57HzZkpNEFBcHkyZ1+PU9GLXsC5MF/rfbo1B+oW1eBiML6S57RNyW4kze2c96TKZhKhrpbkIoswmBTj9dVfg9fz349DP51/Bq8wieYceOtYnD2nVX2hyhF2C0x1opt9glW1puepB+d8q+8zAa1eu98vl2MC4rri6unzZyeoCq8BvnWBDFAk2xl004idZf+5xP6/QXha3RWtoR1U4JFff3PWQkpvtB4azbxAyQQfVawQH5Hk+nREwTHPvP57Mv0xjKg2cvnT2A2f2h32nZqMM/Ashl5JCHQG2XRfsgGJDav/zRSOgwHciu5tQxAFO/nY0Irl6vdfvL2Ju2uYAdhotxWl+9uhHkVnNz84Cvfac3mdOSlbl4xGyYZULI8DDDXAymr80wqwklukk6OI0Q3YlKzmOWpDoVCszmuXZMJ7VNESUiAQoQoh+JEeNKyeaQSllNSwFREZnV2n8sjTOfKXPWAuayiFrmdhIXflhXGUE6bIJyaPecZhnRYxlAgf0biSZi+BAo3Ihzum/r7v2/4yiu0LZz3o39LwDo49mJfkAjDOi4XMaW9VscimtqGwBm8M8UKT9fwy+U29QM6T4BS+SR5WUXdJkVv4ow6dqCgh4XISaz/itx37YmkDdRI1a7YttTQDyhOPs0YeDhxQLY+hdzgO02wCWF2cDKvMDPyU601V2Rg39a6+10e9O7VDl6ilvDMSLbFSFa5EymrbPOr44jtq9hCmuYnSu7eu4jvAoy5gouJbL/Tk6Y+nDpcpB+9l3A/s1aNBoxgoFpNmz3osz6I3dMKrz2X2XOSMsZADkII/GGnvj+jBgU5dAl1qpScllP1em/tP06WBSXw8GqY0fW4Rsj S/x4veZx Qs46m8JRmQ5m0fZEv3HK0gLXrxp2NYNNCXkpEochu705gIVm5SQJiuYeJqEEKQ7q9MUT73QZz54mE+6AgRs6H2UiotQJMVI9FOQXZyDYkuLBC/N2VsOS/Y26rHffH6St+TAPL/v3TKzRvlBPm/Ya7hRCLoCOgf3k2UaP1C8MQxKEDr8fOb9avZqVklF992KYmbVrEWnYplj/cfQ5aj8Hyg99oktqZg4bEfZwqK4b7FvjGU54/Slp1fopiQ6oD4tJVUBDCgBF8clEWbK176C/MFMu7+6ZT3rKQ8M+C5+r98nMdhg2xW4g5XZwagDVw5fBB1shs8uea3Xlo1hfHA97IYWPp/g== 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: Since commit (5d8edfb900d5 "iomap: Copy larger chunks from userspace"), iomap will try to copy in larger chunks than PAGE_SIZE. However, if the mapping doesn't support large folio, only one page of maximum 4KB will be created and 4KB data will be writen to pagecache each time. Then, next 4KB will be handled in next iteration. This will cause potential write performance problem. If chunk is 2MB, total 512 pages need to be handled finally. During this period, fault_in_iov_iter_readable() is called to check iov_iter readable validity. Since only 4KB will be handled each time, below address space will be checked over and over again: start end - buf, buf+2MB buf+4KB, buf+2MB buf+8KB, buf+2MB ... buf+2044KB buf+2MB Obviously the checking size is wrong since only 4KB will be handled each time. So this will get a correct chunk to let iomap work well in non-large folio case. With this change, the write speed will be stable. Tested on ARM64 device. Before: - dd if=/dev/zero of=/dev/sda bs=400K count=10485 (334 MB/s) - dd if=/dev/zero of=/dev/sda bs=800K count=5242 (278 MB/s) - dd if=/dev/zero of=/dev/sda bs=1600K count=2621 (204 MB/s) - dd if=/dev/zero of=/dev/sda bs=2200K count=1906 (170 MB/s) - dd if=/dev/zero of=/dev/sda bs=3000K count=1398 (150 MB/s) - dd if=/dev/zero of=/dev/sda bs=4500K count=932 (139 MB/s) After: - dd if=/dev/zero of=/dev/sda bs=400K count=10485 (339 MB/s) - dd if=/dev/zero of=/dev/sda bs=800K count=5242 (330 MB/s) - dd if=/dev/zero of=/dev/sda bs=1600K count=2621 (332 MB/s) - dd if=/dev/zero of=/dev/sda bs=2200K count=1906 (333 MB/s) - dd if=/dev/zero of=/dev/sda bs=3000K count=1398 (333 MB/s) - dd if=/dev/zero of=/dev/sda bs=4500K count=932 (333 MB/s) Fixes: 5d8edfb900d5 ("iomap: Copy larger chunks from userspace") Cc: stable@vger.kernel.org Reviewed-by: Darrick J. Wong Signed-off-by: Xu Yang Reviewed-by: Christoph Hellwig Reviewed-by: Matthew Wilcox (Oracle) --- Changes in v2: - fix address space description in message Changes in v3: - adjust 'chunk' and add mapping_max_folio_size() in header file as suggested by Matthew - add write performance results in commit message Changes in v4: - split mapping_max_folio_size() into a single patch 1/2 - adjust subject - add Rb tag Changes in v5: - no change --- fs/iomap/buffered-io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 41c8f0c68ef5..c5802a459334 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -898,11 +898,11 @@ static bool iomap_write_end(struct iomap_iter *iter, loff_t pos, size_t len, static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i) { loff_t length = iomap_length(iter); - size_t chunk = PAGE_SIZE << MAX_PAGECACHE_ORDER; loff_t pos = iter->pos; ssize_t total_written = 0; long status = 0; struct address_space *mapping = iter->inode->i_mapping; + size_t chunk = mapping_max_folio_size(mapping); unsigned int bdp_flags = (iter->flags & IOMAP_NOWAIT) ? BDP_ASYNC : 0; do {