From patchwork Tue May 21 11:36:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 13668882 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 30668C25B77 for ; Tue, 21 May 2024 03:28:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 901C96B009A; Mon, 20 May 2024 23:28:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B0B66B009B; Mon, 20 May 2024 23:28:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7039B6B009D; Mon, 20 May 2024 23:28:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4E8876B009A for ; Mon, 20 May 2024 23:28:26 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D0D8180535 for ; Tue, 21 May 2024 03:28:25 +0000 (UTC) X-FDA: 82140970170.15.3CB3122 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2085.outbound.protection.outlook.com [40.107.6.85]) by imf30.hostedemail.com (Postfix) with ESMTP id 1A9DA80008 for ; Tue, 21 May 2024 03:28:21 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=nxp.com header.s=selector2 header.b=MQr3FTER; spf=pass (imf30.hostedemail.com: domain of xu.yang_2@nxp.com designates 40.107.6.85 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=1716262102; 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=kpBy7C2LF/T+5wMu59RClHeVqnf8zCo0un+Q8AuCxaU=; b=54JXMos/kFrbtenS/z7PXDxtlfCzFSjMNIyaS8DXOdj0u/JPfnY+bw8FTGzTTrFnnT2Yzd lKJqGDOjO9j/QNzORI+ykmfT+KPP9osFqz90bFNleA0L+6Xi0Rs+eln9Zcyr4uGWriPa+U VrfUh96eGF3j1pNv/DfPQos41Y4DiR8= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1716262102; a=rsa-sha256; cv=pass; b=EccCq0GPiRfFajuzeniOZqI/ajV5wZICCy3gr4KdEUpUK8LJbsSysSvAz4Wr2T6q5ddeVf Rrf9T2u+cGAu8juq/s1giAfJBZlGv229Nf2M2kTdocYToDrHPUJo87NFW1GKeIflUkD9gj ShnguhJJTYogTrx0ofdc/KRHLujGYsg= ARC-Authentication-Results: i=2; imf30.hostedemail.com; dkim=pass header.d=nxp.com header.s=selector2 header.b=MQr3FTER; spf=pass (imf30.hostedemail.com: domain of xu.yang_2@nxp.com designates 40.107.6.85 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=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nijPkSngFQNVgoKCip/wvwaImX8FBtfm2lSk+q5XpBeDBBg/nJtT0ExFe4UhuWBqOndn25/ItB/gjapKYvK8GBn3l9ZGwy/Gql7vMX6WwUrxaoNLXIzAwbBzUFcR8odIArvnf+nT946AYoebKdf5v/vevjiO1ucvj0oC6xkc/3HrAuT7GSTeLOvEZRfrxNC5WaKmBIVJOLxlx6EDzp6T2Ng41l7seKqL1L+v7Q+tyQMrvvOkCf/+iG2T2q0t0gD2rxeezwuYgPoW0wQLwJpdPbL7JS5xgtsQb4hgp1W42Pd0O+XnS6D7TnwBSxPBCGJyTPG+A31aPtt4/tJAyE0u0A== 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=kpBy7C2LF/T+5wMu59RClHeVqnf8zCo0un+Q8AuCxaU=; b=WtYJMm25M4CuGDYhVz9C0y7pqexxoMWLOhWV0xqgpXYgX6FCKeCV6VJQkXKIWV+/22oFFcdoGJV82hjivqc5VqR5Vvf5nTdLBTEHeYte7haUfAv2iuoUfzwwO2pjgPTrf7aDc5c9OHKeV4hv239gxXcH4gP0Jb11HseXEP6cVw4ZufMGYmCi9YvONC0Dfr/yt7fNDE+AOrunU/VNGjNU0iZ9INuxqMmCpSlRNeu7nfLnXAZ+zWo8n8kKUBNq2chKmBFLWyNTjqNtC+9AT9wqfnpMfqU0FJ+KpPHBrLkzjc7/Gn5+UjR1nxzNLl5Dc5XK1yXtjhQoERaTuX3oD/G3kA== 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=kpBy7C2LF/T+5wMu59RClHeVqnf8zCo0un+Q8AuCxaU=; b=MQr3FTERt+hhmosTGCOlrnF1jQDhIrAVj7j+4wSoDCz+QBcxrIHTokvuoMHuSsHSql6g5Xhnnkd18nqGn5c86pKaHnJGsh+/iEQ+xqkfIMbEolwGQUymzWsJkhIuwV9DlJT2oR0C3iSAIfGcCGPvrUyjC1d5fbkMI3hNdRSjzIQ= Received: from DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) by PAXPR04MB8606.eurprd04.prod.outlook.com (2603:10a6:102:219::21) 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:28:18 +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:28:18 +0000 From: Xu Yang To: brauner@kernel.org, djwong@kernel.org, willy@infradead.org, kpm@linux-foundation.org Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, jun.li@nxp.com Subject: [PATCH v4 1/2] filemap: add helper mapping_max_folio_size() Date: Tue, 21 May 2024 19:36:23 +0800 Message-Id: <20240521113624.2538951-1-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SI2P153CA0022.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::8) To DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8822:EE_|PAXPR04MB8606:EE_ X-MS-Office365-Filtering-Correlation-Id: d1fb49b4-2882-485c-6407-08dc79460ea8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|52116005|366007|38350700005; X-Microsoft-Antispam-Message-Info: CQ5jYG8iMWR9o+4uQbMBHbj4FBT4c3ibyQKDewZ9xekaHrkbeorVBubKPt+xg7bZO8Rzu7A5O0398eSba1NpJkpzsju63Tee+I7bIQhSwzqJUn7S4mamrDPI8GIOD6lU+H6HqW7Dv0ZkHfUxxadhm0K8EyAw1ADmDpixIh/gd7CiUJm5GUBJ1+Xq3w5KBQRFk9IDC6EiHAfzKzx8KtiZ51Oewq0Q6otdsRjxTU9nr6o7tzOKaPt1mpehr4Uzqua+/Kijo+u7KntFMb5H0/Rus1fzmw1Dj+XbOOFHtk6C5AyaqCj72eNuHj5ZD+MMR1NEzl0nf5W/6BoNwcclqTBg2I7R2VsQjqPn0r9NzMtTmV+XSU/SHw6QQjA5dqCypq6eK97rnDdICwDDAE1u5/+Mt9Bq3Y+eN0Aq88ReRKshxHmI9jTcOBzYFiD4dJvf7503DT5sjlaL2DLSFtDPGto2E3hZM7PuViOPPTe8haFOH2wv8udo1a+9y2Y8A7a4cdkhpBRu2pIMcMVx8GZtdMsGHys3H3H+QzjEdv656mtFDQkko1xZvpENLAi0fKQiv4u8PEp9/a82C+5YuRqkV0EzPsnneYI6ZKELlyBF7LE5ZaDJqN/UUi0MLGXWlptIuJPkVie/W9pmAPbmXq72HYzDTsqEM4Mh1r9ZRzt4GMCN7FOwtZPpJu7MTKDRLzQfWNJeoMhf+N7bXPHUgr7XJpOGuUW7WDmdJuiaCS9TGifDhWEQXwulChAnEsSsU94zvpKJcqwE4CeyRq2Jl0f5dgBtXLUDv4oEVmG/KC7HplDib5fJN2zsjWen4FlXgRAEf/EAlcLSzwlz7jt/gC5p7gYSw4d2e/u4T25i8heJY2FPvlteIZ4HeGboo/YKM7FgJklJbkMAprGmNFjYwZkp9M4H98BLg+GifXQMi6VCFAONN8Q8e+t1gEDZw3MsVUVW+b+0L5aC0j/01lfSB5ll7kjtRl+7+WB9bLlbvuCkGoxKJlkNtSfez7SR7cDuiBt6UGActt88V/PeEQgKZp1NdjHId1t3c+OhyZaa/sIg4LuRDDg0KIh5QWz9Dhe2UKrcrmCsgLAKrhcTCohjbqvHBoZPG8/h58GCRx9KlwZ8kRoWloFh1h0xzmyoRla4sYx+lOxTPCvdTDjLq0QM/NUJSL0VDgOCbj0CTlCLm10Elj0Nm2rTn6l2AmMweHJ7lDXZyiGm9/iL+BVqwlc2eBosVxyGzNMu8ynybYEiEjSkMGFatLoaQB52/AEwERSpBNui6JjmS1TE11szSTWrxZJ8Gh3KT1n2hyyIouF2hah66dPtUq3iTd51V3FUwjdbsi+DD1Czmgd7+qpyMcKcdU26Xf+9FQ== 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)(376005)(52116005)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ILXP/AiSf49y27eq0OFLsww+ISEGzfXx5abrXvUEVdQ+WPmf7LjMEQlqN6yL74SrxDUU8oIVpSFrV0KNVFqvm4h6RW3Np5E3i+inclCQYtq2EC5rZ+VKrOizHluuUGzMyTNrT25J/u6aZhc9jqKacCdsL701z2NGfJYwzO1m/MdC01R1wcf2j8A3iW8/Lpy55rlsU8e3ZE56y09f8e3Q0QHQAUPNm61Z0r4LzAp5YH7u4QmCnplWgU3EFs5ZfaUv/XvpLdyxPmRiiMXDnmKbJ+ah4pfA4Zaj2upQN9Ha3oxF64dlOA4KgiGLtNyyi6Xul5M1sQoiIrTRXeBesVLoROqrjRBac+3u6qHFPEhD9OYmB47CmMgOWotRPC4+Tdc4e+4ElnSRhaO6agyuuhiOhOKXM37fiotpwGCPur7J4OHJNcGoZCpZGLeTJTHzhib7oxFKuVLVPW02/NNu1kQ3h48LKDTPn9et31kQMt7Yt9ybKGBUXH+rJnkGrg19oCxU35/XMAUHzrMwgDrxUIF1ygi+ti20eNYY7mm9y6RX8KLcr0s/rVEaxgSatQjiYlxyeb8p4BYD1R71ziXjDMD5fbTmM6JPVEDLDKOp1PXP+KcxAogMgOjP2XTflEbgdytBCARHwaQ4He1eWk5Vg5TQNHe99mYcX6kpdUUzRnqKI1r8YaJdlUHDLUJ+CAuKc0twNEAkGjp5njk0h+IPZ97rjYQuckABQ94Piz8/1m5OpmGI0lILzleb6k9hAqKG8PtxQO9zTMuTO8Y6KgrCyohFKUukeW5rllIQYVaPT2EcSu9OokXbJx7LEl/67BzToD0GHJoHk9DrhIUqtVsoxFQv9dgtj7mS0B4GzXcSKkaAyxQEnOX98IFwDWXJ5zaoDemmKX3kpNgW0GQL/Hp7kmX2gzdKFgSZfnB0rDR7C+pIwpN12JjFK0ohXHJayV12MdOgzcUpLP2d01o9LegEprg8ACkicah3CmIfGX/PMxs7pTxlvPxs8Mal3/hjvpIZsPd3v6FtjL2+nG36UBQOpseg0oECm+6ugBOemTGu2FbGrJsoILa+lRnqiPhVS6lJ7RjD8CU0Yd/0lcWK3pd60w61SRjZ3fP42xXsl9/d31B2nw/dDNYxezJ+gFOD1+q+Ys34yUkdCaBgzX/zSBW/FKJ1+XgG1QwPkbScPLAQ1qcLmggl+aiBIPGgBTKlz0VHWL2Lx6gOK8rTJHwfcXdLknn4RrX1ewauW9S+sXVt42Dy6z7Pt3N+B2Lf6lb3ryj5QSG76Oz5gJFRG6mJ7InU4oxWjgHFmK7uvGJ3qxftzp2RljcI/arrh7NmCReVAkk7Rl2CNikx+IYGF0euRh1l2w/JqtI72dk7+t06cedPGXJPxZBPW6/XWN9XHTYvqireoBv71m+pE4F3AW6//RqUm6FaLVtuDDucbNu3GqXJXABIvymVPlSajVFta5jh+UtRe3rSx9Gjag7LL8AWWjXyULD76KPMNvpmxzyy2CjW/Kx0pqmx9fYheu+oQjJgG2TJORPmDRjuMohJ9dPeO2VGTlGxU5g6tu24sa5y/3K6RecSkWDZXtJvajIubAqpSVNDOnHp X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1fb49b4-2882-485c-6407-08dc79460ea8 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:28:18.3103 (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: Bc/eXfTkVaPo3+QDNkP7voklK9LySVId3XEXlowdszw7Fc3PWuM3TtKSF5aVScUC0nMttd2nHCYTvwskAIQ3Ng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8606 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 1A9DA80008 X-Rspam-User: X-Stat-Signature: i7h4ga7fp478x3mmstngqwg1c57py3j5 X-HE-Tag: 1716262101-670836 X-HE-Meta: U2FsdGVkX18Blq1BXfF6mH676B7Anc4GGbDPNVYOzz3YOpTqPizVhgs8NrCwuQqBvokY1dor40POi6pVkQgRbGQ4uTwsF6bGYPdZV29iMoWtp7EvIq9sDZCND1EjauT4rfIPguyTVHYnFOoFRC+aVmxvzo5kGx+UhmE1OIsCZtgRbdK88tna8CSduiJcXPOStm6QN3ZZRCYk/41c3opNG74gXWmq66s6PIAKkl7aAu/D7obUq7BN57mA/+3M82ISdzlEECUnywExd7CvUyEow8i7rEf8jzpi93fZ0XHKcQ3FuEzTQjHs4chasEqaIse4aevULahHAmUhFAoBGkb1LsFKTsUmGkw1tNKB46eTr4a0BT/jh2qE9vyolRmXozO2YU3z0/vusmuktsFaJEFWJbAX0JRDG88iEF0TT0lSy4xdYbC/MygesMYsHlEivNqaRvH73jTJ35oAMIi44izmQcEnmUdmXPxAS2XGVvr1W695wJjPL5VhtsV5D48+d9rMhQo1Bd9r0NCL0oOPGKErzR8FXBxiB/X9kTk4/EJNTgXCo0UrfDiqJXKQRakifkE27LCUCf96TBygvOglN4bquVIo+2S8g14JzzNr4BAuJEKzATPYACJk2o28ngtyDXANB4dnUaFarOWXIRu8V02oVdHtVGH7DYbuB4m90dUrdqQDa3y2OTNTWPfgIKeSg9vgsU93qH3jf7v99OquKbPljKQfrtYF9xZ6bTVAtjGUDAFqIn/QFSa9I6T9quJ1wlPcoTUoy+I9eHWCjywoyp1dyjX5IKT5yDNHc+0iSCUuUKeeKJrUcY56TKREJkEnPCqhZri3OdaulqjBubDTZMVW88ZNJRgF5hFQvu/UKe7wzAM9bbYYz/OfNGo3iJVRoKnplM+WBoOSEyoG/uxizTQrPbI8Jbj2Xr4aOt/JUd7sCcnjBdykD6yDrVrM2GEMMIwVsMi8YAkQOE89k/LajCH E2e3anaa GbilG87dhw8olLSBT5M60ULJNcuIqAFP3NcfC4obgFOyfnQUB2mKh8+yAcVXNcSQ0oCU2ulwPcxewME9+giz/1voVZbvsB1S23PBxQBepBaYazCid6UKWb8j7n76pg61FYpne0ZtKyXtEXqgOBPYtH0XzAGCobxsFrN7dahQbOdkRCXm8atTinbeQgXObvia1sa+hnSK7KJ6j9lkJZIWOKgn0xbDFkRY9iJ/okRuSc6pzTdEz9LU5bHWe8GROVcAkuOtu0HUqNPEDv7MXiN3Kbh9ooZkfGKDdVKALPDs45v7+uZ/GsmoqTlLwhAg8dYTUWBhpXowae8OAlpG7W++9MqaO7ukLN0FDheXufSSeepN20Ho6LCdwW1s57+ThVuuKqLTq 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. Reviewed-by: Darrick J. Wong Signed-off-by: Xu Yang --- Changes in v4: - split the mapping_max_folio_size() from v3 - adjust mapping_max_folio_size() comment - add Rb tag --- 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:36:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 13668883 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 3E4A9C25B79 for ; Tue, 21 May 2024 03:28:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B99576B008C; Mon, 20 May 2024 23:28:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B49596B0092; Mon, 20 May 2024 23:28:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C31E6B009D; Mon, 20 May 2024 23:28:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7A91C6B008C for ; Mon, 20 May 2024 23:28:40 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2DCDB160FCF for ; Tue, 21 May 2024 03:28:40 +0000 (UTC) X-FDA: 82140970800.10.6454CE1 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2084.outbound.protection.outlook.com [40.107.8.84]) by imf26.hostedemail.com (Postfix) with ESMTP id 5B622140005 for ; Tue, 21 May 2024 03:28:37 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=nxp.com header.s=selector2 header.b=UVPo1Zb2; dmarc=pass (policy=none) header.from=nxp.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf26.hostedemail.com: domain of xu.yang_2@nxp.com designates 40.107.8.84 as permitted sender) smtp.mailfrom=xu.yang_2@nxp.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716262117; 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=WochignTIwIPyyTdxOzcLlmWpQ7M5ZVQRhp2E5OLnAQ=; b=laEYgzFo+ToRu7R5Ii3eXfcu5qV7aQTDrtxjLA3dQl2nxYB3rfk0zZfICEc54mbX5MpEGk H6i5GiIf1QlO9OOtdhVFzZRraK8nAcKF5M56YMEK2Pld+MdpgxFJj4jcksw/V0rbg3KqU6 qOHl12eR/pEU81WszsAeIFnL5igwZF4= ARC-Authentication-Results: i=2; imf26.hostedemail.com; dkim=pass header.d=nxp.com header.s=selector2 header.b=UVPo1Zb2; dmarc=pass (policy=none) header.from=nxp.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf26.hostedemail.com: domain of xu.yang_2@nxp.com designates 40.107.8.84 as permitted sender) smtp.mailfrom=xu.yang_2@nxp.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1716262117; a=rsa-sha256; cv=pass; b=n9FejHv/sISxnHUFk4oOVgM2A/3wVs0IIXSnFdY9imh2HjC3jCyS/Hbb+9w3qCU20gF+xk o58X3Y40xV033i1EKYSK9lfZcwl4tK28R+PeAJfytaFPMcqcGTMyCusJtqFiY4I+N6+aKA xK5x6yBnrphMTDhzr/n/UWBz75BkDiw= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YOsKWZF19KLSmWu208QqdOHaEtg7AfUmOf1+uD8fl6c3ZghHIFQ7GeJ1fLuVQio19OnYPxq4q90GpPPu01gZSc5wIP7fF62SwLRpXN7wfOdKwDd0A/ygPZu97FyH10YSbeIew2bJ8e0yhKRaREO82+Ep9JuQ1ZoNGy0TkwLBBUEtAkaVNJDRLazcI4ybSC6zmXCSZMDETbJSVEzhSsh0Kvn409GawRA32mdU2gG9muesiD7V4+qEcBffwE8h3bSB1wbIYgGUP2BMt1oZ/5bJtC+MPKA7lmUVG3/yJfn5d3mAow1jjW2hN4U4XLIubOH9ZOpw6yRYmo+sYZOQqHQmaw== 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=WochignTIwIPyyTdxOzcLlmWpQ7M5ZVQRhp2E5OLnAQ=; b=j7KykuDttWzGPZTsvhGRRfy1WYIK2rTNjcnvurgaKru1cbpPbbLA4gSnGAVkf74ypC7IHVNjBZbrLGS92lppD/2++zicGzYU6zPOKQ2L8jQhXY6slk+66jTG9P48a2Z38Dd/MYdN1PFuTyw5XqVj+THg7pETDIu2LzIjpu2fokd+twRrjYcJkb6mypaJIoBo4gZGnE9GYVdIUKj4f9vPIsANBsbcbqenx44aRBMCaSAKD44+yi8o5gjhjPU78ngM1DgXxLepICuvUnQ3cgTE/ySYbg5ETGKq7efb88XL33a1rwiVx+owcAJiGT8B1E016klXB6ypO6vHLg41//xzsw== 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=WochignTIwIPyyTdxOzcLlmWpQ7M5ZVQRhp2E5OLnAQ=; b=UVPo1Zb2eq/rhEHN6lYLXFXba7TIjrJEAB8e7zKG+AtaaCtvjHOtU7x7tMyceT3FWKN+LCn+4jrgvHsfKMtpk1XRa+oZzt0oUc1jx1gN0AUfgFvLWGPJE5mJ9xVIU4k9e+VmJvFid5RI+DseNW21oceBuQam8t/y4m9IoCW9wvA= Received: from DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) by PAXPR04MB8606.eurprd04.prod.outlook.com (2603:10a6:102:219::21) 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:28:21 +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:28:21 +0000 From: Xu Yang To: brauner@kernel.org, djwong@kernel.org, willy@infradead.org, kpm@linux-foundation.org Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, jun.li@nxp.com Subject: [PATCH v4 2/2] iomap: fault in smaller chunks for non-large folio mappings Date: Tue, 21 May 2024 19:36:24 +0800 Message-Id: <20240521113624.2538951-2-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240521113624.2538951-1-xu.yang_2@nxp.com> References: <20240521113624.2538951-1-xu.yang_2@nxp.com> X-ClientProxiedBy: SI2P153CA0022.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::8) To DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8822:EE_|PAXPR04MB8606:EE_ X-MS-Office365-Filtering-Correlation-Id: b283f680-2b96-4a97-fa65-08dc794610a4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|52116005|366007|38350700005; X-Microsoft-Antispam-Message-Info: mtIuQs436rEL/iPQ6cnC7nMG5A3Y0WK5ehJTqVlacpNpwpMqWdRJwY9X9GEFlG6AOE1CKDUq5VVnltqYT4MLroEdhUmkj4Bsd7TdfvSpUBZjs9SazwUKYQwchL4G3ZiWeAyT86mIviEsXwQDvZUL8EEPbn9L4wsz4/kbtQH0Nb/DXXqMQk14f9xsS8TTaFn+SmOxgA4iNv7v+WYNSeTxfQ16NPcvDJ0+kqobZdcsy6OEPfYqQdHp1uTW4tn/PAscJGoqqBqDd29nYbQZ2YHx8jQwpJgCE9K1yI+KeRaYTw3HRaryl/8YhNcu5h/dsoWZr8KAYgh06znGW89IX4VPR0ja1xGTBUnK6zP4+Au1sM3skI4uWWfSX07PfUshDDi5nLAnCnwnytvWGlOaYFCSYhDBVivYYwzcfrA8fcIQECGW4C9qG6woj0kaeQ2aTy+7Ug3TAuawhubfJnBjpHFMOkcioflSfoHlwQfbGlagFoVO6FdrvrfChQd631W7IJoymRMk6h9sm8OxdwCjyOuzdeRUsBMfXkTQYBnCQ3TxNHgY29EPg/aMhtM6nBS6s8F0DrV3QxaWSZf4O8vdPvxYlweyRLUxKDp/OI31/L8y6JbhWA8e8kDWiIGdSbfh/iOa4yjoDkD/No8RdCRJhGgI/xvg5NEf4U+WlOrRobZKoO6gkd5CQEzZ1uh4sMWgQ5pbMgTZhj8ZJtRJViu6j1zMh2AcWUhjrlC6YKqy3fccFeN+hgIy07gQYveCX1kaZiTNNqG1JZoNI6nffkIYJvSXATmdwzRVa+2J7OXQBGdHweVAkECKkKfDT+QA1u6DuAcSsfHfw5RwInfnivIdBe73Vt7ntdh8la+EqNV6EiZS78zIyO67LugMuk/Eq4EuqJvN3EO56FrEJek61v8h3vO04LE2KALrhLJtQW/e7CYKFQf4eq2uk3pOpHjVdwWevbJwcp+DGC5YMMnJK9J6YX3IE8+NjBz5T1P8S6Qq1+Rg7i2UJLcVDxjEX9sz0iGjEg1bJdlD9xLlPMC9hlKpcB7UVo+KY1EC4MdVKdOOeyPiQUTriI9yBayVHx96KvNgr6mpCGSBIaXz1Y1xGyDwJW2PvgSvEp1E3VvU10aa8IjR35SJGn+2xpdGwptsNnF5SVPdgfTmqekCKIa2zV24AA64Hm3XsMJzzMgwzJdVVkNrCDBXNWg3EZoUDmhVgx3v0XTNQCsGRQX2JEQKfZ0G48EVStZknS1FDjOqquc6d+L/ZafcyDPkTP6cYpPGLYHgxmGNfztsnpTO0h/Te0di1evaKA3Q4jA78WfIseU1dI9U+TTLcoWFMGsaqaVgBhAAIe+j/JADP1MahHmyNJT3MZqDSg== 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)(376005)(52116005)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DZ+VDfzlbLPa3j43FmSht4mwUDXDTVZoCUwjHcrxZylmYUBvzDRdEvdyW9Bu/ysuCNdHfEUxXWp3+I+D8KFMs3sew+3PC/hlc7r4PE0F+lvVkR/hW42ScK+2wLmAFayaG6D/IplNDEiFA2hBfrAEopJB8y1KkEU1m2e7zB+ulA6fh6iyQpmuoAitaVXiH+MJVzw2SRgB7v2ddLeFefhBtgV//iNNr/aInQSLPVyG6KP5YNI9UnFhpv5uM7Nh+tz/IuQp8x2srp4tzIkmDrPYhcs2BlTwHk/ONdLT6OKnDwaYkrdbl/0GvAoleEU0z/sfJ86Y6qFV/u37UhHun6xuKlLdZ4finRmSZJ7ZRLiF4t0s1NgZBPe34ecBGm7SLhr3KUFZ37HVXO44mPNWWOi4tcI2L6P37mIDiUPAsS0jnlQft5Id9NmYAJM90A5yIFeUlaYvb8w6F+hlYMF7F/OcS8yOCaWtbbBZ6par9EAb7zA80e9/oJTu5k0pauhJGOzixIV9ZXKTNmWceaRXkYy6btfPc6ToaGB0DXlKmNeubP0OK2PyCnvm3y6idori5ZUL7VSJByt7XRIK5qyHazixBMGTVWx4V4hRBld8KJvcsl4B0HOm8FhoBAs61wbXeSbqkmEt/vsA2PYeNCNgntLEYk0Bnr0ID4HLkLf/nt+niqXDcCwhj6C7GYoL8PCXV0+xxTZ/p3uDUbIHu8sPtzHYj411Teqw1qp/wngKN+m/BSATRaz+IMAASE5qZhSzIMpiCzR89cYFszygFk76dlEfgGc+zohv/o4jSC/z9jsEQaaj44l0T4ultPgtNjvJPwqKGl5hpmv08pRwtYC/QLH9Y3ZyEussfDaO3WyJZGcLBKHoPNixPosQfXs9X70GyTGm5NEBEnCBS5k72gBhUtU8XKZCHToXrY/NluPdQ6jGg6kFmSzRW2wKLH0ZJTHngvBRzstIsQEVPVThpKWTBSURYQ4YM4p+hgxG+AAS6+Uhetuj5rXjKTG1anBs3npzoe5K3EGLq3focTiu4n0BTUCaDKnYU6qV3TVM9+5lSqFSNtKlE61LamFBnv0r+UEAdobCTtmufuzJFQmuj6Q/te0K5f1UdUetu4eQBTn0SqQN625lwTanCT9XTtcsAqJTy/KGPg/IPMwvgdQQjdU/BoqNOjNGv/GPm+PVQkCLQyFP8ziHd8EcYCXFXZTcN+oAUKWIh5TDjql437h/tJgFJrocWlSnDAc62RfUawpTSO4ny79Kan7VeDSSRcJAwcay9VOSHgxI71BiKgJHkZLCbfBfvJkLHA1FHgwHQt/1L4akMUbTZ5L8WjG/V85HcLMsg+HSg3VDKt1cY7yDHwApYgyzu6MapHdDmUiox+xl6sZcvCX+bZr7qS5imb+CxQMuTDhhqXyhib0JTPC9DdTRYCPAjL2xMabRnYcSK9GRCMrJLnZxoACvGKgFzXEGPOxxUB7q83MmNwT0uXMQKqPlaGwDSpPCy6W4wK9JQB1HE0Xw6vgrKp80qUgeBDJq8QXxAd4rX90heMzfxZa2ygrCwpTcrQyKf+drbFR3sqNB3X7qvHYZAW9P1EwK18kQjDcZ3Nl0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b283f680-2b96-4a97-fa65-08dc794610a4 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:28:21.6777 (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: kXuiFbf7TgqmUIn09s4fmFe7zwhLC2ErouoZ2cUEe6zXl773XL+xRnxYsMJd9OUo70UnHiYjBIwBjiy5xUDEZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8606 X-Rspamd-Queue-Id: 5B622140005 X-Stat-Signature: e6e38171367npypdqwhxqq8xnw7w43mw X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1716262117-40317 X-HE-Meta: U2FsdGVkX1+r9IXpbUve6o/ilqVwSB9HdJgJ7XYv1q0PvD7Vj0Ij9LQpzCRuWkZNi/1EpOTVqKEW+/8IvfhNHyHqKSRMz/nXGA/t7gllNkr2DlZGQMMebsV26dOUt3NctnLMyIaLtsAEz4qWGfjuSX24GVvegWKBOX8QSSmSc5Wy0fOLtR6szVlPqk62Xa56Ot89Z0e16w3KrvZjlPUjWlyemdcJ6E3e3Wbgiv8fWPX2/KfDfZqJzv2MF2G8I65Yf37gub+67J5vYeMQzGMpVXLlcwiYVO7YGz5c1Lo3EW5gdo/7cLdmriFfYZwtoy/cjRLS+D53LrZh09PJxU0/gE7UDlwCMkN7caIZibC3NsIG4J2ZUCfXW0rNLhexRTCouIgDAZdVMe9MGTcMRzdpR9hBjHnyBQoi3im+4rf64Tk4Jz2Y5et3tbSKGY4HKN5RjOmGF9UjTAsuXmYx6y1+MecvQ9RvHwhyk/AjDjHJ4wmsfdNcmRVD+jqe2WC7MjKMvo9XStNUuR+xzlfnsRTbALMVe8ag65c5KsXiNEQ1+l506c/aQLQI2i1DzyAEsdQZla0kSXWjXtRfehQ1zFKU6c65z822suMtRegdt/vWMoGARo8JJTGf6MoWENzVxFVVPz+WOsqKEUYHmM402S65Rxsreu5bPE4L6+GdY5OhwUxdb6gj/CWiX+o8INAUB5FGsDTP0rMD5K0IUDy7ELrY4i+gQ3ktXPeIc43/AR0N276dYJzytFsThll85Kh4CyQZ9PksiaECTg6DyWilwRDOkEBbYeZkdhuZZh32RSjguvS+SqnVF3lU9/yljBNT+Hdn5eWpgTgBWC8w68+YHvhazB1ASDvxMNDhPDkM4m5dQtso1Ud2mHqhJajRw75ahlHvULv5kS9d/yKEck17HzPCImPcmoMc1GegGTVvFqT56UE1T7UpjsK6RYTrkuHB+XbXXK7/G26mACnxdrcO9eJ 4KWwKdlH LoA9ZRCZWR2crAbkWIkpH7YygxKhGVSjVY9sSkfjEwzi+mIiK9S7ar5XJPgkjk5mMJNPlRPu9T54n/V4Q9dJWwX0PUkt63HcKMUTKRq3BqIl/2v+mBlCe4NL2GkBavTQFUZUoa4PBYiVw9QFwML1hSk0DxRoUQy7PY3ieMrgdtsEXuSCGcDDiDe+y3cVD7Er/VtPhjwymRwDC/EIzgK5T7XOcteSaWHio9XSo4MVh2cY9hrJhdiwgVGkxZ3n4cvBJZUt6BQb4mJX/7xu+wNidAyAA+H4Qs6VrSiTnH4zrU+bRmAZSManlP/XDxKbyp1MHNOrlUkELVZG2gsrXBjl54oWNaQ== 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 --- 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 --- 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 {