From patchwork Mon Oct 5 15:40:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 11816881 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 A246592C for ; Mon, 5 Oct 2020 15:42:44 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 743AE20639 for ; Mon, 5 Oct 2020 15:42:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="yfCsy6rX"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="ISCc2/Q+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 743AE20639 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:From:Subject:Mime-Version:Message-Id:Date:Reply-To: To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=9TUMS+isYydxswTyZEaBWrJJFpvHRDg6Cj0Z57vfxB4=; b=yfCsy6rX+hYTJF+qYtYYW6n02V 4BG70/3AnRj0eWpFxxfYjKrI7lNctWUjKH89xUlwnC3kQvMs74SOfMtIb9VFax4ahsVORuwuTOxXf c4/OHe0GtYNa41srpH/Hd7W7Cq1w4vBWmmAc6TgV1kIzQevxfnQlK9I92paMNZkeRlIQ7gKYe9fmH 13e453W8uXPA61dUp2GWnpw6d7aADUaxHrI73soBQlJH9nZELOacHoT5vS+Vh6OyEbLGybLTLAWvF abb47zYxZE7uF1TVYIa+eDOuJVb3cOKbM6a7fB+gCPnyy6b6+py/jtPhwUjMGEafhfEe2m8m7VXEg F/HAU+PQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPSbG-00012F-MD; Mon, 05 Oct 2020 15:40:30 +0000 Received: from mail-qv1-xf49.google.com ([2607:f8b0:4864:20::f49]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPSbB-0000xM-Lu for linux-arm-kernel@lists.infradead.org; Mon, 05 Oct 2020 15:40:28 +0000 Received: by mail-qv1-xf49.google.com with SMTP id 99so6098915qva.1 for ; Mon, 05 Oct 2020 08:40:22 -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=roRRmpnOQfqBgouvFdnsiNMWHoFG1to3sn9HMTXsuVQ=; b=ISCc2/Q+3RqQHnmu/kT5NtbJpNZ7wC8V64UlYxth0OYKIluZdxX7K1qgddenEuyZkZ Wc8U6+kyTzsPPNyB+D9cDFo3M4s3lBLOfMlJJxYiV4Ltu9WPKkx8LeCnf3CGMyu8pe24 QIGKxtMSedAWRhEGXxS0Czaq2oiy71ShEVY7Ny+oG2nkFMpoiSWHyoAzbffu/G8vt1qm eXe1gnFdmR2B0WLUvrfX5yF+c/CGo5F5OCtcPRN88pnNiyl4nNnJeDRa7KIyr/t/xLbn r+McOy57d3h71tj/brwaYwm0tHmetXO0th1kYsTBVqPc0WeiLDFOn5mbQ/vuX5IbqSp1 CFqw== 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=roRRmpnOQfqBgouvFdnsiNMWHoFG1to3sn9HMTXsuVQ=; b=sQ8ol2DEJdjsutmXWGn5cuPsFqa5rYzrFohx0xoaewWYjfkOWRXbgZCogJFR2v6LOs A8RuwoTT3JiuvjwnMgMDQQhoDv2adCd1d+ZNCTXr2KILSBXcEkFc7Ci2zYXDuxTwe17S WxBEopOrtZO5Phwm59lTVpKL0dLi7TUerPdNtsVtlCf7GDYPs0bxaeijrG8vzv4c3HBi rc+93hmRqWg+2T2E0Zv0loX7a9edCC6cJ2pTxqKFh0KQOpvfGWLjtUQRmqk426liEXGH 7Dgv+87wqdu/OhS64+MrdHDU6HCQk5ossO4bGAHFeg3ggRDKGX5BTw8JTCSeI4jlY98d jDvQ== X-Gm-Message-State: AOAM532iMetTN4/gCAz71vTQaPxoqhPVzm7RUujBVEOGE87An1MajVUw b4mJCuNMYTVPdjz2qxYIacH98EAjv+Mdn6zudw== X-Google-Smtp-Source: ABdhPJzWIPbd8bmYokW5hjiB2Kdv49nELig2YTyft80Zu/HTSnekvJDgjzVfD9yHuYp1YWGhjsp5xyZutg5nHRLLjw== X-Received: from kaleshsingh.c.googlers.com ([fda3:e722:ac3:10:14:4d90:c0a8:2145]) (user=kaleshsingh job=sendgmr) by 2002:ad4:58c7:: with SMTP id dh7mr278895qvb.20.1601912420924; Mon, 05 Oct 2020 08:40:20 -0700 (PDT) Date: Mon, 5 Oct 2020 15:40:03 +0000 Message-Id: <20201005154017.474722-1-kaleshsingh@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.806.g8561365e88-goog Subject: [PATCH v3 0/5] Speed up mremap on large regions From: Kalesh Singh X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201005_114025_809456_D3AB282C X-CRM114-Status: GOOD ( 18.94 ) X-Spam-Score: -6.5 (------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-6.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:f49 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.2 MISSING_HEADERS Missing To: header -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_MED DKIMwl.org - Medium trust sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: joelaf@google.com, Mark Rutland , Gavin Shan , Brian Geffon , Peter Zijlstra , Catalin Marinas , kaleshsingh@google.com, Ram Pai , Dave Hansen , Will Deacon , lokeshgidra@google.com, linux-kselftest@vger.kernel.org, "H. Peter Anvin" , Christian Brauner , Shuah Khan , Mina Almasry , Jia He , Arnd Bergmann , "Aneesh Kumar K.V" , Masahiro Yamada , x86@kernel.org, Krzysztof Kozlowski , Jason Gunthorpe , Ingo Molnar , Sami Tolvanen , kernel-team@android.com, Hassan Naveed , Masami Hiramatsu , Ralph Campbell , Kees Cook , minchan@google.com, Zhenyu Ye , John Hubbard , Frederic Weisbecker , Mark Brown , Borislav Petkov , Thomas Gleixner , surenb@google.com, linux-arm-kernel@lists.infradead.org, SeongJae Park , linux-mm@kvack.org, "Kirill A. Shutemov" , linux-kernel@vger.kernel.org, Thiago Jung Bauermann , Andrew Morton , Mike Rapoport , Sandipan Das Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This version 3 of the mremap speed up patches previously 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.com 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’t 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/CKPGL4FH4NG7TGH2CVYX2UX76L25BTA3/ 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 base-commit: 549738f15da0e5a00275977623be199fbbf7df50