From patchwork Tue Jan 17 15:58:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13104837 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 B7E7DC6379F for ; Tue, 17 Jan 2023 15:58:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 345556B0073; Tue, 17 Jan 2023 10:58:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F4566B0074; Tue, 17 Jan 2023 10:58:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 196046B0075; Tue, 17 Jan 2023 10:58:47 -0500 (EST) 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 0CE556B0073 for ; Tue, 17 Jan 2023 10:58:47 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D5C24140225 for ; Tue, 17 Jan 2023 15:58:46 +0000 (UTC) X-FDA: 80364749052.01.C97A91F Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2050.outbound.protection.outlook.com [40.107.94.50]) by imf05.hostedemail.com (Postfix) with ESMTP id 49414100009 for ; Tue, 17 Jan 2023 15:58:42 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=PZg397gx; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf05.hostedemail.com: domain of jgg@nvidia.com designates 40.107.94.50 as permitted sender) smtp.mailfrom=jgg@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673971124; 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=z+zU2bL6Q4UsyC8WTn8rNgc6zu2cH2OTtjO9/DKIc2I=; b=8i/yzlkPJvPMEY/GANI6WlhPkzmuPTW9M+UsdDNJU5SDyvTVnlXYQiIL3wsrJo2Z/8v4QM uBk4+EhpLozPXTTYBArP0wPJ3Il/LXUNS33sO125rpsshDfyxdL8C+rBw8WGnDirSEC0WD OD8omW2pxSNYOGmBQudArKjDUUwvdyI= ARC-Authentication-Results: i=2; imf05.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=PZg397gx; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf05.hostedemail.com: domain of jgg@nvidia.com designates 40.107.94.50 as permitted sender) smtp.mailfrom=jgg@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1673971124; a=rsa-sha256; cv=pass; b=pqHSu+XljSY1kj3EcQLsRtPjH25LulmM4Gv5Gy28iYxlyxPgRrqFB1eRQiaxu/umoriWY8 PfZCQ3/GTi/Havw9IX8RonttUhP/4NspqCVR7/lQ+5OXefakk/Z7NIAzVIY0TvIKyQW7TY rX1fANvMgRf2uwUh4w6G89Bf6Aw9taI= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=anlg1L/BQiBLd8nafnlmM5erGW+zDaJ6cJyUSGML8S447cseoecPoCYWIxcYyYXY5xpFr8HJLjEhRmHfM4enHZYIuMr66VmHi847j3ytjVaID30FMOxmlPuQCMf3CISoKGYSQ2etswrPp7meocfeOJcYPJDJ57Zn5+OOqYpMaTZhfkk7pi8d22Co0M3Fm7r+A+FYw7Yc1LmBT1pPNgk6J3Clffel88XLc/CFzlDIWLNOQlWRJEPReWHg5Ht9oY0+ouN4Jf6BLmyLeLt0Abo1y1pNSSwSHDlKfJVfdPec/Xq3WpbHmOpbZxgUNNyjWCWA6uet2WKAgNTt7nD21ZuCMA== 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=z+zU2bL6Q4UsyC8WTn8rNgc6zu2cH2OTtjO9/DKIc2I=; b=kBGobhz6oRa0oiNk/ct5hQQsMmt2pQT3xaDxEBg7p5mrsIjrtbVtCUjdoG5yvACyJsdifXUX3pZKNBR5Y7J98K1B2haMspt43SKn1dLoYZo81ZlHTXLAeJNagwmNBVx3PfI/QL/2C3bOhMRMypu4ACLj+XbR6JKcolpAW6LxRpGPQgM8mFQAus6959KotnI0K8TPjgPdLDNO2Nt+hDTE6g3aFUX2Mx5/5AgdVlWShcZY/nSTYRcpOCRkXTVOOe2KosmnWUxPzi7nxBJ+hK+S1DksXtRxD/33LhJ4sWKMs1/bXsDdlHMk1HlvGQtQq0GoTSFDoq0FXbDbxf9jMMlFtw== 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=z+zU2bL6Q4UsyC8WTn8rNgc6zu2cH2OTtjO9/DKIc2I=; b=PZg397gxEUDf2TAQkKiOHo4sJhQpiPQ+NxrN0I0geFYcjyfvLmjh3fGsmyZT0o3PKQ2MoNGtPlDTet9wh7fod/wZ0sNrnFwZ5z0MiJ1sLR8PaMaKg9V6tbCLggWLFKhfFr2x2G+I/I9gSuAhqoUukn2n70qqGBV93BLEpD8+554X18gK0Z23X7/kBA5AUABXjLzt6fj8pUywCTcV7atkr5PH6aTXs43oNOA+c661WjWYXqo8jCFMbpVGQrOYKj1MQv0t4QVdb1sXGgiz44COUwzL2f9aAQGgshlZ5WmN0manlz8AgnjAetnj8v0ikolPLI7o4trCfR2JNtQsOtCPqQ== Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by IA1PR12MB8334.namprd12.prod.outlook.com (2603:10b6:208:3ff::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Tue, 17 Jan 2023 15:58:40 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.6002.013; Tue, 17 Jan 2023 15:58:40 +0000 From: Jason Gunthorpe To: Cc: Alistair Popple , John Hubbard , linux-mm@kvack.org Subject: [PATCH 0/8] Simplify the external interface for GUP Date: Tue, 17 Jan 2023 11:58:31 -0400 Message-Id: <0-v1-dd94f8f0d5ad+716-gup_tidy_jgg@nvidia.com> X-ClientProxiedBy: BN9P221CA0014.NAMP221.PROD.OUTLOOK.COM (2603:10b6:408:10a::19) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|IA1PR12MB8334:EE_ X-MS-Office365-Filtering-Correlation-Id: beb1af67-5080-4b9e-61a6-08daf8a3b3a5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e5MxmPlTGtk1ceCDSZgUu++LNRJqsflN7EBamhWm4QN1ZOfMXryhUcrxXM1RZp0gDRWtIMRRcFMyXsL9dsua+rMc88OdtRHoRSKt/vwXfocHBT/1SWtADkgs+3Br0+LNletPv5MnC4s8U78PuxoNo6qYcDHGtS4yUvjaocYN0ApyRab3K4oMsewi93pysPlyNj/r7AkoATqlpRlDuTDABJgxawiV/PstHR41Qsw5mBnECkdwv77/NpxD+aeC8YS2QkWzr5IA5H1Cr2mdWjTSNhsImoU0vIxmt7a2QecWWeD3OPm8vzRPhNf/hrQWFlONOkwGNiwG+ljalOtjc2owdejjpU4nPiplOBFCS+p6o7gVPkIM/zp3yScsKo8Eh8sYstmeKbjMAOYB1NCXlfBuz78zkmSMmoAfEEK6ww5zpOjiofxrceMxwodsdD6MLd693YJkmGOzPYg3qBh7KPmnDcb+eYZ2o3bt9aOTLAj49+jN6PjYQx28FLzlYmLELjLEOSfP69EZIoEUKIR6i8/LC21DgvcBn4qhJ499QZkTIPYPZ/L4q8RNqpQHtSFQ4vCNifCwu5mqCbL9/EzH7qjQg0l7MIrbNRZ/jAz04+Yqx2MmUh8Tk1ecoQRlla8Q8e4vhT/QGZdjXu+tQ5Jf2tse1M74WmXSoGb+wxd2iOcvdzkFElWD4sP4pKv9wuHnYdSXOpFIEytAWwBAOFcAV+Y3YQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(366004)(346002)(136003)(376002)(39860400002)(109986013)(451199015)(36756003)(86362001)(2616005)(66556008)(4326008)(26005)(8676002)(6512007)(186003)(66946007)(66476007)(41300700001)(83380400001)(6666004)(6506007)(316002)(54906003)(478600001)(2906002)(6486002)(38100700002)(8936002)(5660300002)(4216001)(266003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RlfQh7CvqpU8E5kue24j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BPjuepCVv7sH6lJ8bFOIvkEbI+mcj0Qv0n9y6znGiCmKmIR7nNodSMqfrP0IPeqJz8YP4Ql0AM/qPAGfTSE9mWR6WTveZauQBmw5Q7DPlpaU8GsbJp3OzM61wwUsPO2Z34rlECVRY+BhMhVTHCH6zG8rN/FXwB/W9ko4pK4e8ZceKyi3ynhNN3LHUWZZUloL7DUDL8a1WIKD6yCzVfLbSuZG0mthMcTND9t4TV9Jnw8InXUbB5eEDTLExpzVUe6Jg9re6TtKUjHqVC/wg09kpCzI6ZC9xjCLTeF30X5vAZBtjBd0JhRvNajT7dPH5qQGEc1k5JQu5UNkw/jAWobgMA7S0g3qe9PUEvspcZ1CvL4rehF6p+TchZ0J/4aW2Wom9M9b8IclC8rVG+e9x0HAwFQaeR0ofKJ17wzIy1vl3zCVujO84wIES7WNhWsEPl5uSyapeweMsn8p9AbMmDK2+M/ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: beb1af67-5080-4b9e-61a6-08daf8a3b3a5 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2023 15:58:40.4914 (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: z44a1LytKkSrSmA2lSzUiWvHFjwE6LKmM5kJhw78aUC9PdcBkaNYgQvTteQuKSE6 X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8334 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 49414100009 X-Rspam-User: X-Stat-Signature: juosp5atysfm1f1di6nxwdg95w5prnxh X-HE-Tag: 1673971122-713655 X-HE-Meta: U2FsdGVkX19a5XgK7QCqxsGj8LZ3mFt4sV0zSb6WztnKgDxN7BWlVyEN+PR1C0ggWGuW5WAq+4DwdJ0GA1qvHNpkqSpCTXz0EUWzsb3ieejUYv/j+m0TGRhsSwey7DYu36b9wjAwC4IuU0v0FGi0LrT+IzO+iwTFuT3bTKhZOAkf0x6ec5oy/TCc2k59aphX6w4nm7xn2voH0rR6K/x4KZgwJtr9IqvgXVJ1YLVaVHOhwiIsVUhuzNL1mZcGWKdFq8tc/ycE7qnCY7wU11gNGn3MCldtkwMP6RP0OAKFzpTQW79IqDuiP6lBHDGh5/MIwIa5HrQSVWLK01DlRN4XRJaeBwNSo3u4wCxQiMkYDfJ/JabD8kWFEONCAIaa/w8v4DXU6/wVwEtG8Gitrruup4c0baC8kQTyQbEKWyPZMFEUJXGy7rgrXNDh9Dcgo6zR1xCOEnm3nt8zsZBY0yRH/yi2WFW/r/jGV6vUP9QYPdQQSaKBcWT5ccouxInejCR40e5YzwR96XJVxHMZyUvA0KBIHEHNYyrUVqLxCIHDecLIQ4gDFVH9OLI+CAdJQOa0CTRRORt7cJs4/0dl7DViUEAI2/GcH42zMdScjuEIoPyKoCaSv8Lt9SqCS/JXs18IHZDZ+UYs/BoOR9sKtrx6JZ/vT/ORwgtRgW+CNV1vNqCdLDYsTTVO4EHLKzBt87oGfdU4zZTNZzq6q34JFGXHb6X3q/8fp4XJp/11o29YIdQN2flgsp1fQh/lyvtLG18cRxyGptSXlUTIWRUJ97liZBd48Ac578Pmt5mMHx0eHXXoRPC77VxEBcTgogLPoD7/AoXxPNUGzSQku1kEUyY1raASSa1MJerws0dJ9yTSom1adV5OXmQ3K0FIO+jaS+1bvjjg5g0KwqBoUdGSJwz9GR9lwt0zTT8c4KLd5GgxnuGPB/JqFwE9VKbTw4i47ap/nnJx5w2mZUE= X-Bogosity: Ham, tests=bogofilter, spamicity=0.003906, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: It is quite a maze of EXPORTED symbols leading up to the three actual worker functions of GUP. Simplify this by reorganizing some of the code so the EXPORTED symbols directly call the correct internal function with validated and consistent arguments. Consolidate all the assertions into one place at the top of the call chains. Remove some dead code. Jason Gunthorpe (8): mm/gup: have internal functions get the mmap_read_lock() mm/gup: don't call __gup_longterm_locked() if FOLL_LONGTERM cannot be set mm/gup: simplify the external interface functions and consolidate invariants mm/gup: add an assertion that the mmap lock is locked mm/gup: add FOLL_UNLOCK mm/gup: make locked never NULL in the internal GUP functions mm/gup: remove pin_user_pages_fast_only() mm/gup: make get_user_pages_fast_only() return the common return value include/linux/mm.h | 3 +- mm/gup.c | 319 +++++++++++++++++++++------------------------ mm/huge_memory.c | 10 -- 3 files changed, 150 insertions(+), 182 deletions(-) base-commit: 5dc4c995db9eb45f6373a956eb1f69460e69e6d4 Acked-by: Mike Rapoport (IBM)