Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp572207pxu; Wed, 14 Oct 2020 08:20:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzjyJd+r5a44+AJob+1eyc2ra1BfIjsE6vcUxztoYvxiCgMVsg7TQa/J/Yow51t8pdHHnW X-Received: by 2002:aa7:c915:: with SMTP id b21mr5799312edt.25.1602688853642; Wed, 14 Oct 2020 08:20:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602688853; cv=none; d=google.com; s=arc-20160816; b=rGJEviNxLLzwDpvk4AqNFyqcc/eNINXHhAIkC/M3aniQZubSjTvQg/8spXS5iWznfk 76CrqPtB6gYBBQ9SIFA1+uP2oo1pFSA1EgR3W+e5jJMV+UsoDzhCKv8BGLSz4wD/VVjw mYM1E5aXXMbDqYaBcoY+PM6df0xBfYCXDxcgG/sRtbruImCwAcOCHQhFnmsuWmL7RSe7 6VAFfncIZO/tjoLP2906R/kEccEEVY4LBFBgzJAGksxSGphbQQf95LEuNV8WVT0rgX5z Itafe9QR9cu/Uow7oMOFEqoKKlvuob4hFOPI0/CwBUdxHGTykIcnIFPh5z3VBC2svFD0 4l/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:cc:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=htuM5XIelPXQQXL8oIf2e/a5DAtFUl+iOYnn4bwvhGc=; b=1DkMoiJ345VarVSfjfLZO739H931H3ZR2KZlBOImOnAy4j1Irk6yCnK660vlNfslQO zhEe7+vABNg/QgtPS2EnJIiQ9XuCQ+vOTbhYMAFmzEaj434g0fqRaTNeJ1Wj1mHOynrS vm+CQcn1uVvOXHO9F+25sNDh5bOCFfqWmW3AaOWTBNY837PrcRieAkSiBnmMQC1WwReY ruOUxWZfnrGqH6v7V5o0HcGuESjpTCKnfHjeAEpsKQr4vO/dmrJK665V4ybQeUiUx/8f /Ja3G90aXXO2lqrTK6GHhWnc2v6CC1pTMA5w3mQr5Qchz+T8VjzGZjOxHUz2ER8AgkhJ vZUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CMRAL6JA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m4si2536942edv.101.2020.10.14.08.20.28; Wed, 14 Oct 2020 08:20:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CMRAL6JA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730531AbgJNJUO (ORCPT + 99 others); Wed, 14 Oct 2020 05:20:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730757AbgJNJUJ (ORCPT ); Wed, 14 Oct 2020 05:20:09 -0400 Received: from mail-vs1-xe49.google.com (mail-vs1-xe49.google.com [IPv6:2607:f8b0:4864:20::e49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAB27C0251BB for ; Tue, 13 Oct 2020 17:54:39 -0700 (PDT) Received: by mail-vs1-xe49.google.com with SMTP id z9so504096vsl.3 for ; Tue, 13 Oct 2020 17:54:39 -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=htuM5XIelPXQQXL8oIf2e/a5DAtFUl+iOYnn4bwvhGc=; b=CMRAL6JAtDqSgRV7ZpF02r6NBp/0nc+94iGdBDTPU4PFiUZAv/Y8jRqN27jzxwPPnp vFLsngZcAyUU4xkRcpm1NFeKRmryyQP+fIVaPMNUpCX7nipK//0mhwToBcbbm//49Us7 ECHrX/3nZUKbULbZaqhOX1/zGLBAGzJ3WfYq2z5KhQXv6oORHwIN3MpulDFaG6oq722y 2/Kw2pi8QZLqn1DCHLaOFIvLY5/Yvg/aRP6S/Rz0VbFMh8XltQKWyAkMsZt3sNViURIJ l3jVm32z1TgDhRNocvrC/nsAUzCWhkrMOnW355gs+qtWsum8sO+E9aDZI11FZLqRBAOQ saZQ== 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=htuM5XIelPXQQXL8oIf2e/a5DAtFUl+iOYnn4bwvhGc=; b=BQbqW6jhnW4UEX1Z4wrT+psftMhjOZ2q5Wr8wLAyqysA0Eh087Up5WWFp4H8ShSvsE AFUp78DWLx7yisl0UG6RRA25no0QUUYZ1u599fcaBlAA46la652fwYgyBlR+hg69JI0m uyCjq9wsErvJDj69vHqBaIA8vDzg802hEOp6cYG4RlNJQxI046S+5nhI4lemckrYl9lA wOUdr4P44+dTjkke1oT2LI4RF6cvtIuBj6mre9+AUNhzkwITE7+ABKO6ZIbmKzPaUoZE 9vkDrzgTPVYjg8iPVfeTmV8BVaMXwy/LTjK6hxvsFgdVJz16YBP7dAYXPaq56AOtTR8P 5w9g== X-Gm-Message-State: AOAM531UIuhjeiRs8Vy7fVzhsmVyJWEsYilFmQKi2UcLTkiGbrtrBrlG j6fuH5G+vrSaaDLS5MzsP+mXB8Gc63+sX3ARyg== Sender: "kaleshsingh via sendgmr" X-Received: from kaleshsingh.c.googlers.com ([fda3:e722:ac3:10:14:4d90:c0a8:2145]) (user=kaleshsingh job=sendgmr) by 2002:a05:6122:804:: with SMTP id 4mr1935610vkj.15.1602636878883; Tue, 13 Oct 2020 17:54:38 -0700 (PDT) Date: Wed, 14 Oct 2020 00:53:09 +0000 In-Reply-To: <20201014005320.2233162-1-kaleshsingh@google.com> Message-Id: <20201014005320.2233162-5-kaleshsingh@google.com> Mime-Version: 1.0 References: <20201014005320.2233162-1-kaleshsingh@google.com> X-Mailer: git-send-email 2.28.0.1011.ga647a8990f-goog Subject: [PATCH v4 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, "Kirill A . Shutemov" , Catalin Marinas , Will Deacon , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Shuah Khan , Peter Zijlstra , "Aneesh Kumar K.V" , Kees Cook , Josh Poimboeuf , Sami Tolvanen , Masahiro Yamada , Arnd Bergmann , Frederic Weisbecker , Krzysztof Kozlowski , Hassan Naveed , Christian Brauner , Stephen Boyd , Anshuman Khandual , Gavin Shan , Mike Rapoport , Steven Price , Jia He , John Hubbard , Ram Pai , Ralph Campbell , Mina Almasry , Sandipan Das , Dave Hansen , Brian Geffon , Masami Hiramatsu , Kamalesh Babulal , SeongJae Park , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Acked-by: Kirill A. Shutemov Cc: Catalin Marinas Cc: Will Deacon Cc: Andrew Morton --- Changes in v3: - Add set_pud_at() macro - Used by move_normal_pud(). Changes in v4: - Add Kirill's Acked-by. 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 434d6791e869..7191a79fb44d 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -124,6 +124,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 a11bf52e0c38..0b0b36974757 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -454,6 +454,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) -- 2.28.0.1011.ga647a8990f-goog