Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7276683pxb; Thu, 18 Feb 2021 06:12:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmXcbIZkwalN5euZaJQV3v/2Byoc3QuJiqvNtDIE5RvyKwdG58Y+Go91K/9qmkqTc82TLH X-Received: by 2002:a05:6402:4391:: with SMTP id o17mr4333057edc.196.1613657539888; Thu, 18 Feb 2021 06:12:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613657539; cv=none; d=google.com; s=arc-20160816; b=nUQr9v2qRq5MJG4JN+DI5qfmmbIDudX1IsW4d4pAoXTgkUwMZ6tERiYjp/M2TT/QUu 48qlAnkOiOx/YL/3ymOh5dUqJlEGZUiMRiOuLxmG6vJAsndcnNF9XmdoEvexKWJ7asFK YvHac9Mj+Dg07uOhBnKm1O5e/HBWJWaMP4RoYhq1rYdz1TorZlB6CCa42yF9ad3yCYkw xYasHWjAMgx+GfZBVScxIJx1riAIKo/Xg9nJDzjzR6x9AQhuozv75UylDcP9lCJ/mBWB yVdYIExod98DNbTAKVSCpjdeZNI4uruZE+niiyuS8LyETYyih+63FzHdKNbFYD3qPyhY YBzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yhLVfX0fB/D8R1zKoQVO+TMTBrUwUHt7HIxasf2kZek=; b=EWU4xZz/+yjveaBqEIAk7ojSlmlZpNl/QTyuNKrATE7GSXElZkKGLW5jjgIZwZgIIp +8z/tz4Og/ZufLybtxcF3SJiUSyUYQ+bJHt8ZukxOXEdWZ+ETXIpsBI2MQEUSnl2v8Jx fK1tg1I4hixeCAx15S3x2GiTHVvy8jTjGwgctvqOZmMBfEVGJ0QEYdNeK/wL3SpEVtFn e5qGGeOq/H9itp+WcwvG2fKSKyNU6GbPGDnZkyXzibWoDHZjs59oUbnWzIKH8OymM9En g3XwpZfmVptbup+3zZRSJXqFRXAWyhjPic4TdmeITvBDdDZUFWdQuk9Se3zpTOisTGG+ dzKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Al081Z3a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t9si3699732ejx.434.2021.02.18.06.11.54; Thu, 18 Feb 2021 06:12:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Al081Z3a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233621AbhBROJt (ORCPT + 99 others); Thu, 18 Feb 2021 09:09:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60336 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232725AbhBRMYH (ORCPT ); Thu, 18 Feb 2021 07:24:07 -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 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 -- 2.29.2