From patchwork Mon Oct 5 15:40:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 11816863 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D4AE06CA for ; Mon, 5 Oct 2020 15:41:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 97C5E206DD for ; Mon, 5 Oct 2020 15:41:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="W2aOWNF9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 97C5E206DD Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A50D3900006; Mon, 5 Oct 2020 11:41:13 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9D95B8E0001; Mon, 5 Oct 2020 11:41:13 -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 89FD7900006; Mon, 5 Oct 2020 11:41:13 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0250.hostedemail.com [216.40.44.250]) by kanga.kvack.org (Postfix) with ESMTP id 560498E0001 for ; Mon, 5 Oct 2020 11:41:13 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id EF9EB1EE6 for ; Mon, 5 Oct 2020 15:41:12 +0000 (UTC) X-FDA: 77338285584.10.tree21_270a347271bf Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id C96A716A0D1 for ; Mon, 5 Oct 2020 15:41:12 +0000 (UTC) X-Spam-Summary: 1,0,0,1a2cb87f36f0e297,d41d8cd98f00b204,3lz57xwskcaqoepiwlwmrklksskpi.gsqpmry1-qqozego.svk@flex--kaleshsingh.bounces.google.com,,RULES_HIT:41:152:355:379:387:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1535:1542:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3152:3353:3865:3866:3867:3868:3870:3871:3872:3874:4117:4250:4321:4605:5007:6261:6630:6653:6742:6743:7875:7903:9121:9969:10004:10400:11026:11232:11233:11473:11657:11658:11914:12043:12295:12296:12297:12438:12555:12895:12986:13161:13229:14096:14097:14181:14394:14659:14721:21444:21451:21627:30054:30070,0,RBL:209.85.219.73:@flex--kaleshsingh.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04yfig7e1r4is636jrxiikpnpfxm7oph5qysqmg57du3me54e89nxawowjaymwx.agmihhb8umbbcrk899dje83ptdpc7rcdm4zmd8icho7htt7zsejoq3ok8td9yqt.r-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNS BL:neutr X-HE-Tag: tree21_270a347271bf X-Filterd-Recvd-Size: 6839 Received: from mail-qv1-f73.google.com (mail-qv1-f73.google.com [209.85.219.73]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Mon, 5 Oct 2020 15:41:12 +0000 (UTC) Received: by mail-qv1-f73.google.com with SMTP id p20so6103462qvl.4 for ; Mon, 05 Oct 2020 08:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:cc; bh=A4+tWYJC+Fdx2lTpRNnDkPfjCAnLWkjDYMNCZGAhfI0=; b=W2aOWNF9PsP0MZcadNdtub1GL6B+1QEv2O6Tx/gfiiqRQrQ7sZ2eN0RLDb51NqwTf2 5Rwk0gro4+qBtPMNI2l5xlU3U8/6Luiau8YNKUNkauTENCGXDsWYVJKPe8QOvHAmYhwB QKkz99XZMdn81N/UKOnZAyk8RyF8RhCGuAsYMcIvhy8FmEyP/YQ8XU4tIOVzrs2A5uYt sSw18nX8ARS7WlBHu/wLjtkuPPwAhp3hk4q1HPOtxz0nfrymx4x9azSzkbfjQSQ48+Fs c9fqzdbm+NLNQygBtOAaOl5dSQO1qzNo96WzL+jrkL/IxLY6k0ZqTVu4WCo7gRbyqE3u 1ttA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:cc; bh=A4+tWYJC+Fdx2lTpRNnDkPfjCAnLWkjDYMNCZGAhfI0=; b=p5F/6WdmyLxNKg5pxLxEduwUhJ3mNgDRph4hjBYhnK/dpw5umRvl2xugcf45ubOoaN ly9MhumbPLh+kSILgNsGd2TZXgvPMI7p5u/3KrzFmQNM69xxAU4PaYH/6qm00+ZAXX3V 05/c1ySY8QGAtcHufE5G6cI2LXFudwqziXUMPkygYyyZexgrCJ7JlMWaMVEH5ye2ub8x JQo1ZlX+w5j+lUNZwDVJMIj+JOfzGivepyY42BJm+vkmmrbHn8wOa45M8txIqhf5zkxG uAQH/b2m45QcI7z8K7PxI3UA63iEa9+gU6buhUeXbZ3AGHxxnY6Slhd68RvUvkLRQgcS IPfw== X-Gm-Message-State: AOAM531DjwrRDaf1LB8k6/O79hhTB2gRaG0PVpUScWg2yPG5L4drxfJg ks8eo2rjxxImVmd2li4lWYkHGQmzkkGd66H2Fw== X-Google-Smtp-Source: ABdhPJwqH4Axuv8vQCr8AfVkLchHe5yXirxmBMUhO08uFxA9uxjk4KI3PjyIYdGPjqJpAGRfK7VpShrpY66rRcAmTA== X-Received: from kaleshsingh.c.googlers.com ([fda3:e722:ac3:10:14:4d90:c0a8:2145]) (user=kaleshsingh job=sendgmr) by 2002:a05:6214:a03:: with SMTP id dw3mr251880qvb.44.1601912471400; Mon, 05 Oct 2020 08:41:11 -0700 (PDT) Date: Mon, 5 Oct 2020 15:40:07 +0000 In-Reply-To: <20201005154017.474722-1-kaleshsingh@google.com> Message-Id: <20201005154017.474722-5-kaleshsingh@google.com> Mime-Version: 1.0 References: <20201005154017.474722-1-kaleshsingh@google.com> X-Mailer: git-send-email 2.28.0.806.g8561365e88-goog Subject: [PATCH v3 4/5] arm64: mremap speedup - Enable HAVE_MOVE_PUD From: Kalesh Singh Cc: surenb@google.com, minchan@google.com, joelaf@google.com, lokeshgidra@google.com, kaleshsingh@google.com, kernel-team@android.com, Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Andrew Morton , Shuah Khan , Kees Cook , "Aneesh Kumar K.V" , Peter Zijlstra , Masahiro Yamada , Arnd Bergmann , Sami Tolvanen , Frederic Weisbecker , Krzysztof Kozlowski , Hassan Naveed , Christian Brauner , Mark Rutland , Mike Rapoport , Gavin Shan , Dave Martin , Mark Brown , Jia He , Zhenyu Ye , John Hubbard , Greg Kroah-Hartman , Zi Yan , Ram Pai , Ralph Campbell , Mina Almasry , "Kirill A. Shutemov" , Sandipan Das , Dave Hansen , Jason Gunthorpe , Masami Hiramatsu , Brian Geffon , Kamalesh Babulal , SeongJae Park , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org 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: HAVE_MOVE_PUD enables remapping pages at the PUD level if both the source and destination addresses are PUD-aligned. With HAVE_MOVE_PUD enabled it can be inferred that there is approximately a 19x improvement in performance on arm64. (See data below). ------- Test Results --------- The following results were obtained using a 5.4 kernel, by remapping a PUD-aligned, 1GB sized region to a PUD-aligned destination. The results from 10 iterations of the test are given below: Total mremap times for 1GB data on arm64. All times are in nanoseconds. Control HAVE_MOVE_PUD 1247761 74271 1219896 46771 1094792 59687 1227760 48385 1043698 76666 1101771 50365 1159896 52500 1143594 75261 1025833 61354 1078125 48697 1134312.6 59395.7 <-- Mean time in nanoseconds A 1GB mremap completion time drops from ~1.1 milliseconds to ~59 microseconds on arm64. (~19x speed up). Signed-off-by: Kalesh Singh --- Change in v3: - Add set_pud_at() macro - Used by move_normal_pud(). arch/arm64/Kconfig | 1 + arch/arm64/include/asm/pgtable.h | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 844d089668e3..4d521f0a5863 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -122,6 +122,7 @@ config ARM64 select HANDLE_DOMAIN_IRQ select HARDIRQS_SW_RESEND select HAVE_MOVE_PMD + select HAVE_MOVE_PUD select HAVE_PCI select HAVE_ACPI_APEI if (ACPI && EFI) select HAVE_ALIGNED_STRUCT_PAGE if SLUB diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index d5d3fbe73953..8848125e3024 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -415,6 +415,7 @@ static inline pmd_t pmd_mkdevmap(pmd_t pmd) #define pfn_pud(pfn,prot) __pud(__phys_to_pud_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot)) #define set_pmd_at(mm, addr, pmdp, pmd) set_pte_at(mm, addr, (pte_t *)pmdp, pmd_pte(pmd)) +#define set_pud_at(mm, addr, pudp, pud) set_pte_at(mm, addr, (pte_t *)pudp, pud_pte(pud)) #define __p4d_to_phys(p4d) __pte_to_phys(p4d_pte(p4d)) #define __phys_to_p4d_val(phys) __phys_to_pte_val(phys)