Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp191060imp; Tue, 19 Feb 2019 21:32:01 -0800 (PST) X-Google-Smtp-Source: AHgI3IbA0PJ4WkEibNLer0/KT89Q3wkW8ZyFfUP0DV+kpG7rec6q0UvwwtqKpy0zuoK28bD6BEoh X-Received: by 2002:a63:5207:: with SMTP id g7mr27802696pgb.253.1550640721786; Tue, 19 Feb 2019 21:32:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550640721; cv=none; d=google.com; s=arc-20160816; b=fX0tKNI8ADBE2pDGJtIxM8kgQtq7bphQwYETkf9gKVknYdezJZDwu12ZggtAYV4sFS TiyhFrUZJlq1Oai5Cy1/x5UikoZKPhai1s9jj8PyAlw6UFhxwmkgkYOI/vk8ZIO0N4fg QobJIC4SiTxAjx5FWcOjUAd8tytiLub95i8QQelXNbXft3sApOFv5tD0vE8H8KPMNKRD OQIfi1h5Ea94HlYHpyyS319RVzM93T/8OkYbOTNu61cg3vf2C/tGhYFqUJKgbOUJJzBy 1IzYrAQL4ExfU3xG6PEzTLPkK1O7tFQCB0eA1J36pdOUInzbUpllxQNNDO6k1f7JXhil IaSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=tgNdEt5FRga0HkLa8ndjlDXGyjg8hU5HkhXgPKbLuBo=; b=EOQtJkY/p3lHzkHcC6w1IylvcQlgbzSLQ8rMKDpOO8Q+3WrOB35vDFeJIoewSI72Ip kLB3uG+osoP+bxqvAGYVUDKugztjOJO4Ax8f8SBWibefvnpetZFJVFcUQAu9FgFOiwd5 Rq7qgJJrkRyquvWsODsvcZ8W0OCrqwwFxKpfjLDZ5zrJzjorQlcNsEmbuDSG0nXZ92vO GSUV+nCqD5zl/1g/x3LgRO2gdU9Uof7wCIyiRmoQDe/cbEVrWVWFAZuYydzsIGxpjt8g Jwycyw17LvcT2cymuRYQG2a/e0z9/Q2RiE8ZHNMs5UtVu942Xn7z5WkMgzcjhctb89jR rpkg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l17si243804pgm.541.2019.02.19.21.31.47; Tue, 19 Feb 2019 21:32:01 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730617AbfBTFbB (ORCPT + 99 others); Wed, 20 Feb 2019 00:31:01 -0500 Received: from mga06.intel.com ([134.134.136.31]:25315 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729770AbfBTFay (ORCPT ); Wed, 20 Feb 2019 00:30:54 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Feb 2019 21:30:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,388,1544515200"; d="scan'208";a="144924913" Received: from iweiny-desk2.sc.intel.com ([10.3.52.157]) by fmsmga002.fm.intel.com with ESMTP; 19 Feb 2019 21:30:50 -0800 From: ira.weiny@intel.com To: John Hubbard , Andrew Morton , Michal Hocko , "Kirill A. Shutemov" , Peter Zijlstra , Jason Gunthorpe , Benjamin Herrenschmidt , Paul Mackerras , "David S. Miller" , Martin Schwidefsky , Heiko Carstens , Rich Felker , Yoshinori Sato , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Ralf Baechle , Paul Burton , James Hogan Cc: Ira Weiny , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, linux-fpga@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, linux-media@vger.kernel.org, linux-scsi@vger.kernel.org, devel@driverdev.osuosl.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-fbdev@vger.kernel.org, xen-devel@lists.xenproject.org, devel@lists.orangefs.org, ceph-devel@vger.kernel.org, rds-devel@oss.oracle.com Subject: [RESEND PATCH 4/7] mm/gup: Add FOLL_LONGTERM capability to GUP fast Date: Tue, 19 Feb 2019 21:30:37 -0800 Message-Id: <20190220053040.10831-5-ira.weiny@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190220053040.10831-1-ira.weiny@intel.com> References: <20190220053040.10831-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ira Weiny DAX pages were previously unprotected from longterm pins when users called get_user_pages_fast(). Use the new FOLL_LONGTERM flag to check for DEVMAP pages and fall back to regular GUP processing if a DEVMAP page is encountered. Signed-off-by: Ira Weiny --- mm/gup.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 6f32d36b3c5b..f7e759c523bb 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1439,6 +1439,9 @@ static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end, goto pte_unmap; if (pte_devmap(pte)) { + if (unlikely(flags & FOLL_LONGTERM)) + goto pte_unmap; + pgmap = get_dev_pagemap(pte_pfn(pte), pgmap); if (unlikely(!pgmap)) { undo_dev_pagemap(nr, nr_start, pages); @@ -1578,8 +1581,11 @@ static int gup_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr, if (!pmd_access_permitted(orig, flags & FOLL_WRITE)) return 0; - if (pmd_devmap(orig)) + if (pmd_devmap(orig)) { + if (unlikely(flags & FOLL_LONGTERM)) + return 0; return __gup_device_huge_pmd(orig, pmdp, addr, end, pages, nr); + } refs = 0; page = pmd_page(orig) + ((addr & ~PMD_MASK) >> PAGE_SHIFT); @@ -1904,8 +1910,20 @@ int get_user_pages_fast(unsigned long start, int nr_pages, start += nr << PAGE_SHIFT; pages += nr; - ret = get_user_pages_unlocked(start, nr_pages - nr, pages, - gup_flags); + if (gup_flags & FOLL_LONGTERM) { + down_read(¤t->mm->mmap_sem); + ret = __gup_longterm_locked(current, current->mm, + start, nr_pages - nr, + pages, NULL, gup_flags); + up_read(¤t->mm->mmap_sem); + } else { + /* + * retain FAULT_FOLL_ALLOW_RETRY optimization if + * possible + */ + ret = get_user_pages_unlocked(start, nr_pages - nr, + pages, gup_flags); + } /* Have to be a bit careful with return values */ if (nr > 0) { -- 2.20.1