From patchwork Wed Oct 30 03:01:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 13855880 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 88885D74954 for ; Wed, 30 Oct 2024 03:01:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B91BB8D0002; Tue, 29 Oct 2024 23:01:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B3B5F8D0001; Tue, 29 Oct 2024 23:01:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 965038D0002; Tue, 29 Oct 2024 23:01:32 -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 73DE08D0001 for ; Tue, 29 Oct 2024 23:01:32 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DFF791C5E1D for ; Wed, 30 Oct 2024 03:01:31 +0000 (UTC) X-FDA: 82728766638.09.E2CACCA Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2047.outbound.protection.outlook.com [40.107.236.47]) by imf28.hostedemail.com (Postfix) with ESMTP id 99B1DC0009 for ; Wed, 30 Oct 2024 03:01:03 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=UtTfJl4z; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf28.hostedemail.com: domain of jhubbard@nvidia.com designates 40.107.236.47 as permitted sender) smtp.mailfrom=jhubbard@nvidia.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1730257245; a=rsa-sha256; cv=pass; b=iJL/HNTepBM94+yIwdFJHrPZXyUOHM0B/rvPY2Dbus6cAesBrSxqGRzck+sYLR7kyvB2C3 6/XFV0GEIjHSDETdmhSIudA82FkDgCNQRGnf6L1KrLgh0vwlAOmkyd0MaBZn8ZKs7aAG7q jBVuzTBI+x3XMQN+yjLnASr8KfI2/60= ARC-Authentication-Results: i=2; imf28.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=UtTfJl4z; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf28.hostedemail.com: domain of jhubbard@nvidia.com designates 40.107.236.47 as permitted sender) smtp.mailfrom=jhubbard@nvidia.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730257245; 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=jL08yHeylUs0GdLn4moveH2FIqZLD6DzHQASfZmcSMI=; b=hC4tF1DMtHvj99bbPFxnDb7EYwhPqizXrGWkGC0Xi8jwSruWMwJHVWts8LADOsW4BdqWXH g1pJQSJ7qwgJqOnaeoe8We8GiItud+5vpKxRIl0dpbnQKLnSwstZAGb1ltLkn4GPz8Oo4L bF1xX0uz6V8ZixxAreK9bNcWIffNLKk= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ERFq5HpELdEvFeHRkX1fDaaKNPWxSKGgwfzd84nXVGV2jBLsfhpwtCVrSyT1fYJlFBN+Yw5fnlFfZNBgW9DIiEXm9qX6j/AhokSGMeJ67Rz8lZXreB+diOaYsWSkackRBI1IWU7tdEZnkMpozHNKGH4OERnzHiP7ejJufDoA/bExY2H3hFtx4dbN63uheHqq/cgy5yErco2H+JJ0G+HQ6c+rZk3yynlabqZ/aWscykiaE8wZ62G20ir2/oKQdAO/QVziNKWejdjCOg4GliE3DjBdTv7IQoWRFm8eKv3PCzqaV25XjqFQe7g5KoUn9lm0HbL3EJN/scca/dm3wh5uaA== 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=jL08yHeylUs0GdLn4moveH2FIqZLD6DzHQASfZmcSMI=; b=Hpuw1SS/xPhhZnujEaps5q94NJXqecOvNVmmNpEFR+MAcHVtIp6CyWzclX2c97yIPF/tFgYsrzNjYJ2RdJN6MvKRXgAO2onxYzrNdeBBNslUcSPMGyiclyIiwFtt4T3q/5U+S4sKjMhyiyXdLxj+y17YnWW3hDwRUkJpj+2ojqhhVp43v20/obYg5oMyETXitDXIEbUwAz+TAtUGngkGuBbAhZVJ3mYulL9EDY6jTVOOTrjY7zml3ZEWq5nXbT5bUa3Ei4t0FnKDlKAywoFrSP8NF9iWF3q1qM1TR7J/61e+jLpqTkkVLZ6KFBCZ8VjgxMweTThcR2ZE638iiShfug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jL08yHeylUs0GdLn4moveH2FIqZLD6DzHQASfZmcSMI=; b=UtTfJl4zfJaWbjcu+JRiFN9IG+Ouaac6cIi7V4tvkBoFU3gm8rvFkmBGbeV+Ki5223MDgfZl7gNPwG8Cf9BDPUiHUgVCCHz3CnDIIkl1bdi4E9dqxAt2LgxQdmE/kDp0AIePInjioqEbdSpI53OBKWvskXJGPbJPp1R3tsc3VN/kNuoXQJFnKC/HInyrSzMx7YnO2m4sD1MESy5pgNmnzq0QShmMzWSGEnWClCuqmiaxpZFr9Jes3sPb7Bp3AWs0mpT18R7UZGV2wuw2WjH+5YgxO+Wtm1Vuoj17rf+P9poJxYxaFCIKyqruo/rFzlLY427Rv7wxMHyn6XckN4safQ== Received: from DM8PR12MB5462.namprd12.prod.outlook.com (2603:10b6:8:24::11) by BN5PR12MB9463.namprd12.prod.outlook.com (2603:10b6:408:2a9::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 03:01:21 +0000 Received: from DM8PR12MB5462.namprd12.prod.outlook.com ([fe80::1be8:1c01:29ba:579]) by DM8PR12MB5462.namprd12.prod.outlook.com ([fe80::1be8:1c01:29ba:579%7]) with mapi id 15.20.8093.023; Wed, 30 Oct 2024 03:01:21 +0000 From: John Hubbard To: Andrew Morton Cc: LKML , linux-mm@kvack.org, John Hubbard , linux-stable@vger.kernel.org, Vivek Kasireddy , David Hildenbrand , Dave Airlie , Gerd Hoffmann , Matthew Wilcox , Christoph Hellwig , Jason Gunthorpe , Peter Xu , Arnd Bergmann , Daniel Vetter , Dongwon Kim , Hugh Dickins , Junxiao Chang , Mike Kravetz , Oscar Salvador Subject: [PATCH] mm/gup: restore the ability to pin more than 2GB at a time Date: Tue, 29 Oct 2024 20:01:16 -0700 Message-ID: <20241030030116.670307-1-jhubbard@nvidia.com> X-Mailer: git-send-email 2.47.0 X-NVConfidentiality: public X-ClientProxiedBy: SJ0P220CA0022.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::33) To DM8PR12MB5462.namprd12.prod.outlook.com (2603:10b6:8:24::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM8PR12MB5462:EE_|BN5PR12MB9463:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ec510dd-ab0c-4fa5-bf06-08dcf88f2215 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: xR9eDEcT7XaNy+WoTkkK24SUpfbEIo2CQBmVMF9Qa+rEtepBlsCUnh/xxwhqdsTZThIWdpE2PCwbodxFTN7bWLOwbdxzuUxpMeGxID9fq2H+j2xoSAV4Rhmo+QaSAnx4n4UHuNhWtvJARAESfFyIJK2bLl8sKKolup08pkis8PJZZqj54+Lv/dN/ks6WAmb5j16clQqVSZ8ve2Y6hYghm3laQdbxv0knUKqamXg5BCatmGn4iDIrMuLA+A4B26QFF3krV4NthM66PRwtxtLqV/ANAfzVZn5HxA+YKRrTiKKZmEY/N/I25FSzJVCX0M6jNDSO8yi0ygJ8F4uDGsCACHKYzsmmDCDTh9m64cjWaItmybIZd1/YoSwM/95I8Lw3Qdq2ZK0wxoNzw3LNaSB3HsIkKq9Pl8Kqt9RRCPwYqmx/F0sp0auceyTQ0jqXNZTghk1E9FaFH+O5mvmdBOY4G/LwUEJ3YBSjJwMf1okHrI0TnKSAxRqzXxSKCcteLVJ0enNl8sqlDd9dKV/djfr6qfmUiyKxeYg2JAhdSRAM7rA6Vdpel0aXP3Ta45UsFZAvi5HwHJb5BxU20b+yK4XeGR8sS3Lals0oNl8Sov8yvU4mJqXoCFSMDMBTtPqROI8WX8++dI5TYjyfb1psEZkUe6u2Tgn0X811fgjG2woPUaYA0cD1p+83L+oCJIoBsO7RSTw9RUqVVwZNRG8LTIU1AM1yVJR20oub/N/iqUwoqVJ3eft5H3t1dfK6OlgVGz0t5rlRBNhIBPsDtQ2sJKkhrguA2+nXI3B8J90n/A9rIMdAqaSVBq4lyWYj8t1Xxdlmv361pEZYmhT4pXOzGBm9vWnslxuNHFWqz8rg81uHymFNxupQ+TwZIdvqJUhMxdXzbMb+MiLiTTGvWU7rWdPRqRlRKqoyLSVjKPrk99P8bXZ+gKX9AlMkT77OpTWnBYZgsIUEGnD09/FlhrAeT1dyUTfHBa3rzYwd5O8xf72fBuiRWpdD9zTX87/w1UDMmSRrYVj0ImE6o6S5i5xdhyItpEWkZqj0Hs3200V58S+tpRXh4jn6CLFbEAuFk4no8kxXfjSYLTVOa0F5dCnTKjLOu+d0PqeEaDXoarB4xn7Xhf5C2hb0CuwwpNz0ouO3JPzx06PXDxT8uSNwOXuQVq/irq2dPvNw/gebM3mPC3BySK/nq8uFf6n8sYmD86SQ/kY2RswcuRK5XwSN+2mcLRx7Ctf7DSnW8ODe9vtb288zOMISFp4+OpKEEM+sRFhJvWqym8+ngZC/+13huf1mmPlXqN5NdFao1yMrnxTNVn1ygyaDN8hxqhIox+7aMqBKmBuo X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM8PR12MB5462.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: v5WEi9BEgNdVC4mFlr4SEQ4mKEuVKmEM3fsKlemR2Ov8tXpvDGXnQoTd2Y6hJD8WC4SdtQ1QPwCaiV1dlFwGgj4rD0R2QCBTHBhyk7RZ7FAlCJ8yYWbsmrJqnUxgt4eZnimatMD7Bl260VucjMpYIxZS6fLHA8BwhXwvht3B6yk0NJjR22YDYbVDnQuhTpAqz0WKrYH74+C4Ry0Vag+gHdlZ3pgidPVGkm9FSI9nvNxAj7yL74kB3W62XeRgsqPJowTte62lyl6qFyUMuTTQfJe1pc2hYSUoc0NfjEuxgZ2fDuNUV9woYkaW4zpEvZay1fPb56928+OUlqunCA3lLGT7j3PeyXTLrUfrYYlvVvKur+pm6/+9QZGQ92a8NW47M1we5yxIWkyuQMvl/vrv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q1zxfRRETAYk7m7BxOiIWF7mJ1cTmL8oZfI3Ngnp3QgKqusMbODf/1NkluAQo79xkhzVjIeEBPu068As4nXqPNZVAs/soZkX2UXOq0JutubZ+RNJlODFL+7iK8wf9 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7ec510dd-ab0c-4fa5-bf06-08dcf88f2215 X-MS-Exchange-CrossTenant-AuthSource: DM8PR12MB5462.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 03:01:21.8577 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +G3jj0OMARuzViLxc4tnJqKAU/VbrOZLahOzhuMtVAcATlg7oao5/g/fwekJai3zAYiPsnu7jO97XWia7SSn4Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN5PR12MB9463 X-Rspam-User: X-Stat-Signature: 7eydojbo3thiw19fgrokeuiueygokom8 X-Rspamd-Queue-Id: 99B1DC0009 X-Rspamd-Server: rspam02 X-HE-Tag: 1730257263-105835 X-HE-Meta: U2FsdGVkX18e/lMiT+7lMGvrcYNXulGXCx0VhCtJHs0AOl8GKATHy8xw91HfKVMGLvmujFlcbDUAjb2eHRTzJfuVYJ0KLM1mwbD5YDo10f2iGWV5XsT5zyFhxMCp/Hjh6bD4IA+jxM6OAY25+dl+EtC2eLIfDNu8Mt43Sb0NC5I3LlHo9pPvwpiHoKfxuys2bdWZesGy127o7Zbk6ILHPae3PtIXT9FSNSZsM8KqsjW/R43Uyo7cf8DiZH0F7ZXLyTrluOZU7VGlowP8Wuuexc7g5Efte/8nafablsre4F32Pu1JFR4PRYUfp0p6951Gn3zOtt2+2ibPjjkZzyu4CF8RPvYJUU9RWsyWqiy56lXH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vns1qZXoapCpFlc4d1HZwrBmB34XqccV9UjVNa1wqNAzng== 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: commit 53ba78de064b ("mm/gup: introduce check_and_migrate_movable_folios()") created a new constraint on the pin_user_pages*() API family: a potentially large allocation must now occur, internally. A user-visible consequence has now appeared: user space can no longer pin more than 2GB of memory anymore on x86_64. That's because, on a 4KB PAGE_SIZE system, when user space tries to (indirectly, via a device driver that calls pin_user_pages()) pin 2GB, this requires an allocation of a folio pointers array of MAX_PAGE_ORDER size, which is the limit for kmalloc(). Fix this (restore the original behavior), by using replacing kmalloc_array() with kvmalloc_array(), which falls back to vmalloc() for larger allocations. Fixes: 53ba78de064b ("mm/gup: introduce check_and_migrate_movable_folios()") Cc: linux-stable@vger.kernel.org Cc: Vivek Kasireddy Cc: David Hildenbrand Cc: Dave Airlie Cc: Gerd Hoffmann Cc: Matthew Wilcox Cc: Christoph Hellwig Cc: Jason Gunthorpe Cc: Peter Xu Cc: Arnd Bergmann Cc: Daniel Vetter Cc: Dongwon Kim Cc: Hugh Dickins Cc: Junxiao Chang Cc: Mike Kravetz Cc: Oscar Salvador Signed-off-by: John Hubbard Signed-off-by: David Hildenbrand --- This applies to mm-hotfixes-unstable (only), because it relies on my earlier patch to this exact same location: commit 255231c75dcd mm/gup: stop leaking pinned pages in low memory conditions. thanks, John Hubbard mm/gup.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) base-commit: b70a32bbebeae216a3e846e01965880b309ca173 diff --git a/mm/gup.c b/mm/gup.c index 4637dab7b54f..346186788a49 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -2439,7 +2440,7 @@ static long check_and_migrate_movable_pages(unsigned long nr_pages, struct folio **folios; long i, ret; - folios = kmalloc_array(nr_pages, sizeof(*folios), GFP_KERNEL); + folios = kvmalloc_array(nr_pages, sizeof(*folios), GFP_KERNEL); if (!folios) { unpin_user_pages(pages, nr_pages); return -ENOMEM; @@ -2450,7 +2451,7 @@ static long check_and_migrate_movable_pages(unsigned long nr_pages, ret = check_and_migrate_movable_folios(nr_pages, folios); - kfree(folios); + kvfree(folios); return ret; } #else