Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1543047pxb; Thu, 16 Sep 2021 09:35:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqyp2pywjnvxewhRgJirvD1LlSOTsQTqQETk7fzmLly096+496ykfCSXF5noJAstmWC+am X-Received: by 2002:a05:6638:304b:: with SMTP id u11mr5070831jak.97.1631810108454; Thu, 16 Sep 2021 09:35:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631810108; cv=none; d=google.com; s=arc-20160816; b=MKgL0y0NMqd2WwihcX1m7wQniVOp46oZO+1gJy8xxlggpAnt93wEuCoktIALIqFkDB LE4ZycOzIEc/tefbLukHn/xYi+xYDM3Hu1qvydzIEh3d9CcaDHRIzYmVQJdn920WubY4 DEgz1k5TcewEESE8i410C5eJVdME9Vs3BNL6J76Pyhi8mj0/2mzGjOWc4yUV8SgIR1+j izCI+LPThwU/9ZvT3RhIBCCNYSjCWPYp3SOHYcIMD89IAnbX8z7kNYQ6/sXYzuAYDuCv vaEaLl0t8ziqvMtaLgNCXoSxIv/1yGd4sljbMU0C+jhqpuZUzCVHde8cTbKf5FW7BYH/ NAVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=edDPYT/7Smjd3hCoDINq9nHh4dmg9e5iRycIkKUAYSw=; b=TvfPadPM/rMSX8HKfOrPJ/2Q1LqWOoifQuNGhVZINMbeuPOUILJHyH49LzMzL3MqcV PDrDbIUmEc6QzHLlT2fJwyGIrQsBDZ8ObCo1IiIg2czgDfCz2lUXZipdou5EvkdjX1i4 uml8t5QdEXDQA89SvyVW7Sncnma81eY2bo9scLR7fg70LtemtCvrmVOMcVkKxszjWmus FZkCtUWrAOlJl8q6FdvO+nlybKU7VrP4fRzvDnqXF0i9dQy2fe9nuPmUbF6FFSrwS7YL ZglNWxNq41vqQFKd8Iqg+TLXcERt2MvVzZzzYtYwXvIciymvCcJLVQqi7TbEQUxNb/XC de8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uUGjPpW8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i11si3008406ilb.173.2021.09.16.09.34.52; Thu, 16 Sep 2021 09:35:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uUGjPpW8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243879AbhIPQe1 (ORCPT + 99 others); Thu, 16 Sep 2021 12:34:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:38936 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241917AbhIPQ00 (ORCPT ); Thu, 16 Sep 2021 12:26:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 874016152B; Thu, 16 Sep 2021 16:17:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809034; bh=IJKP0UOwGNAsWCUOhenYOs6dc+NNB1BXv5lIKAXqvbE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uUGjPpW8VCkEksRaNHh35ljkZqbPJUECCV8FffjYTbYxTvZaDoaiVPXcopHa+JOJs p9Z+4aFuPzlwPKIaz9y17VPts16QM1mPMZQNbOAGlBpu9m+k1o1v3W8bLmzBjKrJJQ 9S7xhPotsbn6vrWzd//WCoeiX3qFwgrvVmJ5P3x8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Li Zhijian , Christoph Hellwig , Jason Gunthorpe , Andrew Morton , Linus Torvalds Subject: [PATCH 5.10 288/306] mm/hmm: bypass devmap pte when all pfn requested flags are fulfilled Date: Thu, 16 Sep 2021 18:00:33 +0200 Message-Id: <20210916155803.924560407@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Li Zhijian commit 4b42fb213678d2b6a9eeea92a9be200f23e49583 upstream. Previously, we noticed the one rpma example was failed[1] since commit 36f30e486dce ("IB/core: Improve ODP to use hmm_range_fault()"), where it will use ODP feature to do RDMA WRITE between fsdax files. After digging into the code, we found hmm_vma_handle_pte() will still return EFAULT even though all the its requesting flags has been fulfilled. That's because a DAX page will be marked as (_PAGE_SPECIAL | PAGE_DEVMAP) by pte_mkdevmap(). Link: https://github.com/pmem/rpma/issues/1142 [1] Link: https://lkml.kernel.org/r/20210830094232.203029-1-lizhijian@cn.fujitsu.com Fixes: 405506274922 ("mm/hmm: add missing call to hmm_pte_need_fault in HMM_PFN_SPECIAL handling") Signed-off-by: Li Zhijian Reviewed-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/hmm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/mm/hmm.c +++ b/mm/hmm.c @@ -291,10 +291,13 @@ static int hmm_vma_handle_pte(struct mm_ goto fault; /* + * Bypass devmap pte such as DAX page when all pfn requested + * flags(pfn_req_flags) are fulfilled. * Since each architecture defines a struct page for the zero page, just * fall through and treat it like a normal page. */ - if (pte_special(pte) && !is_zero_pfn(pte_pfn(pte))) { + if (pte_special(pte) && !pte_devmap(pte) && + !is_zero_pfn(pte_pfn(pte))) { if (hmm_pte_need_fault(hmm_vma_walk, pfn_req_flags, 0)) { pte_unmap(ptep); return -EFAULT;