From patchwork Mon Apr 19 13:54:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 12211883 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D08E6C43460 for ; Mon, 19 Apr 2021 13:55:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5894B61245 for ; Mon, 19 Apr 2021 13:55:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5894B61245 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AA0BC6B006C; Mon, 19 Apr 2021 09:55:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A522D6B006E; Mon, 19 Apr 2021 09:55:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8CB036B0070; Mon, 19 Apr 2021 09:55:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0226.hostedemail.com [216.40.44.226]) by kanga.kvack.org (Postfix) with ESMTP id 6DF7B6B006C for ; Mon, 19 Apr 2021 09:55:07 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 195263640 for ; Mon, 19 Apr 2021 13:55:07 +0000 (UTC) X-FDA: 78049263054.24.7C25E19 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf01.hostedemail.com (Postfix) with ESMTP id A406F5001530 for ; Mon, 19 Apr 2021 13:55:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618840506; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=sH/va859G7+kPRIk42Cl7YV9RauhBxFyo2eED4b+bpA=; b=YHdIGuqFOvRW7uEl4LyfhtD2I+pRSmo70kTUMO9XzdHjjpadSOgLOjrlidpPGJHskdciBS iuBrn855LQ3m/U9JDF0c+ICCgXfDRI+6749GHa6GyvdDqE+3kyo5SWJtdWTB3YKyXBR/4a UgjZIu04rBjZZ//jrZNm4y1OddwlZVU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-523-em2bedRCMIOvFc4uC3t2lA-1; Mon, 19 Apr 2021 09:55:01 -0400 X-MC-Unique: em2bedRCMIOvFc4uC3t2lA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 45A27107B02A; Mon, 19 Apr 2021 13:54:56 +0000 (UTC) Received: from t480s.redhat.com (ovpn-115-67.ams2.redhat.com [10.36.115.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27A3E10016FD; Mon, 19 Apr 2021 13:54:43 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrea Arcangeli , Andrew Morton , Arnd Bergmann , Chris Zankel , Dave Hansen , Helge Deller , Hugh Dickins , Ivan Kokshaysky , "James E.J. Bottomley" , Jann Horn , Jason Gunthorpe , "Kirill A. Shutemov" , Linux API , "Matthew Wilcox (Oracle)" , Matt Turner , Max Filippov , "Michael S. Tsirkin" , Michal Hocko , Mike Kravetz , Minchan Kim , Oscar Salvador , Peter Xu , Ram Pai , Richard Henderson , Rik van Riel , Rolf Eike Beer , Shuah Khan , Thomas Bogendoerfer , Vlastimil Babka Subject: [PATCH v2 0/5] mm/madvise: introduce MADV_POPULATE_(READ|WRITE) to prefault page tables Date: Mon, 19 Apr 2021 15:54:38 +0200 Message-Id: <20210419135443.12822-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: A406F5001530 X-Stat-Signature: fba67pdkms6xzq7n36x169g899h91e68 Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf01; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1618840505-112839 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: Excessive details on MADV_POPULATE_(READ|WRITE) can be found in patch #2. v1 -> v2: - "mm/madvise: introduce MADV_POPULATE_(READ|WRITE) to prefault page tables" -- Renamed patch/series to match what's happening -- prefault page tables -- Clarified MADV_POPULATE_READ semantics on file holes and that we might want fallocate(). -- Updated/clarified description -- Dropped -EINVAL and -EBUSY checks -- Added a comment regarding FOLL_TOUCH and why we don't care that pages will get set dirty when triggering write-faults for now. -- Reran and extended performance measurements by more fallocate() combinations RFCv2 -> v1 - "mm: fix variable name in declaration of populate_vma_page_range()" -- Added - "mm/madvise: introduce MADV_POPULATE_(READ|WRITE) to prefault ..." -- Fix detection of memory holes when we have to re-lookup the VMA -- Return -EHWPOISON to user space when we hit HW poisoned pages -- Make variable names in definition and declaration consistent - "MAINTAINERS: add tools/testing/selftests/vm/ to MEMORY MANAGEMENT" -- Added - "selftests/vm: add protection_keys_32 / protection_keys_64 to gitignore" -- Added - "selftests/vm: add test for MADV_POPULATE_(READ|WRITE)" -- Added RFC -> RFCv2: - Fix re-locking (-> set "locked = 1;") - Don't mimic MAP_POPULATE semantics: --> Explicit READ/WRITE request instead of selecting it automatically, which makes it more generic and better suited for some use cases (e.g., we usually want to prefault shmem writable) --> Require proper access permissions - Introduce and use faultin_vma_page_range() --> Properly handle HWPOISON pages (FOLL_HWPOISON) --> Require proper access permissions (!FOLL_FORCE) - Let faultin_vma_page_range() check for compatible mappings/permissions - Extend patch description and add some performance numbers David Hildenbrand (5): mm: make variable names for populate_vma_page_range() consistent mm/madvise: introduce MADV_POPULATE_(READ|WRITE) to prefault page tables MAINTAINERS: add tools/testing/selftests/vm/ to MEMORY MANAGEMENT selftests/vm: add protection_keys_32 / protection_keys_64 to gitignore selftests/vm: add test for MADV_POPULATE_(READ|WRITE) MAINTAINERS | 1 + arch/alpha/include/uapi/asm/mman.h | 3 + arch/mips/include/uapi/asm/mman.h | 3 + arch/parisc/include/uapi/asm/mman.h | 3 + arch/xtensa/include/uapi/asm/mman.h | 3 + include/uapi/asm-generic/mman-common.h | 3 + mm/gup.c | 58 ++++ mm/internal.h | 5 +- mm/madvise.c | 66 ++++ tools/testing/selftests/vm/.gitignore | 3 + tools/testing/selftests/vm/Makefile | 1 + tools/testing/selftests/vm/madv_populate.c | 342 +++++++++++++++++++++ tools/testing/selftests/vm/run_vmtests.sh | 16 + 13 files changed, 506 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/vm/madv_populate.c