From patchwork Mon Feb 29 14:44:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 63223 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1293154lbc; Mon, 29 Feb 2016 06:50:32 -0800 (PST) X-Received: by 10.66.61.204 with SMTP id s12mr22867705par.108.1456757430977; Mon, 29 Feb 2016 06:50:30 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id r6si4699622pap.212.2016.02.29.06.50.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Feb 2016 06:50:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aaP8Q-0006DL-Hw; Mon, 29 Feb 2016 14:49:18 +0000 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aaP5J-0003S7-Bp for linux-arm-kernel@lists.infradead.org; Mon, 29 Feb 2016 14:46:07 +0000 Received: by mail-wm0-x22b.google.com with SMTP id l68so65917813wml.0 for ; Mon, 29 Feb 2016 06:45:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=B4LUuy7n2b0j/cO4tMQRpiVaP24C8PjkW/R76OeN+ds=; b=R9HNaevuwOZtLD7/bJ7QgeOb+Qwpoplw17gG+mfR4uI5ZlLCwcuJd8uPCxzMTmxXvL ej6594aVSTPeBL6kkpvajQsl103wY0mAaOSfsTg+1rQU0cbkXUu+8ZUz9MW5WtJPKpYP fePBxa3Zo+gYzkquf+7f5EEmlEIWYT8ZTRemA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=B4LUuy7n2b0j/cO4tMQRpiVaP24C8PjkW/R76OeN+ds=; b=QFauj6zRgWuXe1jKl79zRl5+XGWCfQtCibCq/9wzAyBdahPx6rzjn6iX2tAmoWe5Qo CRQBeyXpCDCm+bq9l7XQanJbhBUMVb+ymeBWG+n4EAO3bcdB337ytmDkvkR+G8X62Egz MNws2JYRTWYgNbeblqtjGVwDqW5nAtwK6RKYh8wMnkW8XbSXFz3LMZnqPOV5X8TxBP5A 73ogkhK+JVWsl8Gjp63NI4SjoH8qTgiDD8V0OGL1aOoLN30rm3v67vNXi5Zz2GDzgxUz /Y/ae5qT69JpJXRxR9omNTM+eZAPKNRmP2wWBzeMeOKVWcsJwXOyafltJVhvEmK1tLUJ 1kJg== X-Gm-Message-State: AD7BkJKBG8I3EMfWJUpRrTqxgunbFM9wJG00K28VDjtJkI1+pWCgnkKaasEc+90jkkAVfwhF X-Received: by 10.194.216.99 with SMTP id op3mr15624158wjc.26.1456757143554; Mon, 29 Feb 2016 06:45:43 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id di1sm26196693wjc.3.2016.02.29.06.45.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Feb 2016 06:45:42 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will.deacon@arm.com, mark.rutland@arm.com Subject: [PATCH v2 9/9] mm: replace open coded page to virt conversion with page_to_virt() Date: Mon, 29 Feb 2016 15:44:44 +0100 Message-Id: <1456757084-1078-10-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1456757084-1078-1-git-send-email-ard.biesheuvel@linaro.org> References: <1456757084-1078-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160229_064605_711304_82F61930 X-CRM114-Status: GOOD ( 16.20 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:22b listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jonas@southpole.se, Ard Biesheuvel , linux-mm@kvack.org, nios2-dev@lists.rocketboards.org, linux@lists.openrisc.net, lftan@altera.com, akpm@linux-foundation.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org The open coded conversion from struct page address to virtual address in lowmem_page_address() involves an intermediate conversion step to pfn number/physical address. Since the placement of the struct page array relative to the linear mapping may be completely independent from the placement of physical RAM (as is that case for arm64 after commit dfd55ad85e 'arm64: vmemmap: use virtual projection of linear region'), the conversion to physical address and back again should factor out of the equation, but unfortunately, the shifting and pointer arithmetic involved prevent this from happening, and the resulting calculation essentially subtracts the address of the start of physical memory and adds it back again, in a way that prevents the compiler from optimizing it away. Since the start of physical memory is not a build time constant on arm64, the resulting conversion involves an unnecessary memory access, which we would like to get rid of. So replace the open coded conversion with a call to page_to_virt(), and use the open coded conversion as its default definition, to be overriden by the architecture, if desired. The existing arch specific definitions of page_to_virt are all equivalent to this default definition, so by itself this patch is a no-op. Cc: linux-mm@kvack.org Cc: Andrew Morton Signed-off-by: Ard Biesheuvel --- include/linux/mm.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.5.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/include/linux/mm.h b/include/linux/mm.h index 516e14944339..82cb74a3b158 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -71,6 +71,10 @@ extern int mmap_rnd_compat_bits __read_mostly; #define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x), 0)) #endif +#ifndef page_to_virt +#define page_to_virt(x) __va(PFN_PHYS(page_to_pfn(x))) +#endif + /* * To prevent common memory management code establishing * a zero page mapping on a read fault. @@ -927,7 +931,7 @@ static inline void set_page_memcg(struct page *page, struct mem_cgroup *memcg) static __always_inline void *lowmem_page_address(const struct page *page) { - return __va(PFN_PHYS(page_to_pfn(page))); + return page_to_virt(page); } #if defined(CONFIG_HIGHMEM) && !defined(WANT_PAGE_VIRTUAL)