From patchwork Fri Aug 27 14:45:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 12462199 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-21.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99C39C4320E for ; Fri, 27 Aug 2021 14:40:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 81AAC60F4C for ; Fri, 27 Aug 2021 14:40:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233058AbhH0OlM (ORCPT ); Fri, 27 Aug 2021 10:41:12 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:9944 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231327AbhH0OlK (ORCPT ); Fri, 27 Aug 2021 10:41:10 -0400 IronPort-HdrOrdr: A9a23:2npoUagCEbajKHeHnHDuQbZJ3XBQXr8ji2hC6mlwRA09TyX4raCTdZsguCMc5Ax6ZJhCo7G90cu7Lk80nKQdieIs1N+ZLWrbUQCTQL2Kg7GN/wHd X-IronPort-AV: E=Sophos;i="5.84,356,1620662400"; d="scan'208";a="113573694" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 27 Aug 2021 22:40:18 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id F288C4D0DC6D; Fri, 27 Aug 2021 22:40:14 +0800 (CST) Received: from G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.85) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 27 Aug 2021 22:40:15 +0800 Received: from localhost.localdomain (10.167.225.141) by G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.23 via Frontend Transport; Fri, 27 Aug 2021 22:40:14 +0800 From: Li Zhijian To: , , , , CC: , , Li Zhijian , Subject: [PATCH] mm/hmm: bypass devmap pte when all pfn requested flags are fulfilled Date: Fri, 27 Aug 2021 22:45:00 +0800 Message-ID: <20210827144500.2148-1-lizhijian@cn.fujitsu.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-yoursite-MailScanner-ID: F288C4D0DC6D.AEC5F X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: lizhijian@fujitsu.com Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Previously, we noticed the one rpma example was failed[1] since 36f30e486d, 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(). [1]: https://github.com/pmem/rpma/issues/1142 CC: stable@vger.kernel.org Signed-off-by: Li Zhijian --- mm/hmm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/hmm.c b/mm/hmm.c index fad6be2bf072..4766bdefb6c3 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -294,6 +294,12 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr, if (required_fault) goto fault; + /* + * just bypass devmap pte such as DAX page when all pfn requested + * flags(pfn_req_flags) are fulfilled. + */ + if (pte_devmap(pte)) + goto out; /* * Since each architecture defines a struct page for the zero page, just * fall through and treat it like a normal page. @@ -307,6 +313,7 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr, return 0; } +out: *hmm_pfn = pte_pfn(pte) | cpu_flags; return 0;