Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.53.62 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796113900; b=19SONh986NxvfOqocC6XcL1V5uL2Lkg/E0fz4HggS3cjGnWbSJEbjAkd2BhwYAtzHYi7 XoHUV66c9r48X57/ppEQ4yai4VvBaZHdEfx6znR7FSxix1sF18UlLBzxbFT2KIJME7mg/ HpCWaT68DPFaoG51/fLkD74qKdRvWrSFPID1d1/41LmTFXuUv6E6bHv6QiuswyIl5TbhK Er88fIPqbxCdQ5zpW7IWftDNxzr7BbB8tFbaO0jkqGRjcFcwvlNXqyUWgNPOaeMrO3hdm 2QA1Q4M0d4gck32oRbj+lXrKBQer73ctyYgrb2tNBYiRJOd2oL5s7J/c4h+pKI2DuzQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796113900; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-ID:References:In-Reply-To:To:CC:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Originating-IP: X-ClientProxiedBy:X-EOPAttributedMessage:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=EuKSZcn8oEGqX3XChh7sH86KntDgr2QZj+QAR1xg6aE=; b=xmCVQTheByUzFpMyYm9VPP90d/VwcJEUbZQTHTLvGeslHhVxvlj9aJi0+taN5IoSfvBG MQKaLmMTLwQXAgxKuKceGTAsSeT6F+bI2PSVcl/KTTY0pi1u9q/T0/TN4Qe6LyBaTmkHP K9lmCtaZcFjpsOefqiLC2d2zoU3z4Fqx5Azbufx09A6X670Qz8pjgfZuq3aVkENTDbzbm h4N1VTKKSA+c+03FRj+hRvWDJM0Zew3vmcAr7bB81+wxfUmH99gNK1SMlSop7vaSQju3d v5RWHIujsy1RILj+UQ4F1g0K57b9XF4ECCZTyi6ePCEIzyjxaPUJibzPlT28lwTAu1w== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=4SAMD86M; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.53.62 Received: from BL0PR03CU003.outbound.protection.outlook.com (mail-eastusazon11012062.outbound.protection.outlook.com [52.101.53.62]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95937606A320 for ; Tue, 1 Dec 2026 08:31:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 95937606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=4SAMD86M ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZRDPxu1FT8ok6uE807fpaLnRePcF/eUQXNgXpIx5e2+VgJhraQ5+YMI+c63ptGnYLmUyDcatpvqu1xMrugilTxqk8XK1II8T5V/VJZzcCjtIaCTa7Ay5zNU7HLnr5XMTf8iSIQcmQRZAiCzOsX2MH/MQdy1BUWTeZnu6GUh4hWQGFa/Zew8AwKeUQiL+hoUeBD9F9su2wER4zmPS+vs56BDOSiP4XSy6k4TpLZgNh9yQ8DT6p3WRMa7AJBHSLIxzeXinfWchfShadXG0w41lmkJnQQlql3ByMV4BV7lRm9eNqqj6aCBzcCUBbUzYcmTo7gvIlgLLyqSZGoyvkuYCDg== 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=EuKSZcn8oEGqX3XChh7sH86KntDgr2QZj+QAR1xg6aE=; b=U4GoAyKEjaqPEq/FJlNlHcC2CoSzOQZMZi8BwyoK9fKCw/Oj09NJPc7EDRcH+RPUcvkEP9bEhZSX7/z+6Ytu2X/HyNDgdyNd7jSYpvk9q5J8E3rjkcV+ZL0Ti7vBtCKHJCLZXU0otHhtgrsKe/yQKotJWFAjuKAzakqz+NjQHrJzVtfw2c0zahaPq45l3wGaA18iaB1h3SPFKKT/aqk4jF2EgmpSbwEXMoZw4+tEXRlGGlkc7rMhTPhAf8sbN35/r5wGAZ+NKUrcElU8JySJn7iTMgQkUoIUEQzNFvYMylFTyiqytBl27LtMB3MPyBXmlF4XHxVaQDVj0E65gm4BOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=oracle.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EuKSZcn8oEGqX3XChh7sH86KntDgr2QZj+QAR1xg6aE=; b=4SAMD86M0tO6O70LfYOUCU9myxyyDxAQvUSXwxSLB2Tcxlv5zIzAafBztwDRNd1onY1H7k8A4eOG9OQXSOam2paDSHDvmdkr3w+80aXO6ccnXvLHJMwCG3P4ppCVv07q/tNV0oLGQ4BRvt/yW/8398Y819EImHq8MT2kS2t1c4w= Received: from MN2PR06CA0028.namprd06.prod.outlook.com (2603:10b6:208:23d::33) by PH0PR12MB8030.namprd12.prod.outlook.com (2603:10b6:510:28d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.13; Tue, 1 Dec 2026 08:31:32 +0000 Received: from BL4PEPF000003EF.namprd04.prod.outlook.com (2603:10b6:208:23d:cafe::22) by MN2PR06CA0028.outlook.office365.com (2603:10b6:208:23d::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.662.13 via Frontend Transport; Tue, 1 Dec 2026 08:31:32 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by BL4PEPF000003EF.mail.protection.outlook.com (10.167.249.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Tue, 1 Dec 2026 08:31:32 +0000 Received: from [127.0.1.1] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Tue, 1 Dec 2026 02:31:23 -0600 From: Shivank Garg Date: Tue, 1 Dec 2026 08:29:52 +0000 Subject: [PATCH v4 6/6] mm: copy_user_large_folio(): copy page ranges X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-ID: <20261201-batpagecopy-v4-6-dd82a573e573@amd.com> References: <20261201-batpagecopy-v4-0-dd82a573e573@amd.com> In-Reply-To: <20261201-batpagecopy-v4-0-dd82a573e573@amd.com> To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Borislav Petkov , Ankur Arora , Dave Hansen , "Thomas Gleixner" , Bharata B Rao , "Hrushikesh Salunke" , Ingo Molnar , "H . Peter Anvin" , David Laight , David Rientjes , Linus Torvalds , "Teja Vojjala" , Huan Nguyen , "Pedro Falcato" , Peter Zijlstra , Zi Yan , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Kiryl Shutsemau , Ying Huang CC: , , , Shivank Garg X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1796113822; l=7484; i=shivankg@amd.com; s=20260518; h=from:subject:message-id; bh=Yj8qYE0DZCdNCoiZMsbqwcAmVnpOnd6v5vlqkDOg4fg=; b=m7p8WYSRX6VA3CmHtf9Ag1LbnELIVzjpm2ECyJgrr9T9aFCIQeH2nfrRXS/+dzYJCo1LrbS10 vpfFcb87bHxBYSdR9xPboLPWTPROqtgSDFNJi8nOCtJBLUUPT8tFxuk X-Developer-Key: i=shivankg@amd.com; a=ed25519; pk=2l2QGTeXuGkZTtfmx0nPQU8iFZfjYmX/ymMojitevx4= X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL4PEPF000003EF:EE_|PH0PR12MB8030:EE_ X-MS-Office365-Filtering-Correlation-Id: 6badfd5e-eb71-42be-74d1-08df4f858149 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|36860700016|1800799024|23010399003|11063799006|261009223027099003|18002099003|22082099003|921020|10067099003|261028144727099003|56012099006|261102130727099003|261026140227099003|261026121527099003|261021123027099003|261021121427099003|261022075727099003|261022105027099003|261102123227099003; X-Microsoft-Antispam-Message-Info: Z4UG/u6Bz2CuGzADEP+2HAC0TobCj3wZQLCZxuwl+6iL2rTcYC0pr63hBC0cbDXHrV58LPyz172fkysXcjd9wBJIMz26QdQ3pOTsOGwrjPBarGm3oKlOP1WP7PsdJ61omdDt2JiQNq1wc4T2D0Ch+Epr+DD2eydAlVeTfhLERxyYrR66hgUREbB56szmIuKHRWx4x7aoK3XwoghJ0QV4+d6JcwQWUtTUyKhlVRODTTVkDTOEXSdFZOnAlamx66OFindDu8oByC/24nQTe0aGsuib8W1oLfWKlO05FaBQPpe/+BIFnpKoeFM/sgDCtGeFJMOynwCot3iqJ/YORdaR4CPDQFpOBT3G1IEB9RfqXpoJ1f+aMt9vDQ5Rx+CPBNFzXtLS6Z9MM8ri7Lw72bUQO7g4lL1Ifqt9sz7pVxtSApY8WeMmB++GPlJPwbj5yaajT7/ku38ru7Sh0L91A64xTuDq4ivPmisgix1UoAxHI5CdgrYthIoOb8Gcjv2bXpSYogCMe6BcPAJsiR5bmG24kyJnAlLEwKdtNkYcGWfhpfIulHtlRCb53y6CuVNqjtFDTr1yzMFwzzcDxuPjxxRqwB1gGQsMyVgk62SbKldYLHodpUsKRtCk/grf8KqYBbA3O6cBWzQQNzoWnm23sgr5a92HWtwkU9avh3BWFtwmMDzcXmQtLwwmMw45dmwrj+x93qJY7yia/G1BBzb2EG5WB2BwKxiueO/tbUlRduJpgzOZYv2HH0ftZTKxfibqmWM7 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(36860700016)(1800799024)(23010399003)(11063799006)(261009223027099003)(18002099003)(22082099003)(921020)(10067099003)(261028144727099003)(56012099006)(261102130727099003)(261026140227099003)(261026121527099003)(261021123027099003)(261021121427099003)(261022075727099003)(261022105027099003)(261102123227099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Fyu8Pl5Y0YwwZMXak2CUZW6NPlWjtfG6foXB+vFVCg78x3byHuTyYuqzxiILP0ZqSHey2tUz04Ct9DtGB/jHtfv//ySXlW7Qtoh2jwqGrgaStU+HwzSqFnOySEhXLe22ss0DAIJNwO5BFNH1JD9buoNbucxVeSVW214QcHkjngv6MDxI2MCmGzsjFpif1SUs8CjXAbOa1QT32QHhCtXfvyFjFIhxwP8vWawr5ib+qaIz1BEhlltxTqJGtuUWFfwKk1RY2IGTvGmvKjUQLwpnHUgDgfwVp76pHddDBoZGbKmhFANPDPTZf6eDhrzG349VVgKokZzPae12+uXQKmuCyqvJdrc5CaclEYmdtKB2ZvbKZsF2hBRBGnWPdzRUdkbPi2J+0DGpAAcblegHs0lZXMPo+0sb59dvKCWpfK5rAeNy8njFLH4D43ZDUQhqprYj X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 08:31:32.7782 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6badfd5e-eb71-42be-74d1-08df4f858149 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL4PEPF000003EF.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8030 copy_user_large_folio() still copies a folio one page at a time in the order given by process_huge_page(), with a separate loop in copy_user_gigantic_page() for gigantic folios, although folio_zero_user() moved to clearing page ranges. process_huge_page() processes the pages farthest from the faulting page first, converging on it by alternating between left and right. That keeps the faulting page cache hot, but its non-sequential access pattern defeats the hardware prefetcher, which is why clearing was moved away from it in commit 9890ecab6ad9 ("mm: folio_zero_user: clear pages sequentially") Make copy_user_large_folio() mirror folio_zero_user(): split the folio into the same three page ranges with folio_user_ranges() and copy each range with copy_mc_user_highpages(). The range around the faulting page (the faulting page and two pages either side of it) is copied last, as clearing does since commit 93552c9a3350 ("mm: folio_zero_user: cache neighbouring pages"). This keeps the cache locality that process_huge_page() was introduced for in commit c9f4cd713835 ("mm, huge page: copy target sub-page last when copy huge page") process_huge_page() was only used by copy_user_large_folio(), and copy_user_gigantic_page() and struct copy_subpage_arg with its callback only existed to feed those two, so remove them. On an AMD EPYC Zen 6 system, a single thread bound to one CPU writes to each hugetlb page of a MAP_PRIVATE mapping of a populated hugetlb memfd. Each write takes a copy on write fault, at the first or at the middle page of the folio. Copy throughput (GB/s, mean ± stddev): page size fault at base patched speedup 2MB first 22.40 ± 0.23 33.46 ± 0.65 1.49x 2MB middle 22.76 ± 0.31 33.37 ± 0.64 1.47x 1GB first 27.10 ± 0.03 53.25 ± 0.59 1.96x 1GB middle 27.10 ± 0.03 53.35 ± 0.57 1.97x With the single-call copy disabled, the new copy order alone gives 25.87 and 25.80 GB/s (~15%) for 2MB pages. 1GB pages were already copied sequentially and don't change. The rest of the gain comes from copying each range with one call. Signed-off-by: Shivank Garg --- mm/memory.c | 139 ++++++++++++++---------------------------------------------- 1 file changed, 32 insertions(+), 107 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index bd2c276e83aa..329ad8099e6b 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -7678,66 +7678,6 @@ EXPORT_SYMBOL(__might_fault); #endif #if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_HUGETLBFS) -/* - * Process all subpages of the specified huge page with the specified - * operation. The target subpage will be processed last to keep its - * cache lines hot. - */ -static inline int process_huge_page( - unsigned long addr_hint, unsigned int nr_pages, - int (*process_subpage)(unsigned long addr, int idx, void *arg), - void *arg) -{ - int i, n, base, l, ret; - unsigned long addr = addr_hint & - ~(((unsigned long)nr_pages << PAGE_SHIFT) - 1); - - /* Process target subpage last to keep its cache lines hot */ - might_sleep(); - n = (addr_hint - addr) / PAGE_SIZE; - if (2 * n <= nr_pages) { - /* If target subpage in first half of huge page */ - base = 0; - l = n; - /* Process subpages at the end of huge page */ - for (i = nr_pages - 1; i >= 2 * n; i--) { - cond_resched(); - ret = process_subpage(addr + i * PAGE_SIZE, i, arg); - if (ret) - return ret; - } - } else { - /* If target subpage in second half of huge page */ - base = nr_pages - 2 * (nr_pages - n); - l = nr_pages - n; - /* Process subpages at the begin of huge page */ - for (i = 0; i < base; i++) { - cond_resched(); - ret = process_subpage(addr + i * PAGE_SIZE, i, arg); - if (ret) - return ret; - } - } - /* - * Process remaining subpages in left-right-left-right pattern - * towards the target subpage - */ - for (i = 0; i < l; i++) { - int left_idx = base + i; - int right_idx = base + 2 * l - 1 - i; - - cond_resched(); - ret = process_subpage(addr + left_idx * PAGE_SIZE, left_idx, arg); - if (ret) - return ret; - cond_resched(); - ret = process_subpage(addr + right_idx * PAGE_SIZE, right_idx, arg); - if (ret) - return ret; - } - return 0; -} - static void clear_contig_highpages(struct page *page, unsigned long addr, unsigned int nr_pages) { @@ -7831,61 +7771,46 @@ void folio_zero_user(struct folio *folio, unsigned long addr_hint) } } -static int copy_user_gigantic_page(struct folio *dst, struct folio *src, - unsigned long addr_hint, - struct vm_area_struct *vma, - unsigned int nr_pages) +/** + * copy_user_large_folio - Copy a large folio which will be mapped to userspace. + * @dst: The destination folio. + * @src: The source folio. + * @addr_hint: The address accessed by the user or the base address. + * @vma: The VMA @dst will be mapped in. + * + * Copy page ranges, with the one around @addr_hint last to keep its + * cachelines hot, see folio_user_ranges(). On a machine check, the poisoned + * source page is queued for memory_failure() and the remaining pages are + * not copied. + * + * Context: Process context. May sleep. + * Return: 0 on success, -EHWPOISON if a machine check was handled. + */ +int copy_user_large_folio(struct folio *dst, struct folio *src, + unsigned long addr_hint, struct vm_area_struct *vma) { - unsigned long addr = ALIGN_DOWN(addr_hint, folio_size(dst)); - struct page *dst_page; - struct page *src_page; - int i; + const unsigned long base_addr = ALIGN_DOWN(addr_hint, folio_size(dst)); + struct range r[3]; + int i, ret; - for (i = 0; i < nr_pages; i++) { - dst_page = folio_page(dst, i); - src_page = folio_page(src, i); + folio_user_ranges(dst, addr_hint, r); - cond_resched(); - if (copy_mc_user_highpage(dst_page, src_page, - addr + i*PAGE_SIZE, vma)) - return -EHWPOISON; - } - return 0; -} - -struct copy_subpage_arg { - struct folio *dst; - struct folio *src; - struct vm_area_struct *vma; -}; + for (i = 0; i < ARRAY_SIZE(r); i++) { + const unsigned long addr = base_addr + r[i].start * PAGE_SIZE; + const long nr_pages = (long)range_len(&r[i]); -static int copy_subpage(unsigned long addr, int idx, void *arg) -{ - struct copy_subpage_arg *copy_arg = arg; - struct page *dst = folio_page(copy_arg->dst, idx); - struct page *src = folio_page(copy_arg->src, idx); + if (nr_pages <= 0) + continue; - if (copy_mc_user_highpage(dst, src, addr, copy_arg->vma)) - return -EHWPOISON; + ret = copy_mc_user_highpages(folio_page(dst, r[i].start), + folio_page(src, r[i].start), + addr, vma, nr_pages); + if (ret) + return ret; + } return 0; } -int copy_user_large_folio(struct folio *dst, struct folio *src, - unsigned long addr_hint, struct vm_area_struct *vma) -{ - unsigned int nr_pages = folio_nr_pages(dst); - struct copy_subpage_arg arg = { - .dst = dst, - .src = src, - .vma = vma, - }; - - if (unlikely(nr_pages > MAX_ORDER_NR_PAGES)) - return copy_user_gigantic_page(dst, src, addr_hint, vma, nr_pages); - - return process_huge_page(addr_hint, nr_pages, copy_subpage, &arg); -} - long copy_folio_from_user(struct folio *dst_folio, const void __user *usr_src, bool allow_pagefault) -- 2.53.0