From patchwork Thu Feb 18 12:22:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 12093479 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=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 866EDC433DB for ; Thu, 18 Feb 2021 12:22:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 00AAD64E5F for ; Thu, 18 Feb 2021 12:22:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 00AAD64E5F 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 4D5156B0006; Thu, 18 Feb 2021 07:22:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4849A6B006C; Thu, 18 Feb 2021 07:22:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 373E76B006E; Thu, 18 Feb 2021 07:22:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0234.hostedemail.com [216.40.44.234]) by kanga.kvack.org (Postfix) with ESMTP id 22F816B0006 for ; Thu, 18 Feb 2021 07:22:42 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id DDE615853 for ; Thu, 18 Feb 2021 12:22:41 +0000 (UTC) X-FDA: 77831302122.09.C98B1D6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 36F2490009E2 for ; Thu, 18 Feb 2021 12:22:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613650960; 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: in-reply-to:in-reply-to:references:references; bh=yhLVfX0fB/D8R1zKoQVO+TMTBrUwUHt7HIxasf2kZek=; b=Al081Z3aHbE5jdQK80eTI7QmH5Gpc/UmEcSCSp1N+3NUc118lXFA6lW6iJyXCYP6gcSESU e/egyXlvEUcFkwth4sJUkP+tD1LLTpzJcYdfjrGICmpRH0ilBSE8tjvof/2oSg/OvFyq4w HpxBShX6FYU7dN0k1lgM59mtkZ0I1Lg= 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-513-nqPI8Ju-OrO5-wTceZ7uYA-1; Thu, 18 Feb 2021 07:22:36 -0500 X-MC-Unique: nqPI8Ju-OrO5-wTceZ7uYA-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 7A694835E25; Thu, 18 Feb 2021 12:22:32 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-59.ams2.redhat.com [10.36.114.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A9F02C01F; Thu, 18 Feb 2021 12:22:17 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Arnd Bergmann , Michal Hocko , Oscar Salvador , Matthew Wilcox , Andrea Arcangeli , Minchan Kim , Jann Horn , Jason Gunthorpe , Dave Hansen , Hugh Dickins , Rik van Riel , "Michael S . Tsirkin" , "Kirill A . Shutemov" , Vlastimil Babka , Richard Henderson , Ivan Kokshaysky , Matt Turner , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Chris Zankel , Max Filippov , Mike Kravetz , Rolf Eike Beer , linux-alpha@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-arch@vger.kernel.org, Linux API Subject: [PATCH RFC] madvise.2: Document MADV_POPULATE Date: Thu, 18 Feb 2021 13:22:16 +0100 Message-Id: <20210218122216.12424-1-david@redhat.com> In-Reply-To: <20210217154844.12392-1-david@redhat.com> References: <20210217154844.12392-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Stat-Signature: ts9da3umc6uxyxhr6rzmim93z4ain7yj X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 36F2490009E2 Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf19; 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: 1613650959-841478 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: Preview of MADV_POPULATE documentation, which is still under discussion: https://lkml.kernel.org/r/20210217154844.12392-1-david@redhat.com Once/if merged, there will be an official patch to man-page folks. Cc: Andrew Morton Cc: Arnd Bergmann Cc: Michal Hocko Cc: Oscar Salvador Cc: Matthew Wilcox (Oracle) Cc: Andrea Arcangeli Cc: Minchan Kim Cc: Jann Horn Cc: Jason Gunthorpe Cc: Dave Hansen Cc: Hugh Dickins Cc: Rik van Riel Cc: Michael S. Tsirkin Cc: Kirill A. Shutemov Cc: Vlastimil Babka Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: Thomas Bogendoerfer Cc: "James E.J. Bottomley" Cc: Helge Deller Cc: Chris Zankel Cc: Max Filippov Cc: Mike Kravetz Cc: Rolf Eike Beer Cc: linux-alpha@vger.kernel.org Cc: linux-mips@vger.kernel.org Cc: linux-parisc@vger.kernel.org Cc: linux-xtensa@linux-xtensa.org Cc: linux-arch@vger.kernel.org Cc: Linux API Signed-off-by: David Hildenbrand --- man2/madvise.2 | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/man2/madvise.2 b/man2/madvise.2 index 2af407212..ff08768a3 100644 --- a/man2/madvise.2 +++ b/man2/madvise.2 @@ -469,6 +469,48 @@ If a page is file-backed and dirty, it will be written back to the backing storage. The advice might be ignored for some pages in the range when it is not applicable. +.TP +.BR MADV_POPULATE " (since Linux 5.13) +Populate (prefault) page tables for the whole range. +Depending on the underlying mapping, preallocate memory or read the +underlying file. +Do not generate +.B SIGBUS +when populating fails, return an error instead. +The populate semantics match +.BR MAP_POPULATE +(see +.BR mmap (2)) +with the exception that +.B MADV_POPULATE +fails if there is a proplem populating page tables. +.B MADV_POPULATE +simulates user space access to all pages in the range without actually +reading/writing the pages. +For private, writable mappings, simulate a write access; for all other +mappings, simulate a read access. +.IP +If +.B MADV_POPULATE +succeeds, all page tables have been populated (prefaulted) once. +If +.B MADV_POPULATE +fails, some page tables might have been populated. +.IP +.B MADV_POPULATE +cannot be applied to +.B PROT_NONE +and special mappings marked with the kernel-internal +.B VM_PFNMAP +and +.BR VM_IO . +.IP +Note that +.B MADV_POPULATE +will ignore any poisoned pages in the range. +Similar to +.BR MAP_POPULATE , +it cannot protect from the OOM (Out Of Memory) handler killing the process. .SH RETURN VALUE On success, .BR madvise () @@ -533,6 +575,17 @@ or .BR VM_PFNMAP ranges. .TP +.B EINVAL +.I advice +is +.BR MADV_POPULATE , +but the specified address range includes +.BR PROT_NONE , +.B VM_IO +or +.B VM_PFNMAP +ranges. +.TP .B EIO (for .BR MADV_WILLNEED ) @@ -548,6 +601,12 @@ Not enough memory: paging in failed. Addresses in the specified range are not currently mapped, or are outside the address space of the process. .TP +.B ENOMEM +.I advice +is +.BR MADV_POPULATE , +but populating (prefaulting) page tables failed. +.TP .B EPERM .I advice is