Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp36828pxk; Wed, 30 Sep 2020 17:06:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAIVxgstqxuSifeoWhtqgo7XzG+YAwwQA9WFt/Lx2PidR65pKpQ/wg4on3Qu9FUp9dLZLE X-Received: by 2002:a17:906:8559:: with SMTP id h25mr5325807ejy.536.1601510784092; Wed, 30 Sep 2020 17:06:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601510784; cv=none; d=google.com; s=arc-20160816; b=CiaomOF0fHQ/leBtCZ9UkIDyMZmFYBd1TMsqLBLiL+a+dPw+jndZQ/1tJDKr+ieDiE o3snQOrcPPom63MSEkMj66w7DrSZjoiZj/0w22Qk8usA4630yPZczmZPr/clMaJACOrk q4cO+XnxKVZSCMZcVauu46khBVoKWdvhe+BiowWjCjc+Q8hyYuoDLzZeG/aC96YQflcw Wr2lhOHUnCCOQcHs2Np19ROnKvyH1DLrTH2TdcglPHY/4U6HQsgYwIiG8d+wRMJXCkaw qA1k3icJad8thl92gM7BWD5kuuuLZ54Epr3S2U8LZDYD0e4OTupscbI5FE3oQdXCSB6A mc/g== 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=5nGapf7xO2rZTSaxGiPwPbuengbwYhe3dVDIYorRiWY=; b=ugnMlTzF9LFzeTZCmXzYxcB6lxRPh+XDTmrFhz7q5Cp+NYXPsuM1GGdnfP88AusmAp dviXUjHXdUlhIK0DYVvMWf7FAuqndYFrdV4+T3pxSZgEJYEIL3ZfR7SCgRsj5Y/jYQA5 TznH2rmhYWm92kG/PccW6YbCEaKtwpGuHloCT1rwFps41dqsP9PFMJSwWPZh203uRf77 zQ1yBDEjV8h9cB6U/nLVyi4RqVecN4NTA6hS9Sok2QzpLK61IP39JhwB1l+gYlR6t8VH h6/qUuDV4jC9Y/WelydYgw557Vdlc7iQ5WDxajJJYDgJRiQfFy186CjLDMu6y1CVib+u YZAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FInMstcR; 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 lt17si2366119ejb.56.2020.09.30.17.05.34; Wed, 30 Sep 2020 17:06:24 -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=FInMstcR; 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 S1731189AbgI3WVh (ORCPT + 99 others); Wed, 30 Sep 2020 18:21:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727210AbgI3WVh (ORCPT ); Wed, 30 Sep 2020 18:21:37 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA9D6C0613D0 for ; Wed, 30 Sep 2020 15:21:35 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id bo17so1901870qvb.2 for ; Wed, 30 Sep 2020 15:21:35 -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=5nGapf7xO2rZTSaxGiPwPbuengbwYhe3dVDIYorRiWY=; b=FInMstcRCnnn+Uwb4uVZz2nOr0YsNe2fsrv2kqony8tTtnivnPNz7vNuxsLLqKt2WJ 7XPavd/j9HHPjLjnosmvSIix+mb0vxh/gY4VKOfM8P8BR8OMeGSrUC/wTxKidQ8pCTQe Sm7OTzOhdOAtg3DByPpqY0zvTUI2i3YrSnjdfbSWuxmila0sOR5kl1pQLE8zY7NSNTpz HI+IRGKji9bQMdE+BJ07zmdSj7CKbTJZNkaSuSc5xIClV3PCsYA+RxKm6B1yH8mYzXli V/Odoyc22NVRZmUoSt07JUBp3CPreD9H8XzC7mXd4FeYw5zZmotd3fbx/viALT0egfZB 71qQ== 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=5nGapf7xO2rZTSaxGiPwPbuengbwYhe3dVDIYorRiWY=; b=MHqaDHp1IVdrJ81U8x39gDmK7/oBPTCtObox9RwmzFvstxSAZ0nuIpeP5DyNntzC5u kHyKtlH6XzBuyMWheJI/nYVoB7NbyCnWNHf9X5nYQa6j9lO98YEZqWztozkP6TWeacJW YsbDG6+pSC70zd65LowlR7G99H/D6Px+epErRq+Tw0h6s3N6X3esukGXbwPZPuozA5ZC zYKAT8BlhGufnkNbRpYKFuqUNlHkEify2RPpP+SVow6IJeepfEMgNJ3qQ03wFy4pzUEp AG5DG0PRdUeyI5uBQZ1mrxhLt2tkEsuhRANZOQNwhPocogHkxB/Xv2J+JmLqZbD3Cc/P tsLQ== X-Gm-Message-State: AOAM530Q5RJEGUB3L5vXhLgPz+bTOR+5cy2yR1vcb3PNGsCT2FDUZF9G 8uXZIGy6yPLLSck+LJThe7JvVJG0Vs8xH0MHzg== 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:d443:: with SMTP id r3mr4849305qvh.20.1601504494642; Wed, 30 Sep 2020 15:21:34 -0700 (PDT) Date: Wed, 30 Sep 2020 22:21:17 +0000 Message-Id: <20200930222130.4175584-1-kaleshsingh@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.709.gb0816b6eb0-goog Subject: [PATCH 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 , "Aneesh Kumar K.V" , Kees Cook , Peter Zijlstra , Sami Tolvanen , Masahiro Yamada , Arnd Bergmann , Frederic Weisbecker , Krzysztof Kozlowski , Hassan Naveed , Christian Brauner , Mark Rutland , Mike Rapoport , Gavin Shan , Zhenyu Ye , Jia He , John Hubbard , William Kucharski , Sandipan Das , "Kirill A. Shutemov" , Ralph Campbell , Mina Almasry , Ram Pai , Dave Hansen , Kamalesh Babulal , Masami Hiramatsu , Brian Geffon , 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 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. 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 | 211 +++++++++++++++++--- tools/testing/selftests/vm/.gitignore | 1 + tools/testing/selftests/vm/Makefile | 1 + tools/testing/selftests/vm/mremap_test.c | 243 +++++++++++++++++++++++ tools/testing/selftests/vm/run_vmtests | 11 + 9 files changed, 448 insertions(+), 30 deletions(-) create mode 100644 tools/testing/selftests/vm/mremap_test.c -- 2.28.0.709.gb0816b6eb0-goog