Received: by 10.223.176.5 with SMTP id f5csp1990761wra; Sun, 4 Feb 2018 17:36:15 -0800 (PST) X-Google-Smtp-Source: AH8x2244otGvFMpXkMxNOWa9Qh9fqV8JQPaft60dFGvioVJGjBwzaGe/70RYYV+8l4QEJMPQ++kB X-Received: by 2002:a17:902:6c0c:: with SMTP id q12-v6mr33917660plk.51.1517794575564; Sun, 04 Feb 2018 17:36:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517794575; cv=none; d=google.com; s=arc-20160816; b=i6Z109t70tT8py16XPWoL3S1jwNEKWW16sYeWvsdGwmoI/+gQgx9PNF/EcTG0A2Acv fjvai8x/g9xGrfme87aM0cgYOQppz6uC7k3THmL6siXKcW8DHfTe0O1XRPazXAFZeEWC gbPzD96rpClpE6lxmvJHF6vsw38E1QQiA2ZKE7O7t7kQN36Y5RCOxVP/AUasYl+oU9XY qpwi9Vg/boVjT92s9Ffk0xgewC5NE/IICfT0q4ZUIedYZRXmeFDWOUjPyUvvoyQLtpAJ 4pMy6lXK/nw++vbLzTzDaRzLkEN4GeiMW96zKVwC87PKzsvYQVEGawshTmF7TD6apoVy Vw9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=THdIJk3RH6mInz/Dnj9SfFLL9yYar5Wp9/XZHkgOidk=; b=qfKp8PiwELr1M6R4FRwUaX4cRLtp/Vz2ETatTB9RVD472AW0EfgEsTF3b56x8d/fqL W+1o1/aUMF3QZzX1yawy7P4KNqHSqhDkQDHWEohlI/YJMmhwDyPoxuhMeBIn2BZVG2ZK P7YBSfokK2aG15IMpIgH4UL4w3Ub07QD1u1Jh8X0ld6eptYcLc7o5852pR0LMoH5Nhd7 lmAkHonBd7VqeaDSXGyerRe6jTfYFEhyGGuEemgnD0yq4KzRnxmIFXHuebzZ97Vy6Uqy Y1Zx0lf/EDjAw69Hq0H9CbL4PhYJ/Y5nn6scdvAjP3qtH2HrrHGq2x/CimWXqxIxgeNT m10g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 126si3235540pfe.390.2018.02.04.17.36.01; Sun, 04 Feb 2018 17:36:15 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752386AbeBEBdy (ORCPT + 99 others); Sun, 4 Feb 2018 20:33:54 -0500 Received: from mx2.suse.de ([195.135.220.15]:44091 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752507AbeBEB3T (ORCPT ); Sun, 4 Feb 2018 20:29:19 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 89197AE1A; Mon, 5 Feb 2018 01:28:01 +0000 (UTC) From: Davidlohr Bueso To: akpm@linux-foundation.org, mingo@kernel.org Cc: peterz@infradead.org, ldufour@linux.vnet.ibm.com, jack@suse.cz, mhocko@kernel.org, kirill.shutemov@linux.intel.com, mawilcox@microsoft.com, mgorman@techsingularity.net, dave@stgolabs.net, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: [PATCH 60/64] drivers/xen: use mm locking wrappers Date: Mon, 5 Feb 2018 02:27:50 +0100 Message-Id: <20180205012754.23615-61-dbueso@wotan.suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180205012754.23615-1-dbueso@wotan.suse.de> References: <20180205012754.23615-1-dbueso@wotan.suse.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Davidlohr Bueso All callers use mmap_sem within the same function context. No change in semantics. Signed-off-by: Davidlohr Bueso --- drivers/xen/gntdev.c | 5 +++-- drivers/xen/privcmd.c | 12 +++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index bd56653b9bbc..9181eee4e160 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c @@ -648,12 +648,13 @@ static long gntdev_ioctl_get_offset_for_vaddr(struct gntdev_priv *priv, struct vm_area_struct *vma; struct grant_map *map; int rv = -EINVAL; + DEFINE_RANGE_LOCK_FULL(mmrange); if (copy_from_user(&op, u, sizeof(op)) != 0) return -EFAULT; pr_debug("priv %p, offset for vaddr %lx\n", priv, (unsigned long)op.vaddr); - down_read(¤t->mm->mmap_sem); + mm_read_lock(current->mm, &mmrange); vma = find_vma(current->mm, op.vaddr); if (!vma || vma->vm_ops != &gntdev_vmops) goto out_unlock; @@ -667,7 +668,7 @@ static long gntdev_ioctl_get_offset_for_vaddr(struct gntdev_priv *priv, rv = 0; out_unlock: - up_read(¤t->mm->mmap_sem); + mm_read_unlock(current->mm, &mmrange); if (rv == 0 && copy_to_user(u, &op, sizeof(op)) != 0) return -EFAULT; diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c index 1c909183c42a..3736752556c5 100644 --- a/drivers/xen/privcmd.c +++ b/drivers/xen/privcmd.c @@ -257,6 +257,7 @@ static long privcmd_ioctl_mmap(struct file *file, void __user *udata) int rc; LIST_HEAD(pagelist); struct mmap_gfn_state state; + DEFINE_RANGE_LOCK_FULL(mmrange); /* We only support privcmd_ioctl_mmap_batch for auto translated. */ if (xen_feature(XENFEAT_auto_translated_physmap)) @@ -276,7 +277,7 @@ static long privcmd_ioctl_mmap(struct file *file, void __user *udata) if (rc || list_empty(&pagelist)) goto out; - down_write(&mm->mmap_sem); + mm_write_lock(mm, &mmrange); { struct page *page = list_first_entry(&pagelist, @@ -301,7 +302,7 @@ static long privcmd_ioctl_mmap(struct file *file, void __user *udata) out_up: - up_write(&mm->mmap_sem); + mm_write_unlock(mm, &mmrange); out: free_page_list(&pagelist); @@ -451,6 +452,7 @@ static long privcmd_ioctl_mmap_batch( unsigned long nr_pages; LIST_HEAD(pagelist); struct mmap_batch_state state; + DEFINE_RANGE_LOCK_FULL(mmrange); switch (version) { case 1: @@ -497,7 +499,7 @@ static long privcmd_ioctl_mmap_batch( } } - down_write(&mm->mmap_sem); + mm_write_lock(mm, &mmrange); vma = find_vma(mm, m.addr); if (!vma || @@ -553,7 +555,7 @@ static long privcmd_ioctl_mmap_batch( BUG_ON(traverse_pages_block(m.num, sizeof(xen_pfn_t), &pagelist, mmap_batch_fn, &state)); - up_write(&mm->mmap_sem); + mm_write_unlock(mm, &mmrange); if (state.global_error) { /* Write back errors in second pass. */ @@ -574,7 +576,7 @@ static long privcmd_ioctl_mmap_batch( return ret; out_unlock: - up_write(&mm->mmap_sem); + mm_write_unlock(mm, &mmrange); goto out; } -- 2.13.6