Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3487674pxk; Mon, 5 Oct 2020 10:54:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9Mc3p+oYwvw/VqhC2vsof0EanNk/hWH4ffJAebt/vHayVrr2GVCAtw9lyJHlyjr/m2R3C X-Received: by 2002:a17:906:dbf7:: with SMTP id yd23mr871199ejb.281.1601920493904; Mon, 05 Oct 2020 10:54:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601920493; cv=none; d=google.com; s=arc-20160816; b=uD8WWLA0sew5ptLFbrsOgQjol1ahMZSE5+wNr1Yojn5mQ/OoBxJSUTMTegUeBWugIe jU2SxfdlmpsbvkLL/TSjWv3YhNLmWUzgq2aGSV0OeMGAizgM1AgkFyZ4aIC2cIowMUoq 6EQ5PG9kJYCNTZGzej/GV8OdVA1FmAfJFoCkEBvpwF9ugIQvNA5eJ8uR6z+eAOqcXk9T C+PJ1SyYF8+KjXF3tKWgOLGnvq+JHJd9IblwYB3/KeMtI/nItD9OR5/LH4jEkTac8N8H ad91+XRGxzIUs4sdMY9T+Nmr1oOAGtxGjjAaCkpwTRJWSqu3LdivTZqZIQwkX97PYRrs prCg== 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=A4+tWYJC+Fdx2lTpRNnDkPfjCAnLWkjDYMNCZGAhfI0=; b=IEhW0bUc0OnAumiKvGXD8j4xTmiiCMuwnQnOyNBmO65UBfajZGJht3hCfgLUJy6nXK Nki8p76krrrmEszM66I8eMTDgsd13yOO2p61CsZ9DmiiJopg9aD/noZuR/vURRmuRK5d TOvYg7I1JkKQQgTLWoQLC4nmQrOk7cWXB3XMXoIUNb4/UikQRhULajXd4fL6v8OHcTkD sCSvtzxPoM1z364KtrMf75KxKt7I042IAQIaOkagLpHo59fw9SpqUEKazXbydGOaYq7a 1KGR68XPw+oh2a+XwWk3cNJQ2sHnlCujX4+h+Ota2c1XxILtM6tzMW4tcOxoG67XUZjp tOXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=W2aOWNF9; 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 i4si241820eja.130.2020.10.05.10.54.05; Mon, 05 Oct 2020 10:54: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=W2aOWNF9; 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 S1728819AbgJEPlj (ORCPT + 99 others); Mon, 5 Oct 2020 11:41:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728803AbgJEPlO (ORCPT ); Mon, 5 Oct 2020 11:41:14 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F037C0613A7 for ; Mon, 5 Oct 2020 08:41:12 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id s8so3311080qvv.18 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=HW9pmoMFoMNBGB/IbcbZ4fPJblQkpFlfAu040tZz6A8NK5RR/+6180WMtg/OBMl9se Qm61RzCRONwM4HnxpDvGcyNTs6dVZIVANGsxBJZHWo1nl2zYe5Uiqq7NzCSV1wLeRUSZ LRjHc4AviOExtvy/yHZxMcF2WrEk2nNML+tymEsWf+X8+03xJTUKwVqE8VSzCZ5Y50/h tEjSB1ENyMKv90la3etVA2U4NSQFaqVAGFxHoguyYv2c6zf87icQrbBpqpj7ZNjK3orj QxhczJrEIPIXznHvMg01/rFD+aj9H0YUeDxiGmNBLgpoN4eUg0UpN28Zg+68atn68oGI UTLA== X-Gm-Message-State: AOAM531qz9gkUSsyAIQtY/5rH+Ua45h1o13dOUUsNhxRg9W8QfCPUPJn /ilPX4DqJ3/BrQWskqQBTAuXIX6qvqMvA0/vNQ== 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: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 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 --- 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) -- 2.28.0.806.g8561365e88-goog