From patchwork Wed Mar 17 11:06:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 12145539 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 autolearn=ham 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 69F84C433DB for ; Wed, 17 Mar 2021 11:07:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0099E64F5E for ; Wed, 17 Mar 2021 11:07:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0099E64F5E 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 61AAF6B006E; Wed, 17 Mar 2021 07:07:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F3FB6B0070; Wed, 17 Mar 2021 07:07:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4931C6B0071; Wed, 17 Mar 2021 07:07:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0191.hostedemail.com [216.40.44.191]) by kanga.kvack.org (Postfix) with ESMTP id 2F78D6B006E for ; Wed, 17 Mar 2021 07:07:13 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E5E051E13 for ; Wed, 17 Mar 2021 11:07:12 +0000 (UTC) X-FDA: 77929089504.28.161604D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf11.hostedemail.com (Postfix) with ESMTP id CDB5C200039E for ; Wed, 17 Mar 2021 11:07:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615979230; 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=IwjEMMT3RPtm6JyY0ASCQIpX+lhDqbTUqfP/62uVVEY=; b=gve9d5El0TX4pw6W78yTIPFd0qHdHfnrABTndSFkX4jxfSGF0A6XM1zFryxlax3K0IPxSK M4I1j5mR4RIn86yKleW9g1z+sG9N7Q+0VKpjadIfoJWYcA/w/ZfCihS+V5M7s1pT4x+nmQ WFfBOhvNX8GBXqaF9I1v2k3ccSit4EU= 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-441-BjG_LOKEN1mdN0p7ad2jYg-1; Wed, 17 Mar 2021 07:07:08 -0400 X-MC-Unique: BjG_LOKEN1mdN0p7ad2jYg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 637B61009446; Wed, 17 Mar 2021 11:07:04 +0000 (UTC) Received: from t480s.redhat.com (ovpn-112-124.ams2.redhat.com [10.36.112.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3888B50FAF; Wed, 17 Mar 2021 11:06:45 +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 v1 0/5] mm/madvise: introduce MADV_POPULATE_(READ|WRITE) to prefault/prealloc memory Date: Wed, 17 Mar 2021 12:06:39 +0100 Message-Id: <20210317110644.25343-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Stat-Signature: ye68spikgetzx4j43sk6tziaf1wzqm9e X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: CDB5C200039E Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf11; 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: 1615979230-657401 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. Now accompanied by minor adjustments and selftests/vm tests. 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/prealloc memory 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 | 54 ++++ mm/internal.h | 5 +- mm/madvise.c | 69 +++++ 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, 505 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/vm/madv_populate.c