From patchwork Mon Dec 7 11:31:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yulei zhang X-Patchwork-Id: 11955441 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 33EE6C433FE for ; Mon, 7 Dec 2020 11:34:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CE5B0233A0 for ; Mon, 7 Dec 2020 11:34:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE5B0233A0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 69E0B8D0014; Mon, 7 Dec 2020 06:34:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 674518D0001; Mon, 7 Dec 2020 06:34:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 589FF8D0014; Mon, 7 Dec 2020 06:34:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0225.hostedemail.com [216.40.44.225]) by kanga.kvack.org (Postfix) with ESMTP id 42DBF8D0001 for ; Mon, 7 Dec 2020 06:34:46 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 08832181AEF1F for ; Mon, 7 Dec 2020 11:34:46 +0000 (UTC) X-FDA: 77566278972.04.waste73_4117019273de Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id E0ACB8000422 for ; Mon, 7 Dec 2020 11:34:45 +0000 (UTC) X-HE-Tag: waste73_4117019273de X-Filterd-Recvd-Size: 5152 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Mon, 7 Dec 2020 11:34:45 +0000 (UTC) Received: by mail-pf1-f181.google.com with SMTP id q22so9591430pfk.12 for ; Mon, 07 Dec 2020 03:34:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PsVgOpQIgSKKX9sKyFMtyV6DCXy6X7BZeXZh0AyMkHE=; b=QMmaSsp/kPkYAOoJQsM9EoXqVH9lanjFe06YoMyS63YE92kVOJCcMfFXgEA7yjn87P y28+hU0OuDWvBX7SY2rxnQlWNrE6D+KzZK9M4ko1y+IRrfeYC8ZoXYQ5j/FHutEdRnUA CFnWcAyRmrIXQyQXqs6RE+G5CKAhGupvDHeYaQpkizYK/LR7w2A0MDaQ4i13inwSb1f4 eMV/GFBnZ9S+DZABkEr6AOMkeB8HeEP6uKXvczuBshAKSC1DzmYlsaa6DQXz6YZzMVS5 wqQYorLHoqsJF9fPQ4cEzpX39pO4YzMWouHhku6ju81R+o5U+fSNpP/dEc35m36/1jNg h5Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PsVgOpQIgSKKX9sKyFMtyV6DCXy6X7BZeXZh0AyMkHE=; b=VetbjZpvhgF7pllGYICaLELQzWXPv7Zpa/U5wwMrVouLiZxRCn7P69/Gu2aXQESVpH cuLOAqpAsM3Tln0WKlBYnvHzO2Vb3tqOtz0iiy18G1oADSezBoz+mUc6f93WmVlLtq2e tv53s4E4WNlG6emROrDTioaTQ03eq9YwvHcMTpGg2N6spgqJ54gva58ojfWSfhDuUVc8 3Uc3OYOboXxvqIAr8II03K1L3arYpM8niilpQ6k4mr6J8hAK3t8wV3KJgBEmQkGd16k7 AA3GiUCVR0fcND6ULWSzqq512EHbmZQf+MTxkGKQ4k3mGQZ84Mb7bf8g9bnktLFFIA0n jgjA== X-Gm-Message-State: AOAM533TE3AL9iChAn2JuKFgvpEyZXrRArrcoQLxPawwYRTvPUqFQ1Dc xoRRTyeQ5nORM8ksWyKgab3S1ohNPS8= X-Google-Smtp-Source: ABdhPJynrUsQxj48xNiMU/huEKvcNjt/ObGmP+cORAqqJJ7WrkW6MqDOQEZH+sv1gpYZpKvKfsdZ0g== X-Received: by 2002:a62:6d06:0:b029:19d:9728:2b71 with SMTP id i6-20020a626d060000b029019d97282b71mr15195431pfc.69.1607340884475; Mon, 07 Dec 2020 03:34:44 -0800 (PST) Received: from localhost.localdomain ([203.205.141.39]) by smtp.gmail.com with ESMTPSA id d4sm14219822pfo.127.2020.12.07.03.34.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Dec 2020 03:34:44 -0800 (PST) From: yulei.kernel@gmail.com X-Google-Original-From: yuleixzhang@tencent.com To: linux-mm@kvack.org, akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, naoya.horiguchi@nec.com, viro@zeniv.linux.org.uk, pbonzini@redhat.com Cc: joao.m.martins@oracle.com, rdunlap@infradead.org, sean.j.christopherson@intel.com, xiaoguangrong.eric@gmail.com, kernellwp@gmail.com, lihaiwei.kernel@gmail.com, Yulei Zhang , Chen Zhuo Subject: [RFC V2 19/37] mm: gup_huge_pmd() for dmem huge pmd Date: Mon, 7 Dec 2020 19:31:12 +0800 Message-Id: <1a8eaaf72af4bd98c8fa1a90d36a64612f7c14b0.1607332046.git.yuleixzhang@tencent.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Yulei Zhang Add pmd_special() check in gup_huge_pmd() to support dmem huge pmd. GUP will return zero if enconter dmem page, and we could handle it outside GUP routine. Signed-off-by: Chen Zhuo Signed-off-by: Yulei Zhang --- mm/gup.c | 6 +++++- mm/pagewalk.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index ad1aede..47c8197 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2470,6 +2470,10 @@ static int gup_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr, if (!pmd_access_permitted(orig, flags & FOLL_WRITE)) return 0; + /* Bypass dmem huge pmd. It will be handled in outside routine. */ + if (pmd_special(orig)) + return 0; + if (pmd_devmap(orig)) { if (unlikely(flags & FOLL_LONGTERM)) return 0; @@ -2572,7 +2576,7 @@ static int gup_pmd_range(pud_t *pudp, pud_t pud, unsigned long addr, unsigned lo return 0; if (unlikely(pmd_trans_huge(pmd) || pmd_huge(pmd) || - pmd_devmap(pmd))) { + pmd_devmap(pmd) || pmd_special(pmd))) { /* * NUMA hinting faults need to be handled in the GUP * slowpath for accounting purposes and so that they diff --git a/mm/pagewalk.c b/mm/pagewalk.c index e81640d..e7c4575 100644 --- a/mm/pagewalk.c +++ b/mm/pagewalk.c @@ -71,7 +71,7 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end, do { again: next = pmd_addr_end(addr, end); - if (pmd_none(*pmd) || (!walk->vma && !walk->no_vma)) { + if (pmd_none(*pmd) || (!walk->vma && !walk->no_vma) || pmd_special(*pmd)) { if (ops->pte_hole) err = ops->pte_hole(addr, next, depth, walk); if (err)