From patchwork Tue Jan 15 18:12:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 10764933 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 297666C5 for ; Tue, 15 Jan 2019 18:13:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CD2E2D467 for ; Tue, 15 Jan 2019 18:13:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10B772D4D8; Tue, 15 Jan 2019 18:13:37 +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=unavailable 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 976582D467 for ; Tue, 15 Jan 2019 18:13:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 662F48E0004; Tue, 15 Jan 2019 13:13:32 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5C4F08E0006; Tue, 15 Jan 2019 13:13:32 -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 43E488E0004; Tue, 15 Jan 2019 13:13:32 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id EEE8A8E0006 for ; Tue, 15 Jan 2019 13:13:31 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id q64so2531173pfa.18 for ; Tue, 15 Jan 2019 10:13:31 -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=aA+9kNc02EQmqMkRS/WiCkbnf0PIV936miLHkJ8CwR4=; b=ORNCT5d26U9EJnegARHAoPu5Mqwy5SbBjUpBcrZPdI7axmqT7BWQhTdBsZ74GC013D uU3OsDMrB857XpVyYO5sRFZXZU/TdKbWuKH0ZM+Z/XjEEfHKrjTZbDgsf+P7zYzz2wdP ArUa1EfCsBmO6nvmBfGunr/hxw7rDbIqDXJBxAvEwHkQh/bSzQaW2qQp5SfrfPWsKVCg F5zgQl9GSMpD8O2X2mxA6zrVlyKrR65UG9P3Ik/yk+8dEuMslu9PiS39q2X5R5LBIe1g k09ngJOIR5MxEqEYdcn7NAjNUL7D1TfSMTqXH5oDSGgtNCE6aCxM8jAkfiRTc2IHW/Lp UD6w== 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: AJcUukdZrdQQv+eKh4K51bMgDPSl9cYODZXtO2p8QBCMouIFpC4ORi2G LEYImNplYUE51nOrzGN7+68rD7dg135x76bMX3+JwyrYf0WcbErXWg8SzRh5zOnfU0yywQHHULy dN3132F7gCG32sekFkb2WQx5GLF1GhsqQrI4lWHCxCvja+RCF3wgCZ/86nv+9MJM= X-Received: by 2002:a17:902:f20d:: with SMTP id gn13mr5223099plb.11.1547576011629; Tue, 15 Jan 2019 10:13:31 -0800 (PST) X-Google-Smtp-Source: ALg8bN6G6YRRek+Ob6JVU9VIr3PBW+UEUNLGbaTpgqw39iMh507iW3lroyaX/bbaNE0NPp/3u0AH X-Received: by 2002:a17:902:f20d:: with SMTP id gn13mr5223051plb.11.1547576010863; Tue, 15 Jan 2019 10:13:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547576010; cv=none; d=google.com; s=arc-20160816; b=D2KDZn+Rjm/3a+U7NO43Bbkhd5nCzcjbkSfgo5nOCoaH2LOJ5/hGxCvmqfcTIdb5nt zIaaqBPcQkqSThACa5XHsFYSBzV5Bh4v9JmPy5g/QVV3JOADCUouwmaEy8z6+KDAj9nd qvoNGWS+kE5hO1kuawq38mYWgFRmOmOUzf0Nigoh6BfQSwRlZd7G+yYi4QPjO7GMJAox y8vgQ75vP5YWhgvATVfUCHP1AEnyOtgsUxoappkKxnjXLcu85Wn0x6arLE1mHT3WwJAc R5TcubA6FNHg9OVlFYrpfHlVHV3OicIZ2gKJwykOz5i9G4z/lN7oBl/6M/TFzL1YNs51 1MGg== 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=aA+9kNc02EQmqMkRS/WiCkbnf0PIV936miLHkJ8CwR4=; b=pKnDrzzkpj0fIiL1Q498ubppnd4ayiUmkKn/l+Lz/ZeEEa/ti+YrPso8zRZf9uS1k1 RYqCiYkAQxTJI3GaECRxbtQINs3x3T9USpotvbp/Rcv6YkHvC1S0BDh9s0soN898HvFa 2v5tR2ixbFtl17YgSGdIb4dmx9TXwv8X7h7yeV+JgLRoSliInILaUtM6ls4gAfKuJr0y XUgaWF8Ls2N3kq22ZfcNWurfJX4bS2g4Kzd/SBtFNH4ty56tnWpiSAEZs6lanxhzP98D 9nUuDuA5qV17XZ8ufwB6kzoIhblXKP7GLGnYsTtAhcnUIJsXsy5cLmIhB5Hbj9Q0npG/ 4DvA== 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 v75si3889866pfd.157.2019.01.15.10.13.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 10:13:30 -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); Tue, 15 Jan 2019 11:13:26 -0700 From: Davidlohr Bueso To: akpm@linux-foundation.org Cc: dledford@redhat.com, jgg@mellanox.com, linux-rdma@vger.kernel.org, linux-mm@kvack.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: Tue, 15 Jan 2019 10:12:58 -0800 Message-Id: <20190115181300.27547-5-dave@stgolabs.net> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190115181300.27547-1-dave@stgolabs.net> References: <20190115181300.27547-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 Signed-off-by: Davidlohr Bueso Reviewed-by: Ira Weiny --- 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 df86a596d746..f0c6f219f575 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 = atomic_long_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); atomic_long_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); atomic_long_sub(npages, &mm->pinned_vm); - up_write(&mm->mmap_sem); } }