From patchwork Mon Apr 29 17:22:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 10922173 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E83E14B6 for ; Mon, 29 Apr 2019 17:22:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82AD8251F4 for ; Mon, 29 Apr 2019 17:22:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 76FCF286AC; Mon, 29 Apr 2019 17:22:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D49F8251F4 for ; Mon, 29 Apr 2019 17:22:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A6E206B0005; Mon, 29 Apr 2019 13:22:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9F5CE6B0007; Mon, 29 Apr 2019 13:22:30 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E67A6B0008; Mon, 29 Apr 2019 13:22:30 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id 4232B6B0005 for ; Mon, 29 Apr 2019 13:22:30 -0400 (EDT) Received: by mail-ed1-f69.google.com with SMTP id f17so5159867edq.3 for ; Mon, 29 Apr 2019 10:22:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=2eKKxYJ9+/a0EhcYiOjWwiTGOV8tvC7ALn17if7OocU=; b=fSn9kSLNP8CVS3NSH52unUfSToeobFeEZWrRrXR872QC0RfLHpGmUgRO3xbn09L80z r1+cKd20x4lPDwOCWlEgmk35KV+hZdoM3T8KtKgKpWfql14PbyPVGtYC9MQI0RMh3Hv4 NlcHN343bIsAPSS2XiOYtJKINsFr3gBmH3GWp2Gyuj3ctS7WDkORt45xT9xbYV6sAEpQ Nl9Gl5FV4Ojt82QfHjRFMS4EAywGkb1VB+MTGtRA50oDvc6UGBhn6Di1QbNNUfD7dHSw NorKapF2uI354uYicnxEjkroPbr462NUFNtDdaH/VGdYHKS2/MChxqRKteTm3qFJzLVZ SySw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of robin.murphy@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=robin.murphy@arm.com X-Gm-Message-State: APjAAAXDZgb3oNlbnmnHO+1ThlzhrDzH4X72KQKD+ZMWNGG9avhU9khx LdqV4m++peIZHmO2FqqndGncUHpfqmRMBTu5siiNeoDeOqICSZnYz+BZll+bzYmI4VEArK4C6SQ brcG207nhbWsq7/5b8guYS6Sf78lzyJPIqUoTnV6uCSxwIvXmTxCvQdidaBWafZyFfQ== X-Received: by 2002:a50:a3c2:: with SMTP id t2mr39466726edb.46.1556558549786; Mon, 29 Apr 2019 10:22:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxM05fa+S12u+/pAWFRMFetLpGKd0nIIYBDMKaYF7un27LgBOopgh9/t3uQd//et/wwyUUK X-Received: by 2002:a50:a3c2:: with SMTP id t2mr39466674edb.46.1556558548854; Mon, 29 Apr 2019 10:22:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556558548; cv=none; d=google.com; s=arc-20160816; b=OCoVlfyUHBo9M7JeuYr4b83mqyi0tX4YyHLEILgzUgGRpyaUAExyj4gOQcRQNovV3E +4wt7RmUDAUQZUBofGVCsm6nq4GRO6pBM2rQmFi/8RQJ4OvxK80G3rxQ35Ifh2yWKmrD epgcEmdldQEaOhDTsS4TpX+s/x7nA7AcDjOD0GzdiWryCzrjzgeQRfwTsvJy3PyN1CLj MbhW0x/F1j7brmUDcqafrS2M0Ux2yac6Q/8jAhQ3EZobaf+Xzg4zM7x3nSrLrb50hvrj xgNl4LgndPbve8zOlp8Y5pyutsSWdcqXntWLQWlYP2aORL8nxqnAnmxqeygi9IhtkpFX 6LoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=2eKKxYJ9+/a0EhcYiOjWwiTGOV8tvC7ALn17if7OocU=; b=gD2arC1sUu4z0boo3cFNC6MOksl8CIPykJZm/+g2Hz7X9SpVNKEA3B0mpIbSuL5VSI EQy6gWHwckkVgWINMPAVkWv7kG3AllI1ZXPsriD4Fw551G1bKnCG9jgaKyG95vSVVLvK Zzb+kcOBuTOB+xmSnjjt23aujn6mZUPeU3leD7ps3c6AEZj+QdOvnTHQabHpLKavkk9a RK3wzZ4lOuTn+Oi0TRuRNa4ZodPeNvb7Y8/n9O0JnTRmfUiILjZWhqz/yqXs8Z1EuBR6 iuT1JKw7pVcV5Gqq2OOhsY94UAFDToR4kGe6122jZIMou0ZUAPyG+aOgR6wEuaOiN0gr rJ1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of robin.murphy@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=robin.murphy@arm.com Received: from foss.arm.com (foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id f7si9658718edj.85.2019.04.29.10.22.28 for ; Mon, 29 Apr 2019 10:22:28 -0700 (PDT) Received-SPF: pass (google.com: domain of robin.murphy@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robin.murphy@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=robin.murphy@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9426780D; Mon, 29 Apr 2019 10:22:27 -0700 (PDT) Received: from e110467-lin.cambridge.arm.com (e110467-lin.cambridge.arm.com [10.1.196.75]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2E14B3F557; Mon, 29 Apr 2019 10:22:26 -0700 (PDT) From: Robin Murphy To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Michal Hocko , David Hildenbrand , Dan Williams , Anshuman Khandual Subject: [PATCH v2 1/3] mm/memremap: Rename and consolidate SECTION_SIZE Date: Mon, 29 Apr 2019 18:22:15 +0100 Message-Id: <7c31ee50c533a67f88d21ba439851837a00d7d50.1556555457.git.robin.murphy@arm.com> X-Mailer: git-send-email 2.21.0.dirty 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: X-Virus-Scanned: ClamAV using ClamSMTP Trying to activate ZONE_DEVICE for arm64 reveals that memremap's internal helpers for sparsemem sections conflict with and arm64's definitions for hugepages, which inherit the name of "sections" from earlier versions of the ARM architecture. Disambiguate memremap (and now HMM too) by propagating sparsemem's PA_ prefix, to clarify that these values are in terms of addresses rather than PFNs (and because it's a heck of a lot easier than changing all the arch code). SECTION_MASK is unused, so it can just go. [anshuman: Consolidated mm/hmm.c instance and updated the commit message] Acked-by: Michal Hocko Reviewed-by: David Hildenbrand Acked-by: Dan Williams Signed-off-by: Robin Murphy Signed-off-by: Anshuman Khandual --- v2: Fix commit message typo, add review tags. include/linux/mmzone.h | 1 + kernel/memremap.c | 10 ++++------ mm/hmm.c | 2 -- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index fba7741533be..ed7dd27ee94a 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1081,6 +1081,7 @@ static inline unsigned long early_pfn_to_nid(unsigned long pfn) * PFN_SECTION_SHIFT pfn to/from section number */ #define PA_SECTION_SHIFT (SECTION_SIZE_BITS) +#define PA_SECTION_SIZE (1UL << PA_SECTION_SHIFT) #define PFN_SECTION_SHIFT (SECTION_SIZE_BITS - PAGE_SHIFT) #define NR_MEM_SECTIONS (1UL << SECTIONS_SHIFT) diff --git a/kernel/memremap.c b/kernel/memremap.c index a856cb5ff192..dda1367b385d 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -14,8 +14,6 @@ #include static DEFINE_XARRAY(pgmap_array); -#define SECTION_MASK ~((1UL << PA_SECTION_SHIFT) - 1) -#define SECTION_SIZE (1UL << PA_SECTION_SHIFT) #if IS_ENABLED(CONFIG_DEVICE_PRIVATE) vm_fault_t device_private_entry_fault(struct vm_area_struct *vma, @@ -98,8 +96,8 @@ static void devm_memremap_pages_release(void *data) put_page(pfn_to_page(pfn)); /* pages are dead and unused, undo the arch mapping */ - align_start = res->start & ~(SECTION_SIZE - 1); - align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE) + align_start = res->start & ~(PA_SECTION_SIZE - 1); + align_size = ALIGN(res->start + resource_size(res), PA_SECTION_SIZE) - align_start; nid = page_to_nid(pfn_to_page(align_start >> PAGE_SHIFT)); @@ -154,8 +152,8 @@ void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap) if (!pgmap->ref || !pgmap->kill) return ERR_PTR(-EINVAL); - align_start = res->start & ~(SECTION_SIZE - 1); - align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE) + align_start = res->start & ~(PA_SECTION_SIZE - 1); + align_size = ALIGN(res->start + resource_size(res), PA_SECTION_SIZE) - align_start; align_end = align_start + align_size - 1; diff --git a/mm/hmm.c b/mm/hmm.c index fe1cd87e49ac..ef9e4e6c9f92 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -33,8 +33,6 @@ #include #include -#define PA_SECTION_SIZE (1UL << PA_SECTION_SHIFT) - #if IS_ENABLED(CONFIG_HMM_MIRROR) static const struct mmu_notifier_ops hmm_mmu_notifier_ops; From patchwork Mon Apr 29 17:22:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 10922175 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DEC2D14D5 for ; Mon, 29 Apr 2019 17:22:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C356A287EA for ; Mon, 29 Apr 2019 17:22:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7AB5288CB; Mon, 29 Apr 2019 17:22:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E45E288BC for ; Mon, 29 Apr 2019 17:22:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6762B6B0007; Mon, 29 Apr 2019 13:22:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 625AF6B0008; Mon, 29 Apr 2019 13:22:32 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4CBBB6B000A; Mon, 29 Apr 2019 13:22:32 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id EC8E66B0007 for ; Mon, 29 Apr 2019 13:22:31 -0400 (EDT) Received: by mail-ed1-f71.google.com with SMTP id p26so5136031edy.19 for ; Mon, 29 Apr 2019 10:22:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=EGw7+OH1x4FPPC/oUKCYcTtdBb+/Z2Qy/RRdJBfjQZI=; b=RWGQPIfYqRRfb7guUfG+LjQBvLTmSl9MbKkEcByWclc2m4nGV61Cz73QECd7LtCEiq dPx+PNakJPhidGDxBy49pQVPnLx6FXZor9m+vdcEwi/jpjW8j2eZb9bdydK49dkkHBLY iGUPYHc2QWVNDLr8eb4cSTJktB3t+xEKjN9BMQZf+bR46Hlvs6oc6zUz3qGweFlibmMh 9fB2JwnPKAKNOhXSH8IIqYXeI0vuu8+CtsHpYyCd2UiYsSSEt+ta/pcRlpHB82cTW7hM mZpdmMAkIFt/iw4Pi/y/8QfIGPz/Ui8NKDnjwTkHNlewjbtbVVZpHSoTgeGrGNxQZuux 56/w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of robin.murphy@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=robin.murphy@arm.com X-Gm-Message-State: APjAAAVTe+oVx8l/l02J3YdJACVjPTOqJjNnjSlRqTge/vCekyeYOdII wqBzAaYQxoW7WZXDy9tAZDUd4LU3pHxUoveihkQrAaKHWjKiSPXaZgizOQbsnbxh3uYXG8Sjfz9 ghjuYZxhOLJHAnb9FHuvPeL0kT1n68wdPFWUm4GZNeFCNgPiyRdtyAU9lUUK/TZ5qQA== X-Received: by 2002:a17:906:1c8c:: with SMTP id g12mr30651078ejh.97.1556558551428; Mon, 29 Apr 2019 10:22:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqzlCF4mF/uZnoGKW1GQl5noR/FQhxnh4ZUp29jwXz0lMDD7jG1ZAyCLMwxzUoligrHFJjzp X-Received: by 2002:a17:906:1c8c:: with SMTP id g12mr30651050ejh.97.1556558550555; Mon, 29 Apr 2019 10:22:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556558550; cv=none; d=google.com; s=arc-20160816; b=Tg9ovJBC9gdNAEiAPChDPYebYvPxsAJ8R9W//WJ2WyRnFQFeZF75Gigr7vUTKqnw29 NgT8fB+3gyJLlIx3lJtzEK849e4rZnnRTqPV0RfWS90bz3e0Xo61Gqz74QJgwjX8G55W 8qtCuffXw0LmQojpRPf+qt5L+2aj6M4ZUhctZmkv8CVhbNM3EIf4omMbEvqWB2js/Bnb 2t+IQMEN28jrm6jx2H+sfoDl2DBlPLhpElveWZbNPv0gp9DDiCyaY0Orrq3YJPHX+Wjk MOKJp4P2sJyT41o1Q5BIS1g/aAXjhyug0+tRewtuJXMvesylMJb0KXHjZfpw1YACfNxV 79Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=EGw7+OH1x4FPPC/oUKCYcTtdBb+/Z2Qy/RRdJBfjQZI=; b=0TCBwe8cdV/++FoKDmeJdvb2kAYnw7V/0SslfqgLof1fFW5vVKT3NZLT5g8ewRRye+ qe3q3ZCbEESD8H8oZNEHGUa5izq5DhSzzaQd/22Og7DOPWqerxjDvYJXBbcYsCCyrZI4 igl61uetPP/sWIJegZg3ceV/xnqhK6heytqhlJQ6Hvqoa8mixmr4omq09PBkjgtklNHG i/PwL7HsFoI65YR9QiNd657clQAORSrm8bI+4cpMiWooqi7LunxO6ov6LhMMXaPl54nn qPYYFGoDxspItAomGmRzgBQENM7CnoJOt/IsFNtzKh66GEsde0TLq5Du4/k7+6tTyUq4 3lSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of robin.murphy@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=robin.murphy@arm.com Received: from foss.arm.com (foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id z11si278934ejp.297.2019.04.29.10.22.30 for ; Mon, 29 Apr 2019 10:22:30 -0700 (PDT) Received-SPF: pass (google.com: domain of robin.murphy@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robin.murphy@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=robin.murphy@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8B4A8EBD; Mon, 29 Apr 2019 10:22:29 -0700 (PDT) Received: from e110467-lin.cambridge.arm.com (e110467-lin.cambridge.arm.com [10.1.196.75]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7079A3F557; Mon, 29 Apr 2019 10:22:28 -0700 (PDT) From: Robin Murphy To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Jerome Glisse , Anshuman Khandual Subject: [PATCH v2 2/3] mm: clean up is_device_*_page() definitions Date: Mon, 29 Apr 2019 18:22:16 +0100 Message-Id: <4d00e3aff0192dcfef244a348d8927f06ee3f394.1556555457.git.robin.murphy@arm.com> X-Mailer: git-send-email 2.21.0.dirty 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: X-Virus-Scanned: ClamAV using ClamSMTP Refactor is_device_{public,private}_page() with is_pci_p2pdma_page() to make them all consistent in depending on their respective config options even when CONFIG_DEV_PAGEMAP_OPS is enabled for other reasons. This allows a little more compile-time optimisation as well as the conceptual and cosmetic cleanup. Suggested-by: Jerome Glisse Reviewed-by: Anshuman Khandual Signed-off-by: Robin Murphy --- v2: Add review tags. include/linux/mm.h | 43 +++++++++++++------------------------------ 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 76769749b5a5..d76dfb7ac617 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -910,32 +910,6 @@ static inline bool put_devmap_managed_page(struct page *page) } return false; } - -static inline bool is_device_private_page(const struct page *page) -{ - return is_zone_device_page(page) && - page->pgmap->type == MEMORY_DEVICE_PRIVATE; -} - -static inline bool is_device_public_page(const struct page *page) -{ - return is_zone_device_page(page) && - page->pgmap->type == MEMORY_DEVICE_PUBLIC; -} - -#ifdef CONFIG_PCI_P2PDMA -static inline bool is_pci_p2pdma_page(const struct page *page) -{ - return is_zone_device_page(page) && - page->pgmap->type == MEMORY_DEVICE_PCI_P2PDMA; -} -#else /* CONFIG_PCI_P2PDMA */ -static inline bool is_pci_p2pdma_page(const struct page *page) -{ - return false; -} -#endif /* CONFIG_PCI_P2PDMA */ - #else /* CONFIG_DEV_PAGEMAP_OPS */ static inline void dev_pagemap_get_ops(void) { @@ -949,22 +923,31 @@ static inline bool put_devmap_managed_page(struct page *page) { return false; } +#endif /* CONFIG_DEV_PAGEMAP_OPS */ static inline bool is_device_private_page(const struct page *page) { - return false; + return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && + IS_ENABLED(CONFIG_DEVICE_PRIVATE) && + is_zone_device_page(page) && + page->pgmap->type == MEMORY_DEVICE_PRIVATE; } static inline bool is_device_public_page(const struct page *page) { - return false; + return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && + IS_ENABLED(CONFIG_DEVICE_PUBLIC) && + is_zone_device_page(page) && + page->pgmap->type == MEMORY_DEVICE_PUBLIC; } static inline bool is_pci_p2pdma_page(const struct page *page) { - return false; + return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && + IS_ENABLED(CONFIG_PCI_P2PDMA) && + is_zone_device_page(page) && + page->pgmap->type == MEMORY_DEVICE_PCI_P2PDMA; } -#endif /* CONFIG_DEV_PAGEMAP_OPS */ static inline void get_page(struct page *page) { From patchwork Mon Apr 29 17:22:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 10922177 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B813314D5 for ; Mon, 29 Apr 2019 17:22:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BC75287EA for ; Mon, 29 Apr 2019 17:22:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F764288CB; Mon, 29 Apr 2019 17:22:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD7F9287EA for ; Mon, 29 Apr 2019 17:22:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 607936B0008; Mon, 29 Apr 2019 13:22:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 515956B000A; Mon, 29 Apr 2019 13:22:35 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42AA16B000C; Mon, 29 Apr 2019 13:22:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id E1AB86B0008 for ; Mon, 29 Apr 2019 13:22:34 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id r48so5145448eda.11 for ; Mon, 29 Apr 2019 10:22:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=TeehqriwnfAzZxk6PUNuJHpfUbkf/0d7jrAAjX1GZsM=; b=k9SfOw+ETou5MUs2bWEigsgIMLjeYstiVAKxfJDlVLCT68UM3QHy6ViFivm0QttUxw sUJouqhB8SR8xnTaaH8v/a8z7PW+yWaWC73RMiaw/2beLO7usuo5d2mCw8R4dWOiklZp nOKQpz5vPuYlFTi/Rhee+7j+QiqWTTJ+xY0NpYKuZRg2y6h05hQpy/arxyX1Ulb3xUPW NoCrqeVKU75UbL69oofiRmb1DOaHqqwnMEsHY3h0Evd2mEFwkM5zz3rhE1KVYK43/Q0m AA/RqO1WSEbeB64yvvAsTECl9UKOi3ys9noH2HhybZ1si2+AnsJkZmoxkb68Yg+4qGr2 qJKQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of robin.murphy@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=robin.murphy@arm.com X-Gm-Message-State: APjAAAWU/LoCG4Vu5a1qdmxhG/MgN94mJFRjrrg1hvxbhKUmBbv4mdRu QWwehTsEyd/rMiQkgPtDm8VJe6B7PniZzqOmGDtNLvQd/TbgeMlTlfQEZTNuwLN0tDPTIS81hb8 l9CRET28hR7wQoPFTbqs+GdA88cPPIJn4IMEaIqskO6XhRXBhXiVeprQpmch2sliQ3Q== X-Received: by 2002:a50:a4db:: with SMTP id x27mr39733316edb.120.1556558554416; Mon, 29 Apr 2019 10:22:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwSY36OeVoXo9c2t8gXY0WAa8SM4jAojM0CVap1OQEjNXh6C/z3B1Da2WFPQEhooPLxLOiJ X-Received: by 2002:a50:a4db:: with SMTP id x27mr39733262edb.120.1556558553527; Mon, 29 Apr 2019 10:22:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556558553; cv=none; d=google.com; s=arc-20160816; b=O4DYlHDhJyjfoOfjCUZqgRn9wCqj/ylR+4EAMYn458CVixjkure9EtVz/hOigzD3WL TVAJCvYrRfr25vtpYlPisNv8fPkjhik3l9z6mDl0PeIxBt4ogMjTVPIoNPyZhtrBVEKf Ndg8pcZydmZcK9oK39DFXq0CdwjUix0zsmLj+p0WZEl/bu+IhUWl5dPWxYe1E+5UHTbb t59xRypifVRZVNo8bylOzjCrLumOCb554CB/icjuBtr8JegMj1Wrpw/lTDHIGvz5GLOA gKh1D03XPLa9UNvrG9dldE9uB9nATCiFhRhseJrq9PidNwcOdsTEs7CGmcLCZajNVXmj zp6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=TeehqriwnfAzZxk6PUNuJHpfUbkf/0d7jrAAjX1GZsM=; b=hAJDjDMwlGZy/6XEHZeQkLWW5XT8c37pCd5J8FB/ytSTbIUqKqDng/nTl7GZmR9U8i AJ8HlsRWwImjhniC0HqT+6Rtb/IrVwdDx27KUSn50qn5UYgnIreeMfWmlsV8JacfOA+T /t7r6uCHL3eZjtFLOPnyOuWHPr/VZi4GKhIee0ONMge+CULbJLTVU4IPG9J4UDS9/Tj0 PqHh+T3LY9JdNcFgdqoyUk1mhqTnszIUZdXNzmJ4P47pdLacx6ui0LZeaFFX7SFBLWBi n3kJ1dF/WliCqXx2a8pp10jjnWXfrYxeY3Nvtu6Q0/sV75xxAmj3ixf24SsvhdnfFnyF EBvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of robin.murphy@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=robin.murphy@arm.com Received: from foss.arm.com (foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id hk19si2492861ejb.321.2019.04.29.10.22.33 for ; Mon, 29 Apr 2019 10:22:33 -0700 (PDT) Received-SPF: pass (google.com: domain of robin.murphy@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robin.murphy@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=robin.murphy@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5391CEBD; Mon, 29 Apr 2019 10:22:32 -0700 (PDT) Received: from e110467-lin.cambridge.arm.com (e110467-lin.cambridge.arm.com [10.1.196.75]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 746633F557; Mon, 29 Apr 2019 10:22:30 -0700 (PDT) From: Robin Murphy To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, Michael Ellerman , Dan Williams , Ira Weiny , Oliver O'Halloran , Anshuman Khandual Subject: [PATCH v2 3/3] mm: introduce ARCH_HAS_PTE_DEVMAP Date: Mon, 29 Apr 2019 18:22:17 +0100 Message-Id: <39f00b9e5768d05bf7bbc75493f121ad7b553a2f.1556555457.git.robin.murphy@arm.com> X-Mailer: git-send-email 2.21.0.dirty 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: X-Virus-Scanned: ClamAV using ClamSMTP ARCH_HAS_ZONE_DEVICE is somewhat meaningless in itself, and combined with the long-out-of-date comment can lead to the impression than an architecture may just enable it (since __add_pages() now "comprehends device memory" for itself) and expect things to work. In practice, however, ZONE_DEVICE users have little chance of functioning correctly without __HAVE_ARCH_PTE_DEVMAP, so let's clean that up the same way as ARCH_HAS_PTE_SPECIAL and make it the proper dependency so the real situation is clearer. Cc: x86@kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: Michael Ellerman Acked-by: Dan Williams Reviewed-by: Ira Weiny Acked-by: Oliver O'Halloran Reviewed-by: Anshuman Khandual Signed-off-by: Robin Murphy --- v2: Add review tags. arch/powerpc/Kconfig | 2 +- arch/powerpc/include/asm/book3s/64/pgtable.h | 1 - arch/x86/Kconfig | 2 +- arch/x86/include/asm/pgtable.h | 4 ++-- arch/x86/include/asm/pgtable_types.h | 1 - include/linux/mm.h | 4 ++-- include/linux/pfn_t.h | 4 ++-- mm/Kconfig | 5 ++--- mm/gup.c | 2 +- 9 files changed, 11 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 5e3d0853c31d..77e1993bba80 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -135,6 +135,7 @@ config PPC select ARCH_HAS_MMIOWB if PPC64 select ARCH_HAS_PHYS_TO_DMA select ARCH_HAS_PMEM_API if PPC64 + select ARCH_HAS_PTE_DEVMAP if PPC_BOOK3S_64 select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_MEMBARRIER_CALLBACKS select ARCH_HAS_SCALED_CPUTIME if VIRT_CPU_ACCOUNTING_NATIVE && PPC64 @@ -142,7 +143,6 @@ config PPC select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_HAS_UACCESS_FLUSHCACHE if PPC64 select ARCH_HAS_UBSAN_SANITIZE_ALL - select ARCH_HAS_ZONE_DEVICE if PPC_BOOK3S_64 select ARCH_HAVE_NMI_SAFE_CMPXCHG select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_SERIO diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index 581f91be9dd4..02c22ac8f387 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -90,7 +90,6 @@ #define _PAGE_SOFT_DIRTY _RPAGE_SW3 /* software: software dirty tracking */ #define _PAGE_SPECIAL _RPAGE_SW2 /* software: special page */ #define _PAGE_DEVMAP _RPAGE_SW1 /* software: ZONE_DEVICE page */ -#define __HAVE_ARCH_PTE_DEVMAP /* * Drivers request for cache inhibited pte mapping using _PAGE_NO_CACHE diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 5ad92419be19..ffd50f27f395 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -60,6 +60,7 @@ config X86 select ARCH_HAS_KCOV if X86_64 select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_PMEM_API if X86_64 + select ARCH_HAS_PTE_DEVMAP if X86_64 select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_REFCOUNT select ARCH_HAS_UACCESS_FLUSHCACHE if X86_64 @@ -69,7 +70,6 @@ config X86 select ARCH_HAS_STRICT_MODULE_RWX select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE select ARCH_HAS_UBSAN_SANITIZE_ALL - select ARCH_HAS_ZONE_DEVICE if X86_64 select ARCH_HAVE_NMI_SAFE_CMPXCHG select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI select ARCH_MIGHT_HAVE_PC_PARPORT diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 2779ace16d23..89a1f6fd48bf 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -254,7 +254,7 @@ static inline int has_transparent_hugepage(void) return boot_cpu_has(X86_FEATURE_PSE); } -#ifdef __HAVE_ARCH_PTE_DEVMAP +#ifdef CONFIG_ARCH_HAS_PTE_DEVMAP static inline int pmd_devmap(pmd_t pmd) { return !!(pmd_val(pmd) & _PAGE_DEVMAP); @@ -715,7 +715,7 @@ static inline int pte_present(pte_t a) return pte_flags(a) & (_PAGE_PRESENT | _PAGE_PROTNONE); } -#ifdef __HAVE_ARCH_PTE_DEVMAP +#ifdef CONFIG_ARCH_HAS_PTE_DEVMAP static inline int pte_devmap(pte_t a) { return (pte_flags(a) & _PAGE_DEVMAP) == _PAGE_DEVMAP; diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h index d6ff0bbdb394..b5e49e6bac63 100644 --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h @@ -103,7 +103,6 @@ #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX) #define _PAGE_DEVMAP (_AT(u64, 1) << _PAGE_BIT_DEVMAP) -#define __HAVE_ARCH_PTE_DEVMAP #else #define _PAGE_NX (_AT(pteval_t, 0)) #define _PAGE_DEVMAP (_AT(pteval_t, 0)) diff --git a/include/linux/mm.h b/include/linux/mm.h index d76dfb7ac617..fe05c94f23e9 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -504,7 +504,7 @@ struct inode; #define page_private(page) ((page)->private) #define set_page_private(page, v) ((page)->private = (v)) -#if !defined(__HAVE_ARCH_PTE_DEVMAP) || !defined(CONFIG_TRANSPARENT_HUGEPAGE) +#if !defined(CONFIG_ARCH_HAS_PTE_DEVMAP) || !defined(CONFIG_TRANSPARENT_HUGEPAGE) static inline int pmd_devmap(pmd_t pmd) { return 0; @@ -1698,7 +1698,7 @@ static inline void sync_mm_rss(struct mm_struct *mm) } #endif -#ifndef __HAVE_ARCH_PTE_DEVMAP +#ifndef CONFIG_ARCH_HAS_PTE_DEVMAP static inline int pte_devmap(pte_t pte) { return 0; diff --git a/include/linux/pfn_t.h b/include/linux/pfn_t.h index 7bb77850c65a..de8bc66b10a4 100644 --- a/include/linux/pfn_t.h +++ b/include/linux/pfn_t.h @@ -104,7 +104,7 @@ static inline pud_t pfn_t_pud(pfn_t pfn, pgprot_t pgprot) #endif #endif -#ifdef __HAVE_ARCH_PTE_DEVMAP +#ifdef CONFIG_ARCH_HAS_PTE_DEVMAP static inline bool pfn_t_devmap(pfn_t pfn) { const u64 flags = PFN_DEV|PFN_MAP; @@ -122,7 +122,7 @@ pmd_t pmd_mkdevmap(pmd_t pmd); defined(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD) pud_t pud_mkdevmap(pud_t pud); #endif -#endif /* __HAVE_ARCH_PTE_DEVMAP */ +#endif /* CONFIG_ARCH_HAS_PTE_DEVMAP */ #ifdef CONFIG_ARCH_HAS_PTE_SPECIAL static inline bool pfn_t_special(pfn_t pfn) diff --git a/mm/Kconfig b/mm/Kconfig index 25c71eb8a7db..fcb7ab08e294 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -655,8 +655,7 @@ config IDLE_PAGE_TRACKING See Documentation/admin-guide/mm/idle_page_tracking.rst for more details. -# arch_add_memory() comprehends device memory -config ARCH_HAS_ZONE_DEVICE +config ARCH_HAS_PTE_DEVMAP bool config ZONE_DEVICE @@ -664,7 +663,7 @@ config ZONE_DEVICE depends on MEMORY_HOTPLUG depends on MEMORY_HOTREMOVE depends on SPARSEMEM_VMEMMAP - depends on ARCH_HAS_ZONE_DEVICE + depends on ARCH_HAS_PTE_DEVMAP select XARRAY_MULTI help diff --git a/mm/gup.c b/mm/gup.c index f84e22685aaa..72a5c7d1e1a7 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1623,7 +1623,7 @@ static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end, } #endif /* CONFIG_ARCH_HAS_PTE_SPECIAL */ -#if defined(__HAVE_ARCH_PTE_DEVMAP) && defined(CONFIG_TRANSPARENT_HUGEPAGE) +#if defined(CONFIG_ARCH_HAS_PTE_DEVMAP) && defined(CONFIG_TRANSPARENT_HUGEPAGE) static int __gup_device_huge(unsigned long pfn, unsigned long addr, unsigned long end, struct page **pages, int *nr) {