From patchwork Thu May 23 15:03:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 10957917 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 27F30924 for ; Thu, 23 May 2019 15:03:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 111F228630 for ; Thu, 23 May 2019 15:03:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 058362852A; Thu, 23 May 2019 15:03:31 +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 6B36128630 for ; Thu, 23 May 2019 15:03:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 20B186B000C; Thu, 23 May 2019 11:03:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 194616B000D; Thu, 23 May 2019 11:03:29 -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 F02B06B000E; Thu, 23 May 2019 11:03:28 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id A22B66B000C for ; Thu, 23 May 2019 11:03:28 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id f41so9481605ede.1 for ; Thu, 23 May 2019 08:03:28 -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=zg85nJ35pKxFSS0/87yLMaYaC6bRh9JcCczKm9Nv3WA=; b=HdI9t8gg5uqKgx4GhNX7ZTw+IdCN2UhfbyPYlePy4dm9Tk9+mCzIOXvZvKPzsDIQWK cKtL3ZBYLI6CnYekxjP/nv5QsMQpSoqVvokw9IFNMPC3f4wHjBLCoEuTGm7KHRkLtnaa 5Bxj377hzXHQaRNHdFN51QTIOTh50DZempUE7Ty2CB+afCGlLeTj1w2U7Vg52Eo9xH8g NDoAf3TJapEADyRdLm2Ov1Nx837tm8XX3FMATB8p1HeD0UGXw0J6P1wlmCij/kRgD4DT zycY51Re3prpX2IJOQiqBc53PVK5kdsTMKX0FRgk+2zyrOL4djY6ACXKYPN/mlhTiN1Q YbqA== 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: APjAAAUiiM+37YmQ69HdsAazeC3dovFT/qbBrq7RzuP+XbVEqYun1/Cy QyHJdvEFclS26VYNDFRey4CGv0ilKWGx/X28iF5RXSCCr26H5oAZ5bcNXiCbo6KiJc+9q40rdAn knlUXdjtoKRyzL9cEaBpwyRD4ESs+StcUg0Ap1wXgl2shMMm6hkt5Xb9SREwkO2oUUg== X-Received: by 2002:a50:f5d9:: with SMTP id x25mr95689358edm.128.1558623808099; Thu, 23 May 2019 08:03:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzu2e5eLO2rGWMZ7XtltV3TLvKsQCTHKIIrzkMu/RSggogrT1ZucqWzJYnKeNbz1UHPMMEF X-Received: by 2002:a50:f5d9:: with SMTP id x25mr95689242edm.128.1558623807115; Thu, 23 May 2019 08:03:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558623807; cv=none; d=google.com; s=arc-20160816; b=bNa4YoC9F2M1A/Cw47Q7LZDGoe6wzEM6J+WHdd9/Qlo+B/+oYxfXN7xUo/r2SVIh+n zh1+o9XxHsKxLqgemPE2LfuOQ3xsaodiiUXCWZ69K5QgYZJWGASoWY1jCb7+Z6dj3F1B Ham70WcDH17ndVPDG+YyteXPfPTushkk1fmRsndUh+5ct6N87vQymohFliyfwYNxqFgH dfa/BXloP3MSJXEkW1tH83xocOSsfTNix8WXeNr7tkHhS5NQ96Lm0pEoFBDrYO166E6V gD5Lh3z1c3sUSVqadt0VBZl5dISO1YadLEafa9QlE0VbFw0PX0HjOfcNiw7yXdnw32Y5 Cn9g== 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=zg85nJ35pKxFSS0/87yLMaYaC6bRh9JcCczKm9Nv3WA=; b=VO/SNho8G48J2up29mjvjPM5EBLj5tmEHWRR5Ncqc4/oPkygsPdpaIUrzXX6EAPLzT xYSfHf1+KvBX4bjP1PmfGmp2T5LvvtXu5YpK+XtKjmtxNnOf4HgZgVOpsUVVFYLSEmtj Y5xtYeuUcfbRJgmjotg8TV/VRjxsuMB2pvW/XMs780oSJ4BtOl4ukCbeEOPN/lyddtZy 5MFn6La7LiePgXBw/mZYKbckL9sJk0NSmlL6e7OvxnfwLCRm/nHN7H3WISHRzYBUxXg+ otgTz8aGPECAdv9GusE/CffqSzvecCyQkCTzceepifEtbrhZfP2Ps/RwsquoLPQ+lCJb LYfg== 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 (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id w19si4622189eju.0.2019.05.23.08.03.26 for ; Thu, 23 May 2019 08:03:27 -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 EE37780D; Thu, 23 May 2019 08:03:25 -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 2055C3F690; Thu, 23 May 2019 08:03:23 -0700 (PDT) From: Robin Murphy To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, will.deacon@arm.com, catalin.marinas@arm.com, anshuman.khandual@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Michal Hocko , David Hildenbrand , Dan Williams Subject: [PATCH v3 1/4] mm/memremap: Rename and consolidate SECTION_SIZE Date: Thu, 23 May 2019 16:03:13 +0100 Message-Id: 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 --- 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 70394cabaf4e..427b79c39b3c 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1134,6 +1134,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 1490e63f69a9..b8c8010e87e0 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, @@ -97,8 +95,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)); @@ -159,8 +157,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 0db8491090b8..a7e7f8e33c5f 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -34,8 +34,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 Thu May 23 15:03:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 10957919 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 99D89924 for ; Thu, 23 May 2019 15:03:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83DF12852A for ; Thu, 23 May 2019 15:03:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 783E028643; Thu, 23 May 2019 15:03:36 +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 A103A2852A for ; Thu, 23 May 2019 15:03:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 083656B000D; Thu, 23 May 2019 11:03:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 00E3A6B000E; Thu, 23 May 2019 11:03:31 -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 E179B6B0010; Thu, 23 May 2019 11:03:31 -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 95D186B000D for ; Thu, 23 May 2019 11:03:31 -0400 (EDT) Received: by mail-ed1-f69.google.com with SMTP id z5so9473651edz.3 for ; Thu, 23 May 2019 08:03: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=MS3bRiad9Fep4WHmQ9etJt6j6qqU4xpmR+31qYwLW3Q=; b=DeRCnDiGPGhF7SHw1JUbkcnOVhS5c3E1fuAlBTFC5IPiwa4XGmeHWZ3ad3FRuug2vw LrQFtft+pULd+gUBS47y2v4QREwuNBpy7lGWl5M+D157sqGBR3pkh+LxInvmqELsn3qU yRfamGgRKe0OcOK1QKi5l9C4oGBqTDy3c8T90gQw9XDzwNEMUhRLUld+nQrPeNeO2zeL 9QOW48Zo8/DiPeRPx3MK06Off6wOz8xHMQ8DAt9FCbS+vn6zZKwWzk1VR+PcvcC2x3RC F/g5jFGq6N5TQB2Q6Iym4rYKZqik9wlllIn3Il6UxV6eECAv8Tj7DBxovYEB2WoX6XWS 89Pg== 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: APjAAAWtrV4oiWgj8QHSGB0vq6WznoHPW9QfOw2jm/YSFszJhdQsndzC hb/9IinyRmv370kJnilkSTmMFNpfEPZV6On6cpQJSxQfvIbQkeyJAKHT8SVb5u1xODzJYyMB42S TERphsGFmAxHecxYpBNXxCChJwJ2oGIQXeD5q6b3uJUI6S61oxBpyX0EwaMDYpEpgNg== X-Received: by 2002:a50:ad98:: with SMTP id a24mr97413509edd.235.1558623810860; Thu, 23 May 2019 08:03:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxIBzoLtlYfiOPFBxmh0UW/f3BJClG9lI29JaTvifomDcqs0b0F2LxeO2tjgNgJUcK/PP9M X-Received: by 2002:a50:ad98:: with SMTP id a24mr97413346edd.235.1558623809414; Thu, 23 May 2019 08:03:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558623809; cv=none; d=google.com; s=arc-20160816; b=b5XlIlGNLuKX9W5YSzIdMNzxRDsZVcdnONn3tWGX8FQO6AN1YVO2JTR1YfAuWi7yv1 +I3SoyjgFASusWKHqz7sswYOm2d7iZD2ceodcujNqELf2CQv+ImrF+tRPOSBTJK5GIO/ su87H5ICMrWmykPotYQx433LzF/waa0otqDDjpUI3aWXSrcU6JF8dkQ3480+OtcpVyUI qsVL0299cP7RGeert7LsfYz9Olp4LAOcIjEt/oNjCsK1fnVIb69fR7gWYStlDnv9eC9C 1b9a+QojCvIX2pkzrhtbPdYRaZxQGeKpi8w7oL1SyM0sdQLed62zT+QKXuyu1QVFVwMx a0zg== 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=MS3bRiad9Fep4WHmQ9etJt6j6qqU4xpmR+31qYwLW3Q=; b=XKWEeAfB8xVgaiz61GckJSOLyOdR09f96QFhBkH07JrDLZfwFpQd12YUEmyerUexth QuBqoLGBES4wl74jlw/qjTCPmfjBhQ84FRSJtz8GuzX6KWFKzl3pia6ZcMZSH1LoTrsk C3GwFMymQKwcYhnyk6K39KLnSeGjrco/26DeWezbsBem4Jj/dGhdh/NJ9Nw02R0sI9np q2jnGl92xlihWjKGnjdk+lKAVPRBYz9OHARSTWfAAIbBmRS8C66IYUII3Q9e3qsSC7SR RWZiD7TwakvMlLh7pB7KbVIR8XALv+Kfc0jP1CVwslCH16KGWMgMkqv5XzObFvS5tuNA U5Zg== 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 (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id k13si7518215ejr.389.2019.05.23.08.03.29 for ; Thu, 23 May 2019 08:03:29 -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 7383AA78; Thu, 23 May 2019 08:03:28 -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 DF5823F690; Thu, 23 May 2019 08:03:26 -0700 (PDT) From: Robin Murphy To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, will.deacon@arm.com, catalin.marinas@arm.com, anshuman.khandual@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jerome Glisse Subject: [PATCH v3 2/4] mm: clean up is_device_*_page() definitions Date: Thu, 23 May 2019 16:03:14 +0100 Message-Id: <187c2ab27dea70635d375a61b2f2076d26c032b0.1558547956.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 --- 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 0e8834ac32b7..9cd613a7f67b 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -942,32 +942,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) { @@ -981,22 +955,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 */ /* 127: arbitrary random number, small enough to assemble well */ #define page_ref_zero_or_close_to_overflow(page) \ From patchwork Thu May 23 15:03: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: 10957921 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 99D76933 for ; Thu, 23 May 2019 15:03:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 830512852A for ; Thu, 23 May 2019 15:03:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 779BD2864A; Thu, 23 May 2019 15:03:38 +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 9E54F2852A for ; Thu, 23 May 2019 15:03:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B0B346B000E; Thu, 23 May 2019 11:03:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A95136B0010; Thu, 23 May 2019 11:03: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 93A616B0266; Thu, 23 May 2019 11:03:35 -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 458C46B000E for ; Thu, 23 May 2019 11:03:35 -0400 (EDT) Received: by mail-ed1-f71.google.com with SMTP id h12so9397322edl.23 for ; Thu, 23 May 2019 08:03:35 -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=GpTEqD8XoKhCQeXR0WWWARsHxCmoAKY+/W+smFPVQrY=; b=P4sxr/EAXBKqSGs+/WRd9Igq99rwmFKqBXam5r7Y5KLO0ObbFBz0wOdB9Ji9OajiP8 3GislsYSDGgCETh6x+lRDMXKxGgp9KW7+Gt0wWrOiCaCrjXzQrMPOZdwjDPo33hMrYFx zxm83aSmKG64e6hL8Zk0VorX1eK8Jry6q24Gva9BwG0++lQ42g+XWcScsEqP5YRwDds0 rIf/1w3YIe44usTUIQ0+HPvd6L+qF59wvkQWYwWZ2PdEgkMBUFRE69kzC0zAeBiFSfNo pbeiGHbgiGOnvqi4uMOjw8cgMgmGU7gqZPdXJ6iOhS4JkvL0k5Z3lMEBc7CpjIIbIsF6 VOQQ== 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: APjAAAVbB/BXpBYoXwXekREax5cFmjs3kYw6WkWIdMwaFIZHfLLj9E2S 0sKmFpjEiMc0cRb+1grj1qmKmnXxma94mk/S2fJfBdaBUBIMdjE9aP+ndGbK7YXSLSLyvEl2WHo 1ZawLXI352258CtNGtIcsOxB6CeIOqcz8jlaeQubn5pqBALJXlqntq1nHjx09XNyxMQ== X-Received: by 2002:a17:906:4f8f:: with SMTP id o15mr61507891eju.129.1558623814685; Thu, 23 May 2019 08:03:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwot+DmcQxP90El4eAEGytzf/fT5baWGO8/eMlqYS/u0lz172wrhxQAkUsp4wlZAKznCxOy X-Received: by 2002:a17:906:4f8f:: with SMTP id o15mr61507716eju.129.1558623812945; Thu, 23 May 2019 08:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558623812; cv=none; d=google.com; s=arc-20160816; b=DOb/+LB5eFSAv3YgobRUL94BFJ0agGOc7Hcpqzs/anjMHD6Cdf6s4HjNNHq4BY/but wZgzZ2t4EkPPNMFsYeYsKMCUHUPvvOuhaRGUMbBqhaQ2j8pyJcmEMS4r7yAEKbxqA5zr 91Bp5P//E+VBk2vi11eCXhzkpZQ5JbiMI36QgiFJwLxdzgTX8zxsutNpMd75o9S5ubgS cVXJTJzfClL2magyoCBsKkOT52UhFQvL/CKlRT+YW9aFSzdyAiPtZCbU8QyOnciDpS3H DUstAAHQtgmYnTD/inmVrfTcQgTpRtRFQRkYYJ+Yu1kHctGsACZ2/ZxB++kpsRv9oOEY 3oYA== 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=GpTEqD8XoKhCQeXR0WWWARsHxCmoAKY+/W+smFPVQrY=; b=dkPHvkpI9cCKZC8algzhJSwfjoWO0weGLPJttXAuRqrr3wu7echBN0Fq5zr6tCE/FS fWKSx8SWIwNZKN+tgfvqSpT3V1QMWFiDhjBrb/r7iQjeDGhd67zJ9o3XSPiutBEN8vdn C0j1sxjf2AJcN6n1BPLMPfUfr55bx6JiMfn6/FqJqdJXHqLcaScaYqOyDsg7cDN57WnG abSXX3IqCpeC4hjjzMmdmxmky1Sj8KCy5a4vqhtdg6kv16kmhikgnBRK8IaErXens9dI +4cCVOtjT1bxKuwf9SKK4PejAWwCasbCMD78sv7fR/ypn17evR67tCUjvbSwZJpFOPOq l+2A== 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 (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id r1si12697555ejh.347.2019.05.23.08.03.32 for ; Thu, 23 May 2019 08:03:32 -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 BF3AA15AB; Thu, 23 May 2019 08:03:31 -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 7E2B83F690; Thu, 23 May 2019 08:03:29 -0700 (PDT) From: Robin Murphy To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, will.deacon@arm.com, catalin.marinas@arm.com, anshuman.khandual@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, Michael Ellerman , Dan Williams , Ira Weiny , Oliver O'Halloran Subject: [PATCH v3 3/4] mm: introduce ARCH_HAS_PTE_DEVMAP Date: Thu, 23 May 2019 16:03:15 +0100 Message-Id: <87554aa78478a02a63f2c4cf60a847279ae3eb3b.1558547956.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 --- 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 8c1c636308c8..1120ff8ac715 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -128,6 +128,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 @@ -135,7 +136,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_KEEP_MEMBLOCK select ARCH_MIGHT_HAVE_PC_PARPORT diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index 7dede2e34b70..c6c2bdfb369b 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 2bbbd4d1ba31..57c4e80bd368 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -69,6 +69,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 @@ -79,7 +80,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 5e0509b41986..0bc530c4eb13 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -271,7 +271,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); @@ -732,7 +732,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 9cd613a7f67b..f61c016de005 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -536,7 +536,7 @@ static inline void vma_set_anonymous(struct vm_area_struct *vma) struct mmu_gather; struct inode; -#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; @@ -1754,7 +1754,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 ee8d1f311858..3aeef0442d03 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -647,8 +647,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 @@ -656,7 +655,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 2c08248d4fa2..777010ca3bf0 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1799,7 +1799,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) { From patchwork Thu May 23 15:03: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: 10957923 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 14CCE933 for ; Thu, 23 May 2019 15:03:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F264E2864F for ; Thu, 23 May 2019 15:03:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E658628644; Thu, 23 May 2019 15:03:41 +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 4291928649 for ; Thu, 23 May 2019 15:03:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4557C6B0010; Thu, 23 May 2019 11:03:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3E1736B0266; Thu, 23 May 2019 11:03:37 -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 196EC6B0269; Thu, 23 May 2019 11:03:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id BDD2B6B0010 for ; Thu, 23 May 2019 11:03:36 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id y12so9414043ede.19 for ; Thu, 23 May 2019 08:03:36 -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=Ui0u17U43eS4rMS8Az194VeWDWEwmyWvLDsXU/OlQLo=; b=qKr+IOJ0dgv19NcdtTXlXbypXQRkAP3eVfleHuOSDAU4PUg5p79BQXip2Obg4iA0JQ 2TQVjM7aBu5rQghyGwU7YmH39FA/ZG+ghbST4CdMXTnkJyj3iePyv1oxxjMLFWiHFz0C /uyPNy7mpAYC7gxScDW9RBo0N2sElCk9lT+IyzxdzOaC6X675Hrvt4JnVfYAffNvm7Bx HHFR3gFgDWJEGc3ZW2IyD5gJ4fdpgKRjT4jpiHOhsxI2aNXshwz3070qY08e4FfBRx8F 6Zn7c3nOkBlmEuMO5+H61z6wAOJlKaOHEKtb4qt3RmGMqkWxgzmeUo4RmVhbToipi8bJ RTeg== 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: APjAAAX5tZhD4pkuM+NDpNzSeV+bJ/p5OZwAdOAp1tZkdQ7Z1tCReZRA ZioPKcgV+sM0AoZnSnZBf4xKbHbs2uGvxfs1B8onELGo/x9VuvES+u8qvN9tDVvo/do5Ol9ePVb Tz38Z5nXP3j7PAWPqK0vR3c4x4B5pq/WfB8Q3+YTnY6ymSo/adNcKTA780SmwiFSKtA== X-Received: by 2002:a50:f5d9:: with SMTP id x25mr95690286edm.128.1558623816212; Thu, 23 May 2019 08:03:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzlB50joiOwayYhHchY9EOHxi24JduABxyxunBm1yqxO06QAfsfr9tx1/ZOJDTFqKxx8X31 X-Received: by 2002:a50:f5d9:: with SMTP id x25mr95690122edm.128.1558623814771; Thu, 23 May 2019 08:03:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558623814; cv=none; d=google.com; s=arc-20160816; b=SCWGuKSvvfu3jpcZlT2flQllltU8hkVD/2c8sPB0LGzS3jx0aNNkPh084LkK46pkgQ 1Wni58pALkABBSMp0D/0i28eQviS8VtktlFBbedFvgQczHh/kB39Ppq+g3CmMwuk0Eoj Wq33QqCDSR395PIN2aAzOSlj9bBrL1r3Z28r2t/SJyHuf3fA2GF49qTslkezbJ0769uP qbVZnjhYuEpeuockI1w3QjJKcs19UQogtyOwkMapIV4CvJQ/AnbWyWWoh+Q8fooCldiM AwYQjeIBriOSqHoFgPLQUNQZEI13Rb47lBVfvKA7ZvrP2bxMWvRfIONK6I3fnSe9RIz4 /IYg== 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=Ui0u17U43eS4rMS8Az194VeWDWEwmyWvLDsXU/OlQLo=; b=AwZgXCXcVGRCLJDw4+Yz3z8HHQzdigsbD00PUl9EQ7Fp7XpwRMiK4XlAzXPNlUEp7u 4/EQX3Jij2EzEtGj7aLkhv7BavJTqhIkkt4TRH5An/fEm7Xe0wFtPWnHGvdP1d7MFYMP dqc2zLBeABTunevwua8Kw1a7jn19/WTlYQ6awzKlKLu2yVJJRiD8qKgrmoqIJu/A6IET +HkD9PjF+jiLM1I/iaCeBlEBWge0vgNSOXaGQmFo18XQGUtxDUjUm4tfajWjlu4ePuGY E3q4vroMv9Qa4Gen2GD8p/jyKMrhrzrn6asfqwJjmRWBkMO4mbv0a7yB+ZR/ZZr9d9Ec cTkg== 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 (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id g4si8019294ejw.305.2019.05.23.08.03.34 for ; Thu, 23 May 2019 08:03:34 -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 6DE8115BF; Thu, 23 May 2019 08:03:33 -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 0BDDB3F690; Thu, 23 May 2019 08:03:31 -0700 (PDT) From: Robin Murphy To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, will.deacon@arm.com, catalin.marinas@arm.com, anshuman.khandual@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 4/4] arm64: mm: Implement pte_devmap support Date: Thu, 23 May 2019 16:03:16 +0100 Message-Id: <817d92886fc3b33bcbf6e105ee83a74babb3a5aa.1558547956.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 In order for things like get_user_pages() to work on ZONE_DEVICE memory, we need a software PTE bit to identify device-backed PFNs. Hook this up along with the relevant helpers to join in with ARCH_HAS_PTE_DEVMAP. Signed-off-by: Robin Murphy --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/pgtable-prot.h | 1 + arch/arm64/include/asm/pgtable.h | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 4780eb7af842..b5a4611fa4c6 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -23,6 +23,7 @@ config ARM64 select ARCH_HAS_KCOV select ARCH_HAS_KEEPINITRD select ARCH_HAS_MEMBARRIER_SYNC_CORE + select ARCH_HAS_PTE_DEVMAP select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_SETUP_DMA_OPS select ARCH_HAS_SET_MEMORY diff --git a/arch/arm64/include/asm/pgtable-prot.h b/arch/arm64/include/asm/pgtable-prot.h index 986e41c4c32b..af0b372d15e5 100644 --- a/arch/arm64/include/asm/pgtable-prot.h +++ b/arch/arm64/include/asm/pgtable-prot.h @@ -28,6 +28,7 @@ #define PTE_WRITE (PTE_DBM) /* same as DBM (51) */ #define PTE_DIRTY (_AT(pteval_t, 1) << 55) #define PTE_SPECIAL (_AT(pteval_t, 1) << 56) +#define PTE_DEVMAP (_AT(pteval_t, 1) << 57) #define PTE_PROT_NONE (_AT(pteval_t, 1) << 58) /* only when !PTE_VALID */ #ifndef __ASSEMBLY__ diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 2c41b04708fe..a6378625d47c 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -90,6 +90,7 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]; #define pte_write(pte) (!!(pte_val(pte) & PTE_WRITE)) #define pte_user_exec(pte) (!(pte_val(pte) & PTE_UXN)) #define pte_cont(pte) (!!(pte_val(pte) & PTE_CONT)) +#define pte_devmap(pte) (!!(pte_val(pte) & PTE_DEVMAP)) #define pte_cont_addr_end(addr, end) \ ({ unsigned long __boundary = ((addr) + CONT_PTE_SIZE) & CONT_PTE_MASK; \ @@ -217,6 +218,11 @@ static inline pmd_t pmd_mkcont(pmd_t pmd) return __pmd(pmd_val(pmd) | PMD_SECT_CONT); } +static inline pte_t pte_mkdevmap(pte_t pte) +{ + return set_pte_bit(pte, __pgprot(PTE_DEVMAP)); +} + static inline void set_pte(pte_t *ptep, pte_t pte) { WRITE_ONCE(*ptep, pte); @@ -381,6 +387,9 @@ static inline int pmd_protnone(pmd_t pmd) #define pmd_mkhuge(pmd) (__pmd(pmd_val(pmd) & ~PMD_TABLE_BIT)) +#define pmd_devmap(pmd) pte_devmap(pmd_pte(pmd)) +#define pmd_mkdevmap(pmd) pte_pmd(pte_mkdevmap(pmd_pte(pmd))) + #define __pmd_to_phys(pmd) __pte_to_phys(pmd_pte(pmd)) #define __phys_to_pmd_val(phys) __phys_to_pte_val(phys) #define pmd_pfn(pmd) ((__pmd_to_phys(pmd) & PMD_MASK) >> PAGE_SHIFT) @@ -537,6 +546,11 @@ static inline phys_addr_t pud_page_paddr(pud_t pud) return __pud_to_phys(pud); } +static inline int pud_devmap(pud_t pud) +{ + return 0; +} + /* Find an entry in the second-level page table. */ #define pmd_index(addr) (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1)) @@ -624,6 +638,11 @@ static inline phys_addr_t pgd_page_paddr(pgd_t pgd) #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd_val(pgd)) +static inline int pgd_devmap(pgd_t pgd) +{ + return 0; +} + /* to find an entry in a page-table-directory */ #define pgd_index(addr) (((addr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))