From patchwork Tue Jan 24 05:42:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 13113486 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 B251DC25B4E for ; Tue, 24 Jan 2023 05:44:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 573096B0071; Tue, 24 Jan 2023 00:44:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5231E6B0080; Tue, 24 Jan 2023 00:44:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 39C776B0081; Tue, 24 Jan 2023 00:44:32 -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 260716B0071 for ; Tue, 24 Jan 2023 00:44:32 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 00A058028B for ; Tue, 24 Jan 2023 05:44:31 +0000 (UTC) X-FDA: 80388602742.23.45C84BF Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2058.outbound.protection.outlook.com [40.107.94.58]) by imf14.hostedemail.com (Postfix) with ESMTP id 30042100014 for ; Tue, 24 Jan 2023 05:44:28 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=VMqRAsov; dmarc=pass (policy=reject) header.from=nvidia.com; spf=pass (imf14.hostedemail.com: domain of apopple@nvidia.com designates 40.107.94.58 as permitted sender) smtp.mailfrom=apopple@nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674539069; 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=Ys/BSuVjvYg3vlQckN9qotw9N9puGnTTdwB3lsffmG0=; b=4Yj2olNvfrs2e0DByykVaUHe2ioiLMVOD+4AvZRXzlFVTQ0AQsj2GgrZowBNr7e7gHI+aX PX5Z/u2Dkk4mo/Z5tmGMHYNRdwul41zEy875crzct9qbY1dAKrI3rpU1ugsYtstrdvLT3m ANSTSJ4Mxm2BjjCedWmTarx1ykz4v+I= ARC-Authentication-Results: i=2; imf14.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=VMqRAsov; dmarc=pass (policy=reject) header.from=nvidia.com; spf=pass (imf14.hostedemail.com: domain of apopple@nvidia.com designates 40.107.94.58 as permitted sender) smtp.mailfrom=apopple@nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1674539069; a=rsa-sha256; cv=pass; b=zn7Yv31E8owozYfgOfzhV+giZMwlDjV0y1ExMyiK0c15Y3eN84HNGSmjGIcjszNkKvZ+Iu tCcA5/JMoGGdYj/dNsd2yzginhfUlGK1xrcDiU+tBIsxFKRrQ6UV/d++AsUVOoTgnPbVef WS96yUsBLJwRXsFF49UrojZ5SSOOdxA= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bb3O+BkGV052ySnoKOa7LGiPh2Q84Rl3VxYSPCZyfCMfut4iT4sIDGkl0m0xkmmGCUUutkX30pHcOkY0zi5PeG9T9BxhydURS+/JEjrZy7ZbAS6PfXEwbKW/Ve8xD0hCXjTjuJJkSULQRd0U0exHZyIzl4n4TyEog8fju9JGQkUMxAyeO72CJmdAdQQafabNayo2i/0WHzsg47+q7/nz/pg8wp+Cvn5eWe+HueUP2k3g0d/tPn+Yp3Kc2bXjVCMWyFX8NGwJMPL3TUzWGD+glJjs6yk0n84hoTN1ii8hpSctLyz+a07gPOC9tPHR+jg90szeA7px7KBlhVkx0eSr5Q== 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=Ys/BSuVjvYg3vlQckN9qotw9N9puGnTTdwB3lsffmG0=; b=XcYRMNMgrw1kZusBBbteylsMkZYnSX4eKvlNjEzTBw3gs/8ojFq7VioI8U+nGpn+aD1qFyHZxW66vVb7jdzzV+ZElUZ7ap6+nWw6A9xlZ0+C8mIf0PJ5yxrJ2loS7SaJ1zIK0f31KT8+oyg3X7GAFTX1zlWhx8bCrftTlxHzWuqkLlq3wH2Pl3CakN/JaG2v3x4tZUjtoopH5xl3AoK+4k70TOMxEJomFgvBYl+s4VhqHUwypzi7HO9lucXbCuDvT0wWnF09x6Rzm6mZ1jLGg0FSaPpGAWPb1ZtJKg7WrDaKaW8/bKRQPbzxj+ezXWClmdHVkCPZ/XZRRdcqvVHEXQ== 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=Ys/BSuVjvYg3vlQckN9qotw9N9puGnTTdwB3lsffmG0=; b=VMqRAsovhuiP1xlHzwhCtlAjrD4l00fCvvvfVy44+q4zWKTW6AUznfapM3qZYyLL7Zo0TAow/blShV90PvoRb/xlIdIEcSWt1wjlefZcGYfPH0PNi0Nim0zEBTM+KQtfCZljuIo/dZej0/O7Lzij2jWwT/I+zJefY+jRSTh6d4LY/bwZvypcYNH2x98rb1c4MLPKTRRvBBYBeeXFeVkE8CAfo9r49jlyUqbQiDI8wo6tgtDIECAIdDXMM+gvgr5drIdK9BDxSZKUgWyhK6xcrjZyT5pIQHWglSQlxWrX4UxkJoj5AeQXqe3CsNNxgwNKwvj+DHbEuJ99Zl0nVNKhwg== Received: from BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) by MW3PR12MB4540.namprd12.prod.outlook.com (2603:10b6:303:52::12) 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 05:44:27 +0000 Received: from BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::465a:6564:6198:2f4e]) by BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::465a:6564:6198:2f4e%4]) with mapi id 15.20.6002.033; Tue, 24 Jan 2023 05:44:27 +0000 From: Alistair Popple To: linux-mm@kvack.org, cgroups@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jgg@nvidia.com, jhubbard@nvidia.com, tjmercier@google.com, hannes@cmpxchg.org, surenb@google.com, mkoutny@suse.com, daniel@ffwll.ch, Alistair Popple , Bernard Metzler , Jason Gunthorpe , Leon Romanovsky , linux-rdma@vger.kernel.org Subject: [RFC PATCH 05/19] RMDA/siw: Convert to use vm_account Date: Tue, 24 Jan 2023 16:42:34 +1100 Message-Id: <4f8b1d54ab5d6909c46ba5470065f8326f9fcc62.1674538665.git-series.apopple@nvidia.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: References: X-ClientProxiedBy: SYBPR01CA0005.ausprd01.prod.outlook.com (2603:10c6:10::17) To BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR12MB3176:EE_|MW3PR12MB4540:EE_ X-MS-Office365-Filtering-Correlation-Id: 90992122-bf85-4cfb-bbac-08dafdce0e2f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xPoVJFoi2Q5dygKTO+tA+wp3wYXP9Odmw4uNetAYU4PsftNIGUxGUSIGMDEW66kbv0L2pSv8IZjHerNBaTqA5BYNpiMVI5B0Hq1KDbrtgEYfIOmjrCbE9o1Gy66CvMgAQWSSnDjRI4vKUhN6AH1ANkK2Gcq6AxxGPJhBjNZ4PWb74q+wDutA68XJ3+qsGGufYgOukDkgeO809WDn5iWQdOMgF6bAi0c7p2Tc18KbyVMSI0xfykAiXcSOM/LhUll1taz4rr5qY6CPR6ZU1Ax6bOiaOyg5lysmjGowykz0T9yVTX884HzXeCOzlLeJG2IgDJgDft/LMh1zMxh8wYhUqmEjIfSjW7Ts+8NYvTuyPwM9aO3BUym3YQVYX/FtBuC7YdHUG9LGX0CAGY0Ak9PH79YJDLqglVlzK/sQaUcEZdAkPBH2i2ML2OcN4TQGnvMzEIt42NY3seep/YvCG8Tz6av5ZRBs5qF75zuUCFW9qMPWaisSprb57iJaalEWYqGDbk98sOkxIJIlgHv6Y3OBlk7LUI1zYj/nUwKHogF5HbJiLDSkAf6sSRnffjlwYOzZrE3CJ4LCsA4mciMOSwHysuMd6cNPB6K9Nje3vwCF3YvK3AuVoCmB2neSiiIYdpvz++SDX2Rl0IN+Cm9SHV8yhg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB3176.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(366004)(376002)(136003)(396003)(39860400002)(451199015)(36756003)(86362001)(5660300002)(38100700002)(2906002)(4326008)(8936002)(7416002)(83380400001)(41300700001)(66476007)(478600001)(6486002)(66556008)(6506007)(6512007)(8676002)(26005)(186003)(316002)(66946007)(2616005)(54906003)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7INmr83+joiH8mGAyXhiTEKLgagnKOtAuPSs35DKgMe51e2kS33fbUWuaCDtjViRoxUpqVo1pOgkJxQY0rGOIOG5X861wNtgV7tX9idG2Z3nQ/mQV6g8gnuVrJfy0fS36QCEUBVwpvuvVQPIS1suhS1pTgZmoCPFuFlUMnGYd7+ZqpEcCj6JnZTtILSzltnzZySskWf6iLV66xj+NAxsUgLlrrq9fFRXrEgM5OBfGYoWp7GqGtEMVGw9BnwkAA+nChegXAC9jbvpal3V7vEUo/5BRjUt3eaWbXE72P/MFtWMPAR5VnG0B6H/VwTdMSJA1T1uVDSQYUyH7crXfv47Q09NAaWK3n7IE4CsQ09Ek8pw9FG4Pz3LMeeeoSjFtpwWHz301Ya7dafRTqfiLJgIDeJ4A7Js9CAsXWySqOSYSC5jf03idiW/PoZABpMOchr+S41KTQN102Pb5ge8sUZ1eTuoRpfQXhJ5/gT17z+Z+aSxVdlv+4VuURtVdEnINALsORK64gTgRrU5lsGrQ1WNvVw/ajyMAzAqvvkkIoqLhHhwqVAhO+uHsnHCaRreRtD0JvQ3CBsuj1sf7QvEIop9aCaACT5Q3x4H3W0YeRUfrkK7yhSYnk5oyonPDzsPxuCGGSYouLNhRbvm09eQGbfxPUL7HHcQQCP9CfRatdBrxe0XqspdxXGou8Sfo+/AecJ2u0pmnDx0xETm43qT1LJLyb3dsxnmtwJ0YFTe/qFIXSqCoAX1ojr7StL7AGRbiVZu+DRtOGjhBZ8tCA/DVbHoneq1J8FGedSTHTQzzjuhVzZKkDZXtJL86tJyHWZ4klqw0XjGKFjP/+ON514Zd6vpNYwDuqjU+XAUWAeBKbDcMJmQXbVmK79W7S9krG/eXvDGYJGtbCefdiiP4jx+OO9eVzgtTiTgpUBQw8AHPczYgd7Wxcyfx3HfcH73kcgWZtTFF4eVraYb5cioQ40FT/oV+Bbo/fT4aCftSI81r9hUwTLlgmtMlgaOgcfY+qB176mjqhgIv8bfWriwOFawZjJxIY+QSO6Ld883nMuD8f4uFmOTdOPjXRYWSV6Tp031k5ShYEPrbs5kivclLPnES47Dfdxi1JOFIVvN3Qd0jqEIWUb4Q510CywcoWZf3B1IhWN4TjLWv+4ZXKM+4m8xUu7wVkqbVo/oOLX35vQyZojGDBmCXkplz3IRzsvVje7dwCuXFx/7Ani3FB97FW36RzPkm/t4f69CP0djQOcgCr4lBRLbVAe4m0vdCzu85nuaD4gewwowQzpykrJWXIjnmYOP0YvEGie3xyu/SqYVeKxbYLW8bbD9052o1egjKcLyStEhIauRNHSjU5DSianf1ueeNODGOs+Fc7OMLKanJG9d1n8UAlpBgzMZlhqc0caF5A3nOItY2wP65A+X+mfpF8oEF4GcTCxIj5GhntDQrMKiGKyq67ghzWGMjY0cXyPLOm0RuxDnQ6r1DhOXixTPO6iPcXH+sIu5XZKhzpiUPwiFnFeGtqWG91VKBxyG/NLL3yzdMa4Lo6bujdGeta40XrCOQMhXY86m0rhApeqgbDFgjs+taJ9YlGhwGtiRMS7UZGxi X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 90992122-bf85-4cfb-bbac-08dafdce0e2f X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3176.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 05:44:27.2570 (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: GfimHfBEj5y93A4hAuyjqPMkRtt0veLtE4+3AW9Jcl3CCT/FaZIc5uyx7oJJGClA2Xa69XYBm4Y+udtVvo/ePg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4540 X-Rspamd-Queue-Id: 30042100014 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: 7rwgponwnkuyg65g8isu9oex1yf8mbhm X-HE-Tag: 1674539068-993496 X-HE-Meta: U2FsdGVkX18vRUj1ninn8q0YUpCtL7e9JMEkgQdEnXYPA3Y/wcl0lR/HLm2QUZe8s/meCochMSQhQ1iUniO+adHVy4Kzo5B9CElhDZaHZCCgjWhdK89KwAq7UDelZEZxWydNG+MQR8XOcErhvU+bxryTEk5l4zRw4HdIus9WJLxgHaZmm0woUeMMHCZpDUm0pDBm9fbSXgxhJQXEUmq8NDaKoJk+3ngiHG5KpavxmSBivJ5PeaXIx3vl63gVJD9mJL9oJpIShAE9SOf/2LfnoSYjdl0L2wJJP9O15Q8io3sPYhmdpQVVkR/tnyRxj/vkvp152XfyDsGGM6qxjxnXMmgoSCYnX4hpxX76tILKV1LOt5Sqnj+0S5TRiF/nlXSooQ2gWF9OyxWOdfX/jHDm5QWkEhnYNDwH8Hcjc4X1E2MGzIAX9g3uh/zVtG1PtvY05fRIl9McK+rbr5SYGxqWMU+5zUVDGFGH92CAlZ92PeCUHC1HPohVaUch1do/7FHbsVNt/YZSaBUkdVO5m0tocFrwmi1pjqXPJlf+qUPf6URd3d4M0ebzPUaNeVripHh9QTJgXQrAqr0itM2+b28fhW7r/Rnc/e9HYFIa+uKnfDg+/EbgxJuavwL138MQbxIVi1kl6Grrb51qIXXlGTr9Wh9f9QwMop6zOb6H8OXZThBC5dz6eLFRzXt3FNkSQz0rKR/qtPK2dlcmvhZp6daC0aHq58c+Gcqa9//zlVg4aA3vtg0gyhNelR0NEAjIAUVOKpPk68ypwOA4iF31LQu670vZD1b6ZsSljucpvbQkhjCfdKbIJzRHjUz1tIVcemNPrCK2yheW6U3HbMKLZ3imIzroYbz2Hg5UdxJPMXy6WfzCKCBWcjQJkW81TVmxuHfyVkqSIzUZr/3CYADxLD71VsdPlM4kn2j7NubSMuqy7zocbOXaCc6lZuZjHhG5/oXBVzPb3tfiByCvvPZO6z5 Yj1fKLZV 5yH+Wk1TQb1ZODWNVkV6UZsMymyFvpj+D95e7BIZfBq0tbyMvbJtHmv+3WKLEIAX0Mo7HKJkx7kzPFb2YnEAgHae+V++dyrOSe05YcIRUhbBdIAzglZ6gwgtfpItMTHAWHeqJzPdWCvyDMTFnqKiQECnLyOXhyx2YicfXI0Ok8JXxdRsIsvXpnXkO07UQSHtuoT7bYwhcxBoeTQzswN7CUfiAQipXSJDXk/QgeDUIIv9aFAG3Hk3AeAPIpiUg1rloHrQgh8GmVDQQny0Fe4Snv+mIUmy+Oi5XJQVd2dJFE97Ysj+y2wUNGkidPnryWEmNjNUW7OBOqCJj1IDUrG9nib3SNO9oKqjTRQUHvCQg8ylAPAkCG0DfjHc7wfIFol+lXaRcbRv7IRGvta6lwVkLQSW5sff96ViRmS75N85EaZ8hdLJf3bS4st/AKg== 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: Convert to using a vm_account structure to account pinned memory to both the mm and the pins cgroup. Signed-off-by: Alistair Popple Cc: Bernard Metzler Cc: Jason Gunthorpe Cc: Leon Romanovsky Cc: linux-rdma@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/infiniband/sw/siw/siw.h | 2 +- drivers/infiniband/sw/siw/siw_mem.c | 20 ++++++-------------- drivers/infiniband/sw/siw/siw_verbs.c | 15 --------------- 3 files changed, 7 insertions(+), 30 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw.h b/drivers/infiniband/sw/siw/siw.h index 2f3a9cd..0c4a3ec 100644 --- a/drivers/infiniband/sw/siw/siw.h +++ b/drivers/infiniband/sw/siw/siw.h @@ -124,7 +124,7 @@ struct siw_umem { int num_pages; bool writable; u64 fp_addr; /* First page base address */ - struct mm_struct *owning_mm; + struct vm_account vm_account; }; struct siw_pble { diff --git a/drivers/infiniband/sw/siw/siw_mem.c b/drivers/infiniband/sw/siw/siw_mem.c index b2b33dd..9c53fc3 100644 --- a/drivers/infiniband/sw/siw/siw_mem.c +++ b/drivers/infiniband/sw/siw/siw_mem.c @@ -68,7 +68,6 @@ static void siw_free_plist(struct siw_page_chunk *chunk, int num_pages, void siw_umem_release(struct siw_umem *umem, bool dirty) { - struct mm_struct *mm_s = umem->owning_mm; int i, num_pages = umem->num_pages; for (i = 0; num_pages; i++) { @@ -79,9 +78,9 @@ void siw_umem_release(struct siw_umem *umem, bool dirty) kfree(umem->page_chunk[i].plist); num_pages -= to_free; } - atomic64_sub(umem->num_pages, &mm_s->pinned_vm); + vm_unaccount_pinned(&umem->vm_account, umem->num_pages); + vm_account_release(&umem->vm_account); - mmdrop(mm_s); kfree(umem->page_chunk); kfree(umem); } @@ -365,9 +364,7 @@ struct siw_pbl *siw_pbl_alloc(u32 num_buf) struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) { struct siw_umem *umem; - struct mm_struct *mm_s; u64 first_page_va; - unsigned long mlock_limit; unsigned int foll_flags = FOLL_LONGTERM; int num_pages, num_chunks, i, rv = 0; @@ -385,20 +382,16 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) if (!umem) return ERR_PTR(-ENOMEM); - mm_s = current->mm; - umem->owning_mm = mm_s; umem->writable = writable; - mmgrab(mm_s); + vm_account_init_current(&umem->vm_account); if (writable) foll_flags |= FOLL_WRITE; - mmap_read_lock(mm_s); + mmap_read_lock(current->mm); - mlock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT; - - if (num_pages + atomic64_read(&mm_s->pinned_vm) > mlock_limit) { + if (vm_account_pinned(&umem->vm_account, num_pages)) { rv = -ENOMEM; goto out_sem_up; } @@ -429,7 +422,6 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) goto out_sem_up; umem->num_pages += rv; - atomic64_add(rv, &mm_s->pinned_vm); first_page_va += rv * PAGE_SIZE; nents -= rv; got += rv; @@ -437,7 +429,7 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) num_pages -= got; } out_sem_up: - mmap_read_unlock(mm_s); + mmap_read_unlock(current->mm); if (rv > 0) return umem; diff --git a/drivers/infiniband/sw/siw/siw_verbs.c b/drivers/infiniband/sw/siw/siw_verbs.c index 906fde1..8fab009 100644 --- a/drivers/infiniband/sw/siw/siw_verbs.c +++ b/drivers/infiniband/sw/siw/siw_verbs.c @@ -1321,8 +1321,6 @@ struct ib_mr *siw_reg_user_mr(struct ib_pd *pd, u64 start, u64 len, struct siw_umem *umem = NULL; struct siw_ureq_reg_mr ureq; struct siw_device *sdev = to_siw_dev(pd->device); - - unsigned long mem_limit = rlimit(RLIMIT_MEMLOCK); int rv; siw_dbg_pd(pd, "start: 0x%pK, va: 0x%pK, len: %llu\n", @@ -1338,19 +1336,6 @@ struct ib_mr *siw_reg_user_mr(struct ib_pd *pd, u64 start, u64 len, rv = -EINVAL; goto err_out; } - if (mem_limit != RLIM_INFINITY) { - unsigned long num_pages = - (PAGE_ALIGN(len + (start & ~PAGE_MASK))) >> PAGE_SHIFT; - mem_limit >>= PAGE_SHIFT; - - if (num_pages > mem_limit - current->mm->locked_vm) { - siw_dbg_pd(pd, "pages req %lu, max %lu, lock %lu\n", - num_pages, mem_limit, - current->mm->locked_vm); - rv = -ENOMEM; - goto err_out; - } - } umem = siw_umem_get(start, len, ib_access_writable(rights)); if (IS_ERR(umem)) { rv = PTR_ERR(umem);