Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6856169ybx; Mon, 11 Nov 2019 16:12:34 -0800 (PST) X-Google-Smtp-Source: APXvYqxfSZVEwxXhMDz1sdgvAz+ZlKuNyHsnbXP/9OuokafG4znTm7gkGZ3R1GHctAjQhsFr4DMm X-Received: by 2002:a17:906:a981:: with SMTP id jr1mr25361715ejb.255.1573517554393; Mon, 11 Nov 2019 16:12:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573517554; cv=none; d=google.com; s=arc-20160816; b=Ccz9kssdPaFFrtRNAtm8xTvdxv5yu8s8F0RsMMIJ6Y/Mm0702IcN3EGoRNKEPVogF4 3HsD8e3XBBoODeD1pAm3n6hgIK0hcTbfxdhtq/iMkXIzcwOc4ijSge+DciySdQauGPWf GHepPRCnY8PBeDcfexenG8iQrCb4t/acW8cRjGEsAOUtitawXF2sDNwdkPdjlpKaukc/ lbfU+OxLoNQULLQuwxJ4euNSZdiHzm+lrgswYwRw4sT7rqYTPoZjJi/+otqv5jfIHH9Z gIMZ1xE75mwED09hanOw1jtu8Gh7zjbcPqL7OQvgZrqeoxlhhoZ4mzaTdy8dUIj5Y4Zu xzyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=PPNQFWxgYbSBG60Oh3uZy3iaVFj8VG12aJVlvrNgBtA=; b=Hny8Kw85D3orRgaiQvew6nmVE9vuhxfEcybqLh9CAXnOx0hgmFFx1sJhBmFw0gPhLU jk7Sne+UFcIe8ua1OAYhpwiI2IIVQv8FC0pAy37QL7LfTJZNLox3GLK5H606YfePKfTz g6ti86NWW7Id9uHhlGxwrb4g6k65dxU3NMnb3Wyni0WI9B+ARwFzoN1y0UAsRvyDA9N9 nVw/gSaBxrSZTAmX5JYd7nuyopQJQLPbrTIQVQjvG7N5K8lWZt5gSvSfOpNAy1eBCgOY Z3DITGKk/xzvTnQIEd5KpueWackN4SD+fnmdQvi7lFsB9IIbQKxUvhxzk5adPXz85ZjX AglQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=KhLyNKkC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e32si12731581eda.267.2019.11.11.16.12.10; Mon, 11 Nov 2019 16:12:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=KhLyNKkC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727249AbfKLAHO (ORCPT + 99 others); Mon, 11 Nov 2019 19:07:14 -0500 Received: from hqemgate14.nvidia.com ([216.228.121.143]:10606 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726952AbfKLAHM (ORCPT ); Mon, 11 Nov 2019 19:07:12 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 11 Nov 2019 16:07:13 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Mon, 11 Nov 2019 16:07:11 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Mon, 11 Nov 2019 16:07:11 -0800 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 12 Nov 2019 00:07:10 +0000 Received: from rnnvemgw01.nvidia.com (10.128.109.123) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Tue, 12 Nov 2019 00:07:09 +0000 Received: from blueforge.nvidia.com (Not Verified[10.110.48.28]) by rnnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Mon, 11 Nov 2019 16:07:09 -0800 From: John Hubbard To: Andrew Morton CC: Al Viro , Alex Williamson , Benjamin Herrenschmidt , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Christoph Hellwig , Dan Williams , Daniel Vetter , Dave Chinner , David Airlie , "David S . Miller" , Ira Weiny , Jan Kara , Jason Gunthorpe , Jens Axboe , Jonathan Corbet , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Magnus Karlsson , Mauro Carvalho Chehab , Michael Ellerman , Michal Hocko , Mike Kravetz , Paul Mackerras , Shuah Khan , Vlastimil Babka , , , , , , , , , , , , , LKML , John Hubbard Subject: [PATCH v3 06/23] IB/umem: use get_user_pages_fast() to pin DMA pages Date: Mon, 11 Nov 2019 16:06:43 -0800 Message-ID: <20191112000700.3455038-7-jhubbard@nvidia.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191112000700.3455038-1-jhubbard@nvidia.com> References: <20191112000700.3455038-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1573517233; bh=PPNQFWxgYbSBG60Oh3uZy3iaVFj8VG12aJVlvrNgBtA=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-NVConfidentiality: Content-Transfer-Encoding:Content-Type; b=KhLyNKkCzhj34VhXuUGSIyHKFQpNlddwQKTMNRSggrE3w/lk5jSmv2ZPbZbufxy2D DwaHNn9deLnwb+9S3bnPYQt2Y8a3N/x+xRd7lyCZjJtBVXS48USN4LyP/T0wSL31A9 PHqCuFVCls1I4InDR/rmL4jQ59eW6S2dzy1GP6jDulz/TY3IS2beeDr/v5uOBQkkt8 cgTue/HPtPzjoomkooCtsjx52sbOSGnuwdu4CRFlEX4ieAvkNbohjJOFrY+GPgctFC eybfSvcxdSFjY5MlzuusMY1vIOFT2942rU66o5rV0txugAXwkPygIU4TkcCtTuqA4d LT2EnhJx44zxw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org And get rid of the mmap_sem calls, as part of that. Note that get_user_pages_fast() will, if necessary, fall back to __gup_longterm_unlocked(), which takes the mmap_sem as needed. Reviewed-by: Ira Weiny Cc: Jason Gunthorpe Signed-off-by: John Hubbard --- drivers/infiniband/core/umem.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.= c index 24244a2f68cc..3d664a2539eb 100644 --- a/drivers/infiniband/core/umem.c +++ b/drivers/infiniband/core/umem.c @@ -271,16 +271,13 @@ struct ib_umem *ib_umem_get(struct ib_udata *udata, u= nsigned long addr, sg =3D umem->sg_head.sgl; =20 while (npages) { - down_read(&mm->mmap_sem); - ret =3D get_user_pages(cur_base, - min_t(unsigned long, npages, - PAGE_SIZE / sizeof (struct page *)), - gup_flags | FOLL_LONGTERM, - page_list, NULL); - if (ret < 0) { - up_read(&mm->mmap_sem); + ret =3D get_user_pages_fast(cur_base, + min_t(unsigned long, npages, + PAGE_SIZE / + sizeof(struct page *)), + gup_flags | FOLL_LONGTERM, page_list); + if (ret < 0) goto umem_release; - } =20 cur_base +=3D ret * PAGE_SIZE; npages -=3D ret; @@ -288,8 +285,6 @@ struct ib_umem *ib_umem_get(struct ib_udata *udata, uns= igned long addr, sg =3D ib_umem_add_sg_table(sg, page_list, ret, dma_get_max_seg_size(context->device->dma_device), &umem->sg_nents); - - up_read(&mm->mmap_sem); } =20 sg_mark_end(sg); --=20 2.24.0