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: 11813943 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 11A50139A for ; Fri, 2 Oct 2020 16:21:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B5F7F208A9 for ; Fri, 2 Oct 2020 16:21:17 +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="eyT9arWU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B5F7F208A9 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 D00D06B005C; Fri, 2 Oct 2020 12:21:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C89A76B005D; Fri, 2 Oct 2020 12:21:16 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B51676B0062; Fri, 2 Oct 2020 12:21:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0020.hostedemail.com [216.40.44.20]) by kanga.kvack.org (Postfix) with ESMTP id 8652D6B005C for ; Fri, 2 Oct 2020 12:21:16 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 1E1941EE6 for ; Fri, 2 Oct 2020 16:21:16 +0000 (UTC) X-FDA: 77327500152.13.pen30_460acfc271a5 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id E7AB918140B70 for ; Fri, 2 Oct 2020 16:21:15 +0000 (UTC) X-Spam-Summary: 1,0,0,2b882aa5fb064759,d41d8cd98f00b204,3eln3xwskcaelbmftitjohihpphmf.dpnmjovy-nnlwbdl.psh@flex--kaleshsingh.bounces.google.com,,RULES_HIT:41:152:355:379:387:541:800:967:973:982:988:989:1260:1277:1313:1314:1345:1437:1516:1518:1535:1542:1593:1594:1711:1730:1747:1777:1792:1801:2194:2199:2393:2525:2559:2564:2682:2685:2859:2895:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3152:3354:3865:3866:3867:3868:3870:3871:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4117:4250:4321:4605:5007:6119:6261:6630:6653:6742:6743:7875:7903:9010:9025:9121:9969:10004:10400:11026:11233:11473:11657:11658:11914:12043:12266:12291:12296:12297:12438:12555:12663:12679:12895:12986:13095:13161:13229:13845:13846:14096:14097:14181:14394:14659:14721:21365:21433:21444:21451:21627:30054:30056:30069:30070,0,RBL:209.85.222.202:@flex--kaleshsingh.bounces.google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04yr9ze6icnb7zkdtjkxyt7dowfe7yptrqm57wdi37etr8gtfnznizzfaydyr4n .8qfj8p3 X-HE-Tag: pen30_460acfc271a5 X-Filterd-Recvd-Size: 6857 Received: from mail-qk1-f202.google.com (mail-qk1-f202.google.com [209.85.222.202]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Fri, 2 Oct 2020 16:21:15 +0000 (UTC) Received: by mail-qk1-f202.google.com with SMTP id x191so1429329qkb.3 for ; Fri, 02 Oct 2020 09:21:15 -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=GaNyISp62YordfLmC/HcPqverlDs7UfR0oYdLZfeW7ARSQu+8Tl36vELhQ2qaw6y6B RvMOI9AmY0bhEYL0ESTjAZWz9ItvKOxQTr3gU+mSXo5OJjdlWEMeHU6v3y/rn+d+L89t LY0KU6p/6zynsc6wzsvNpq9vwJ/Amw4bYvK/vMJh91/PA+fn48fBGHiFxR4yh1jM9Ipf CM8bKgEvWLyRd6aQuqGgdhbGmS+x809egVVSO2nYn4uApDfc5npWNyyPeA68ydjhhOJi yUbKxLkcAu4CTF7TIiiuGLqsuM4lduFQt5lp6sDaxdFB3p1Sx2nvix3ffTXtZamN8Wpc qPIg== X-Gm-Message-State: AOAM531/RLqOqQuPIKDn0RUcV391JD8tNx7BzH6YsK32NyGYLRQezjD4 R30NXhsOg61zdJ7nOABZflzkeO2xRe/LREdHgw== 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 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 , Arnd Bergmann , Masahiro Yamada , Sami Tolvanen , Frederic Weisbecker , Krzysztof Kozlowski , Hassan Naveed , Christian Brauner , Mark Rutland , Mark Brown , Mike Rapoport , Gavin Shan , Zhenyu Ye , Steven Price , Jia He , John Hubbard , William Kucharski , Mike Kravetz , Ralph Campbell , Mina Almasry , Ram Pai , "Kirill A. Shutemov" , Sandipan Das , Dave Hansen , 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 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 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