From patchwork Mon Jan 21 17:42:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 10774261 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B5A08139A for ; Mon, 21 Jan 2019 17:43:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A070D29F0F for ; Mon, 21 Jan 2019 17:43:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 946C12A6E0; Mon, 21 Jan 2019 17:43:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3206C29F0F for ; Mon, 21 Jan 2019 17:43:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B5F088E0007; Mon, 21 Jan 2019 12:43:07 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A26B38E0001; Mon, 21 Jan 2019 12:43:07 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 824188E0007; Mon, 21 Jan 2019 12:43:07 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.70]) by kanga.kvack.org (Postfix) with ESMTP id 5B38F8E0001 for ; Mon, 21 Jan 2019 12:43:07 -0500 (EST) Received: by mail-ot1-f70.google.com with SMTP id p4so8528617otl.10 for ; Mon, 21 Jan 2019 09:43:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=XS5BzN3Kh9mSORepzR9fJCwL4sFTMLrvBU/dIXdFFj4=; b=uBfBWzKGBgwCHE3WgnoGj5y2HiQ6Z2csTI0SBvIu746MVg6hLHJN60s3IzITenDHup x4IOb0kfXdDeS9dRixkSH4mZTM9dQ2fgCfbIdx2G9WWNJPOMUBJhYwdHgKhft9TES5Dz s5Jm4uy+wqv3GqgdK/KPlrp0A3PUK5nX+8JPPc7m9lOHZgoldojIpiemi5OTElhJ6OKN 6hmeLmu/ieVC+Gscnyr7dtjehyu3AoQKLmQprCRQia+cQHmwKeKIlFdmLhdtt6q2jPVM d0w4r7sE4zNyZheRCe8Q82Jkz2ZwQ93eW8i5YO7G1f0tVi8BQQIId+hBU26c/V4mo/Iq a/UQ== X-Original-Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning dave@stgolabs.net does not designate 137.65.250.81 as permitted sender) smtp.mailfrom=dave@stgolabs.net X-Gm-Message-State: AJcUukcVwzAM3aNP6Z6tBnuWwxaFgAqcz79jNJ4GfO2E77Lj+NxdGeHs T1gDH8ku6a1/0SBbLjjtYvcVRqpClytanRNn1YcbvJ4uzYIFmWdr8VyOOjOIF/OnIVkRXPckkD2 Lej+r20/YgHEtxWjLf1KJPcjqG3WBTge8VQHwHO+I1lwr6ASE9FsAkQuqzjZrFKc= X-Received: by 2002:a9d:4a87:: with SMTP id i7mr20515441otf.178.1548092587035; Mon, 21 Jan 2019 09:43:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN4pDISLLe5Cw/x1B+Kh3Bu57GjYhNn8XVOn5fhUzsnzGt/CvndZoLJw7iKeXjvb6pRiyB1d X-Received: by 2002:a9d:4a87:: with SMTP id i7mr20515406otf.178.1548092586399; Mon, 21 Jan 2019 09:43:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548092586; cv=none; d=google.com; s=arc-20160816; b=nsppjvPv/2fp8AFf9fFKKMs0ac3MXkGlKdReNm1i6evzHpnGtJsClvKPOzszfOel7F evve0+7UrRgBhqxvxGFh9coFGvDOLrhr1Z6mvIyWqBv0CYAXoaV14Z0FdhfH8+Gz3luN 5ln8HotyyT8YqjfyFYTkeNSQl7p2WPaUuBYAbK/+9wYp/YO1uOuAmqRdOq9DYni0sczx MSQVACz0CyaUIRE9MH7MlaATEPKMuGX7DZeiUVJLwIBsq3GVtx+Pls6+xiDyGZunHucO Xsc4/4rU7WuCX4hJ13MFC+oXWA1BOhQEoE1QYrWCnuX+BAq98ldDe6UtfHp1yksC2F8O i9Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=XS5BzN3Kh9mSORepzR9fJCwL4sFTMLrvBU/dIXdFFj4=; b=VS8LDqQgQEGALHZZCil6aagg7jyHx6JPg59Y4yijQrB2fU5BNZbC4eWQSNi7isaTzh ba7Vhemije2+Hw8IGT2mUSNdNIaxkTCkPbI6vNz2rZ7/QQ3ofNtu34MS7ogHoXSjhEqd o/U/wrbWOZ6i286J6uwjKwds3CT1WhvLRT2QvTvMDn2xtFtQxzCk9HkmRUBRAVdEZ+Hk GwoYqfQH2tRjXrdnusEfbnGA2UKocLWAvt88ebV23JT/zkKOmRdbxQDOeyR0NXs7izGB L72Hnwj7TbvBz163kf26Sx5ohX9NdnTX88lsC69kPlJgt2r+q1K1WS/yjCG2LRyE8c1Z V4Fw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning dave@stgolabs.net does not designate 137.65.250.81 as permitted sender) smtp.mailfrom=dave@stgolabs.net Received: from smtp2.provo.novell.com (smtp2.provo.novell.com. [137.65.250.81]) by mx.google.com with ESMTPS id g14si5859734otj.14.2019.01.21.09.43.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 09:43:06 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning dave@stgolabs.net does not designate 137.65.250.81 as permitted sender) client-ip=137.65.250.81; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning dave@stgolabs.net does not designate 137.65.250.81 as permitted sender) smtp.mailfrom=dave@stgolabs.net Received: from localhost.localdomain (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Mon, 21 Jan 2019 10:42:57 -0700 From: Davidlohr Bueso To: akpm@linux-foundation.org Cc: dledford@redhat.com, jgg@mellanox.com, jack@suse.de, ira.weiny@intel.com, linux-rdma@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, dave@stgolabs.net, mike.marciniszyn@intel.com, dennis.dalessandro@intel.com, Davidlohr Bueso Subject: [PATCH 4/6] drivers/IB,hfi1: do not se mmap_sem Date: Mon, 21 Jan 2019 09:42:18 -0800 Message-Id: <20190121174220.10583-5-dave@stgolabs.net> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190121174220.10583-1-dave@stgolabs.net> References: <20190121174220.10583-1-dave@stgolabs.net> 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: X-Virus-Scanned: ClamAV using ClamSMTP This driver already uses gup_fast() and thus we can just drop the mmap_sem protection around the pinned_vm counter. Note that the window between when hfi1_can_pin_pages() is called and the actual counter is incremented remains the same as mmap_sem was _only_ used for when ->pinned_vm was touched. Cc: mike.marciniszyn@intel.com Cc: dennis.dalessandro@intel.com Reviewed-by: Ira Weiny Signed-off-by: Davidlohr Bueso --- drivers/infiniband/hw/hfi1/user_pages.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/user_pages.c b/drivers/infiniband/hw/hfi1/user_pages.c index 40a6e434190f..24b592c6522e 100644 --- a/drivers/infiniband/hw/hfi1/user_pages.c +++ b/drivers/infiniband/hw/hfi1/user_pages.c @@ -91,9 +91,7 @@ bool hfi1_can_pin_pages(struct hfi1_devdata *dd, struct mm_struct *mm, /* Convert to number of pages */ size = DIV_ROUND_UP(size, PAGE_SIZE); - down_read(&mm->mmap_sem); pinned = atomic64_read(&mm->pinned_vm); - up_read(&mm->mmap_sem); /* First, check the absolute limit against all pinned pages. */ if (pinned + npages >= ulimit && !can_lock) @@ -111,9 +109,7 @@ int hfi1_acquire_user_pages(struct mm_struct *mm, unsigned long vaddr, size_t np if (ret < 0) return ret; - down_write(&mm->mmap_sem); atomic64_add(ret, &mm->pinned_vm); - up_write(&mm->mmap_sem); return ret; } @@ -130,8 +126,6 @@ void hfi1_release_user_pages(struct mm_struct *mm, struct page **p, } if (mm) { /* during close after signal, mm can be NULL */ - down_write(&mm->mmap_sem); atomic64_sub(npages, &mm->pinned_vm); - up_write(&mm->mmap_sem); } }