From patchwork Fri Oct 2 16:20:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 11813977 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 B3FE3112C for ; Fri, 2 Oct 2020 16:22:47 +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 799C8206FA for ; Fri, 2 Oct 2020 16:22:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hCK4r9J0"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="eyT9arWU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 799C8206FA 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=QndMUAyKsEN3vKHjc+uKeUPq3+GLX07v2x3i9bkaCqc=; b=hCK4r9J0rnPTo1E+lblYdJ05xn nc5j6eE17wOVoaTgG4rkMrjBlP+t1UXqXi+6uO1bLkVRsHo5fgYLyTrB8vLDqXLn9bbLGpwE3z9Di eSZ/7cPQaZeuyVvGpNugxvUhoYCH5d0VY2kc8gGK9Es2zBMk9djEsRJdXJgvqBROpGzRHhY7k0wZX 68eys/bCjhHi1sd+J+3iinHkmDmJw/gZIOksBG+4eyHua7TlX0XjzahzSWNMe8atH3f4x6pG1iNZ9 zcOMF5ggTL+I4l/KhHp3VhEavyuX3kkqCLcV4JC5Vi00KtzZQVh8A1HY7SucZkV9NrLqnMJpfcNPy U0KFy/cQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kONo9-0002Vo-GI; Fri, 02 Oct 2020 16:21:21 +0000 Received: from mail-qk1-x749.google.com ([2607:f8b0:4864:20::749]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kONo6-0002Ti-C6 for linux-arm-kernel@lists.infradead.org; Fri, 02 Oct 2020 16:21:19 +0000 Received: by mail-qk1-x749.google.com with SMTP id 125so1439232qkh.4 for ; Fri, 02 Oct 2020 09:21:16 -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; bh=ihKrgqyZCQ8XMMYJ7a58uDLMLyOCJFezWU7B9DhnIPM=; b=eyT9arWU6MZav0P+TwNEl1M7D8mJOHf3BUXg5k6iIys+Fh+YkGI6KydRKCjp0rh/P4 ZIWMBLXY7zzQQHlr/S3Lx5C4etTuxRCFoGHF1Ya4oKLctPQawr3dgToLEYDCo2RxQxpW VphxbuMFtNZKjZYvp5JBjNyz46aSF6rVyQxXPjqsmOFDg4nt+M4DynJrQdDw72lP0oj8 HUD1CMNUmzpVcXWUUH4qO82oXyFcssOJKtUH1cFmW1D8cDnCdjzLLlwum6mPPRt6wg76 /hnqLxabSgYRtmgswS9ZkOnzO5dG/ElIaT3sIPnm/N2KLUkMfmHYoUh6sh5awof9/01c ElJg== 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; bh=ihKrgqyZCQ8XMMYJ7a58uDLMLyOCJFezWU7B9DhnIPM=; b=uBC11+3WzsJjq41OOOllW6sVffGDOcEbxjabXP8qgJfKMVtrUgIwRvd6vtnCNkSi7w MV0lY//s4Xg4Glx4lXz7HXN4Qd5nmBuXCLaZ6luef38nOSB27hPjO4z5+HoZCDwVtr51 8zfK6/0IerdKvBUARdF9WwuB8DNZnzYMMk0+yxclQUhStCfQPKAZmUWwdApe/j5GF0a7 HXpbIJqz9bAtPFIP+EkYA80e3uYFNx+6l1lVCZau2YKmavdZypNBODcAvQPF25mYsHAA eX30wSzDQLffl0+ulW5q0duxYYMKJXJDBH1HD4eFJV7tuzoDRwBi5gXib8dZGZaYkqkB R6vA== X-Gm-Message-State: AOAM531YO8zuB+OATLJ2+72eqgN9ppv+tDjTQyFTwtJIXPJXLQf8K4cG 02FDFAAoj+7SDMpidZ0s4VlXaYKmRc3Er+pZdg== X-Google-Smtp-Source: ABdhPJygoU2Ty06g5ZIiYrS6tuTHOeKqGmyxuIaNuoeVgzt+NiTCT4wV08YAgwGNDXrC6bntUe6q/jFKCM/nrckqWg== X-Received: from kaleshsingh.c.googlers.com ([fda3:e722:ac3:10:14:4d90:c0a8:2145]) (user=kaleshsingh job=sendgmr) by 2002:a0c:8091:: with SMTP id 17mr2893377qvb.19.1601655674261; Fri, 02 Oct 2020 09:21:14 -0700 (PDT) Date: Fri, 2 Oct 2020 16:20:45 +0000 Message-Id: <20201002162101.665549-1-kaleshsingh@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.806.g8561365e88-goog Subject: [PATCH v2 0/6] 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-20201002_122118_539588_092CE47C X-CRM114-Status: GOOD ( 16.67 ) 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:749 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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 , Kamalesh Babulal , linux-mm@kvack.org, William Kucharski , 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 , Steven Price , Ingo Molnar , Sami Tolvanen , kernel-team@android.com, Hassan Naveed , Masami Hiramatsu , Ralph Campbell , Kees Cook , minchan@google.com, Zhenyu Ye , Sandipan Das , John Hubbard , Frederic Weisbecker , Mark Brown , Borislav Petkov , Thomas Gleixner , surenb@google.com, linux-arm-kernel@lists.infradead.org, SeongJae Park , Dave Hansen , linux-kernel@vger.kernel.org, "Kirill A. Shutemov" , Andrew Morton , Mike Rapoport , Mike Kravetz Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This version 2 of the mremap speed up patches previously posted at: https://lore.kernel.org/r/20200930222130.4175584-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]. [1] https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org/thread/CKPGL4FH4NG7TGH2CVYX2UX76L25BTA3/ Kalesh Singh (6): kselftests: vm: Add mremap tests arm64: mremap speedup - Enable HAVE_MOVE_PMD mm: Speedup mremap on 1GB or larger regions arm64: Add set_pud_at() functions 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 | 220 +++++++++++++-- tools/testing/selftests/vm/.gitignore | 1 + tools/testing/selftests/vm/Makefile | 1 + tools/testing/selftests/vm/mremap_test.c | 333 +++++++++++++++++++++++ tools/testing/selftests/vm/run_vmtests | 11 + 9 files changed, 547 insertions(+), 30 deletions(-) create mode 100644 tools/testing/selftests/vm/mremap_test.c base-commit: 472e5b056f000a778abb41f1e443de58eb259783