From patchwork Tue Jun 8 16:00:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 12307305 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.9 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=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 9B461C47082 for ; Tue, 8 Jun 2021 16:01:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B23E6128E for ; Tue, 8 Jun 2021 16:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233653AbhFHQDD (ORCPT ); Tue, 8 Jun 2021 12:03:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28192 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231465AbhFHQDD (ORCPT ); Tue, 8 Jun 2021 12:03:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623168070; 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=ny0GQOcOMIJ9f9GtQNBSHCKyJm/TZJpAh/jRCTYyLxE=; b=IvXUmP3ziGgphFSY30Wb2ZoQ4EwuIBF3MSjeOa1xl4rG+2aB0/eAYS1mFzTVjXo/QWUSuu 6g3VwIvxmOgfdVS8gSGxBsEfQnQHLa+8E2MfmUYsucOxJaGXDMg7xGsia14UsUI750YnKe FwNaPcBXdLUek8126TnmJPtgjof6daI= 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-8-4Lo9xQCRPVGWI_y5gK4qVQ-1; Tue, 08 Jun 2021 12:01:08 -0400 X-MC-Unique: 4Lo9xQCRPVGWI_y5gK4qVQ-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 EB2EC501F4; Tue, 8 Jun 2021 16:01:04 +0000 (UTC) Received: from t480s.redhat.com (ovpn-115-132.ams2.redhat.com [10.36.115.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1584189C7; Tue, 8 Jun 2021 16:00:49 +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] madvise.2: Document MADV_POPULATE_READ and MADV_POPULATE_WRITE Date: Tue, 8 Jun 2021 18:00:49 +0200 Message-Id: <20210608160049.24685-1-david@redhat.com> In-Reply-To: <20210511081534.3507-1-david@redhat.com> References: <20210511081534.3507-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-parisc@vger.kernel.org Let's document MADV_POPULATE_READ and MADV_POPULATE_WRITE behavior and error conditions. 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 --- Not for upstream man pages yet, only for linux-mm and linux-api review purposes. Once/if the linux changes are merged upstream, I'll send it to the proper man list/maintainers. --- man2/madvise.2 | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/man2/madvise.2 b/man2/madvise.2 index f1f384c0c..3ec8c53a7 100644 --- a/man2/madvise.2 +++ b/man2/madvise.2 @@ -469,6 +469,59 @@ 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_READ " (since Linux 5.14) +Populate (prefault) page tables readable for the whole range without actually +reading. Depending on the underlying mapping, map the shared zeropage, +preallocate memory or read the underlying file; files with holes might or +might not preallocate blocks. +Do not generate +.B SIGBUS +when populating fails, return an error instead. +.IP +If +.B MADV_POPULATE_READ +succeeds, all page tables have been populated (prefaulted) readable once. +If +.B MADV_POPULATE_READ +fails, some page tables might have been populated. +.IP +.B MADV_POPULATE_READ +cannot be applied to mappings without read permissions +and special mappings marked with the kernel-internal +.B VM_PFNMAP +and +.BR VM_IO . +.IP +Note that with +.BR MADV_POPULATE_READ , +the process can be killed at any moment when the system runs out of memory. +.TP +.BR MADV_POPULATE_WRITE " (since Linux 5.14) +Populate (prefault) page tables writable for the whole range without actually +writing. Depending on the underlying mapping, preallocate memory or read the +underlying file; files with holes will preallocate blocks. +Do not generate +.B SIGBUS +when populating fails, return an error instead. +.IP +If +.B MADV_POPULATE_WRITE +succeeds, all page tables have been populated (prefaulted) writable once. +If +.B MADV_POPULATE_WRITE +fails, some page tables might have been populated. +.IP +.B MADV_POPULATE_WRITE +cannot be applied to mappings without write permissions +and special mappings marked with the kernel-internal +.B VM_PFNMAP +and +.BR VM_IO . +.IP +Note that +.BR MADV_POPULATE_WRITE , +the process can be killed at any moment when the system runs out of memory. .SH RETURN VALUE On success, .BR madvise () @@ -533,6 +586,17 @@ or .BR VM_PFNMAP ranges. .TP +.B EINVAL +.I advice +is +.B MADV_POPULATE_READ +or +.BR MADV_POPULATE_WRITE , +but the specified address range includes ranges with insufficient permissions, +.B VM_IO +or +.BR VM_PFNMAP. +.TP .B EIO (for .BR MADV_WILLNEED ) @@ -548,6 +612,14 @@ 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 +.B MADV_POPULATE_READ +or +.BR MADV_POPULATE_WRITE , +but populating (prefaulting) page tables failed. +.TP .B EPERM .I advice is @@ -555,6 +627,14 @@ is but the caller does not have the .B CAP_SYS_ADMIN capability. +.TP +.B EHWPOISON +.I advice +is +.B MADV_POPULATE_READ +or +.BR MADV_POPULATE_WRITE , +and a HW poisoned page is encountered. .SH VERSIONS Since Linux 3.18, .\" commit d3ac21cacc24790eb45d735769f35753f5b56ceb