Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6732131ybx; Mon, 11 Nov 2019 13:48:39 -0800 (PST) X-Google-Smtp-Source: APXvYqzNP4ZVonIuPrEqW+S4qCSmeV3jx67e/FKyeE7npI5FjPntdAFFBrwatMVahpjXZDwJLB21 X-Received: by 2002:a17:906:594f:: with SMTP id g15mr25737253ejr.197.1573508919424; Mon, 11 Nov 2019 13:48:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573508919; cv=none; d=google.com; s=arc-20160816; b=d8tXh/iYgtWEjriP0si9FZRTUHoICuAx/PagoPvkGWXOeIIW11CDVpabw1HmpJUPnT +KGdG0kN6AjAnS4RtvQb4pduDP2CDnnCIUBQh2ikMGvqI5XjQ0ISR6HNIzqtW2XChd2P BP6naGm84vl2kXOVQOQ/FiEvHp7Rz8kYRtxhjnThLejdDBR7zl7JIPjzH0qq/9b1xhSY lmVRdIc3H9wNXKVNjgyg77Pv+36Hpzvnp2wdHKg0Kca5AFSp/iGzNvk6awJd6sxyUDBf WiYjaZa0SvdrrUDVoBUffmHvchCRCMppQl1Xxc//dnMeydV0evsvEgd6KgTPhbe8BUNj bjSQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=yieNXEWI2py9mI29IscrDXJH38weu1ilyh60Q2W8ILg=; b=sY3IgxwWUYZhYnsaNXUbDybj6HOp4mJlnDcrZrmnT56mLPSmbr1uWGdEzLcP89gbVe wZp6xkbNihp9chGn5YWKvDNNAZZrvYuLKrhkn8Wn+L28vt+TxZbOq3pjE9JjxPQlug8a Qoy1DqURnZhxIXseVrJBjOC6p3/+fqn3xT5I5ibzeCbvyQ70J/Cq2GlSVvm25vIK4seX ygDb95/IXrW8aoFRvZRsNds7GFz/eilYa3u+lk8vYjT3fqJG5ppVZyz77AaE/3TA6JUC Rl9zMEG4XrTZca+fwnmNHHJxkHs0vdxi+Y2kmU0m2zRVSOpPtZlRnofiNzFcsYzEOv33 zEvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=JjTN4WKJ; 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 d15si11318924edn.49.2019.11.11.13.48.15; Mon, 11 Nov 2019 13:48:39 -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=JjTN4WKJ; 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 S1727325AbfKKVoJ (ORCPT + 99 others); Mon, 11 Nov 2019 16:44:09 -0500 Received: from hqemgate15.nvidia.com ([216.228.121.64]:9312 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727040AbfKKVoI (ORCPT ); Mon, 11 Nov 2019 16:44:08 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 11 Nov 2019 13:43:06 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Mon, 11 Nov 2019 13:44:08 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Mon, 11 Nov 2019 13:44:08 -0800 Received: from [10.110.48.28] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 11 Nov 2019 21:44:07 +0000 Subject: Re: [PATCH 1/1] IB/umem: use get_user_pages_fast() to pin DMA pages To: Ira Weiny CC: Andrew Morton , Jason Gunthorpe , , , LKML References: <20191109020434.389855-1-jhubbard@nvidia.com> <20191109020434.389855-2-jhubbard@nvidia.com> <20191111032111.GA30123@iweiny-DESK2.sc.intel.com> From: John Hubbard X-Nvconfidentiality: public Message-ID: <1730ced5-a280-1825-54fe-61b9340f8ac6@nvidia.com> Date: Mon, 11 Nov 2019 13:44:07 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20191111032111.GA30123@iweiny-DESK2.sc.intel.com> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1573508586; bh=yieNXEWI2py9mI29IscrDXJH38weu1ilyh60Q2W8ILg=; h=X-PGP-Universal:Subject:To:CC:References:From:X-Nvconfidentiality: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=JjTN4WKJKNmGnmx0Ulub6NGPQ+dTDSHthvdAaABKuIKi5DQxmHuxZaBwqfxJBaEgs 6skuSdfqoL9H6AcvRF0VgBGA2jdfUsmrGtQFiwnZMJW0Zamo5LVsIqGsi2qLpptu+L RDXRE6hmfQGYZOfR0T8pFLWAUXk/+KM7k1QQpHhRLgsQtZBCE/oGidV/vbcIATvpBn 66Rr/yI7VXRJjdVCWaQGOTOmAxs3kcDwbfXhY2z2wRPfuzEGtVY9c2BxlwRxv1T3bb zBnwTH8LRmI3fay5kjUkkBTmP5NXnDRRGa8tgHrvw74cPxKv/Wb3Mu6KtvWPGNxt5Y wjBZxXvUu1zlg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/10/19 7:21 PM, Ira Weiny wrote: > On Fri, Nov 08, 2019 at 06:04:34PM -0800, John Hubbard wrote: >> 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. >> >> Cc: Jason Gunthorpe >> Cc: Ira Weiny > > Reviewed-by: Ira Weiny > Thanks for the review, Ira! This will show up shortly, in the v3 series of "mm/gup: track dma-pinned pages: FOLL_PIN, FOLL_LONGTERM". thanks, -- John Hubbard NVIDIA >> 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, unsigned long addr, >> sg = umem->sg_head.sgl; >> >> while (npages) { >> - down_read(&mm->mmap_sem); >> - ret = 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 = 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; >> - } >> >> cur_base += ret * PAGE_SIZE; >> npages -= ret; >> @@ -288,8 +285,6 @@ struct ib_umem *ib_umem_get(struct ib_udata *udata, unsigned long addr, >> sg = 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); >> } >> >> sg_mark_end(sg); >> -- >> 2.24.0 >> >