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: 12093539 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=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,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 09D3DC433E9 for ; Thu, 18 Feb 2021 13:10:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B344364E76 for ; Thu, 18 Feb 2021 13:10:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233378AbhBRNHr (ORCPT ); Thu, 18 Feb 2021 08:07:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54323 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232729AbhBRMYI (ORCPT ); Thu, 18 Feb 2021 07:24:08 -0500 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 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org 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