From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MISSING_HEADERS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 169B3C433E7 for ; Wed, 14 Oct 2020 00:53:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 75B92208B3 for ; Wed, 14 Oct 2020 00:53:51 +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="WVUVCVw4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 75B92208B3 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 983676B005D; Tue, 13 Oct 2020 20:53:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 90CEB6B0062; Tue, 13 Oct 2020 20:53:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D5216B0068; Tue, 13 Oct 2020 20:53:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0137.hostedemail.com [216.40.44.137]) by kanga.kvack.org (Postfix) with ESMTP id 4CCD46B005D for ; Tue, 13 Oct 2020 20:53:50 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D91851EE6 for ; Wed, 14 Oct 2020 00:53:49 +0000 (UTC) X-FDA: 77368708578.11.band15_5316bd027207 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id B53BE180F8B81 for ; Wed, 14 Oct 2020 00:53:49 +0000 (UTC) X-HE-Tag: band15_5316bd027207 X-Filterd-Recvd-Size: 7761 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Wed, 14 Oct 2020 00:53:49 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id f199so1571362yba.12 for ; Tue, 13 Oct 2020 17:53:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:cc :content-transfer-encoding; bh=kqal+0zLGFPhz9I+TIzRUZfLWtzX1D3uO8CqpABK0Y0=; b=WVUVCVw4XS9agygn2X5xXGsf6TB48LO7rOqfRM26gPVAcIi/Q0oNF1DmibxWSjxvAs umqZ3cfMD9qO8wONFXAV1wVytwjdvMH7Iqeu//x9hJm4vxVOfjDJ98PK+VXVClZTGTCG 0y3Rh/MhLWD6DC1A2hLxY66SD1DNrE0QRDtvOp/lj9yp1fFI130ysngIs7343WzrLyWV vAwj1nW2id05cmwRLC9a8wH1x5ttIdjCeTv8vih/+GMRjVdUKKR/pF48iDG0sGWo42ns 5vmFdl3WQlhAHmw2TuEqZOWYE+pmhQORZLE+F+93WPbOaTRJN3ZpC+ltSa7l+3PJv/iA TOtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :cc:content-transfer-encoding; bh=kqal+0zLGFPhz9I+TIzRUZfLWtzX1D3uO8CqpABK0Y0=; b=jZqJ1Sc8kD7ZwSIQogCrB2aK+uI6BKav26tYv3Q0qUCRWxB+ByWxr3iX50LF0QGL7V XZ49aYORIox8fUzy+fgoSaDxEJYSFFK/2X+6AUK2oEwW9DIZE/SjXkZwSNyVW3KZHL/Y 56lKEWsKJjQ1JSmbqak4M3QavSr0ZUz7G1FQ7SiqKoLjC2ZfOwjgovSC1pSk9rGF5b2j sjwIDLzUxNnL24KlGI4h8gBFNeGwzC7W5950ILmq8GNnY3pWhqx1jtGVZcMaYFHhxqz4 bwKhxJueSmN2Rn6iR0lqKKasyi4BoqV8i9IvifhK9RjTpgiFpHIw9/nOCeGaHGhntIc3 GjNA== X-Gm-Message-State: AOAM530jiLhxDrRSPnlhJvDpahTzG5hG0iaGa+wRYl7KsmXxJHXDkKlU r7m4/76AdxnFaTP5rxKbbx6F7rsPwsSfecqO3g== X-Google-Smtp-Source: ABdhPJxcUglBSX8zjEb9PvLiSn3/zi25+djWBaggtZDkIuOyPU3cZl6r6XPSEWn/Zr5eA1goeDpmGvNtLwj26KYQ5g== X-Received: from kaleshsingh.c.googlers.com ([fda3:e722:ac3:10:14:4d90:c0a8:2145]) (user=kaleshsingh job=sendgmr) by 2002:a25:c709:: with SMTP id w9mr3716846ybe.327.1602636828326; Tue, 13 Oct 2020 17:53:48 -0700 (PDT) Date: Wed, 14 Oct 2020 00:53:05 +0000 Message-Id: <20201014005320.2233162-1-kaleshsingh@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.1011.ga647a8990f-goog Subject: [PATCH v4 0/5] Speed up mremap on large regions 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 , Peter Zijlstra , "Aneesh Kumar K.V" , Kees Cook , Arnd Bergmann , Josh Poimboeuf , Sami Tolvanen , Frederic Weisbecker , Krzysztof Kozlowski , Hassan Naveed , Christian Brauner , Stephen Boyd , Anshuman Khandual , Mark Brown , Gavin Shan , Mike Rapoport , Steven Price , Jia He , John Hubbard , Masahiro Yamada , Ralph Campbell , "Kirill A. Shutemov" , Mina Almasry , Sandipan Das , Dave Hansen , Masami Hiramatsu , Brian Geffon , Jason Gunthorpe , 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" Content-Transfer-Encoding: quoted-printable 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: This is a repost of the mremap speed up patches, adding Kirill's Acked-by's (from a separate discussion). The previous versions are posted at: v1 - https://lore.kernel.org/r/20200930222130.4175584-1-kaleshsingh@google.= com v2 - https://lore.kernel.org/r/20201002162101.665549-1-kaleshsingh@google.c= om v3 - http://lore.kernel.org/r/20201005154017.474722-1-kaleshsingh@google.co= m mremap time can be optimized by moving entries at the PMD/PUD level if the source and destination addresses are PMD/PUD-aligned and PMD/PUD-sized. Enable moving at the PMD and PUD levels on arm64 and x86. Other architectures where this type of move is supported and known to be safe can also opt-in to these optimizations by enabling HAVE_MOVE_PMD and HAVE_MOVE_PUD. Observed Performance Improvements for remapping a PUD-aligned 1GB-sized region on x86 and arm64: - HAVE_MOVE_PMD is already enabled on x86 : N/A - Enabling HAVE_MOVE_PUD on x86 : ~13x speed up - Enabling HAVE_MOVE_PMD on arm64 : ~ 8x speed up - Enabling HAVE_MOVE_PUD on arm64 : ~19x speed up Altogether, HAVE_MOVE_PMD and HAVE_MOVE_PUD give a total of ~150x speed up on arm64. Changes in v2: - Reduce mremap_test time by only validating a configurable threshold of the remapped region, as per John. - Use a random pattern for mremap validation. Provide pattern seed in test output, as per John. - Moved set_pud_at() to separate patch, per Kirill. - Use switch() instead of ifs in move_pgt_entry(), per Kirill. - Update commit message with description of Android garbage collector use case for HAVE_MOVE_PUD, as per Joel. - Fix build test error reported by kernel test robot in [1]. Changes in v3: - Make lines 80 cols or less where they don=E2=80=99t need to be longer, per John. - Removed unused PATTERN_SIZE in mremap_test - Added Reviewed-by tag for patch 1/5 (mremap kselftest patch). - Use switch() instead of ifs in get_extent(), per Kirill - Add BUILD_BUG() is get_extent() default case. - Move get_old_pud() and alloc_new_pud() out of #ifdef CONFIG_HAVE_MOVE_PUD, per Kirill. - Have get_old_pmd() and alloc_new_pmd() use get_old_pud() and alloc_old_pud(), per Kirill. - Replace #ifdef CONFIG_HAVE_MOVE_PMD / PUD in move_page_tables() with IS_ENABLED(CONFIG_HAVE_MOVE_PMD / PUD), per Kirill. - Fold Add set_pud_at() patch into patch 4/5, per Kirill. [1] https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org/thread/CKP= GL4FH4NG7TGH2CVYX2UX76L25BTA3/ Kalesh Singh (5): kselftests: vm: Add mremap tests arm64: mremap speedup - Enable HAVE_MOVE_PMD mm: Speedup mremap on 1GB or larger regions arm64: mremap speedup - Enable HAVE_MOVE_PUD x86: mremap speedup - Enable HAVE_MOVE_PUD arch/Kconfig | 7 + arch/arm64/Kconfig | 2 + arch/arm64/include/asm/pgtable.h | 1 + arch/x86/Kconfig | 1 + mm/mremap.c | 230 ++++++++++++--- tools/testing/selftests/vm/.gitignore | 1 + tools/testing/selftests/vm/Makefile | 1 + tools/testing/selftests/vm/mremap_test.c | 344 +++++++++++++++++++++++ tools/testing/selftests/vm/run_vmtests | 11 + 9 files changed, 558 insertions(+), 40 deletions(-) create mode 100644 tools/testing/selftests/vm/mremap_test.c --=20 2.28.0.1011.ga647a8990f-goog