Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp5223572ybb; Tue, 24 Mar 2020 13:12:27 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuSWC/AZJqkfCo1AE+uAR4PQ5juFHhWMyJblm2BLXXVaAdpTBFC8JarXYN/DojOA4psiyEG X-Received: by 2002:aca:fd09:: with SMTP id b9mr22363oii.88.1585080747082; Tue, 24 Mar 2020 13:12:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585080747; cv=none; d=google.com; s=arc-20160816; b=0WzP2iyTxdJvgYFxj+Lks4P64SL1nWj5/Sk3BL3NV4nV5RhnLSVECNkylwx+l3Q0v/ kVNastpKAKxTqbJJ6uzgeV11tHOs+/9VbViOkTvSAVIF7dYj380oQbd1f3srLBudynS5 3P0o5QSrCGNvnK8h8Nqo+6AnGW1XQjGJoiONLaQtbORDYqHhh/ZUHj3C30gZqe9ogTSc J3YDl3V7/KWZUwlIW8I6ucD1k1yR9X2hUmyi0Uy1oGgVkjdaaQ7OUN5hqxdMPOhoF8xa VMbUv1fYSkQTeMQZtgm3UAfS0mZnMg6LXBZqb04HbVb2JacIyZy4dS/JaAACTRE0G8Wu 2SQw== 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 :dkim-signature; bh=pYNAPEb1NZckcEJVxdLWJG2yG5GWfSpsfdbu9tXTAMc=; b=YbInYsfH8l/Hi/xwsDY6IWo1r2gxMD9fi4jkrp9VzIXa5GVPkVFIIWV+K3VO5QyouZ KgX4UdUnKXRLuC4Pug0llWcPx/jcz9eN4oxLfCLAU47Xaj72nwY7UD9+mD4XC/TPwzlT EeoUBJUwFnz1DDpAOnNCbyg31l30vnpgdwbqABiwf3POb30n9mj7qUY+oIhxkYct/EbB rH0yCTPDL0Pt4bYP+FMwWtumJinMeq73uA6ZQycGmigl6uxXYv8kCsGTssirjFn/FL+a 2fEifE7gwo6wSncjWF0SD6IRUKHekt6k6eWg2M+KD/ZlSR69rnGmweUcYLQsgONO1vT6 224g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@shipmail.org header.s=mail header.b=FnJNWVZ2; 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 y206si4420060oig.253.2020.03.24.13.12.14; Tue, 24 Mar 2020 13:12:27 -0700 (PDT) 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=fail (test mode) header.i=@shipmail.org header.s=mail header.b=FnJNWVZ2; 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 S1728113AbgCXULu (ORCPT + 99 others); Tue, 24 Mar 2020 16:11:50 -0400 Received: from pio-pvt-msa2.bahnhof.se ([79.136.2.41]:37910 "EHLO pio-pvt-msa2.bahnhof.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbgCXULs (ORCPT ); Tue, 24 Mar 2020 16:11:48 -0400 Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTP id 373543F504; Tue, 24 Mar 2020 21:11:46 +0100 (CET) Authentication-Results: pio-pvt-msa2.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=FnJNWVZ2; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Flag: NO X-Spam-Score: -2.099 X-Spam-Level: X-Spam-Status: No, score=-2.099 tagged_above=-999 required=6.31 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Received: from pio-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NsUB7riQ5ocS; Tue, 24 Mar 2020 21:11:41 +0100 (CET) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id EBB5E3F4E7; Tue, 24 Mar 2020 21:11:40 +0100 (CET) Received: from localhost.localdomain.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id 87B9B360308; Tue, 24 Mar 2020 21:11:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1585080700; bh=LllKBqw2wO4T5iGYWqMCexSSQNGBp2Vkl1w4YNHgngg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FnJNWVZ2FVePl3FNGME5FwHpcjnGLBsjHXUNR0BlfOXIHzYdyus3mEgodbgqsEoL6 yhAWDtTJlFUt2ReT31asqI0kmkUTByl3zNPv00xJR30ZQx4av/4oTrtBSMvmAHWJ8L p3QWRYlnrKAkhJPBNQ8i8vYA9ML/T/TKJFS0WjoU= From: =?UTF-8?q?Thomas=20Hellstr=C3=B6m=20=28VMware=29?= To: linux-mm@kvack.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: pv-drivers@vmware.com, linux-graphics-maintainer@vmware.com, "Thomas Hellstrom (VMware)" , Andrew Morton , Michal Hocko , "Matthew Wilcox (Oracle)" , "Kirill A. Shutemov" , Ralph Campbell , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , =?UTF-8?q?Christian=20K=C3=B6nig?= , Dan Williams Subject: [PATCH v7 2/9] mm: Introduce vma_is_special_huge Date: Tue, 24 Mar 2020 21:11:16 +0100 Message-Id: <20200324201123.3118-3-thomas_os@shipmail.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200324201123.3118-1-thomas_os@shipmail.org> References: <20200324201123.3118-1-thomas_os@shipmail.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Thomas Hellstrom (VMware)" For VM_PFNMAP and VM_MIXEDMAP vmas that want to support transhuge pages and -page table entries, introduce vma_is_special_huge() that takes the same codepaths as vma_is_dax(). The use of "special" follows the definition in memory.c, vm_normal_page(): "Special" mappings do not wish to be associated with a "struct page" (either it doesn't exist, or it exists but they don't want to touch it) For PAGE_SIZE pages, "special" is determined per page table entry to be able to deal with COW pages. But since we don't have huge COW pages, we can classify a vma as either "special huge" or "normal huge". Cc: Andrew Morton Cc: Michal Hocko Cc: "Matthew Wilcox (Oracle)" Cc: "Kirill A. Shutemov" Cc: Ralph Campbell Cc: "Jérôme Glisse" Cc: "Christian König" Cc: Dan Williams Signed-off-by: Thomas Hellstrom (VMware) Acked-by: Christian König Acked-by: Andrew Morton --- include/linux/mm.h | 17 +++++++++++++++++ mm/huge_memory.c | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index c54fb96cb1e6..bdd79a72bb42 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2867,6 +2867,23 @@ extern long copy_huge_page_from_user(struct page *dst_page, const void __user *usr_src, unsigned int pages_per_huge_page, bool allow_pagefault); + +/** + * vma_is_special_huge - Are transhuge page-table entries considered special? + * @vma: Pointer to the struct vm_area_struct to consider + * + * Whether transhuge page-table entries are considered "special" following + * the definition in vm_normal_page(). + * + * Return: true if transhuge page-table entries should be considered special, + * false otherwise. + */ +static inline bool vma_is_special_huge(const struct vm_area_struct *vma) +{ + return vma_is_dax(vma) || (vma->vm_file && + (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))); +} + #endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_HUGETLBFS */ #ifdef CONFIG_DEBUG_PAGEALLOC diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 24ad53b4dfc0..19c8d462ab08 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1802,7 +1802,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, orig_pmd = pmdp_huge_get_and_clear_full(tlb->mm, addr, pmd, tlb->fullmm); tlb_remove_pmd_tlb_entry(tlb, pmd, addr); - if (vma_is_dax(vma)) { + if (vma_is_special_huge(vma)) { if (arch_needs_pgtable_deposit()) zap_deposited_table(tlb->mm, pmd); spin_unlock(ptl); @@ -2066,7 +2066,7 @@ int zap_huge_pud(struct mmu_gather *tlb, struct vm_area_struct *vma, */ pudp_huge_get_and_clear_full(tlb->mm, addr, pud, tlb->fullmm); tlb_remove_pud_tlb_entry(tlb, pud, addr); - if (vma_is_dax(vma)) { + if (vma_is_special_huge(vma)) { spin_unlock(ptl); /* No zero page support yet */ } else { @@ -2175,7 +2175,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, */ if (arch_needs_pgtable_deposit()) zap_deposited_table(mm, pmd); - if (vma_is_dax(vma)) + if (vma_is_special_huge(vma)) return; page = pmd_page(_pmd); if (!PageDirty(page) && pmd_dirty(_pmd)) -- 2.21.1