Received: by 10.223.176.5 with SMTP id f5csp2071630wra; Sun, 4 Feb 2018 19:55:10 -0800 (PST) X-Google-Smtp-Source: AH8x226mznaQVMwTL3w6nsJyY0QLSxl/3uSKnM1jB2QhJz1eKnOUnXyBvfEIweed45d/hw9DK+1g X-Received: by 2002:a17:902:b60b:: with SMTP id b11-v6mr21446734pls.210.1517802910269; Sun, 04 Feb 2018 19:55:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517802910; cv=none; d=google.com; s=arc-20160816; b=dvNDbgtiuO8NTZCW4nFkDGVPrYWieUaZecE7yXccxBFwh/NGGO5yU1StCvIlc44jTj SPOtovOWBtEqjvu25NI6Try3K1NAmorpkeIV9tZX7g9Boe9FTCZBuNN3uZMwFCv4SMXG 5DZzkeHYbgzrnF0+s3N64ttPW7V65Q9XzDSkgJDVRHQ5vMfDAPMmh/f9kK+O372/4TGU i+cgQa7NRx4nNr4a44B/jSIHEtV7j8V1rlC4DPfqHfJO1+qEjf3+57z9vdiftgo5BwUT jqATN96fFQDNF01SZ9usniHqS3rjnnGx2sjpcwyzSNgsBY2qwYgAgTRDrbx9hLMnS/oW 3Pww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=oyhaMKc98zzjM2lR68JGX3HbTNZjd9hxZPS3Eer4k3E=; b=TbfSQUeQHCDN6G/sNlveB///MxiXeIXbKkl4XunUmFbKxAQZq3UznHPRL5Q1WPWciq 3tH19j/NywI6ZjTgpnKEVyisKkCgQCUfFqXucwR0TPy/c6wAxON740IXa6Eu5elTUWAx LuGJ0PRpiflvISvOLZm4HO6gAHhuXvbyTgEHY1r92wCySmuqCoI0DJaWIf7TvDLogGtf ReCO0px/zKqMZp3gFXB/tsMrcjhAbTGhjwRj8mnEn/V7kivqX1RK3lA8Jo7SWLJ3gnyO ppPC/AokwK9l4ycghH1EQR3UiQRxc3zC2uQEtXuw/Yd4m0hb7N8TbtL5Y50FlrEinhbB i4zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=YYZaF94c; 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 l2-v6si39295pli.824.2018.02.04.19.54.56; Sun, 04 Feb 2018 19:55:10 -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=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=YYZaF94c; 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 S1752322AbeBEDyT (ORCPT + 99 others); Sun, 4 Feb 2018 22:54:19 -0500 Received: from mail-ot0-f195.google.com ([74.125.82.195]:46320 "EHLO mail-ot0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752082AbeBEDyM (ORCPT ); Sun, 4 Feb 2018 22:54:12 -0500 Received: by mail-ot0-f195.google.com with SMTP id f56so9271630otj.13 for ; Sun, 04 Feb 2018 19:54:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=oyhaMKc98zzjM2lR68JGX3HbTNZjd9hxZPS3Eer4k3E=; b=YYZaF94cG6QPyYhRvX9frREw+tpnloKKVlnZv0RMHcJMzvLGEDQiXsnKIaVOzEnwEi u1beBLh0XrjKHyVM1rmdw1XhbotP8CJ3ALoTCN8c1NCYcK6Vcugx8d8fNYEbpc8KfFwR cyLlmuC8uQ1cHcMU/vmntg7H+SmmH10On6JpJQ5kwoowembvqZ5cgHh4HyI6emBl/ctm LlBmmzlX3iomf51Qnl3Rw2V9lMoufeE2eOAIkQPzR6EatmrhHCJyfkY4ehG2Pa9R+l5u DTd3TwqV1+NdpDl8WvLqfk7YgD/J3gwBeHIgQ+rXgocNA47jP/i1zJb5uwRUavbxW83k kXJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=oyhaMKc98zzjM2lR68JGX3HbTNZjd9hxZPS3Eer4k3E=; b=NYNTtLylMHqCVGtGwtHYRQoIPpHuquxnRt4VrdE3yR70ukmDcRzaiH7rNmxpbAWMzc svKp0jLD1ROGwDBhOHfKcMdUW4EIc9X7JHpla1H0i99OSxSQxrCHlMwyML8rWks9Oy35 PTLfZrTtosgBKAbMuke2L4SQ0ZY9BXCO/TxVPGNYFYEy5r9CA0fO4jxVxHOrgATpKKUA DyS+BsbhtMOiDNPlHlHFtgWcLRFuwHf/3FZFb2jip5M0FxUDVGXdgSjjiR1xYRY7TdsG 8Ku3evbw9B/SWtxmFw1aeZUZcsD79uJ+03U+AaFeaZw0ipsz6MLuSaKD10KbWsZNb2XJ FSOw== X-Gm-Message-State: AKwxytcW8qcgDn+QvaBuhge5uCGZOvliSXGZ6EdRnatDiHGOFMTntMuM iMbr7KFSyJJwHsapstEb16qvNDUu6QjpWApRm7NkfQ== X-Received: by 10.157.36.137 with SMTP id z9mr13586671ota.175.1517802852290; Sun, 04 Feb 2018 19:54:12 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.62.91 with HTTP; Sun, 4 Feb 2018 19:54:11 -0800 (PST) In-Reply-To: <20180205034653.mfnla2nq55ikkhav@hz-desktop> References: <151778551496.7139.17808629759104553625.stgit@dwillia2-desk3.amr.corp.intel.com> <151778553083.7139.6601964812589807125.stgit@dwillia2-desk3.amr.corp.intel.com> <20180205034653.mfnla2nq55ikkhav@hz-desktop> From: Dan Williams Date: Sun, 4 Feb 2018 19:54:11 -0800 Message-ID: Subject: Re: [PATCH 3/3] vfio: disable filesystem-dax page pinning To: Dan Williams , Alex Williamson , Michal Hocko , Jan Kara , KVM list , linux-nvdimm@lists.01.org, Linux Kernel Mailing List , stable@vger.kernel.org, linux-fsdevel , Christoph Hellwig Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Feb 4, 2018 at 7:46 PM, Haozhong Zhang wrote: > On 02/04/18 15:05 -0800, Dan Williams wrote: >> Filesystem-DAX is incompatible with 'longterm' page pinning. Without >> page cache indirection a DAX mapping maps filesystem blocks directly. >> This means that the filesystem must not modify a file's block map while >> any page in a mapping is pinned. In order to prevent the situation of >> userspace holding of filesystem operations indefinitely, disallow >> 'longterm' Filesystem-DAX mappings. >> >> RDMA has the same conflict and the plan there is to add a 'with lease' >> mechanism to allow the kernel to notify userspace that the mapping is >> being torn down for block-map maintenance. Perhaps something similar can >> be put in place for vfio. >> >> Note that xfs and ext4 still report: >> >> "DAX enabled. Warning: EXPERIMENTAL, use at your own risk" >> >> ...at mount time, and resolving the dax-dma-vs-truncate problem is one >> of the last hurdles to remove that designation. >> >> Cc: Alex Williamson >> Cc: Michal Hocko >> Cc: Christoph Hellwig >> Cc: kvm@vger.kernel.org >> Cc: >> Reported-by: Haozhong Zhang >> Fixes: d475c6346a38 ("dax,ext2: replace XIP read and write with DAX I/O") >> Signed-off-by: Dan Williams >> --- >> drivers/vfio/vfio_iommu_type1.c | 18 +++++++++++++++--- >> 1 file changed, 15 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c >> index e30e29ae4819..45657e2b1ff7 100644 >> --- a/drivers/vfio/vfio_iommu_type1.c >> +++ b/drivers/vfio/vfio_iommu_type1.c >> @@ -338,11 +338,12 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr, >> { >> struct page *page[1]; >> struct vm_area_struct *vma; >> + struct vm_area_struct *vmas[1]; >> int ret; >> >> if (mm == current->mm) { >> - ret = get_user_pages_fast(vaddr, 1, !!(prot & IOMMU_WRITE), >> - page); >> + ret = get_user_pages_longterm(vaddr, 1, !!(prot & IOMMU_WRITE), >> + page, vmas); > > vmas is not used subsequently if this branch is taken, so can we use > NULL here? I'd rather go the other way and refactor this a bit further to skip the find_vma_intersection() below since get_user_pages() already does that work.