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;