Received: by 2002:a4f:b056:0:0:0:0:0 with SMTP id m22csp1408894ivi; Fri, 2 Oct 2020 09:22:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyR+BCnQ+tBu1TVpXTYZDu6lo1+hWFsSugB+TW+6dg2QLG0j8AfKZYqESseFiUOTRR85HGf X-Received: by 2002:a17:906:9396:: with SMTP id l22mr3096401ejx.36.1601655775707; Fri, 02 Oct 2020 09:22:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601655775; cv=none; d=google.com; s=arc-20160816; b=JyAXv7Lfa0kT9m/use3mFzxi6ynRCKUCTl7q72UCcFmf2tkonwYSGEmpkN04OeqwYA rUJ381/H+8l0X/wENk4O8s6zO7hYMNJtXON0BoAP5uIVJJGhawcegmrAs93ZZI7wgnoG u23h4qYbsysBAXdTB/FXhrAIPV2Qv9ArrEnV+xdG1+y87c6ms8qyz+tpVR0cgII91l3q TAlQf0jFNk206UsO0fln5NmVfnD64KCdNEYBrlBRy18p+GwAZ7aPrYvlvc2moGO0iE9w YyMMmUr/Qp1pSLiv6tK6zq3NljERpp3G5o4HFz8IMQj4DkQhV0yd0T1UFXnA19gB3F1P aZrg== 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:mime-version:message-id:date :sender:dkim-signature; bh=ihKrgqyZCQ8XMMYJ7a58uDLMLyOCJFezWU7B9DhnIPM=; b=c37ft549Jze0PCc5HZ2Khdv51qDSlzTHKP9OFVi3JYUigW3gAubyzxckybKX1jlsjT c/5Bb+e4rI16SUvRb8iAkCY4cmti08XvOPzwcw0RzHVXRPuofKc/akCWTkVwP8AgNy/Z UkmOrVBiICIrNypWTHb/pfryl76fQkphpDmWtbF58UF8o9x8b3UIiM1KU3La1SR+yVJ7 j9NL3UDHl1ujP1U5NM/PWdQOLFT7YHXsD+UqV4UR/IjDFBQ8HVzOIBCKDFJYiBqGK+Cb 9u+L+rbULV5RILTg3wSihjGG47LTAwBT7k7aNT+oyq/Y0xk1dzffUkMEGqdEDkzCjxiu 8RuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=eyT9arWU; 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 d14si1329150edz.294.2020.10.02.09.22.33; Fri, 02 Oct 2020 09:22:55 -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=eyT9arWU; 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 S2387919AbgJBQVT (ORCPT + 99 others); Fri, 2 Oct 2020 12:21:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726017AbgJBQVT (ORCPT ); Fri, 2 Oct 2020 12:21:19 -0400 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78369C0613E2 for ; Fri, 2 Oct 2020 09:21:15 -0700 (PDT) Received: by mail-qk1-x74a.google.com with SMTP id o28so1402706qkm.23 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=VrjuwHZczv6U0t8aIMkrI69JHqmXzTdlMNHRKa+dbH/OhCmejq3mptzdMgC1PoyP0v 6lXeKKWNdPvNu4UPDGSTPLRwqD1ZYFPVXjUmBjPqK+hFHW5Sbg77X7OReR7gUN9qDCWe PwB1WAqc8knbDGmYlFWCDAlhBNScAhYQrphEfT+hLl3DklnFXl39noIOcTuNbuHAElgo vR9MxaUXDNX+Zhovtsx9PC9JDjrCASLou563QhFuLHFSNS5bAaBFWq/MEUc1Miras1m/ ff3VVGLksts+uMw5SisBtq3G4ODUU4VHVzcCOh6kCASeZuGWNZptnJvRiFVny78uIHQb DQyA== X-Gm-Message-State: AOAM530V4uG3zXNA0+oQrCru86bZI56ikKJHYIkQs/p4JV5Igy+Bio1X 4xD2B4IVCngm1wJIVJMywxnh+UI1rITGhYll3w== 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: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 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 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 -- 2.28.0.806.g8561365e88-goog