From patchwork Tue Jan 24 20:34:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13114777 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 3EAD1C61D97 for ; Tue, 24 Jan 2023 20:34:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1CBA86B0073; Tue, 24 Jan 2023 15:34:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 17AF76B0075; Tue, 24 Jan 2023 15:34:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F11B16B0078; Tue, 24 Jan 2023 15:34:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id C8D846B0075 for ; Tue, 24 Jan 2023 15:34:43 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 936AE40C12 for ; Tue, 24 Jan 2023 20:34:43 +0000 (UTC) X-FDA: 80390846046.14.2337A29 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2056.outbound.protection.outlook.com [40.107.100.56]) by imf28.hostedemail.com (Postfix) with ESMTP id 079F3C0015 for ; Tue, 24 Jan 2023 20:34:40 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b="U8D/mryJ"; spf=pass (imf28.hostedemail.com: domain of jgg@nvidia.com designates 40.107.100.56 as permitted sender) smtp.mailfrom=jgg@nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); 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=1674592481; 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=QlPHXXru62p7gOiv28CYFpjsXey7qbiSjLk5PrB+lI4=; b=STolMxWQCdfc6wZV3KfkYuEJOP2XA76/JskBlQPKRhmwgVLhMhlwRplrHzdhKsQzIQ//so goRcilEltXOI39JBKd7eYNkdam+hUj50CUNeIj8+a4Tv776pL0MUV/Ghf4nSLQ18lKG7AM JKJQKXGn8tUPSBLOTuFKC+yRYhLaRCE= ARC-Authentication-Results: i=2; imf28.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b="U8D/mryJ"; spf=pass (imf28.hostedemail.com: domain of jgg@nvidia.com designates 40.107.100.56 as permitted sender) smtp.mailfrom=jgg@nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=reject) header.from=nvidia.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1674592481; a=rsa-sha256; cv=pass; b=ljX2sQcrdONAKSJpUBIpD7y0ldP+XD3tGEkKEpMGdbR/eGdnkTwClCxneuaYNzsxuKyhk7 FNPeiT7NZoN40MPj1AVZNnqkyiZYch10km6Rugi+sEwGWlrT/rELoj/l+3IuhTNMx9Q8ZI NANFM2QFAmJQvMlAWy+aK+IOS4jL3uI= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H9JDoMo3Fu4OGaEEseBxv3lngcSubbgOwAty8TwmjTeBC6DqzNbOvWuyTqp6iyTPYMO7kUh+3w3qcjiDW1DHFbuTCT/SeOkGFzB8zZLxvXnz7pOxi9RcRfnQQWGIsPfk0/O86a6vGMKPfLeqd07E8FeAo8SBHFeykcA9viuIbIiHg2nq8QmivkmxAlZIltMPYhIr8Oj/DBJaQFtP2hIENX9H6ZsSPS5PwDbkHjKDjVeCmbA6kGFL2lN7ySaApY6vrZpEcxrUyG2fBxwQRJnOSnGpHsvru5awhcm1KwfbsKGn4qHzlDyxQxwzbDO7hoFLlbFhQp3ZlLmYIB5WNi5blQ== 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=QlPHXXru62p7gOiv28CYFpjsXey7qbiSjLk5PrB+lI4=; b=HKj0WU0QuOccDl3tT5iIBh/hh6G707ah0E5BqrnhvpvgoXfaMW9CyHrkmA2S9i4MDh9cGFgP3jipJnNly1Z3SfNlF9P3XMBgpac4u+EnEeJClsVcW2yxPcYyML0m+hrlIwXFi157cXH/uNx906ro2Pi7VTNDeoPJ/TGNjNF5KR6orVkTg7uumAabW8M7Q8zxoFags2McX74LBNgpHcew/noP47gf4Rzs24OOE7WxM2rR9xeRuVcnYE975SF8P68QoRGDK+goVUP9UEyV6rk3zWmf1nRcFTBWX741vvlP45/3mDBwKT90aCzxfPV+Hk1VIO7jLB7K0vRUBy6CcTeWFw== 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=QlPHXXru62p7gOiv28CYFpjsXey7qbiSjLk5PrB+lI4=; b=U8D/mryJah6RBGJ/aw0EfGX81OFDLaQTnmKmboy+rIVuufgAXD0E34p9GssFplwsRPpn5Kuc3+6P+8yvCD9mJ6rCDibgzdsln2NyKDtb805SMxUYwjF5Znw3TVKK0r7GJ9qDzRlx1riUF3K45N62su55eQ57QePcBw5aYpuWus+Npsz2Cb6T5xnHkH10Vk5BFU4oNtJyrFQI0Bj06Uw4ZsIJJvl86HcLtjGIMkzeinc0bdPgtRun1bg0yyK61mkvO/oMF/pO9fTAJjyB8gO1vzwZ3HF810o68HJp42TGpDDxgLnwQoKzaQjkzTfStEyVtdXACcyJsqvloc7JK6nqDg== Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by MN2PR12MB4095.namprd12.prod.outlook.com (2603:10b6:208:1d1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Tue, 24 Jan 2023 20:34:35 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::3cb3:2fce:5c8f:82ee]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::3cb3:2fce:5c8f:82ee%4]) with mapi id 15.20.6002.033; Tue, 24 Jan 2023 20:34:35 +0000 From: Jason Gunthorpe To: Cc: Alistair Popple , David Hildenbrand , David Howells , Christoph Hellwig , John Hubbard , linux-mm@kvack.org, "Mike Rapoport (IBM)" Subject: [PATCH v2 00/13] Simplify the external interface for GUP Date: Tue, 24 Jan 2023 16:34:21 -0400 Message-Id: <0-v2-987e91b59705+36b-gup_tidy_jgg@nvidia.com> X-ClientProxiedBy: BL0PR02CA0011.namprd02.prod.outlook.com (2603:10b6:207:3c::24) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|MN2PR12MB4095:EE_ X-MS-Office365-Filtering-Correlation-Id: eeab64e4-5a68-41d2-906b-08dafe4a67e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Eqv5w2j/vDD71Jh9YfuSUS/cH18xQvKwIXNJSDSfSuVv0xkiPNKU9g/SeqdvHgTphWZjMB+Ia7GqxCQ8IK2q4HH/0w87QgIEZvCNVjQKiauSPUUUGoiRliZ6UtJDZiVb2Y9960FWRnkf98WHzbnSidtGM1Mg+yBP6xPuasUoVSYGUkSx/F6vguKErE3ryBBdE4vGazBP65rg5AGSUatS2txWVCbTJBkx3+OF7ozandf1Lke55XXtjDBX8gS2Nal8rpwCxWOzoadLMXVxefShz2jsP/usMgCc2hXMKqrO0t4hVf/rmoePauhf3HdtKLgX/PR7xGrjE7860E+8d6j4DpbYdpbitSs2nJkkUsA23O9Y0X3FJR2CQMbP6kC0lCq10W64LpsBDdDzeZeXUIKhuWNxoY9rSsz7fKR2Mm1a4naW/bt8dJ6AlmyHns99FCU2IWBICY18OD97Y+hYJQNbRn3CGjJ0PvjdWVngAZfiOoxBCFCIXqvZbr5D6QvV45ryxxRulimQaRzQXk3/CJXVpJGnjZItpz8oMro7eYWSLxzzHoURvqigAQhg/wcfoFbupuNB/J0pOr9+2jyqESMSpUR9C164xVCIn9+k/BcmgMHgAVYmbTtbcCGuzaypQi7dm8K7eS/PxbtfkvwsKyVbvpWAyPLk9DCcNMtsI1xyEDwhKfckkcGjWMhF1tJqnVchHCgj+pnrcYLr0YEixg9L1uogNqW3RNPzBkYRie4vrtyd/oUbEECF+ZUnT3NaE2YP41yrNsGwCVIqbnXBDlpRCo3lo94DbXLrpQYqR/t3AIM= 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:(13230025)(4636009)(366004)(396003)(39860400002)(376002)(346002)(136003)(451199018)(109986016)(38100700002)(83380400001)(5660300002)(41300700001)(86362001)(2906002)(26005)(4326008)(8936002)(316002)(6666004)(6512007)(6506007)(8676002)(186003)(66476007)(66556008)(54906003)(2616005)(478600001)(966005)(6486002)(36756003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PzJTIzL4K2iWswAk6sDHMMa56kRZJjek7+DYR/jOHabbDE1tw16Knfhfb7u1zcUT2/tkPgpgKecnhVSNGaaWpg5aNkYmTA32C6XWnPhOq8sBhEAsOUrm6zi0M73C5sGlG8WT1Sg/S5tYPz2EUAT3vF9d3Y9A/295F+4nDbp1NvYfcVLZKAmv/mIcgApfCqcdpPYfyS5o8EHg9PwcSsvcpPzm2mJUu7V7HZ+cW9Mk7VlMco63YjRozVtLL6gur+U91dCAw3OsWeE4koxE7K2dRo5KS2CCN9q7VSI3y9R/IkuVznZWr2394CE44cqjwEs2bO0QxfAUVU7+0ml2LKbtSWeW3UVwazN7x64UgLeKaoP8CMSJQMEYUbvzXtpWljkvn5WbOdgflpT2VumcwhjVs/3vs5mb31/xj2D3nCwc2UeUhOGsHFC26JVoR+YxjoiJKRrbu5+Y/8blyYYiYuTtiygTabHzvc87ty0hzBYpPAYnZcyeDzsU6RnZr1S2DUJ3AXgkr8Iho9jZxrO3Q7OukimGUjFP07s5ybdG1fNHtGJtk1ey87kj03hHKPxWAkBaSByzsrfIffkmdV2/S123iuDPJi26460/qlUWhwVTWIgIKN1Ip1C X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: eeab64e4-5a68-41d2-906b-08dafe4a67e3 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 20:34:35.1285 (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: MdQRF53dj8kpy71OoVZoOR+RK0iQij701dFysD0iw7wlXCdQ8XPfOXksmBYlHbMc X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4095 X-Rspam-User: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8papw fi69YY74 R42AvzYl/XuKktPi03HVu8ADenf64SN1C4nNC7lmma59wGz85ta/iOwC1Rkt5KarXtd33YJfP1aadbKhzsV7wceTQlJhBeLtA3u+qVLBaRH380BSEF2OeTfmuZa63IA/Wwhu1AVf0WSHFoc5IeWZtjAr0ZQbt9ABnQWDziR2jj8Ao7CAgyqvp8Et7pWA0Alo13hWQVee2A3CrnFn61JMEMGsYXhpX+U1y1UZ+b3uU661B+xj3F9n4+SRYN1ZRVhs1CIInKvt85+qBr8Cp7G9UnBtFAn7p04+afumTswlIDu1UKgo= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000026, 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. Move more things into the mm/internal.h header v2: - Call the new flag FOLL_UNLOCKABLE - Revise comments around locked to reflect FOLL_UNLOCKABLE - s/lock_dropped/must_unlock/ - Various grammer fixes - Add missing FOLL_UNLOCKABLE users populate_vma_page_range, faultin_vma_page_range - Make the mmap_lock assertion unconditional - Move internal FOLL_ flags to mm/internal.h - Rebase onto 41c457e96ba5 ("Merge branch 'mm-nonmm-unstable' into mm-everything") v1: https://lore.kernel.org/r/0-v1-dd94f8f0d5ad+716-gup_tidy_jgg@nvidia.com Jason Gunthorpe (13): mm/gup: have internal functions get the mmap_read_lock() mm/gup: remove obsolete FOLL_LONGTERM comment mm/gup: don't call __gup_longterm_locked() if FOLL_LONGTERM cannot be set mm/gup: move try_grab_page() to mm/internal.h mm/gup: simplify the external interface functions and consolidate invariants mm/gup: add an assertion that the mmap lock is locked mm/gup: remove locked being NULL from faultin_vma_page_range() mm/gup: add FOLL_UNLOCKABLE 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 mm/gup: move gup_must_unshare() to mm/internal.h mm/gup: move private gup FOLL_ flags to internal.h include/linux/mm.h | 69 -------- include/linux/mm_types.h | 62 ++++--- mm/gup.c | 370 +++++++++++++++++++-------------------- mm/huge_memory.c | 10 -- mm/internal.h | 81 +++++++++ 5 files changed, 292 insertions(+), 300 deletions(-) base-commit: 41c457e96ba51547c6e80b125dcba91aa6a00699