From patchwork Tue Jan 24 20:34:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13114780 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 D674AC54E94 for ; Tue, 24 Jan 2023 20:34:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF0E86B0075; Tue, 24 Jan 2023 15:34:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CA0736B0078; Tue, 24 Jan 2023 15:34:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACA1E6B007D; Tue, 24 Jan 2023 15:34:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 8AFF86B0075 for ; Tue, 24 Jan 2023 15:34:46 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 5829AA06D8 for ; Tue, 24 Jan 2023 20:34:46 +0000 (UTC) X-FDA: 80390846172.18.850DC72 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 9F447C000B for ; Tue, 24 Jan 2023 20:34:43 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=oFK08f9Y; 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=1674592483; 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=/sDDSmpcu61aiordYuKth43RrR76IP7M1Qa0wICOl20=; b=BId0vEe10cDfn1qbOesUEwXJtPiLBGdHwW3Wf9FV2hIOLbqsXnogN+dzxDM/XJcwNv2d9e fDuU6D4vFU1LDUg5B8nl4TL/pEA4WQi65AAjQsHfp2aG49iokdobpJvJ/RdxE++s6wCoC0 zcCVzWUy+c43QsVBrLsqnIB3chmzHUU= ARC-Authentication-Results: i=2; imf28.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=oFK08f9Y; 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=1674592483; a=rsa-sha256; cv=pass; b=tfj1Timmcp1nnSbvpcCZ8NPRLClIeQjwCPvYWUmH7gTbtIADFD1rDWPn1HGX+yS/J7h7iI 3NZ+IemgmpC+RyZdEMwrUA9TSnoXwGfCZzxbbTVB7t8mGIq0WqcUMDOcXLSbDce5VM5gmv Eu5Dg9/Nn1/aboEb2MYcIQE46vxVhpY= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NuhmVXN+z76QJB4eR2mlpskFMr2u3vgJXB558SzmyucHLT9/gPJU4I5+F/kLXuZLJYEWSVc35I1xqsxAhx/8Ts1aIA9YJoD8UaRgGAvcfirqjT6CWqBWFPskgN9aO5iP2U239K16wZ70jnkiyzzWT68cqKGKffbsoLzKrgwY6H7atDw8YjVcvsImudMyIAM8kc1UcFY2oobOKDSWvkEdMtQV6s/56K30v8sOuChw5Nor9JOkO13AOJF8rbIpS5MXab/ihxzZSOir4+bnzOssXEnPgK+97oDKjD/xElk/gBCIsnfwz5jpfrh8opHqfEbQaazQOiJ/r2Lyv1Ih5jXXkw== 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=/sDDSmpcu61aiordYuKth43RrR76IP7M1Qa0wICOl20=; b=avBpzNwgbSRktnCN4VZ1fmr65x1UIWEypwxMI2PAsIb6z8V/vMRXTMA8djK0luJXvL1vhFwT1YzRi6+QMzVHyHF1gfFwNYxmrvI2m1YKXE1K5yG3z5SUkahVqNRMKY3IXDc0fjljca2ZDDxdqrNUuOPZno6/J7htLTxXvkWpMdCjRO7KZJ3WeSXdTZzceujZDDEt2gJ8jSd9mM+vwLiSWA/wTVKP3sVI14AY+v9vI5VVbnMkiMvOacsdxAKLjJYR9Q/lh4HDd+905i9xwmObfEXfUkaKPLqiX53ERHuzZaf+g1QGEBQVB9WXUy9qB5TBDI1W5jzb7VmL6B62Oo+hsw== 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=/sDDSmpcu61aiordYuKth43RrR76IP7M1Qa0wICOl20=; b=oFK08f9YGnnIBqTUe44Nz7jGbjh90xB0kCtRT/ERNXcbseAf3BiX4KEbtaN6Yx6ErB9e0TCYlAnGninl8xcFVYF2smxW2HXlDM0rAU9oeRlEKRM7SkJKDHNlKh2HuZwRDqf2Gb0MlH+gE9rUF7tDlJW00Ng/Fes/crm/LhKOI/s0stMQ6h360HBWOpKZsfm2nHb7R+IXUWd5L5thMKj1MWdz66A5j7ldj+otOkqy31KK6kn5uBMyltOgW3ygj01GtTL1t0Uons697tmoCgQD3W6HC4yWTtcVPJCWGZqAk3FCtwWbHAnYI3zQSoPZsx4nDfwcw2oTZIYAT8SGUNJOyQ== 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:37 +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:37 +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 06/13] mm/gup: add an assertion that the mmap lock is locked Date: Tue, 24 Jan 2023 16:34:27 -0400 Message-Id: <6-v2-987e91b59705+36b-gup_tidy_jgg@nvidia.com> In-Reply-To: <0-v2-987e91b59705+36b-gup_tidy_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR20CA0062.namprd20.prod.outlook.com (2603:10b6:208:235::31) 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: d91c0f31-1bea-40af-d667-08dafe4a683d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WpP4g0QoWTvAW1R7Fdy8h7Bxn2ajyqE6OjpLsulYLHBRgRVYQSCJAN0lFkUfPAgFj9DkDqYPYxuna2tvTrgJfDetpR70lknLK/KdtfGv2gLR303xxackF8jkjWdZaFKiWXCXKqTMqnCHW8XcqRFzx85OsfvmsDsuEsnTzHO9gHiboEBqNwD3B7jtFi+RPQOSxALXV9zInj/3xQVOz8C0BPSbbnVSPa9VOLuE89aF2hdMkRKinDN1eX85CPHaVU5xFBJ40sma61DrK6oW2ukf2JkRwhiLMgCsKLhCmOX/XBHpwV+z6rLCWcexI5n8TSSSYiPfWHNJu1umdx83jePH1U8lTPNybUHVRkRg5uC8ipK6c/v5FCI3n+PClv8V0rYaBC9F4VP1VCX0JzeQwINPP3o3Gko3jWaUsgAh5vQuKVhrqYlE2DAazqXt6uxQOvmvtt5Byr1J5PgXTrc9OPUYM39mKitwE/ryiZ5uquHWu53bvH08snd6f0nJlVcC61TvYK1ILYHIAX5Q1YRe/3LYDoKV2ZTbi4M1Wawv2K2SQkFBbnAS5F+Fvg/BdO652j+KS37z4/9wQU/peI3QWXfJFsvn06aAuqsCLgSx3DsfMF9evW6h4O4b2t1BLaVV796hT7pV+npM1y/o4j06gcOWKrwEvehX0rnrJRHTFDyN2VmTmhNUdMR5fbCCSBLbJfstElkeRpDTNlPoYbrJ2Y37BQ== 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)(4744005)(2906002)(26005)(4326008)(8936002)(316002)(6666004)(6512007)(6506007)(8676002)(186003)(66476007)(66556008)(54906003)(2616005)(478600001)(6486002)(36756003)(66946007)(4216001)(266003);DI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scexZLrG6KpouJEIXfo7YvbCcvzFWEseV5Vz+KdsojJOLcjIndz4SNq67dGi2viwwDbfeTnBnqR3+AbuCww0ZqFzGRc508na1lxbOFAznUGmkwaaeiza0+MUNYE6/84WZVEDv1RLZYr4ZEf11US8EG4kV+SkiWhDcPFM49LEflXM39l8//GgNb+msKzPx3+ypjOdak2OwwB894PGbMj3R1XFk6GYoL4D1oTsSoaeIj9FbzadmV5N8btObx1qjk+vE/isYDKu1hZ2NwBtBQ+a3RsbNg5/9BtF3K+LpzSDFIHOUSmVEduVRn8OujAhnEClmTLONv5AiQ3A1wIdYiXG6z24jprUhya/vyI+2MMmVsWuPNkzt7EB8V/GWekA91SBwIfkoF9WQdq4e9JHWlyDPAQd8KY+q8qC4DE9t3WPkjjmZvPtQ9iSig7kTb+353XcsnA3IvwOs/isNw8vvHu6Al+E+DjSqKI0Gr1yIC4gmQmvljI3zmrcp3Fyt8+9hAX0tT1vaKxFGZzrvy6BimrnGSquK+Ya7ZWhNq7G0h2iYZz1Mn+0+TyEl8A9HIPRgNH/jPovgY/hm5t1I3y2w X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: d91c0f31-1bea-40af-d667-08dafe4a683d 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.7513 (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: ClnXV9G2e3E9vWUSp07J4wBQK9o2IKq1I+FTkqKWZqD+BSUXZ/Fn19l3XE/HPYYY X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4095 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-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F7K9fHQXlXyPF2CJu9zQccBiC6WlR7wPolpB98cgAKeiTElNbgwAmQGeudc6cKvR0+tPAQieFlSO7fM4xTRJ1FPibDQ5yPjXSVtXvvAMQEvBFIocJbuV5LLXXdg3H1cE/SG7LRiaycfCBvZkSQl8xquBYalo5aPQVO95jzX2Lcn4kvZnt7N5KRNOkQ23+toqU4gwA4JQeDgodHFSXnrtN+6Kl1wo6D/wEGd5vTYtoopV35wPL12Ilhus0oPS6eYuBIy7HzdGAb2oYAJde6yUyQ1vsLnBnYG29Bne0oP3I9o3+jaFIerWg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000061, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Since commit 5b78ed24e8ec ("mm/pagemap: add mmap_assert_locked() annotations to find_vma*()") we already have this assertion, it is just buried in find_vma(): __get_user_pages_locked() __get_user_pages() find_extend_vma() find_vma() Also check it at the top of __get_user_pages_locked() as a form of documentation. Signed-off-by: Jason Gunthorpe Reviewed-by: John Hubbard --- mm/gup.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/gup.c b/mm/gup.c index 4c236fb83dcd3e..de1a5c64fdfdcf 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1360,6 +1360,8 @@ static __always_inline long __get_user_pages_locked(struct mm_struct *mm, must_unlock = true; *locked = 1; } + else + mmap_assert_locked(mm); if (flags & FOLL_PIN) mm_set_has_pinned_flag(&mm->flags);